diff --git a/src/southbridge/amd/agesa/hudson/smbus_spd.c b/src/southbridge/amd/agesa/hudson/smbus_spd.c index 7dcbbf9a50..c240e5b877 100644 --- a/src/southbridge/amd/agesa/hudson/smbus_spd.c +++ b/src/southbridge/amd/agesa/hudson/smbus_spd.c @@ -16,31 +16,31 @@ * readSmbusByteData - read a single SPD byte from any offset */ -static int readSmbusByteData (int iobase, int address, char *buffer, int offset) +static int readSmbusByteData(int iobase, int address, char *buffer, int offset) { unsigned int status; UINT64 limit; address |= 1; // set read bit - __outbyte (iobase + 0, 0xFF); // clear error status - __outbyte (iobase + 1, 0x1F); // clear error status - __outbyte (iobase + 3, offset); // offset in eeprom - __outbyte (iobase + 4, address); // slave address and read bit - __outbyte (iobase + 2, 0x48); // read byte command + __outbyte(iobase + 0, 0xFF); // clear error status + __outbyte(iobase + 1, 0x1F); // clear error status + __outbyte(iobase + 3, offset); // offset in eeprom + __outbyte(iobase + 4, address); // slave address and read bit + __outbyte(iobase + 2, 0x48); // read byte command // time limit to avoid hanging for unexpected error status (should never happen) - limit = __rdtsc () + 2000000000 / 10; + limit = __rdtsc() + 2000000000 / 10; for (;;) { - status = __inbyte (iobase); - if (__rdtsc () > limit) break; + status = __inbyte(iobase); + if (__rdtsc() > limit) break; if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting if ((status & 1) == 1) continue; // HostBusy set, keep waiting break; } - buffer [0] = __inbyte (iobase + 5); + buffer [0] = __inbyte(iobase + 5); if (status == 2) status = 0; // check for done with no errors return status; } @@ -51,26 +51,26 @@ static int readSmbusByteData (int iobase, int address, char *buffer, int offset) * this function is faster function readSmbusByteData */ -static int readSmbusByte (int iobase, int address, char *buffer) +static int readSmbusByte(int iobase, int address, char *buffer) { unsigned int status; UINT64 limit; - __outbyte (iobase + 0, 0xFF); // clear error status - __outbyte (iobase + 2, 0x44); // read command + __outbyte(iobase + 0, 0xFF); // clear error status + __outbyte(iobase + 2, 0x44); // read command // time limit to avoid hanging for unexpected error status - limit = __rdtsc () + 2000000000 / 10; + limit = __rdtsc() + 2000000000 / 10; for (;;) { - status = __inbyte (iobase); - if (__rdtsc () > limit) break; + status = __inbyte(iobase); + if (__rdtsc() > limit) break; if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting if ((status & 1) == 1) continue; // HostBusy set, keep waiting break; } - buffer [0] = __inbyte (iobase + 5); + buffer [0] = __inbyte(iobase + 5); if (status == 2) status = 0; // check for done with no errors return status; } @@ -84,7 +84,7 @@ static int readSmbusByte (int iobase, int address, char *buffer) * Reads 128 bytes in 7-8 ms at 400 KHz. */ -static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count) +static int readspd(int iobase, int SmbusSlaveAddress, char *buffer, int count) { int index, error; @@ -93,7 +93,7 @@ static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count) iobase, SmbusSlaveAddress, count); /* read the first byte using offset zero */ - error = readSmbusByteData (iobase, SmbusSlaveAddress, buffer, 0); + error = readSmbusByteData(iobase, SmbusSlaveAddress, buffer, 0); if (error) { printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n"); @@ -103,7 +103,7 @@ static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count) /* read the remaining bytes using auto-increment for speed */ for (index = 1; index < count; index++) { - error = readSmbusByte (iobase, SmbusSlaveAddress, &buffer [index]); + error = readSmbusByte(iobase, SmbusSlaveAddress, &buffer [index]); if (error) { printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n"); return error; @@ -115,15 +115,15 @@ static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count) return 0; } -static void setupFch (int ioBase) +static void setupFch(int ioBase) { pm_write16(0x2c, ioBase | 1); - __outbyte (ioBase + 0x0E, 66000000 / 400000 / 4); // set SMBus clock to 400 KHz + __outbyte(ioBase + 0x0E, 66000000 / 400000 / 4); // set SMBus clock to 400 KHz } int hudson_readSpd(int spdAddress, char *buf, size_t len) { int ioBase = 0xB00; - setupFch (ioBase); - return readspd (ioBase, spdAddress, buf, len); + setupFch(ioBase); + return readspd(ioBase, spdAddress, buf, len); } diff --git a/src/southbridge/amd/cimx/sb800/smbus_spd.c b/src/southbridge/amd/cimx/sb800/smbus_spd.c index 43e7e0097d..35c1cccdb4 100644 --- a/src/southbridge/amd/cimx/sb800/smbus_spd.c +++ b/src/southbridge/amd/cimx/sb800/smbus_spd.c @@ -101,6 +101,6 @@ static UINT8 readspd(UINT16 iobase, UINT8 SmbusSlaveAddress, char *buffer, int smbus_readSpd(int spdAddress, char *buf, size_t len) { int ioBase = SMBUS0_BASE_ADDRESS; - setupFch (ioBase); - return readspd (ioBase, spdAddress, buf, len); + setupFch(ioBase); + return readspd(ioBase, spdAddress, buf, len); } diff --git a/src/southbridge/amd/pi/hudson/smbus_spd.c b/src/southbridge/amd/pi/hudson/smbus_spd.c index 5a890bc9fd..48914058ad 100644 --- a/src/southbridge/amd/pi/hudson/smbus_spd.c +++ b/src/southbridge/amd/pi/hudson/smbus_spd.c @@ -16,31 +16,31 @@ * readSmbusByteData - read a single SPD byte from any offset */ -static int readSmbusByteData (int iobase, int address, char *buffer, int offset) +static int readSmbusByteData(int iobase, int address, char *buffer, int offset) { unsigned int status; UINT64 limit; address |= 1; // set read bit - __outbyte (iobase + 0, 0xFF); // clear error status - __outbyte (iobase + 1, 0x1F); // clear error status - __outbyte (iobase + 3, offset); // offset in eeprom - __outbyte (iobase + 4, address); // slave address and read bit - __outbyte (iobase + 2, 0x48); // read byte command + __outbyte(iobase + 0, 0xFF); // clear error status + __outbyte(iobase + 1, 0x1F); // clear error status + __outbyte(iobase + 3, offset); // offset in eeprom + __outbyte(iobase + 4, address); // slave address and read bit + __outbyte(iobase + 2, 0x48); // read byte command // time limit to avoid hanging for unexpected error status (should never happen) - limit = __rdtsc () + 2000000000 / 10; + limit = __rdtsc() + 2000000000 / 10; for (;;) { - status = __inbyte (iobase); - if (__rdtsc () > limit) break; + status = __inbyte(iobase); + if (__rdtsc() > limit) break; if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting if ((status & 1) == 1) continue; // HostBusy set, keep waiting break; } - buffer [0] = __inbyte (iobase + 5); + buffer [0] = __inbyte(iobase + 5); if (status == 2) status = 0; // check for done with no errors return status; } @@ -51,26 +51,26 @@ static int readSmbusByteData (int iobase, int address, char *buffer, int offset) * this function is faster function readSmbusByteData */ -static int readSmbusByte (int iobase, int address, char *buffer) +static int readSmbusByte(int iobase, int address, char *buffer) { unsigned int status; UINT64 limit; - __outbyte (iobase + 0, 0xFF); // clear error status - __outbyte (iobase + 2, 0x44); // read command + __outbyte(iobase + 0, 0xFF); // clear error status + __outbyte(iobase + 2, 0x44); // read command // time limit to avoid hanging for unexpected error status - limit = __rdtsc () + 2000000000 / 10; + limit = __rdtsc() + 2000000000 / 10; for (;;) { - status = __inbyte (iobase); - if (__rdtsc () > limit) break; + status = __inbyte(iobase); + if (__rdtsc() > limit) break; if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting if ((status & 1) == 1) continue; // HostBusy set, keep waiting break; } - buffer [0] = __inbyte (iobase + 5); + buffer [0] = __inbyte(iobase + 5); if (status == 2) status = 0; // check for done with no errors return status; } @@ -84,7 +84,7 @@ static int readSmbusByte (int iobase, int address, char *buffer) * Reads 128 bytes in 7-8 ms at 400 KHz. */ -static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count) +static int readspd(int iobase, int SmbusSlaveAddress, char *buffer, int count) { int index, error; @@ -93,7 +93,7 @@ static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count) iobase, SmbusSlaveAddress, count); /* read the first byte using offset zero */ - error = readSmbusByteData (iobase, SmbusSlaveAddress, buffer, 0); + error = readSmbusByteData(iobase, SmbusSlaveAddress, buffer, 0); if (error) { printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n"); @@ -103,7 +103,7 @@ static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count) /* read the remaining bytes using auto-increment for speed */ for (index = 1; index < count; index++) { - error = readSmbusByte (iobase, SmbusSlaveAddress, &buffer [index]); + error = readSmbusByte(iobase, SmbusSlaveAddress, &buffer [index]); if (error) { printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n"); return error; @@ -115,15 +115,15 @@ static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count) return 0; } -static void setupFch (int ioBase) +static void setupFch(int ioBase) { pm_write16(0x2c, ioBase | 1); - __outbyte (ioBase + 0x0E, 66000000 / 400000 / 4); // set SMBus clock to 400 KHz + __outbyte(ioBase + 0x0E, 66000000 / 400000 / 4); // set SMBus clock to 400 KHz } int hudson_readSpd(int spdAddress, char *buf, size_t len) { int ioBase = 0xB00; - setupFch (ioBase); - return readspd (ioBase, spdAddress, buf, len); + setupFch(ioBase); + return readspd(ioBase, spdAddress, buf, len); }