| 1 |
|
| 2 |
|
| 3 |
#include <amdblocks/agesawrapper.h> |
| 4 |
#include <amdblocks/acpimmio.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <device/pci_def.h> |
| 7 |
#include <device/device.h> |
| 8 |
#include <device/smbus_host.h> |
| 9 |
#include <soc/southbridge.h> |
| 10 |
#include <amdblocks/dimm_spd.h> |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
static int readspd(uint8_t SmbusSlaveAddress, char *buffer, size_t count) |
| 20 |
{ |
| 21 |
uint8_t dev_addr; |
| 22 |
size_t index; |
| 23 |
int error; |
| 24 |
char *pbuf = buffer; |
| 25 |
|
| 26 |
printk(BIOS_SPEW, "-------------READING SPD-----------\n"); |
| 27 |
printk(BIOS_SPEW, "SmbusSlave: 0x%08X, count: %zd\n", |
| 28 |
SmbusSlaveAddress, count); |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
dev_addr = (SmbusSlaveAddress >> 1); |
| 35 |
|
| 36 |
|
| 37 |
error = do_smbus_read_byte((uintptr_t)acpimmio_smbus, dev_addr, 0); |
| 38 |
if (error < 0) { |
| 39 |
printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n"); |
| 40 |
return error; |
| 41 |
} |
| 42 |
*pbuf = (char)error; |
| 43 |
pbuf++; |
| 44 |
|
| 45 |
|
| 46 |
for (index = 1 ; index < count ; index++) { |
| 47 |
error = do_smbus_recv_byte((uintptr_t)acpimmio_smbus, dev_addr); |
| 48 |
if (error < 0) { |
| 49 |
printk(BIOS_ERR, "-------------SPD READ ERROR-----------\n"); |
| 50 |
return error; |
| 51 |
} |
| 52 |
*pbuf = (char)error; |
| 53 |
pbuf++; |
| 54 |
} |
| 55 |
printk(BIOS_SPEW, "\n"); |
| 56 |
printk(BIOS_SPEW, "-------------FINISHED READING SPD-----------\n"); |
| 57 |
|
| 58 |
return 0; |
| 59 |
} |
| 60 |
|
| 61 |
int sb_read_spd(uint8_t spdAddress, char *buf, size_t len) |
| 62 |
{ |
| 63 |
return readspd(spdAddress, buf, len); |
| 64 |
} |