[U-Boot] [RFC PATCH v2 11/18] ddr: socfpga: gen5: read handoff information from devicetree
Simon Goldschmidt
simon.k.r.goldschmidt at gmail.com
Tue Oct 15 20:10:24 UTC 2019
Instead of reading SDRAM handoff data from 'qts' files, read it from
devicetree.
Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
---
Changes in v2: None
drivers/ddr/altera/sdram_gen5.c | 61 ++++++++++++++++++++++++++++-----
1 file changed, 53 insertions(+), 8 deletions(-)
diff --git a/drivers/ddr/altera/sdram_gen5.c b/drivers/ddr/altera/sdram_gen5.c
index 91d9f6c0fc..09ee45026c 100644
--- a/drivers/ddr/altera/sdram_gen5.c
+++ b/drivers/ddr/altera/sdram_gen5.c
@@ -572,20 +572,65 @@ static unsigned long sdram_calculate_size(
static int altera_gen5_sdram_ofdata_to_platdata(struct udevice *dev)
{
struct altera_gen5_sdram_platdata *plat = dev->platdata;
+ int sz;
plat->sdr = (struct socfpga_sdr *)devfdt_get_addr_index(dev, 0);
if (!plat->sdr)
return -ENODEV;
/* Get handoff config */
- plat->cfg = socfpga_get_sdram_config();
- plat->rwcfg = socfpga_get_sdram_rwmgr_config();
- plat->iocfg = socfpga_get_sdram_io_config();
- plat->misccf = socfpga_get_sdram_misc_config();
-
- socfpga_get_seq_inst_init(&plat->inst_rom_init,
- &plat->inst_rom_init_len);
- socfpga_get_seq_ac_init(&plat->ac_rom_init, &plat->ac_rom_init_len);
+ plat->cfg = (const struct socfpga_sdram_config *)
+ dev_read_u8_array_ptr(dev, "altr,sdr-cfg", sizeof(*plat->cfg));
+ if (!plat->cfg) {
+ debug("Failed to parse altr,sdr-cfg\n");
+ return -EINVAL;
+ }
+ plat->rwcfg = (const struct socfpga_sdram_rw_mgr_config *)
+ dev_read_u8_array_ptr(dev, "altr,sdr-rw-mgr-cfg",
+ sizeof(*plat->rwcfg));
+ if (!plat->rwcfg) {
+ debug("Failed to parse altr,sdr-rw-mgr-cfg\n");
+ return -EINVAL;
+ }
+ plat->iocfg = (const struct socfpga_sdram_io_config *)
+ dev_read_u8_array_ptr(dev, "altr,sdr-io-cfg",
+ sizeof(*plat->iocfg));
+ if (!plat->iocfg) {
+ debug("Failed to parse altr,sdr-io-cfg\n");
+ return -EINVAL;
+ }
+ plat->misccf = (const struct socfpga_sdram_misc_config *)
+ dev_read_u8_array_ptr(dev, "altr,sdr-misc-cfg",
+ sizeof(*plat->misccf));
+ if (!plat->misccf) {
+ debug("Failed to parse altr,sdr-misc-cfg\n");
+ return -EINVAL;
+ }
+
+ sz = dev_read_size(dev, "altr,sdr-inst-rom-init");
+ if (sz <= 0) {
+ debug("Failed to read altr,sdr-inst-rom-init size\n");
+ return sz;
+ }
+ plat->inst_rom_init_len = sz / sizeof(u32);
+ plat->inst_rom_init = (const u32*)dev_read_u8_array_ptr(dev,
+ "altr,sdr-inst-rom-init", sz);
+ if (!plat->inst_rom_init) {
+ debug("Failed to parse altr,sdr-inst-rom-init\n");
+ return -EINVAL;
+ }
+ sz = dev_read_size(dev, "altr,sdr-ac-rom-init");
+ if (sz <= 0) {
+ debug("Failed to read altr,sdr-ac-rom-init size\n");
+ return sz;
+ }
+ plat->ac_rom_init_len = sz / sizeof(u32);
+ plat->ac_rom_init = (const u32*)dev_read_u8_array_ptr(dev,
+ "altr,sdr-ac-rom-init", sz);
+ if (!plat->ac_rom_init) {
+ debug("Failed to parse altr,sdr-ac-rom-init\n");
+ return -EINVAL;
+ }
return 0;
}
--
2.20.1
More information about the U-Boot
mailing list