Fix the indent and whitespace to match LinuxBIOS standards

Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2651 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Jordan Crouse
2007-05-10 18:43:57 +00:00
committed by Stefan Reinauer
parent 9934b813da
commit 2a133f7851
7 changed files with 267 additions and 257 deletions

View File

@@ -41,23 +41,23 @@ struct msrinit {
/* Master Configuration Register for Bus Masters.*/ /* Master Configuration Register for Bus Masters.*/
struct msrinit SB_MASTER_CONF_TABLE[] = { struct msrinit SB_MASTER_CONF_TABLE[] = {
{USB2_SB_GLD_MSR_CONF, {.hi=0,.lo=0x00008f000}}, {USB2_SB_GLD_MSR_CONF, {.hi = 0,.lo = 0x00008f000}},
{ATA_SB_GLD_MSR_CONF, {.hi=0,.lo=0x00048f000}}, {ATA_SB_GLD_MSR_CONF, {.hi = 0,.lo = 0x00048f000}},
{AC97_SB_GLD_MSR_CONF, {.hi=0,.lo=0x00008f000}}, {AC97_SB_GLD_MSR_CONF, {.hi = 0,.lo = 0x00008f000}},
{MDD_SB_GLD_MSR_CONF, {.hi=0,.lo=0x00000f000}}, {MDD_SB_GLD_MSR_CONF, {.hi = 0,.lo = 0x00000f000}},
{0,{0,0}} {0, {0, 0}}
}; };
/* 5536 Clock Gating*/ /* 5536 Clock Gating*/
struct msrinit CS5536_CLOCK_GATING_TABLE[] = { struct msrinit CS5536_CLOCK_GATING_TABLE[] = {
/* MSR Setting*/ /* MSR Setting*/
{GLIU_SB_GLD_MSR_PM, {.hi=0,.lo=0x000000004}}, {GLIU_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x000000004}},
{GLPCI_SB_GLD_MSR_PM, {.hi=0,.lo=0x000000005}}, {GLPCI_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x000000005}},
{GLCP_SB_GLD_MSR_PM, {.hi=0,.lo=0x000000004}}, {GLCP_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x000000004}},
{MDD_SB_GLD_MSR_PM, {.hi=0,.lo=0x050554111}}, /* SMBus clock gating errata (PBZ 2226 & SiBZ 3977)*/ {MDD_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x050554111}}, /* SMBus clock gating errata (PBZ 2226 & SiBZ 3977) */
{ATA_SB_GLD_MSR_PM, {.hi=0,.lo=0x000000005}}, {ATA_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x000000005}},
{AC97_SB_GLD_MSR_PM, {.hi=0,.lo=0x000000005}}, {AC97_SB_GLD_MSR_PM, {.hi = 0,.lo = 0x000000005}},
{0,{0,0}} {0, {0, 0}}
}; };
struct acpiinit { struct acpiinit {
@@ -77,7 +77,7 @@ struct acpiinit acpi_init_table[] = {
{PMS_IO_BASE + PM_SIDD, 0x000008C02}, {PMS_IO_BASE + PM_SIDD, 0x000008C02},
{PMS_IO_BASE + PM_WKD, 0x0000000A0}, {PMS_IO_BASE + PM_WKD, 0x0000000A0},
{PMS_IO_BASE + PM_WKXD, 0x0000000A0}, {PMS_IO_BASE + PM_WKXD, 0x0000000A0},
{0,0,0} {0, 0, 0}
}; };
struct FLASH_DEVICE { struct FLASH_DEVICE {
@@ -87,10 +87,10 @@ struct FLASH_DEVICE {
}; };
struct FLASH_DEVICE FlashInitTable[] = { struct FLASH_DEVICE FlashInitTable[] = {
{ FLASH_TYPE_NAND, FLASH_IF_MEM, FLASH_MEM_4K }, /* CS0, or Flash Device 0 */ {FLASH_TYPE_NAND, FLASH_IF_MEM, FLASH_MEM_4K}, /* CS0, or Flash Device 0 */
{ FLASH_TYPE_NONE, 0, 0 }, /* CS1, or Flash Device 1 */ {FLASH_TYPE_NONE, 0, 0}, /* CS1, or Flash Device 1 */
{ FLASH_TYPE_NONE, 0, 0 }, /* CS2, or Flash Device 2 */ {FLASH_TYPE_NONE, 0, 0}, /* CS2, or Flash Device 2 */
{ FLASH_TYPE_NONE, 0, 0 }, /* CS3, or Flash Device 3 */ {FLASH_TYPE_NONE, 0, 0}, /* CS3, or Flash Device 3 */
}; };
#define FlashInitTableLen (sizeof(FlashInitTable)/sizeof(FlashInitTable[0])) #define FlashInitTableLen (sizeof(FlashInitTable)/sizeof(FlashInitTable[0]))
@@ -100,8 +100,7 @@ uint32_t FlashPort[] = {
MDD_LBAR_FLSH1, MDD_LBAR_FLSH1,
MDD_LBAR_FLSH2, MDD_LBAR_FLSH2,
MDD_LBAR_FLSH3 MDD_LBAR_FLSH3
}; };
/* ***************************************************************************/ /* ***************************************************************************/
/* **/ /* **/
@@ -110,39 +109,39 @@ uint32_t FlashPort[] = {
/* * Program ACPI LBAR and initialize ACPI registers.*/ /* * Program ACPI LBAR and initialize ACPI registers.*/
/* **/ /* **/
/* ***************************************************************************/ /* ***************************************************************************/
static void pmChipsetInit(void) { static void pmChipsetInit(void)
{
uint32_t val = 0; uint32_t val = 0;
uint16_t port; uint16_t port;
port = (PMS_IO_BASE + 0x010); port = (PMS_IO_BASE + 0x010);
val = 0x0E00 ; /* 1ms*/ val = 0x0E00; /* 1ms */
outl(val, port); outl(val, port);
/* PM_WKXD*/ /* PM_WKXD */
/* Make sure bits[3:0]=0000b to clear the*/ /* Make sure bits[3:0]=0000b to clear the */
/* saved Sx state*/ /* saved Sx state */
port = (PMS_IO_BASE + 0x034); port = (PMS_IO_BASE + 0x034);
val = 0x0A0 ; /* 5ms*/ val = 0x0A0; /* 5ms */
outl(val, port); outl(val, port);
/* PM_WKD*/ /* PM_WKD */
port = (PMS_IO_BASE + 0x030); port = (PMS_IO_BASE + 0x030);
outl(val, port); outl(val, port);
/* PM_SED*/ /* PM_SED */
port = (PMS_IO_BASE + 0x014); port = (PMS_IO_BASE + 0x014);
/* mov eax, 0x057642 ; 100ms, works*/ /* mov eax, 0x057642 ; 100ms, works*/
val = 0x04601 ; /* 5ms*/ val = 0x04601; /* 5ms */
outl(val, port); outl(val, port);
/* PM_SIDD*/ /* PM_SIDD */
port = (PMS_IO_BASE + 0x020); port = (PMS_IO_BASE + 0x020);
/* mov eax, 0x0AEC84 ; 200ms, works*/ /* mov eax, 0x0AEC84 ; 200ms, works*/
val = 0x08C02 ; /* 10ms*/ val = 0x08C02; /* 10ms */
outl(val, port); outl(val, port);
} }
/*************************************************************************** /***************************************************************************
* *
* ChipsetFlashSetup * ChipsetFlashSetup
@@ -152,7 +151,8 @@ static void pmChipsetInit(void) {
* configured (don't call it if you want IDE). * configured (don't call it if you want IDE).
* *
**************************************************************************/ **************************************************************************/
static void ChipsetFlashSetup(void){ static void ChipsetFlashSetup(void)
{
msr_t msr; msr_t msr;
int i; int i;
int numEnabled = 0; int numEnabled = 0;
@@ -173,13 +173,15 @@ static void ChipsetFlashSetup(void){
else else
msr.hi &= ~0x00000004; msr.hi &= ~0x00000004;
msr.hi |= FlashInitTable[i].fMask; msr.hi |= FlashInitTable[i].fMask;
printk_debug("MSR(0x%08X, %08X_%08X)\n", FlashPort[i], msr.hi, msr.lo); printk_debug("MSR(0x%08X, %08X_%08X)\n", FlashPort[i],
msr.hi, msr.lo);
wrmsr(FlashPort[i], msr); wrmsr(FlashPort[i], msr);
/* now write-enable the device */ /* now write-enable the device */
msr = rdmsr(MDD_NORF_CNTRL); msr = rdmsr(MDD_NORF_CNTRL);
msr.lo |= (1 << i); msr.lo |= (1 << i);
printk_debug("MSR(0x%08X, %08X_%08X)\n", MDD_NORF_CNTRL, msr.hi, msr.lo); printk_debug("MSR(0x%08X, %08X_%08X)\n", MDD_NORF_CNTRL,
msr.hi, msr.lo);
wrmsr(MDD_NORF_CNTRL, msr); wrmsr(MDD_NORF_CNTRL, msr);
/* update the number enabled */ /* update the number enabled */
@@ -190,24 +192,26 @@ static void ChipsetFlashSetup(void){
printk_debug("ChipsetFlashSetup: Finish\n"); printk_debug("ChipsetFlashSetup: Finish\n");
} }
/* ***************************************************************************/ /* ***************************************************************************/
/* **/ /* **/
/* * enable_ide_nand_flash_header */ /* * enable_ide_nand_flash_header */
/* Run after VSA init to enable the flash PCI device header */ /* Run after VSA init to enable the flash PCI device header */
/* **/ /* **/
/* ***************************************************************************/ /* ***************************************************************************/
static void enable_ide_nand_flash_header(){ static void enable_ide_nand_flash_header()
/* Tell VSA to use FLASH PCI header. Not IDE header.*/ {
/* Tell VSA to use FLASH PCI header. Not IDE header. */
outl(0x80007A40, 0xCF8); outl(0x80007A40, 0xCF8);
outl(0xDEADBEEF, 0xCFC); outl(0xDEADBEEF, 0xCFC);
} }
#define RTC_CENTURY 0x32 #define RTC_CENTURY 0x32
#define RTC_DOMA 0x3D #define RTC_DOMA 0x3D
#define RTC_MONA 0x3E #define RTC_MONA 0x3E
static void lpc_init(struct southbridge_amd_cs5536_config *sb){ static void lpc_init(struct southbridge_amd_cs5536_config *sb)
{
msr_t msr; msr_t msr;
if (sb->lpc_serirq_enable) { if (sb->lpc_serirq_enable) {
@@ -246,14 +250,15 @@ static void lpc_init(struct southbridge_amd_cs5536_config *sb){
isa_dma_init(); isa_dma_init();
} }
static void uarts_init(struct southbridge_amd_cs5536_config *sb)
static void uarts_init(struct southbridge_amd_cs5536_config *sb){ {
msr_t msr; msr_t msr;
uint16_t addr; uint16_t addr;
uint32_t gpio_addr; uint32_t gpio_addr;
device_t dev; device_t dev;
dev = dev_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, 0); dev = dev_find_device(PCI_VENDOR_ID_AMD,
PCI_DEVICE_ID_AMD_CS5536_ISA, 0);
gpio_addr = pci_read_config32(dev, PCI_BASE_ADDRESS_1); gpio_addr = pci_read_config32(dev, PCI_BASE_ADDRESS_1);
gpio_addr &= ~1; /* clear IO bit */ gpio_addr &= ~1; /* clear IO bit */
printk_debug("GPIO_ADDR: %08X\n", gpio_addr); printk_debug("GPIO_ADDR: %08X\n", gpio_addr);
@@ -261,9 +266,9 @@ static void uarts_init(struct southbridge_amd_cs5536_config *sb){
/* This could be extended to support IR modes */ /* This could be extended to support IR modes */
/* COM1 */ /* COM1 */
if (sb->com1_enable){ if (sb->com1_enable) {
/* Set the address */ /* Set the address */
switch (sb->com1_address){ switch (sb->com1_address) {
case 0x3F8: case 0x3F8:
addr = 7; addr = 7;
break; break;
@@ -282,7 +287,7 @@ static void uarts_init(struct southbridge_amd_cs5536_config *sb){
} }
msr = rdmsr(MDD_LEG_IO); msr = rdmsr(MDD_LEG_IO);
msr.lo |= addr << 16; msr.lo |= addr << 16;
wrmsr(MDD_LEG_IO,msr); wrmsr(MDD_LEG_IO, msr);
/* Set the IRQ */ /* Set the IRQ */
msr = rdmsr(MDD_IRQM_YHIGH); msr = rdmsr(MDD_IRQM_YHIGH);
@@ -302,7 +307,8 @@ static void uarts_init(struct southbridge_amd_cs5536_config *sb){
outl(GPIOL_9_SET, gpio_addr + GPIOL_IN_AUX1_SELECT); outl(GPIOL_9_SET, gpio_addr + GPIOL_IN_AUX1_SELECT);
/* Set: GPIO 8 + 9 Pull Up (0x18) */ /* Set: GPIO 8 + 9 Pull Up (0x18) */
outl(GPIOL_8_SET | GPIOL_9_SET, gpio_addr + GPIOL_PULLUP_ENABLE); outl(GPIOL_8_SET | GPIOL_9_SET,
gpio_addr + GPIOL_PULLUP_ENABLE);
/* enable COM1 */ /* enable COM1 */
/* Bit 1 = device enable Bit 4 = allow access to the upper banks */ /* Bit 1 = device enable Bit 4 = allow access to the upper banks */
@@ -310,8 +316,7 @@ static void uarts_init(struct southbridge_amd_cs5536_config *sb){
msr.hi = 0; msr.hi = 0;
wrmsr(MDD_UART1_CONF, msr); wrmsr(MDD_UART1_CONF, msr);
} } else {
else{
/* Reset and disable COM1 */ /* Reset and disable COM1 */
printk_err("Not disabling COM1 due to a bug ...\n"); printk_err("Not disabling COM1 due to a bug ...\n");
/* for now, don't do this! */ /* for now, don't do this! */
@@ -325,12 +330,12 @@ static void uarts_init(struct southbridge_amd_cs5536_config *sb){
/* Disable the IRQ */ /* Disable the IRQ */
msr = rdmsr(MDD_LEG_IO); msr = rdmsr(MDD_LEG_IO);
msr.lo |= ~(0xF << 16); msr.lo |= ~(0xF << 16);
wrmsr(MDD_LEG_IO,msr); wrmsr(MDD_LEG_IO, msr);
} }
/* COM2 */ /* COM2 */
if (sb->com2_enable){ if (sb->com2_enable) {
switch (sb->com2_address){ switch (sb->com2_address) {
case 0x3F8: case 0x3F8:
addr = 7; addr = 7;
break; break;
@@ -349,8 +354,7 @@ static void uarts_init(struct southbridge_amd_cs5536_config *sb){
} }
msr = rdmsr(MDD_LEG_IO); msr = rdmsr(MDD_LEG_IO);
msr.lo |= addr << 20; msr.lo |= addr << 20;
wrmsr(MDD_LEG_IO,msr); wrmsr(MDD_LEG_IO, msr);
/* Set the IRQ */ /* Set the IRQ */
msr = rdmsr(MDD_IRQM_YHIGH); msr = rdmsr(MDD_IRQM_YHIGH);
@@ -361,7 +365,7 @@ static void uarts_init(struct southbridge_amd_cs5536_config *sb){
/* Set: Output Enable (0x4) */ /* Set: Output Enable (0x4) */
outl(GPIOL_3_SET, gpio_addr + GPIOL_OUTPUT_ENABLE); outl(GPIOL_3_SET, gpio_addr + GPIOL_OUTPUT_ENABLE);
/* Set: OUTAUX1 Select (0x10) */ /* Set: OUTAUX1 Select (0x10) */
outl(GPIOL_3_SET,gpio_addr + GPIOL_OUT_AUX1_SELECT); outl(GPIOL_3_SET, gpio_addr + GPIOL_OUT_AUX1_SELECT);
/* GPIO4 - UART2_TX */ /* GPIO4 - UART2_TX */
/* Set: Input Enable (0x20) */ /* Set: Input Enable (0x20) */
@@ -370,7 +374,8 @@ static void uarts_init(struct southbridge_amd_cs5536_config *sb){
outl(GPIOL_4_SET, gpio_addr + GPIOL_IN_AUX1_SELECT); outl(GPIOL_4_SET, gpio_addr + GPIOL_IN_AUX1_SELECT);
/* Set: GPIO 3 + 3 Pull Up (0x18) */ /* Set: GPIO 3 + 3 Pull Up (0x18) */
outl(GPIOL_3_SET | GPIOL_4_SET, gpio_addr + GPIOL_PULLUP_ENABLE); outl(GPIOL_3_SET | GPIOL_4_SET,
gpio_addr + GPIOL_PULLUP_ENABLE);
/* enable COM2 */ /* enable COM2 */
/* Bit 1 = device enable Bit 4 = allow access to the upper banks */ /* Bit 1 = device enable Bit 4 = allow access to the upper banks */
@@ -378,8 +383,7 @@ static void uarts_init(struct southbridge_amd_cs5536_config *sb){
msr.hi = 0; msr.hi = 0;
wrmsr(MDD_UART2_CONF, msr); wrmsr(MDD_UART2_CONF, msr);
} } else {
else{
/* Reset and disable COM2 */ /* Reset and disable COM2 */
msr = rdmsr(MDD_UART2_CONF); msr = rdmsr(MDD_UART2_CONF);
msr.lo = 1; // reset msr.lo = 1; // reset
@@ -390,36 +394,33 @@ static void uarts_init(struct southbridge_amd_cs5536_config *sb){
/* Disable the IRQ */ /* Disable the IRQ */
msr = rdmsr(MDD_LEG_IO); msr = rdmsr(MDD_LEG_IO);
msr.lo |= ~(0xF << 20); msr.lo |= ~(0xF << 20);
wrmsr(MDD_LEG_IO,msr); wrmsr(MDD_LEG_IO, msr);
} }
} }
#define HCCPARAMS 0x08 #define HCCPARAMS 0x08
#define IPREG04 0xA0 #define IPREG04 0xA0
#define USB_HCCPW_SET (1 << 1) #define USB_HCCPW_SET (1 << 1)
#define UOCCAP 0x00 #define UOCCAP 0x00
#define APU_SET (1 << 15) #define APU_SET (1 << 15)
#define UOCMUX 0x04 #define UOCMUX 0x04
#define PMUX_HOST 0x02 #define PMUX_HOST 0x02
#define PMUX_DEVICE 0x03 #define PMUX_DEVICE 0x03
#define PUEN_SET (1 << 2) #define PUEN_SET (1 << 2)
#define UDCDEVCTL 0x404 #define UDCDEVCTL 0x404
#define UDC_SD_SET (1 << 10) #define UDC_SD_SET (1 << 10)
#define UOCCTL 0x0C #define UOCCTL 0x0C
#define PADEN_SET (1 << 7) #define PADEN_SET (1 << 7)
static void enable_USB_port4(struct southbridge_amd_cs5536_config *sb) static void enable_USB_port4(struct southbridge_amd_cs5536_config *sb)
{ {
uint32_t * bar; uint32_t *bar;
msr_t msr; msr_t msr;
device_t dev; device_t dev;
dev = dev_find_device(PCI_VENDOR_ID_AMD,
dev = dev_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_EHCI, 0); PCI_DEVICE_ID_AMD_CS5536_EHCI, 0);
if(dev){ if (dev) {
/* Serial Short Detect Enable */ /* Serial Short Detect Enable */
msr = rdmsr(USB2_SB_GLD_MSR_CONF); msr = rdmsr(USB2_SB_GLD_MSR_CONF);
@@ -427,7 +428,7 @@ static void enable_USB_port4(struct southbridge_amd_cs5536_config *sb)
wrmsr(USB2_SB_GLD_MSR_CONF, msr); wrmsr(USB2_SB_GLD_MSR_CONF, msr);
/* write to clear diag register */ /* write to clear diag register */
wrmsr(USB2_SB_GLD_MSR_DIAG,rdmsr(USB2_SB_GLD_MSR_DIAG)); wrmsr(USB2_SB_GLD_MSR_DIAG, rdmsr(USB2_SB_GLD_MSR_DIAG));
bar = (uint32_t *) pci_read_config32(dev, PCI_BASE_ADDRESS_0); bar = (uint32_t *) pci_read_config32(dev, PCI_BASE_ADDRESS_0);
@@ -438,9 +439,9 @@ static void enable_USB_port4(struct southbridge_amd_cs5536_config *sb)
*(bar + HCCPARAMS) = 0x00005012; *(bar + HCCPARAMS) = 0x00005012;
} }
dev = dev_find_device(PCI_VENDOR_ID_AMD,
dev = dev_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_OTG, 0); PCI_DEVICE_ID_AMD_CS5536_OTG, 0);
if(dev){ if (dev) {
bar = (uint32_t *) pci_read_config32(dev, PCI_BASE_ADDRESS_0); bar = (uint32_t *) pci_read_config32(dev, PCI_BASE_ADDRESS_0);
*(bar + UOCMUX) &= PUEN_SET; *(bar + UOCMUX) &= PUEN_SET;
@@ -448,8 +449,7 @@ static void enable_USB_port4(struct southbridge_amd_cs5536_config *sb)
/* Host or Device? */ /* Host or Device? */
if (sb->enable_USBP4_device) { if (sb->enable_USBP4_device) {
*(bar + UOCMUX) |= PMUX_DEVICE; *(bar + UOCMUX) |= PMUX_DEVICE;
} } else {
else{
*(bar + UOCMUX) |= PMUX_HOST; *(bar + UOCMUX) |= PMUX_HOST;
} }
@@ -466,29 +466,35 @@ static void enable_USB_port4(struct southbridge_amd_cs5536_config *sb)
* - set PADEN (former OTGPADEN) bit in uoc register * - set PADEN (former OTGPADEN) bit in uoc register
* - set APU bit in uoc register */ * - set APU bit in uoc register */
if (sb->enable_USBP4_device) { if (sb->enable_USBP4_device) {
dev = dev_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_UDC, 0); dev = dev_find_device(PCI_VENDOR_ID_AMD,
if(dev){ PCI_DEVICE_ID_AMD_CS5536_UDC, 0);
bar = (uint32_t *) pci_read_config32(dev, PCI_BASE_ADDRESS_0); if (dev) {
bar = (uint32_t *) pci_read_config32(dev,
PCI_BASE_ADDRESS_0);
*(bar + UDCDEVCTL) |= UDC_SD_SET; *(bar + UDCDEVCTL) |= UDC_SD_SET;
} }
dev = dev_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_OTG, 0); dev = dev_find_device(PCI_VENDOR_ID_AMD,
if(dev){ PCI_DEVICE_ID_AMD_CS5536_OTG, 0);
bar = (uint32_t *) pci_read_config32(dev, PCI_BASE_ADDRESS_0); if (dev) {
bar = (uint32_t *) pci_read_config32(dev,
PCI_BASE_ADDRESS_0);
*(bar + UOCCTL) |= PADEN_SET; *(bar + UOCCTL) |= PADEN_SET;
*(bar + UOCCAP) |= APU_SET; *(bar + UOCCAP) |= APU_SET;
} }
} }
/* Disable virtual PCI UDC and OTG headers */ /* Disable virtual PCI UDC and OTG headers */
dev = dev_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_UDC, 0); dev = dev_find_device(PCI_VENDOR_ID_AMD,
if(dev){ PCI_DEVICE_ID_AMD_CS5536_UDC, 0);
if (dev) {
pci_write_config8(dev, 0x7C, 0xDEADBEEF); pci_write_config8(dev, 0x7C, 0xDEADBEEF);
} }
dev = dev_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_OTG, 0); dev = dev_find_device(PCI_VENDOR_ID_AMD,
if(dev){ PCI_DEVICE_ID_AMD_CS5536_OTG, 0);
if (dev) {
pci_write_config8(dev, 0x7C, 0xDEADBEEF); pci_write_config8(dev, 0x7C, 0xDEADBEEF);
} }
} }
@@ -499,20 +505,22 @@ static void enable_USB_port4(struct southbridge_amd_cs5536_config *sb)
/* Called from northbridge init (Pre-VSA). */ /* Called from northbridge init (Pre-VSA). */
/* **/ /* **/
/* ***************************************************************************/ /* ***************************************************************************/
void chipsetinit (void){ void chipsetinit(void)
{
device_t dev; device_t dev;
msr_t msr; msr_t msr;
uint32_t msrnum; uint32_t msrnum;
struct southbridge_amd_cs5536_config *sb = (struct southbridge_amd_cs5536_config *)dev->chip_info; struct southbridge_amd_cs5536_config *sb =
(struct southbridge_amd_cs5536_config *)dev->chip_info;
struct msrinit *csi; struct msrinit *csi;
outb( P80_CHIPSET_INIT, 0x80); outb(P80_CHIPSET_INIT, 0x80);
/* we hope NEVER to be in linuxbios when S3 resumes /* we hope NEVER to be in linuxbios when S3 resumes
if (! IsS3Resume()) */ if (! IsS3Resume()) */
{ {
struct acpiinit *aci = acpi_init_table; struct acpiinit *aci = acpi_init_table;
for(; aci->ioreg; aci++) { for (; aci->ioreg; aci++) {
outl(aci->regdata, aci->ioreg); outl(aci->regdata, aci->ioreg);
inl(aci->ioreg); inl(aci->ioreg);
} }
@@ -520,43 +528,42 @@ void chipsetinit (void){
pmChipsetInit(); pmChipsetInit();
} }
/* set hd IRQ */ /* set hd IRQ */
outl( GPIOL_2_SET, GPIO_IO_BASE + GPIOL_INPUT_ENABLE); outl(GPIOL_2_SET, GPIO_IO_BASE + GPIOL_INPUT_ENABLE);
outl( GPIOL_2_SET, GPIO_IO_BASE + GPIOL_IN_AUX1_SELECT); outl(GPIOL_2_SET, GPIO_IO_BASE + GPIOL_IN_AUX1_SELECT);
/* Allow IO read and writes during a ATA DMA operation.*/ /* Allow IO read and writes during a ATA DMA operation. */
/* This could be done in the HD rom but do it here for easier debugging.*/ /* This could be done in the HD rom but do it here for easier debugging. */
msrnum = ATA_SB_GLD_MSR_ERR; msrnum = ATA_SB_GLD_MSR_ERR;
msr = rdmsr(msrnum); msr = rdmsr(msrnum);
msr.lo &= ~0x100; msr.lo &= ~0x100;
wrmsr(msrnum, msr); wrmsr(msrnum, msr);
/* Enable Post Primary IDE.*/ /* Enable Post Primary IDE. */
msrnum = GLPCI_SB_CTRL; msrnum = GLPCI_SB_CTRL;
msr = rdmsr(msrnum); msr = rdmsr(msrnum);
msr.lo |= GLPCI_CRTL_PPIDE_SET; msr.lo |= GLPCI_CRTL_PPIDE_SET;
wrmsr(msrnum, msr); wrmsr(msrnum, msr);
csi = SB_MASTER_CONF_TABLE; csi = SB_MASTER_CONF_TABLE;
for(; csi->msrnum; csi++){ for (; csi->msrnum; csi++) {
msr.lo = csi->msr.lo; msr.lo = csi->msr.lo;
msr.hi = csi->msr.hi; msr.hi = csi->msr.hi;
wrmsr(csi->msrnum, msr); // MSR - see table above wrmsr(csi->msrnum, msr); // MSR - see table above
} }
/* Flash BAR size Setup*/ /* Flash BAR size Setup */
printk_err("%sDoing ChipsetFlashSetup()\n", sb->enable_ide_nand_flash == 1 ? "" : "Not "); printk_err("%sDoing ChipsetFlashSetup()\n",
sb->enable_ide_nand_flash == 1 ? "" : "Not ");
if (sb->enable_ide_nand_flash == 1) if (sb->enable_ide_nand_flash == 1)
ChipsetFlashSetup(); ChipsetFlashSetup();
/* */ /* */
/* Set up Hardware Clock Gating*/ /* Set up Hardware Clock Gating */
/* */ /* */
{ {
csi = CS5536_CLOCK_GATING_TABLE; csi = CS5536_CLOCK_GATING_TABLE;
for(; csi->msrnum; csi++){ for (; csi->msrnum; csi++) {
msr.lo = csi->msr.lo; msr.lo = csi->msr.lo;
msr.hi = csi->msr.hi; msr.hi = csi->msr.hi;
wrmsr(csi->msrnum, msr); // MSR - see table above wrmsr(csi->msrnum, msr); // MSR - see table above
@@ -566,7 +573,8 @@ void chipsetinit (void){
static void southbridge_init(struct device *dev) static void southbridge_init(struct device *dev)
{ {
struct southbridge_amd_cs5536_config *sb = (struct southbridge_amd_cs5536_config *)dev->chip_info; struct southbridge_amd_cs5536_config *sb =
(struct southbridge_amd_cs5536_config *)dev->chip_info;
int i; int i;
/* /*
* struct device *gpiodev; * struct device *gpiodev;
@@ -578,12 +586,15 @@ static void southbridge_init(struct device *dev)
lpc_init(sb); lpc_init(sb);
uarts_init(sb); uarts_init(sb);
if (sb->enable_gpio_int_route){ if (sb->enable_gpio_int_route) {
vrWrite((VRC_MISCELLANEOUS << 8) + PCI_INT_AB, (sb->enable_gpio_int_route & 0xFFFF)); vrWrite((VRC_MISCELLANEOUS << 8) + PCI_INT_AB,
vrWrite((VRC_MISCELLANEOUS << 8) + PCI_INT_CD, (sb->enable_gpio_int_route >> 16)); (sb->enable_gpio_int_route & 0xFFFF));
vrWrite((VRC_MISCELLANEOUS << 8) + PCI_INT_CD,
(sb->enable_gpio_int_route >> 16));
} }
printk_err("cs5536: %s: enable_ide_nand_flash is %d\n", __FUNCTION__, sb->enable_ide_nand_flash); printk_err("cs5536: %s: enable_ide_nand_flash is %d\n", __FUNCTION__,
sb->enable_ide_nand_flash);
if (sb->enable_ide_nand_flash == 1) { if (sb->enable_ide_nand_flash == 1) {
enable_ide_nand_flash_header(); enable_ide_nand_flash_header();
} }
@@ -592,13 +603,13 @@ static void southbridge_init(struct device *dev)
/* disable unwanted virtual PCI devices */ /* disable unwanted virtual PCI devices */
for (i = 0; (i < MAX_UNWANTED_VPCI) && (0 != sb->unwanted_vpci[i]); i++) { for (i = 0; (i < MAX_UNWANTED_VPCI) && (0 != sb->unwanted_vpci[i]); i++) {
printk_debug("Disabling VPCI device: 0x%08X\n", sb->unwanted_vpci[i]); printk_debug("Disabling VPCI device: 0x%08X\n",
sb->unwanted_vpci[i]);
outl(sb->unwanted_vpci[i] + 0x7C, 0xCF8); outl(sb->unwanted_vpci[i] + 0x7C, 0xCF8);
outl(0xDEADBEEF, 0xCFC); outl(0xDEADBEEF, 0xCFC);
} }
} }
static void southbridge_enable(struct device *dev) static void southbridge_enable(struct device *dev)
{ {
printk_err("cs5536: %s: dev is %p\n", __FUNCTION__, dev); printk_err("cs5536: %s: dev is %p\n", __FUNCTION__, dev);

View File

@@ -78,7 +78,7 @@
/* */ /* */
#define USB2_SB_GLD_MSR_CAP (MSR_SB_USB2 + 0x00) #define USB2_SB_GLD_MSR_CAP (MSR_SB_USB2 + 0x00)
#define USB2_SB_GLD_MSR_CONF (MSR_SB_USB2 + 0x01) #define USB2_SB_GLD_MSR_CONF (MSR_SB_USB2 + 0x01)
#define USB2_UPPER_SSDEN_SET (1 << 3 ) /* Bit 35 */ #define USB2_UPPER_SSDEN_SET (1 << 3 ) /* Bit 35 */
#define USB2_SB_GLD_MSR_PM (MSR_SB_USB2 + 0x04) #define USB2_SB_GLD_MSR_PM (MSR_SB_USB2 + 0x04)
#define USB2_SB_GLD_MSR_DIAG (MSR_SB_USB2 + 0x05) #define USB2_SB_GLD_MSR_DIAG (MSR_SB_USB2 + 0x05)
#define USB2_SB_GLD_MSR_OHCI_BASE (MSR_SB_USB2 + 0x08) #define USB2_SB_GLD_MSR_OHCI_BASE (MSR_SB_USB2 + 0x08)
@@ -203,7 +203,6 @@
#define MDD_RTC_MONA_IND (MSR_SB_MDD + 0x056) #define MDD_RTC_MONA_IND (MSR_SB_MDD + 0x056)
#define MDD_RTC_CENTURY_OFFSET (MSR_SB_MDD + 0x057) #define MDD_RTC_CENTURY_OFFSET (MSR_SB_MDD + 0x057)
/* ***********************************************************/ /* ***********************************************************/
/* LBUS Device Equates - */ /* LBUS Device Equates - */
/* ***********************************************************/ /* ***********************************************************/
@@ -321,7 +320,6 @@
#define GPIOH_30_CLEAR (1 << 30) #define GPIOH_30_CLEAR (1 << 30)
#define GPIOH_31_CLEAR (1 << 31) #define GPIOH_31_CLEAR (1 << 31)
/* GPIO LOW Bank Bit Registers*/ /* GPIO LOW Bank Bit Registers*/
#define GPIOL_OUTPUT_VALUE (0x00) #define GPIOL_OUTPUT_VALUE (0x00)
#define GPIOL_OUTPUT_ENABLE (0x04) #define GPIOL_OUTPUT_ENABLE (0x04)
@@ -439,7 +437,6 @@
#define PM_AWKD (0x50) #define PM_AWKD (0x50)
#define PM_SSC (0x54) #define PM_SSC (0x54)
/* FLASH device macros */ /* FLASH device macros */
#define FLASH_TYPE_NONE 0 /* No flash device installed */ #define FLASH_TYPE_NONE 0 /* No flash device installed */
#define FLASH_TYPE_NAND 1 /* NAND device */ #define FLASH_TYPE_NAND 1 /* NAND device */
@@ -467,5 +464,4 @@
#define FLASH_IO_128B 0x0000FF80 #define FLASH_IO_128B 0x0000FF80
#define FLASH_IO_256B 0x0000FF00 #define FLASH_IO_256B 0x0000FF00
#endif /* _CS5536_H */ #endif /* _CS5536_H */

View File

@@ -33,9 +33,11 @@ static void cs5536_setup_extmsr(void)
/* forward MSR access to CS5536_GLINK_PORT_NUM to CS5536_DEV_NUM */ /* forward MSR access to CS5536_GLINK_PORT_NUM to CS5536_DEV_NUM */
msr.hi = msr.lo = 0x00000000; msr.hi = msr.lo = 0x00000000;
if (CS5536_GLINK_PORT_NUM <= 4) { if (CS5536_GLINK_PORT_NUM <= 4) {
msr.lo = CS5536_DEV_NUM << (unsigned char)((CS5536_GLINK_PORT_NUM - 1) * 8); msr.lo = CS5536_DEV_NUM <<
(unsigned char)((CS5536_GLINK_PORT_NUM - 1) * 8);
} else { } else {
msr.hi = CS5536_DEV_NUM << (unsigned char)((CS5536_GLINK_PORT_NUM - 5) * 8); msr.hi = CS5536_DEV_NUM <<
(unsigned char)((CS5536_GLINK_PORT_NUM - 5) * 8);
} }
wrmsr(GLPCI_ExtMSR, msr); wrmsr(GLPCI_ExtMSR, msr);
} }
@@ -96,9 +98,10 @@ static void cs5536_setup_power_button(void)
outl(0x40020000, PMS_IO_BASE + 0x40); outl(0x40020000, PMS_IO_BASE + 0x40);
/* setup GPIO24, it is the external signal for 5536 vsb_work_aux /* setup GPIO24, it is the external signal for 5536 vsb_work_aux
; which controls all voltage rails except Vstandby & Vmem. * which controls all voltage rails except Vstandby & Vmem.
; We need to enable, OUT_AUX1 and OUTPUT_ENABLE in this order. * We need to enable, OUT_AUX1 and OUTPUT_ENABLE in this order.
; If GPIO24 is not enabled then soft-off will not work. */ * If GPIO24 is not enabled then soft-off will not work.
*/
outl(GPIOH_24_SET, GPIO_IO_BASE + GPIOH_OUT_AUX1_SELECT); outl(GPIOH_24_SET, GPIO_IO_BASE + GPIOH_OUT_AUX1_SELECT);
outl(GPIOH_24_SET, GPIO_IO_BASE + GPIOH_OUTPUT_ENABLE); outl(GPIOH_24_SET, GPIO_IO_BASE + GPIOH_OUTPUT_ENABLE);
@@ -123,8 +126,9 @@ static void cs5536_setup_gpio(void)
static void cs5536_disable_internal_uart(void) static void cs5536_disable_internal_uart(void)
{ {
msr_t msr; msr_t msr;
/* ; The UARTs default to enabled. /* The UARTs default to enabled.
; Disable and reset them and configure them later. (SIO init) */ * Disable and reset them and configure them later. (SIO init)
*/
msr = rdmsr(MDD_UART1_CONF); msr = rdmsr(MDD_UART1_CONF);
msr.lo = 1; // reset msr.lo = 1; // reset
wrmsr(MDD_UART1_CONF, msr); wrmsr(MDD_UART1_CONF, msr);
@@ -149,7 +153,6 @@ static void cs5536_setup_cis_mode(void)
wrmsr(GLPCI_SB_CTRL, msr); wrmsr(GLPCI_SB_CTRL, msr);
} }
/* see page 412 of the cs5536 companion book */ /* see page 412 of the cs5536 companion book */
static void cs5536_setup_onchipuart(void) static void cs5536_setup_onchipuart(void)
{ {
@@ -178,7 +181,7 @@ static void cs5536_setup_onchipuart(void)
/* set address to 3F8 */ /* set address to 3F8 */
msr = rdmsr(MDD_LEG_IO); msr = rdmsr(MDD_LEG_IO);
msr.lo |= 0x7 << 16; msr.lo |= 0x7 << 16;
wrmsr(MDD_LEG_IO,msr); wrmsr(MDD_LEG_IO, msr);
/* Bit 1 = DEVEN (device enable) /* Bit 1 = DEVEN (device enable)
* Bit 4 = EN_BANKS (allow access to the upper banks * Bit 4 = EN_BANKS (allow access to the upper banks

View File

@@ -24,13 +24,12 @@
#define SMBUS_WAIT_UNTIL_DONE_TIMEOUT -3 #define SMBUS_WAIT_UNTIL_DONE_TIMEOUT -3
#define SMBUS_TIMEOUT (1000) #define SMBUS_TIMEOUT (1000)
/* initialization for SMBus Controller */ /* initialization for SMBus Controller */
static void cs5536_enable_smbus(void) static void cs5536_enable_smbus(void)
{ {
/* Set SCL freq and enable SMB controller */ /* Set SCL freq and enable SMB controller */
/*outb((0x20 << 1) | SMB_CTRL2_ENABLE, smbus_io_base + SMB_CTRL2);*/ /*outb((0x20 << 1) | SMB_CTRL2_ENABLE, smbus_io_base + SMB_CTRL2); */
outb((0x7F << 1) | SMB_CTRL2_ENABLE, SMBUS_IO_BASE + SMB_CTRL2); outb((0x7F << 1) | SMB_CTRL2_ENABLE, SMBUS_IO_BASE + SMB_CTRL2);
/* Setup SMBus host controller address to 0xEF */ /* Setup SMBus host controller address to 0xEF */
@@ -43,8 +42,8 @@ static void smbus_delay(void)
/* inb(0x80); */ /* inb(0x80); */
} }
static int smbus_wait(unsigned smbus_io_base)
static int smbus_wait(unsigned smbus_io_base) { {
unsigned long loops = SMBUS_TIMEOUT; unsigned long loops = SMBUS_TIMEOUT;
unsigned char val; unsigned char val;
@@ -54,10 +53,10 @@ static int smbus_wait(unsigned smbus_io_base) {
if ((val & SMB_STS_SDAST) != 0) if ((val & SMB_STS_SDAST) != 0)
break; break;
if (val & (SMB_STS_BER | SMB_STS_NEGACK)) { if (val & (SMB_STS_BER | SMB_STS_NEGACK)) {
/*printk_debug("SMBUS WAIT ERROR %x\n", val);*/ /*printk_debug("SMBUS WAIT ERROR %x\n", val); */
return SMBUS_ERROR; return SMBUS_ERROR;
} }
} while(--loops); } while (--loops);
return loops ? 0 : SMBUS_WAIT_UNTIL_READY_TIMEOUT; return loops ? 0 : SMBUS_WAIT_UNTIL_READY_TIMEOUT;
} }
@@ -91,8 +90,8 @@ static int smbus_check_stop_condition(unsigned smbus_io_base)
break; break;
} }
outb((0x7F << 1) | SMB_CTRL2_ENABLE, smbus_io_base + SMB_CTRL2); outb((0x7F << 1) | SMB_CTRL2_ENABLE, smbus_io_base + SMB_CTRL2);
} while(--loops); } while (--loops);
return loops?0:SMBUS_WAIT_UNTIL_READY_TIMEOUT; return loops ? 0 : SMBUS_WAIT_UNTIL_READY_TIMEOUT;
} }
static int smbus_stop_condition(unsigned smbus_io_base) static int smbus_stop_condition(unsigned smbus_io_base)
@@ -113,7 +112,8 @@ static int smbus_ack(unsigned smbus_io_base, int state)
return 0; return 0;
} }
static int smbus_send_slave_address(unsigned smbus_io_base, unsigned char device) static int smbus_send_slave_address(unsigned smbus_io_base,
unsigned char device)
{ {
unsigned char val; unsigned char val;
@@ -122,9 +122,8 @@ static int smbus_send_slave_address(unsigned smbus_io_base, unsigned char device
/* check for bus conflict and NACK */ /* check for bus conflict and NACK */
val = inb(smbus_io_base + SMB_STS); val = inb(smbus_io_base + SMB_STS);
if (((val & SMB_STS_BER) != 0) || if (((val & SMB_STS_BER) != 0) || ((val & SMB_STS_NEGACK) != 0)) {
((val & SMB_STS_NEGACK) != 0)) { /* printk_debug("SEND SLAVE ERROR (%x)\n", val); */
/* printk_debug("SEND SLAVE ERROR (%x)\n", val);*/
return SMBUS_ERROR; return SMBUS_ERROR;
} }
return smbus_wait(smbus_io_base); return smbus_wait(smbus_io_base);
@@ -139,8 +138,7 @@ static int smbus_send_command(unsigned smbus_io_base, unsigned char command)
/* check for bus conflict and NACK */ /* check for bus conflict and NACK */
val = inb(smbus_io_base + SMB_STS); val = inb(smbus_io_base + SMB_STS);
if (((val & SMB_STS_BER) != 0) || if (((val & SMB_STS_BER) != 0) || ((val & SMB_STS_NEGACK) != 0))
((val & SMB_STS_NEGACK) != 0))
return SMBUS_ERROR; return SMBUS_ERROR;
return smbus_wait(smbus_io_base); return smbus_wait(smbus_io_base);
@@ -151,7 +149,9 @@ static unsigned char smbus_get_result(unsigned smbus_io_base)
return inb(smbus_io_base + SMB_SDA); return inb(smbus_io_base + SMB_SDA);
} }
static unsigned char do_smbus_read_byte(unsigned smbus_io_base, unsigned char device, unsigned char address) static unsigned char do_smbus_read_byte(unsigned smbus_io_base,
unsigned char device,
unsigned char address)
{ {
unsigned char error = 0; unsigned char error = 0;
@@ -170,7 +170,7 @@ static unsigned char do_smbus_read_byte(unsigned smbus_io_base, unsigned char de
goto err; goto err;
} }
smbus_ack(smbus_io_base, 1 ); smbus_ack(smbus_io_base, 1);
if ((smbus_send_command(smbus_io_base, address))) { if ((smbus_send_command(smbus_io_base, address))) {
error = 4; error = 4;
@@ -194,8 +194,7 @@ static unsigned char do_smbus_read_byte(unsigned smbus_io_base, unsigned char de
return smbus_get_result(smbus_io_base); return smbus_get_result(smbus_io_base);
err:
err:
print_debug("SMBUS READ ERROR:"); print_debug("SMBUS READ ERROR:");
print_debug_hex8(error); print_debug_hex8(error);
print_debug(" device:"); print_debug(" device:");
@@ -212,4 +211,3 @@ static inline int smbus_read_byte(unsigned device, unsigned address)
{ {
return do_smbus_read_byte(SMBUS_IO_BASE, device, address); return do_smbus_read_byte(SMBUS_IO_BASE, device, address);
} }

View File

@@ -62,13 +62,13 @@
#define SMBUS_TIMEOUT (100*1000*10) #define SMBUS_TIMEOUT (100*1000*10)
#define SMBUS_STATUS_MASK 0xfbff #define SMBUS_STATUS_MASK 0xfbff
static void smbus_delay(void) static void smbus_delay(void)
{ {
inb(0x80); inb(0x80);
} }
static int smbus_wait(unsigned smbus_io_base) { static int smbus_wait(unsigned smbus_io_base)
{
unsigned long loops = SMBUS_TIMEOUT; unsigned long loops = SMBUS_TIMEOUT;
unsigned char val; unsigned char val;
@@ -81,13 +81,14 @@ static int smbus_wait(unsigned smbus_io_base) {
printk_debug("SMBUS WAIT ERROR %x\n", val); printk_debug("SMBUS WAIT ERROR %x\n", val);
return SMBUS_ERROR; return SMBUS_ERROR;
} }
} while(--loops); } while (--loops);
outb(0, smbus_io_base + SMB_STS); outb(0, smbus_io_base + SMB_STS);
return loops ? 0 : SMBUS_WAIT_UNTIL_READY_TIMEOUT; return loops ? 0 : SMBUS_WAIT_UNTIL_READY_TIMEOUT;
} }
static int smbus_write(unsigned smbus_io_base, unsigned char byte) { static int smbus_write(unsigned smbus_io_base, unsigned char byte)
{
outb(byte, smbus_io_base + SMB_SDA); outb(byte, smbus_io_base + SMB_SDA);
return smbus_wait(smbus_io_base); return smbus_wait(smbus_io_base);
@@ -122,8 +123,8 @@ static int smbus_check_stop_condition(unsigned smbus_io_base)
if ((val & SMB_CTRL1_STOP) == 0) { if ((val & SMB_CTRL1_STOP) == 0) {
break; break;
} }
} while(--loops); } while (--loops);
return loops?0:SMBUS_WAIT_UNTIL_READY_TIMEOUT; return loops ? 0 : SMBUS_WAIT_UNTIL_READY_TIMEOUT;
/* Make sure everything is cleared and ready to go */ /* Make sure everything is cleared and ready to go */
@@ -159,7 +160,8 @@ static int smbus_ack(unsigned smbus_io_base, int state)
return 0; return 0;
} }
static int smbus_send_slave_address(unsigned smbus_io_base, unsigned char device) static int smbus_send_slave_address(unsigned smbus_io_base,
unsigned char device)
{ {
unsigned char val; unsigned char val;
@@ -168,8 +170,7 @@ static int smbus_send_slave_address(unsigned smbus_io_base, unsigned char device
/* check for bus conflict and NACK */ /* check for bus conflict and NACK */
val = inb(smbus_io_base + SMB_STS); val = inb(smbus_io_base + SMB_STS);
if (((val & SMB_STS_BER) != 0) || if (((val & SMB_STS_BER) != 0) || ((val & SMB_STS_NEGACK) != 0)) {
((val & SMB_STS_NEGACK) != 0)) {
printk_debug("SEND SLAVE ERROR (%x)\n", val); printk_debug("SEND SLAVE ERROR (%x)\n", val);
return SMBUS_ERROR; return SMBUS_ERROR;
} }
@@ -185,8 +186,7 @@ static int smbus_send_command(unsigned smbus_io_base, unsigned char command)
/* check for bus conflict and NACK */ /* check for bus conflict and NACK */
val = inb(smbus_io_base + SMB_STS); val = inb(smbus_io_base + SMB_STS);
if (((val & SMB_STS_BER) != 0) || if (((val & SMB_STS_BER) != 0) || ((val & SMB_STS_NEGACK) != 0))
((val & SMB_STS_NEGACK) != 0))
return SMBUS_ERROR; return SMBUS_ERROR;
return smbus_wait(smbus_io_base); return smbus_wait(smbus_io_base);
@@ -226,7 +226,7 @@ static void _doread(unsigned smbus_io_base, unsigned char device,
if ((ret = smbus_send_slave_address(smbus_io_base, device | 0x01))) if ((ret = smbus_send_slave_address(smbus_io_base, device | 0x01)))
goto err; goto err;
while(count) { while (count) {
/* Set the ACK if this is the next to last byte */ /* Set the ACK if this is the next to last byte */
smbus_ack(smbus_io_base, (count == 2) ? 1 : 0); smbus_ack(smbus_io_base, (count == 2) ? 1 : 0);
@@ -263,16 +263,18 @@ static unsigned char do_smbus_read_byte(unsigned smbus_io_base,
} }
static unsigned short do_smbus_read_word(unsigned smbus_io_base, static unsigned short do_smbus_read_word(unsigned smbus_io_base,
unsigned char device, unsigned char address) unsigned char device,
unsigned char address)
{ {
unsigned short val = 0; unsigned short val = 0;
_doread(smbus_io_base, device, address, (unsigned char *) &val, _doread(smbus_io_base, device, address, (unsigned char *)&val,
sizeof(val)); sizeof(val));
return val; return val;
} }
static int _dowrite(unsigned smbus_io_base, unsigned char device, static int _dowrite(unsigned smbus_io_base, unsigned char device,
unsigned char address, unsigned char *data, int count) { unsigned char address, unsigned char *data, int count)
{
int ret; int ret;
@@ -288,7 +290,7 @@ static int _dowrite(unsigned smbus_io_base, unsigned char device,
if ((ret = smbus_send_command(smbus_io_base, address))) if ((ret = smbus_send_command(smbus_io_base, address)))
goto err; goto err;
while(count) { while (count) {
if ((ret = smbus_write(smbus_io_base, *data++))) if ((ret = smbus_write(smbus_io_base, *data++)))
goto err; goto err;
count--; count--;
@@ -302,16 +304,16 @@ static int _dowrite(unsigned smbus_io_base, unsigned char device,
return -1; return -1;
} }
static int do_smbus_write_byte(unsigned smbus_io_base, unsigned char device, static int do_smbus_write_byte(unsigned smbus_io_base, unsigned char device,
unsigned char address, unsigned char data) unsigned char address, unsigned char data)
{ {
return _dowrite(smbus_io_base, device, address, return _dowrite(smbus_io_base, device, address,
(unsigned char *) &data, 1); (unsigned char *)&data, 1);
} }
static int do_smbus_write_word(unsigned smbus_io_base, unsigned char device, unsigned char address, static int do_smbus_write_word(unsigned smbus_io_base, unsigned char device,
unsigned short data) unsigned char address, unsigned short data)
{ {
return _dowrite(smbus_io_base, device ,address, (unsigned char *) &data, 2); return _dowrite(smbus_io_base, device, address, (unsigned char *)&data,
2);
} }