diff options
author | John Watts <contact@jookia.org> | 2023-01-22 01:44:29 +1100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-01-25 09:26:14 +0100 |
commit | 71431f95c7891fdd0993b7f1fa6583ebc54235e6 (patch) | |
tree | e5ebedc9191f88f48417623dda6816a562de4bd3 /common/ddr_spd.c | |
parent | dd0d78851e74e9ee9775aed75fe153f64e08f778 (diff) | |
download | barebox-71431f95c7891fdd0993b7f1fa6583ebc54235e6.tar.gz |
ddr_spd: Support reading SPD from DDR3 sticks
DDR4 splits the read in two pages while other DDR types do not.
Introduce a new parameter to indicate how to read the SPD.
Signed-off-by: John Watts <contact@jookia.org>
Link: https://lore.barebox.org/20230121144429.3524905-8-contact@jookia.org
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/ddr_spd.c')
-rw-r--r-- | common/ddr_spd.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/common/ddr_spd.c b/common/ddr_spd.c index dd3b8511e6..f7792360de 100644 --- a/common/ddr_spd.c +++ b/common/ddr_spd.c @@ -480,6 +480,7 @@ static int read_buf(struct pbl_i2c *i2c, * @i2c: I2C controller handle * @addr: I2C bus address for the EEPROM * @buf: buffer to read the SPD data to + * @memtype: Memory type, such as SPD_MEMTYPE_DDR4 * * This function takes a I2C message transfer function and reads the contents * from a SPD EEPROM to the buffer provided at @buf. The buffer should at least @@ -487,19 +488,24 @@ static int read_buf(struct pbl_i2c *i2c, * otherwise. */ int spd_read_eeprom(struct pbl_i2c *i2c, - uint8_t addr, void *buf) + uint8_t addr, void *buf, + int memtype) { unsigned char *buf8 = buf; int ret; - ret = read_buf(i2c, addr, SPD_SPA0_ADDRESS, buf); - if (ret < 0) - return ret; + if (memtype == SPD_MEMTYPE_DDR4) { + ret = read_buf(i2c, addr, SPD_SPA0_ADDRESS, buf); + if (ret < 0) + return ret; - if (buf8[2] == SPD_MEMTYPE_DDR4) { ret = read_buf(i2c, addr, SPD_SPA1_ADDRESS, buf + 256); if (ret < 0) return ret; + } else { + ret = read_buf(i2c, addr, 0, buf); + if (ret < 0) + return ret; } return 0; |