mb/google/brya/var/orisa: Update Type C DisplayPort HPD Configuration
[coreboot2.git] / src / soc / amd / stoneyridge / smbus_spd.c
blob1f83448cd3db124ab482904db11221dac53276bd
1 /* SPDX-License-Identifier: GPL-2.0-only */
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>
13 * readspd - Read one or more SPD bytes from a DIMM.
14 * Start with offset zero and read sequentially.
15 * Optimization relies on autoincrement to avoid
16 * sending offset for every byte.
17 * Reads 128 bytes in 7-8 ms at 400 KHz.
19 static int readspd(uint8_t SmbusSlaveAddress, char *buffer, size_t count)
21 uint8_t dev_addr;
22 size_t index;
23 int error;
24 char *pbuf = buffer;
26 printk(BIOS_SPEW, "-------------READING SPD-----------\n");
27 printk(BIOS_SPEW, "SmbusSlave: 0x%08X, count: %zd\n",
28 SmbusSlaveAddress, count);
31 * Convert received device address to the format accepted by
32 * do_smbus_read_byte and do_smbus_recv_byte.
34 dev_addr = (SmbusSlaveAddress >> 1);
36 /* Read the first SPD byte */
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;
42 *pbuf = (char)error;
43 pbuf++;
45 /* Read the remaining SPD bytes using do_smbus_recv_byte for speed */
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;
52 *pbuf = (char)error;
53 pbuf++;
55 printk(BIOS_SPEW, "\n");
56 printk(BIOS_SPEW, "-------------FINISHED READING SPD-----------\n");
58 return 0;
61 int sb_read_spd(uint8_t spdAddress, char *buf, size_t len)
63 return readspd(spdAddress, buf, len);