Merge pull request #1602 from antmicro/msieron/spd-fixes

SDRAM SPD fixes
This commit is contained in:
enjoy-digital 2023-02-16 21:06:54 +01:00 committed by GitHub
commit fa872cfae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 20 deletions

View File

@ -403,10 +403,9 @@ static void sdram_spd_handler(int nb_params, char **params)
unsigned char spdaddr;
unsigned char buf[SDRAM_SPD_SIZE];
int len = sizeof(buf);
bool send_stop = true;
if (nb_params < 1) {
printf("sdram_spd <spdaddr> [<send_stop>]");
printf("sdram_spd <spdaddr>");
return;
}
@ -420,15 +419,7 @@ static void sdram_spd_handler(int nb_params, char **params)
return;
}
if (nb_params > 1) {
send_stop = strtoul(params[1], &c, 0) != 0;
if (*c != 0) {
printf("Incorrect send_stop value");
return;
}
}
if (!sdram_read_spd(spdaddr, 0, buf, (uint16_t)len, send_stop)) {
if (!sdram_read_spd(spdaddr, 0, buf, (uint16_t)len)) {
printf("Error when reading SPD EEPROM");
return;
}

View File

@ -28,11 +28,10 @@ static bool sdram_select_spd_page(uint8_t page) {
}
#endif
bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool send_stop) {
bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len) {
uint8_t page;
uint16_t offset;
uint16_t temp_len, read_bytes = 0;
bool temp_send_stop = false;
bool ok = true;
@ -43,12 +42,10 @@ bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool
offset = addr % SDRAM_SPD_PAGE_SIZE;
temp_len = SDRAM_SPD_PAGE_SIZE - offset;
if (temp_len >= len) {
temp_send_stop = send_stop;
if (temp_len > len)
temp_len = len;
}
ok &= i2c_read(SPD_RW_ADDR(spd), offset, &buf[read_bytes], len, temp_send_stop, 1);
ok &= i2c_read(SPD_RW_ADDR(spd), offset, &buf[read_bytes], temp_len, false, 1);
len -= temp_len;
read_bytes += temp_len;
addr += temp_len;
@ -57,7 +54,7 @@ bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool
return ok;
}
#else /* no CSR_SDRAM_BASE && CONFIG_HAS_I2C */
bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool send_stop) {
bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len) {
return false;
}
#endif /* CSR_SDRAM_BASE && CONFIG_HAS_I2C */

View File

@ -36,7 +36,7 @@ extern "C" {
#endif /* CSR_SDRAM_BASE && CONFIG_HAS_I2C */
bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool send_stop);
bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len);
#ifdef __cplusplus
}

View File

@ -40,7 +40,7 @@ uint64_t sdram_get_supported_memory(void) {
#if defined(SDRAM_PHY_DDR3) || defined(SDRAM_PHY_DDR4)
uint8_t buf;
if (!sdram_read_spd(0x0, 4, &buf, 1, true)) {
if (!sdram_read_spd(0x0, 4, &buf, 1)) {
printf("Couldn't read SDRAM size from the SPD, defaulting to 256 MB.\n");
return 256 << 20;
}