2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <amdblocks/agesawrapper.h>
16 #include <console/console.h>
17 #include <device/pci_def.h>
18 #include <device/device.h>
19 #include <device/smbus_host.h>
20 #include <soc/southbridge.h>
21 #include <amdblocks/dimm_spd.h>
24 * readspd - Read one or more SPD bytes from a DIMM.
25 * Start with offset zero and read sequentially.
26 * Optimization relies on autoincrement to avoid
27 * sending offset for every byte.
28 * Reads 128 bytes in 7-8 ms at 400 KHz.
30 static int readspd(uint8_t SmbusSlaveAddress
, char *buffer
, size_t count
)
37 printk(BIOS_SPEW
, "-------------READING SPD-----------\n");
38 printk(BIOS_SPEW
, "SmbusSlave: 0x%08X, count: %zd\n",
39 SmbusSlaveAddress
, count
);
42 * Convert received device address to the format accepted by
43 * do_smbus_read_byte and do_smbus_recv_byte.
45 dev_addr
= (SmbusSlaveAddress
>> 1);
47 /* Read the first SPD byte */
48 error
= do_smbus_read_byte(ACPIMMIO_SMBUS_BASE
, dev_addr
, 0);
50 printk(BIOS_ERR
, "-------------SPD READ ERROR-----------\n");
56 /* Read the remaining SPD bytes using do_smbus_recv_byte for speed */
57 for (index
= 1 ; index
< count
; index
++) {
58 error
= do_smbus_recv_byte(ACPIMMIO_SMBUS_BASE
, dev_addr
);
60 printk(BIOS_ERR
, "-------------SPD READ ERROR-----------\n");
66 printk(BIOS_SPEW
, "\n");
67 printk(BIOS_SPEW
, "-------------FINISHED READING SPD-----------\n");
72 int sb_read_spd(uint8_t spdAddress
, char *buf
, size_t len
)
74 return readspd(spdAddress
, buf
, len
);