summaryrefslogtreecommitdiff
path: root/drivers/ddr/fsl/main.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-08-22 07:29:54 -0400
committerTom Rini <trini@konsulko.com>2019-08-22 07:29:54 -0400
commitc399dca83434290ac502207f2d6db13c59d89267 (patch)
tree0e6ed8aa92f4586ca42b167d55e1c315d6cd2a58 /drivers/ddr/fsl/main.c
parent1e60ccd94318fb86610e1e28512b2aaac5f4b069 (diff)
parentb249fcba00e093149f8424492da155572f12d7bb (diff)
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq
- i2c dm model support of lx2160a, ls1088a, lx2088a, ls1028a - icid setup for ls1028a, ls1088a - other small fixes
Diffstat (limited to 'drivers/ddr/fsl/main.c')
-rw-r--r--drivers/ddr/fsl/main.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/drivers/ddr/fsl/main.c b/drivers/ddr/fsl/main.c
index e1f69a1d25c..ac0783b428e 100644
--- a/drivers/ddr/fsl/main.c
+++ b/drivers/ddr/fsl/main.c
@@ -92,7 +92,10 @@ static void __get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)
uint8_t dummy = 0;
#endif
+#ifndef CONFIG_DM_I2C
i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM);
+#endif
+
#ifdef CONFIG_SYS_FSL_DDR4
/*
@@ -101,6 +104,7 @@ static void __get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)
* To access the upper 256 bytes, we need to set EE page address to 1
* See Jedec standar No. 21-C for detail
*/
+#ifndef CONFIG_DM_I2C
i2c_write(SPD_SPA0_ADDRESS, 0, 1, &dummy, 1);
ret = i2c_read(i2c_address, 0, 1, (uchar *)spd, 256);
if (!ret) {
@@ -111,8 +115,38 @@ static void __get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)
(int)sizeof(generic_spd_eeprom_t) - 256));
}
#else
+ struct udevice *dev;
+ int read_len = min(256, (int)sizeof(generic_spd_eeprom_t) - 256);
+
+ ret = i2c_get_chip_for_busnum(0, SPD_SPA0_ADDRESS, 1, &dev);
+ if (!ret)
+ dm_i2c_write(dev, 0, &dummy, 1);
+ ret = i2c_get_chip_for_busnum(0, i2c_address, 1, &dev);
+ if (!ret) {
+ if (!dm_i2c_read(dev, 0, (uchar *)spd, 256)) {
+ if (!i2c_get_chip_for_busnum(0, SPD_SPA1_ADDRESS,
+ 1, &dev))
+ dm_i2c_write(dev, 0, &dummy, 1);
+ if (!i2c_get_chip_for_busnum(0, i2c_address, 1, &dev))
+ ret = dm_i2c_read(dev, 0,
+ (uchar *)((ulong)spd + 256),
+ read_len);
+ }
+ }
+#endif
+
+#else
+
+#ifndef CONFIG_DM_I2C
ret = i2c_read(i2c_address, 0, 1, (uchar *)spd,
- sizeof(generic_spd_eeprom_t));
+ sizeof(generic_spd_eeprom_t));
+#else
+ ret = i2c_get_chip_for_busnum(0, i2c_address, 1, &dev);
+ if (!ret)
+ ret = dm_i2c_read(dev, 0, (uchar *)spd,
+ sizeof(generic_spd_eeprom_t));
+#endif
+
#endif
if (ret) {