liblitedram/sdram_spd: do not send stop symbol
According to the SPD specification, we shouldn't send a stop symbol after the write that sets the address counter. Signed-off-by: Michal Sieron <msieron@antmicro.com>
This commit is contained in:
parent
cdc1152162
commit
f84ecaf707
|
@ -403,10 +403,9 @@ static void sdram_spd_handler(int nb_params, char **params)
|
||||||
unsigned char spdaddr;
|
unsigned char spdaddr;
|
||||||
unsigned char buf[SDRAM_SPD_SIZE];
|
unsigned char buf[SDRAM_SPD_SIZE];
|
||||||
int len = sizeof(buf);
|
int len = sizeof(buf);
|
||||||
bool send_stop = true;
|
|
||||||
|
|
||||||
if (nb_params < 1) {
|
if (nb_params < 1) {
|
||||||
printf("sdram_spd <spdaddr> [<send_stop>]");
|
printf("sdram_spd <spdaddr>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,15 +419,7 @@ static void sdram_spd_handler(int nb_params, char **params)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nb_params > 1) {
|
if (!sdram_read_spd(spdaddr, 0, buf, (uint16_t)len)) {
|
||||||
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)) {
|
|
||||||
printf("Error when reading SPD EEPROM");
|
printf("Error when reading SPD EEPROM");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,10 @@ static bool sdram_select_spd_page(uint8_t page) {
|
||||||
}
|
}
|
||||||
#endif
|
#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;
|
uint8_t page;
|
||||||
uint16_t offset;
|
uint16_t offset;
|
||||||
uint16_t temp_len, read_bytes = 0;
|
uint16_t temp_len, read_bytes = 0;
|
||||||
bool temp_send_stop = false;
|
|
||||||
|
|
||||||
bool ok = true;
|
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;
|
offset = addr % SDRAM_SPD_PAGE_SIZE;
|
||||||
|
|
||||||
temp_len = SDRAM_SPD_PAGE_SIZE - offset;
|
temp_len = SDRAM_SPD_PAGE_SIZE - offset;
|
||||||
if (temp_len >= len) {
|
if (temp_len > len)
|
||||||
temp_send_stop = send_stop;
|
|
||||||
temp_len = len;
|
temp_len = len;
|
||||||
}
|
|
||||||
|
|
||||||
ok &= i2c_read(SPD_RW_ADDR(spd), offset, &buf[read_bytes], temp_len, temp_send_stop, 1);
|
ok &= i2c_read(SPD_RW_ADDR(spd), offset, &buf[read_bytes], temp_len, false, 1);
|
||||||
len -= temp_len;
|
len -= temp_len;
|
||||||
read_bytes += temp_len;
|
read_bytes += temp_len;
|
||||||
addr += temp_len;
|
addr += temp_len;
|
||||||
|
|
|
@ -36,7 +36,7 @@ extern "C" {
|
||||||
|
|
||||||
#endif /* CSR_SDRAM_BASE && CONFIG_HAS_I2C */
|
#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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ uint64_t sdram_get_supported_memory(void) {
|
||||||
#if defined(SDRAM_PHY_DDR3) || defined(SDRAM_PHY_DDR4)
|
#if defined(SDRAM_PHY_DDR3) || defined(SDRAM_PHY_DDR4)
|
||||||
uint8_t buf;
|
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");
|
printf("Couldn't read SDRAM size from the SPD, defaulting to 256 MB.\n");
|
||||||
return 256 << 20;
|
return 256 << 20;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue