From: John Watts <contact@jookia.org>
To: barebox@lists.infradead.org
Cc: John Watts <contact@jookia.org>
Subject: [PATCH 7/7] ddr_spd: Support reading SPD from DDR3 sticks
Date: Sun, 22 Jan 2023 01:44:29 +1100 [thread overview]
Message-ID: <20230121144429.3524905-8-contact@jookia.org> (raw)
In-Reply-To: <20230121144429.3524905-1-contact@jookia.org>
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>
---
arch/arm/boards/ls1046ardb/lowlevel.c | 2 +-
common/ddr_spd.c | 16 +++++++++++-----
include/ddr_spd.h | 3 ++-
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/arch/arm/boards/ls1046ardb/lowlevel.c b/arch/arm/boards/ls1046ardb/lowlevel.c
index 055e5f4c99..9eae032377 100644
--- a/arch/arm/boards/ls1046ardb/lowlevel.c
+++ b/arch/arm/boards/ls1046ardb/lowlevel.c
@@ -205,7 +205,7 @@ static noinline __noreturn void ls1046ardb_r_entry(unsigned long memsize)
IMD_USED_OF(fsl_ls1046a_rdb);
i2c = ls1046_i2c_init(IOMEM(LSCH2_I2C1_BASE_ADDR));
- ret = spd_read_eeprom(i2c, 0x51, &spd_eeprom);
+ ret = spd_read_eeprom(i2c, 0x51, &spd_eeprom, SPD_MEMTYPE_DDR4);
if (ret) {
pr_err("Cannot read SPD EEPROM: %d\n", ret);
goto err;
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;
diff --git a/include/ddr_spd.h b/include/ddr_spd.h
index bcc2171d2a..a96d01df85 100644
--- a/include/ddr_spd.h
+++ b/include/ddr_spd.h
@@ -575,6 +575,7 @@ int ddr3_spd_check(const struct ddr3_spd_eeprom *spd);
int ddr4_spd_check(const struct ddr4_spd_eeprom *spd);
int spd_read_eeprom(struct pbl_i2c *i2c,
- uint8_t addr, void *buf);
+ uint8_t addr, void *buf,
+ int memtype);
#endif /* _DDR_SPD_H_ */
--
2.39.0
next prev parent reply other threads:[~2023-01-21 14:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-21 14:44 [PATCH 0/7] Support generating DIMM parameters on more systems John Watts
2023-01-21 14:44 ` [PATCH 1/7] I2C: i.MX: Add early i2c support for i.MX6 John Watts
2023-01-23 9:01 ` Marco Felsch
2023-01-23 9:49 ` John Watts
2023-01-21 14:44 ` [PATCH 2/7] ddr: fsl: Pass mclk_ps to ddr*_compute_dimm_parameters John Watts
2023-01-21 14:44 ` [PATCH 3/7] ddr_dimms: Move FSL dimm_params to include/ddr_dimms.h John Watts
2023-01-21 14:44 ` [PATCH 4/7] ddr: fsl: Remove includes to fsl-specific code John Watts
2023-01-21 14:44 ` [PATCH 5/7] ddr_dimms: Move ddr*_dimm_params to common John Watts
2023-01-21 14:44 ` [PATCH 6/7] ddr_dimms: Remove mclk_ps for DDR3 and DDR4 John Watts
2023-01-21 14:44 ` John Watts [this message]
2023-01-24 8:26 ` [PATCH 0/7] Support generating DIMM parameters on more systems Sascha Hauer
2023-01-24 11:48 ` John Watts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230121144429.3524905-8-contact@jookia.org \
--to=contact@jookia.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox