sb/amd/*/*/smbus_spd.c: Fix some white spaces issues
Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Change-Id: I47ee16f2d4be34c42b2e7f9fa4c3a72a7a95967f Reviewed-on: https://review.coreboot.org/c/coreboot/+/65897 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
committed by
Martin L Roth
parent
ba9deba362
commit
558d731a4c
@@ -16,31 +16,31 @@
|
|||||||
* readSmbusByteData - read a single SPD byte from any offset
|
* 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;
|
unsigned int status;
|
||||||
UINT64 limit;
|
UINT64 limit;
|
||||||
|
|
||||||
address |= 1; // set read bit
|
address |= 1; // set read bit
|
||||||
|
|
||||||
__outbyte (iobase + 0, 0xFF); // clear error status
|
__outbyte(iobase + 0, 0xFF); // clear error status
|
||||||
__outbyte (iobase + 1, 0x1F); // clear error status
|
__outbyte(iobase + 1, 0x1F); // clear error status
|
||||||
__outbyte (iobase + 3, offset); // offset in eeprom
|
__outbyte(iobase + 3, offset); // offset in eeprom
|
||||||
__outbyte (iobase + 4, address); // slave address and read bit
|
__outbyte(iobase + 4, address); // slave address and read bit
|
||||||
__outbyte (iobase + 2, 0x48); // read byte command
|
__outbyte(iobase + 2, 0x48); // read byte command
|
||||||
|
|
||||||
// time limit to avoid hanging for unexpected error status (should never happen)
|
// time limit to avoid hanging for unexpected error status (should never happen)
|
||||||
limit = __rdtsc () + 2000000000 / 10;
|
limit = __rdtsc() + 2000000000 / 10;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
status = __inbyte (iobase);
|
status = __inbyte(iobase);
|
||||||
if (__rdtsc () > limit) break;
|
if (__rdtsc() > limit) break;
|
||||||
if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting
|
if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting
|
||||||
if ((status & 1) == 1) continue; // HostBusy set, keep waiting
|
if ((status & 1) == 1) continue; // HostBusy set, keep waiting
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer [0] = __inbyte (iobase + 5);
|
buffer [0] = __inbyte(iobase + 5);
|
||||||
if (status == 2) status = 0; // check for done with no errors
|
if (status == 2) status = 0; // check for done with no errors
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -51,26 +51,26 @@ static int readSmbusByteData (int iobase, int address, char *buffer, int offset)
|
|||||||
* this function is faster function readSmbusByteData
|
* 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;
|
unsigned int status;
|
||||||
UINT64 limit;
|
UINT64 limit;
|
||||||
|
|
||||||
__outbyte (iobase + 0, 0xFF); // clear error status
|
__outbyte(iobase + 0, 0xFF); // clear error status
|
||||||
__outbyte (iobase + 2, 0x44); // read command
|
__outbyte(iobase + 2, 0x44); // read command
|
||||||
|
|
||||||
// time limit to avoid hanging for unexpected error status
|
// time limit to avoid hanging for unexpected error status
|
||||||
limit = __rdtsc () + 2000000000 / 10;
|
limit = __rdtsc() + 2000000000 / 10;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
status = __inbyte (iobase);
|
status = __inbyte(iobase);
|
||||||
if (__rdtsc () > limit) break;
|
if (__rdtsc() > limit) break;
|
||||||
if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting
|
if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting
|
||||||
if ((status & 1) == 1) continue; // HostBusy set, keep waiting
|
if ((status & 1) == 1) continue; // HostBusy set, keep waiting
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer [0] = __inbyte (iobase + 5);
|
buffer [0] = __inbyte(iobase + 5);
|
||||||
if (status == 2) status = 0; // check for done with no errors
|
if (status == 2) status = 0; // check for done with no errors
|
||||||
return status;
|
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.
|
* 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;
|
int index, error;
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count)
|
|||||||
iobase, SmbusSlaveAddress, count);
|
iobase, SmbusSlaveAddress, count);
|
||||||
|
|
||||||
/* read the first byte using offset zero */
|
/* read the first byte using offset zero */
|
||||||
error = readSmbusByteData (iobase, SmbusSlaveAddress, buffer, 0);
|
error = readSmbusByteData(iobase, SmbusSlaveAddress, buffer, 0);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n");
|
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 */
|
/* read the remaining bytes using auto-increment for speed */
|
||||||
for (index = 1; index < count; index++)
|
for (index = 1; index < count; index++)
|
||||||
{
|
{
|
||||||
error = readSmbusByte (iobase, SmbusSlaveAddress, &buffer [index]);
|
error = readSmbusByte(iobase, SmbusSlaveAddress, &buffer [index]);
|
||||||
if (error) {
|
if (error) {
|
||||||
printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n");
|
printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n");
|
||||||
return error;
|
return error;
|
||||||
@@ -115,15 +115,15 @@ static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setupFch (int ioBase)
|
static void setupFch(int ioBase)
|
||||||
{
|
{
|
||||||
pm_write16(0x2c, ioBase | 1);
|
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 hudson_readSpd(int spdAddress, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
int ioBase = 0xB00;
|
int ioBase = 0xB00;
|
||||||
setupFch (ioBase);
|
setupFch(ioBase);
|
||||||
return readspd (ioBase, spdAddress, buf, len);
|
return readspd(ioBase, spdAddress, buf, len);
|
||||||
}
|
}
|
||||||
|
@@ -101,6 +101,6 @@ static UINT8 readspd(UINT16 iobase, UINT8 SmbusSlaveAddress, char *buffer,
|
|||||||
int smbus_readSpd(int spdAddress, char *buf, size_t len)
|
int smbus_readSpd(int spdAddress, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
int ioBase = SMBUS0_BASE_ADDRESS;
|
int ioBase = SMBUS0_BASE_ADDRESS;
|
||||||
setupFch (ioBase);
|
setupFch(ioBase);
|
||||||
return readspd (ioBase, spdAddress, buf, len);
|
return readspd(ioBase, spdAddress, buf, len);
|
||||||
}
|
}
|
||||||
|
@@ -16,31 +16,31 @@
|
|||||||
* readSmbusByteData - read a single SPD byte from any offset
|
* 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;
|
unsigned int status;
|
||||||
UINT64 limit;
|
UINT64 limit;
|
||||||
|
|
||||||
address |= 1; // set read bit
|
address |= 1; // set read bit
|
||||||
|
|
||||||
__outbyte (iobase + 0, 0xFF); // clear error status
|
__outbyte(iobase + 0, 0xFF); // clear error status
|
||||||
__outbyte (iobase + 1, 0x1F); // clear error status
|
__outbyte(iobase + 1, 0x1F); // clear error status
|
||||||
__outbyte (iobase + 3, offset); // offset in eeprom
|
__outbyte(iobase + 3, offset); // offset in eeprom
|
||||||
__outbyte (iobase + 4, address); // slave address and read bit
|
__outbyte(iobase + 4, address); // slave address and read bit
|
||||||
__outbyte (iobase + 2, 0x48); // read byte command
|
__outbyte(iobase + 2, 0x48); // read byte command
|
||||||
|
|
||||||
// time limit to avoid hanging for unexpected error status (should never happen)
|
// time limit to avoid hanging for unexpected error status (should never happen)
|
||||||
limit = __rdtsc () + 2000000000 / 10;
|
limit = __rdtsc() + 2000000000 / 10;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
status = __inbyte (iobase);
|
status = __inbyte(iobase);
|
||||||
if (__rdtsc () > limit) break;
|
if (__rdtsc() > limit) break;
|
||||||
if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting
|
if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting
|
||||||
if ((status & 1) == 1) continue; // HostBusy set, keep waiting
|
if ((status & 1) == 1) continue; // HostBusy set, keep waiting
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer [0] = __inbyte (iobase + 5);
|
buffer [0] = __inbyte(iobase + 5);
|
||||||
if (status == 2) status = 0; // check for done with no errors
|
if (status == 2) status = 0; // check for done with no errors
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -51,26 +51,26 @@ static int readSmbusByteData (int iobase, int address, char *buffer, int offset)
|
|||||||
* this function is faster function readSmbusByteData
|
* 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;
|
unsigned int status;
|
||||||
UINT64 limit;
|
UINT64 limit;
|
||||||
|
|
||||||
__outbyte (iobase + 0, 0xFF); // clear error status
|
__outbyte(iobase + 0, 0xFF); // clear error status
|
||||||
__outbyte (iobase + 2, 0x44); // read command
|
__outbyte(iobase + 2, 0x44); // read command
|
||||||
|
|
||||||
// time limit to avoid hanging for unexpected error status
|
// time limit to avoid hanging for unexpected error status
|
||||||
limit = __rdtsc () + 2000000000 / 10;
|
limit = __rdtsc() + 2000000000 / 10;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
status = __inbyte (iobase);
|
status = __inbyte(iobase);
|
||||||
if (__rdtsc () > limit) break;
|
if (__rdtsc() > limit) break;
|
||||||
if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting
|
if ((status & 2) == 0) continue; // SMBusInterrupt not set, keep waiting
|
||||||
if ((status & 1) == 1) continue; // HostBusy set, keep waiting
|
if ((status & 1) == 1) continue; // HostBusy set, keep waiting
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer [0] = __inbyte (iobase + 5);
|
buffer [0] = __inbyte(iobase + 5);
|
||||||
if (status == 2) status = 0; // check for done with no errors
|
if (status == 2) status = 0; // check for done with no errors
|
||||||
return status;
|
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.
|
* 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;
|
int index, error;
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count)
|
|||||||
iobase, SmbusSlaveAddress, count);
|
iobase, SmbusSlaveAddress, count);
|
||||||
|
|
||||||
/* read the first byte using offset zero */
|
/* read the first byte using offset zero */
|
||||||
error = readSmbusByteData (iobase, SmbusSlaveAddress, buffer, 0);
|
error = readSmbusByteData(iobase, SmbusSlaveAddress, buffer, 0);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n");
|
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 */
|
/* read the remaining bytes using auto-increment for speed */
|
||||||
for (index = 1; index < count; index++)
|
for (index = 1; index < count; index++)
|
||||||
{
|
{
|
||||||
error = readSmbusByte (iobase, SmbusSlaveAddress, &buffer [index]);
|
error = readSmbusByte(iobase, SmbusSlaveAddress, &buffer [index]);
|
||||||
if (error) {
|
if (error) {
|
||||||
printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n");
|
printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n");
|
||||||
return error;
|
return error;
|
||||||
@@ -115,15 +115,15 @@ static int readspd (int iobase, int SmbusSlaveAddress, char *buffer, int count)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setupFch (int ioBase)
|
static void setupFch(int ioBase)
|
||||||
{
|
{
|
||||||
pm_write16(0x2c, ioBase | 1);
|
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 hudson_readSpd(int spdAddress, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
int ioBase = 0xB00;
|
int ioBase = 0xB00;
|
||||||
setupFch (ioBase);
|
setupFch(ioBase);
|
||||||
return readspd (ioBase, spdAddress, buf, len);
|
return readspd(ioBase, spdAddress, buf, len);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user