Update Stratix 10 SDRAM driver
Subsystems (3)
cover Update Stratix 10 SDRAM driver
This patchset update Stratix 10 SDRAM driver to support:
- Multi-banks memory (Patch [1-8])
- Stratix 10 support up to 2 memory banks:
Bank 0: Address 0, size 2GB Bank 1: Address 0x100000000, size 124GB
- Add warm reset boot checking function, to use in patch [10] (Patch[9])
- Add ECC memory scrubbing support (Patch [10])
- Use cache enabled + "DC ZVA" instruction to clear memory to zeros
Ley Foon Tan (10):
ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
arm: socfpga: Add sdram_s10.h to sdram.h
ddr: altera: s10: Add multiple memory banks support
arm: socfpga: Update dram_init_banksize() for Stratix10
board: altera: Stratix10: Add board_get_usable_ram_top()
board: altera: Stratix10: Add ft_board_setup()
arm: socfpga: Enable OF_BOARD_SETUP for Stratix 10
configs: stratix10: Change CONFIG_NR_DRAM_BANKS to 2
arm: socfpga: stratix10: Add cpu_has_been_warmreset()
ddr: altera: Stratix10: Add ECC memory scrubbing
arch/arm/mach-socfpga/Kconfig | 1 + arch/arm/mach-socfpga/board.c | 16 +- .../include/mach/reset_manager_s10.h | 3 + arch/arm/mach-socfpga/include/mach/sdram.h | 2 + .../arm/mach-socfpga/include/mach/sdram_s10.h | 10 + arch/arm/mach-socfpga/reset_manager_s10.c | 9 + arch/arm/mach-socfpga/spl_s10.c | 11 -- board/altera/stratix10-socdk/socfpga.c | 37 ++++ configs/socfpga_stratix10_defconfig | 2 +- drivers/ddr/altera/sdram_s10.c | 178 ++++++++++++++++++ 10 files changed, 256 insertions(+), 13 deletions(-)
Signature · 1 line
2.19.0
PATCH 1/10 ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
Move SDRAM size check to SDRAM driver. sdram_calculate_size() is called in SDRAM initialization already, avoid calling twice in size check function.
--- arch/arm/mach-socfpga/spl_s10.c | 11 ----------- drivers/ddr/altera/sdram_s10.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-)
arch/arm/mach-socfpga/spl_s10.c +0 -11
@@ -181,17 +181,6 @@ void board_init_f(ulong dummy)hang (); } - gd->ram_size =sdram_calculate_size (); -printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 )); - -/* Sanity check ensure correct SDRAM size specified */ -debug ("DDR: Running SDRAM size sanity check\n" ); -if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { -puts ("DDR: SDRAM size check failed!\n" ); -hang (); - } -debug ("DDR: SDRAM size check passed!\n" ); -mbox_init ();#ifdef CONFIG_CADENCE_QSPI
drivers/ddr/altera/sdram_s10.c +15 -0
@@ -134,6 +134,17 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_size_check (void ) +{ +/* Sanity check ensure correct SDRAM size specified */ +debug ("DDR: Running SDRAM size sanity check\n" ); +if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { +puts ("DDR: SDRAM size check failed!\n" ); +hang (); + } +debug ("DDR: SDRAM size check passed!\n" ); +} +/** * sdram_mmr_init_full() - Function to initialize SDRAM MMR *
@@ -339,6 +350,8 @@ int sdram_mmr_init_full(unsigned int unused)else gd->ram_size = size; +printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 )); +/* Enable or disable the SDRAM ECC */ if (CTRLCFG1_CFG_CTRL_EN_ECC (ctrlcfg1)) { setbits_le32(SOCFPGA_SDR_ADDRESS + ECCCTRL1,
@@ -361,6 +374,8 @@ int sdram_mmr_init_full(unsigned int unused) DDR_HMC_ECCCTL2_AWB_EN_SET_MSK)); } +sdram_size_check (); +debug ("DDR: HMC init success\n" );return 0 ; }
Signature · 1 line
2.19.0
PATCH 1/10 ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
Quoted 55 lines · Ley Foon Tan
Move SDRAM size check to SDRAM driver.
sdram_calculate_size()is called in SDRAM initialization already, avoid calling twice in size check function.Signed-off-by Ley Foon Tan <[email protected]>--- arch/arm/mach-socfpga/spl_s10.c | 11 ----------- drivers/ddr/altera/sdram_s10.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-)arch/arm/mach-socfpga/spl_s10.c +0
-11@@ -181,17 +181,6 @@ void board_init_f(ulong dummy)hang (); } - gd->ram_size =sdram_calculate_size (); -printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 )); - -/* Sanity check ensure correct SDRAM size specified */ -debug ("DDR: Running SDRAM size sanity check\n" ); -if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { -puts ("DDR: SDRAM size check failed!\n" ); -hang (); - } -debug ("DDR: SDRAM size check passed!\n" ); -mbox_init ();#ifdef CONFIG_CADENCE_QSPI drivers/ddr/altera/sdram_s10.c +11
-0@@ -134,6 +134,17 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_size_check (void ) +{ +/* Sanity check ensure correct SDRAM size specified */ +debug ("DDR: Running SDRAM size sanity check\n" ); +if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { +puts ("DDR: SDRAM size check failed!\n" ); +hang (); + } +debug ("DDR: SDRAM size check passed!\n" ); +} +/** * sdram_mmr_init_full() - Function to initialize SDRAM MMR *
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 353
Quoted 4 lines
drivers/ddr/altera/sdram_s10.c +1
-0@@ -339,6 +350,8 @@ int sdram_mmr_init_full(unsigned int unused)else gd->ram_size = size; +printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 ));
Is the type cast needed?
Quoted 13 lines
drivers/ddr/altera/sdram_s10.c +2
-0/* Enable or disable the SDRAM ECC */ if (CTRLCFG1_CFG_CTRL_EN_ECC (ctrlcfg1)) { setbits_le32(SOCFPGA_SDR_ADDRESS + ECCCTRL1,@@ -361,6 +374,8 @@ int sdram_mmr_init_full(unsigned int unused) DDR_HMC_ECCCTL2_AWB_EN_SET_MSK)); } +sdram_size_check (); +debug ("DDR: HMC init success\n" );return 0 ; }
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/10 ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
Quoted 60 lines · Marek Vasut
Quoted 58 lines · Ley Foon Tan
Move SDRAM size check to SDRAM driver.
sdram_calculate_size()is called in SDRAM initialization already, avoid calling twice in size check function.Signed-off-by Ley Foon Tan <[email protected]>--- arch/arm/mach-socfpga/spl_s10.c | 11 ----------- drivers/ddr/altera/sdram_s10.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-)arch/arm/mach-socfpga/spl_s10.c +0
-11@@ -181,17 +181,6 @@ void board_init_f(ulong dummy)hang (); } - gd->ram_size =sdram_calculate_size (); -printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 )); - -/* Sanity check ensure correct SDRAM size specified */ -debug ("DDR: Running SDRAM size sanity check\n" ); -if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { -puts ("DDR: SDRAM size check failed!\n" ); -hang (); - } -debug ("DDR: SDRAM size check passed!\n" ); -mbox_init ();#ifdef CONFIG_CADENCE_QSPI drivers/ddr/altera/sdram_s10.c +11
-0@@ -134,6 +134,17 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_size_check (void ) +{ +/* Sanity check ensure correct SDRAM size specified */ +debug ("DDR: Running SDRAM size sanity check\n" ); +if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { +puts ("DDR: SDRAM size check failed!\n" ); +hang (); + } +debug ("DDR: SDRAM size check passed!\n" ); +} +/** * sdram_mmr_init_full() - Function to initialize SDRAM MMR * @@ -339,6 +350,8 @@ int sdram_mmr_init_full(unsigned int unused)else gd->ram_size = size;
Quoted 3 lines
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 353
Quoted 1 line
drivers/ddr/altera/sdram_s10.c +1
-0+printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 ));Is the type cast needed?
Yes, otherwise there is warning.
Quoted 8 lines
Quoted 8 lines
drivers/ddr/altera/sdram_s10.c +0
-0/* Enable or disable the SDRAM ECC */ if (CTRLCFG1_CFG_CTRL_EN_ECC (ctrlcfg1)) { setbits_le32(SOCFPGA_SDR_ADDRESS + ECCCTRL1,@@ -361,6 +374,8 @@ int sdram_mmr_init_full(unsigned int unused) DDR_HMC_ECCCTL2_AWB_EN_SET_MSK)); }
Quoted 7 lines
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 381
Quoted 6 lines
drivers/ddr/altera/sdram_s10.c +2
-0+sdram_size_check (); +debug ("DDR: HMC init success\n" );return 0 ; }
Regards
Ley Foon
PATCH 1/10 ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
Quoted 61 lines · Ley Foon Tan
Quoted 60 lines · Marek Vasut
Quoted 58 lines · Ley Foon Tan
Move SDRAM size check to SDRAM driver.
sdram_calculate_size()is called in SDRAM initialization already, avoid calling twice in size check function.Signed-off-by Ley Foon Tan <[email protected]>--- arch/arm/mach-socfpga/spl_s10.c | 11 ----------- drivers/ddr/altera/sdram_s10.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-)arch/arm/mach-socfpga/spl_s10.c +0
-11@@ -181,17 +181,6 @@ void board_init_f(ulong dummy)hang (); } - gd->ram_size =sdram_calculate_size (); -printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 )); - -/* Sanity check ensure correct SDRAM size specified */ -debug ("DDR: Running SDRAM size sanity check\n" ); -if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { -puts ("DDR: SDRAM size check failed!\n" ); -hang (); - } -debug ("DDR: SDRAM size check passed!\n" ); -mbox_init ();#ifdef CONFIG_CADENCE_QSPI drivers/ddr/altera/sdram_s10.c +11
-0@@ -134,6 +134,17 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_size_check (void ) +{ +/* Sanity check ensure correct SDRAM size specified */ +debug ("DDR: Running SDRAM size sanity check\n" ); +if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { +puts ("DDR: SDRAM size check failed!\n" ); +hang (); + } +debug ("DDR: SDRAM size check passed!\n" ); +} +/** * sdram_mmr_init_full() - Function to initialize SDRAM MMR * @@ -339,6 +350,8 @@ int sdram_mmr_init_full(unsigned int unused)else gd->ram_size = size;
Quoted 4 lines
Quoted 3 lines
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 353
Quoted 1 line
drivers/ddr/altera/sdram_s10.c +1
-0+printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 ));Is the type cast needed?
Yes, otherwise there is warning.
Maybe the warning is justified and needs to be fixed instead of hidden ?
[...]
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/10 ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
Quoted 63 lines · Marek Vasut
Quoted 61 lines · Ley Foon Tan
Quoted 60 lines · Marek Vasut
Quoted 58 lines · Ley Foon Tan
Move SDRAM size check to SDRAM driver.
sdram_calculate_size()is called in SDRAM initialization already, avoid calling twice in size check function.Signed-off-by Ley Foon Tan <[email protected]>--- arch/arm/mach-socfpga/spl_s10.c | 11 ----------- drivers/ddr/altera/sdram_s10.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-)arch/arm/mach-socfpga/spl_s10.c +0
-11@@ -181,17 +181,6 @@ void board_init_f(ulong dummy)hang (); } - gd->ram_size =sdram_calculate_size (); -printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 )); - -/* Sanity check ensure correct SDRAM size specified */ -debug ("DDR: Running SDRAM size sanity check\n" ); -if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { -puts ("DDR: SDRAM size check failed!\n" ); -hang (); - } -debug ("DDR: SDRAM size check passed!\n" ); -mbox_init ();#ifdef CONFIG_CADENCE_QSPI drivers/ddr/altera/sdram_s10.c +11
-0@@ -134,6 +134,17 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_size_check (void ) +{ +/* Sanity check ensure correct SDRAM size specified */ +debug ("DDR: Running SDRAM size sanity check\n" ); +if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { +puts ("DDR: SDRAM size check failed!\n" ); +hang (); + } +debug ("DDR: SDRAM size check passed!\n" ); +} +/** * sdram_mmr_init_full() - Function to initialize SDRAM MMR * @@ -339,6 +350,8 @@ int sdram_mmr_init_full(unsigned int unused)else gd->ram_size = size;
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 353
Quoted 1 line
drivers/ddr/altera/sdram_s10.c +1
-0+printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 ));Is the type cast needed?
Yes, otherwise there is warning.
Maybe the warning is justified and needs to be fixed instead of hidden ?
drivers/ddr/altera/sdram_s10.c:461:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘phys_size_t {aka volatile long long unsigned int}’ [-Wformat=]
printf("DDR: %d MiB\n", gd->ram_size >> 20);
~^ ~~~~~~~~~~~~~~~~~~Regards
Ley Foon
PATCH 1/10 ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
Quoted 69 lines · Ley Foon Tan
Quoted 68 lines · Marek Vasut
Quoted 65 lines · Ley Foon Tan
Quoted 60 lines · Marek Vasut
Quoted 58 lines · Ley Foon Tan
Move SDRAM size check to SDRAM driver.
sdram_calculate_size()is called in SDRAM initialization already, avoid calling twice in size check function.Signed-off-by Ley Foon Tan <[email protected]>--- arch/arm/mach-socfpga/spl_s10.c | 11 ----------- drivers/ddr/altera/sdram_s10.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-)arch/arm/mach-socfpga/spl_s10.c +0
-11@@ -181,17 +181,6 @@ void board_init_f(ulong dummy)hang (); } - gd->ram_size =sdram_calculate_size (); -printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 )); - -/* Sanity check ensure correct SDRAM size specified */ -debug ("DDR: Running SDRAM size sanity check\n" ); -if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { -puts ("DDR: SDRAM size check failed!\n" ); -hang (); - } -debug ("DDR: SDRAM size check passed!\n" ); -mbox_init ();#ifdef CONFIG_CADENCE_QSPI drivers/ddr/altera/sdram_s10.c +11
-0@@ -134,6 +134,17 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_size_check (void ) +{ +/* Sanity check ensure correct SDRAM size specified */ +debug ("DDR: Running SDRAM size sanity check\n" ); +if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { +puts ("DDR: SDRAM size check failed!\n" ); +hang (); + } +debug ("DDR: SDRAM size check passed!\n" ); +} +/** * sdram_mmr_init_full() - Function to initialize SDRAM MMR * @@ -339,6 +350,8 @@ int sdram_mmr_init_full(unsigned int unused)else gd->ram_size = size;Quoted 3 lines
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 353
Quoted 1 line
drivers/ddr/altera/sdram_s10.c +1
-0+printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 ));Is the type cast needed?
Yes, otherwise there is warning.
Quoted 8 lines
Quoted 2 lines
Maybe the warning is justified and needs to be fixed instead of hidden ?
drivers/ddr/altera/sdram_s10.c:461:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘phys_size_t {aka volatile long long unsigned int}’ [-Wformat=]printf("DDR: %d MiB\n", gd->ram_size >> 20); ~^ ~~~~~~~~~~~~~~~~~~
That's %lld then.
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/10 ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
Quoted 74 lines · Marek Vasut
Quoted 72 lines · Ley Foon Tan
Quoted 70 lines · Marek Vasut
Quoted 61 lines · Ley Foon Tan
Quoted 60 lines · Marek Vasut
Quoted 58 lines · Ley Foon Tan
Move SDRAM size check to SDRAM driver.
sdram_calculate_size()is called in SDRAM initialization already, avoid calling twice in size check function.Signed-off-by Ley Foon Tan <[email protected]>--- arch/arm/mach-socfpga/spl_s10.c | 11 ----------- drivers/ddr/altera/sdram_s10.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-)arch/arm/mach-socfpga/spl_s10.c +0
-11@@ -181,17 +181,6 @@ void board_init_f(ulong dummy)hang (); } - gd->ram_size =sdram_calculate_size (); -printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 )); - -/* Sanity check ensure correct SDRAM size specified */ -debug ("DDR: Running SDRAM size sanity check\n" ); -if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { -puts ("DDR: SDRAM size check failed!\n" ); -hang (); - } -debug ("DDR: SDRAM size check passed!\n" ); -mbox_init ();#ifdef CONFIG_CADENCE_QSPI drivers/ddr/altera/sdram_s10.c +11
-0@@ -134,6 +134,17 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_size_check (void ) +{ +/* Sanity check ensure correct SDRAM size specified */ +debug ("DDR: Running SDRAM size sanity check\n" ); +if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { +puts ("DDR: SDRAM size check failed!\n" ); +hang (); + } +debug ("DDR: SDRAM size check passed!\n" ); +} +/** * sdram_mmr_init_full() - Function to initialize SDRAM MMR * @@ -339,6 +350,8 @@ int sdram_mmr_init_full(unsigned int unused)else gd->ram_size = size;Quoted 4 lines
Quoted 3 lines
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 353
Quoted 1 line
drivers/ddr/altera/sdram_s10.c +1
-0+printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 ));Is the type cast needed?
Yes, otherwise there is warning.
Maybe the warning is justified and needs to be fixed instead of hidden ?
Quoted 7 lines
Quoted 5 lines
drivers/ddr/altera/sdram_s10.c:461:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘phys_size_t {aka volatile long long unsigned int}’ [-Wformat=]printf("DDR: %d MiB\n", gd->ram_size >> 20); ~^ ~~~~~~~~~~~~~~~~~~That's %lld then.
Same as %llx, tiny printf in SPL doesn't support %ll.
Regards
Ley Foon
PATCH 1/10 ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
Quoted 75 lines · Ley Foon Tan
Quoted 74 lines · Marek Vasut
Quoted 72 lines · Ley Foon Tan
Quoted 70 lines · Marek Vasut
Quoted 61 lines · Ley Foon Tan
Quoted 60 lines · Marek Vasut
Quoted 58 lines · Ley Foon Tan
Move SDRAM size check to SDRAM driver.
sdram_calculate_size()is called in SDRAM initialization already, avoid calling twice in size check function.Signed-off-by Ley Foon Tan <[email protected]>--- arch/arm/mach-socfpga/spl_s10.c | 11 ----------- drivers/ddr/altera/sdram_s10.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-)arch/arm/mach-socfpga/spl_s10.c +0
-11@@ -181,17 +181,6 @@ void board_init_f(ulong dummy)hang (); } - gd->ram_size =sdram_calculate_size (); -printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 )); - -/* Sanity check ensure correct SDRAM size specified */ -debug ("DDR: Running SDRAM size sanity check\n" ); -if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { -puts ("DDR: SDRAM size check failed!\n" ); -hang (); - } -debug ("DDR: SDRAM size check passed!\n" ); -mbox_init ();#ifdef CONFIG_CADENCE_QSPI drivers/ddr/altera/sdram_s10.c +11
-0@@ -134,6 +134,17 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_size_check (void ) +{ +/* Sanity check ensure correct SDRAM size specified */ +debug ("DDR: Running SDRAM size sanity check\n" ); +if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { +puts ("DDR: SDRAM size check failed!\n" ); +hang (); + } +debug ("DDR: SDRAM size check passed!\n" ); +} +/** * sdram_mmr_init_full() - Function to initialize SDRAM MMR * @@ -339,6 +350,8 @@ int sdram_mmr_init_full(unsigned int unused)else gd->ram_size = size;Quoted 4 lines
Quoted 3 lines
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 353
Quoted 1 line
drivers/ddr/altera/sdram_s10.c +1
-0+printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 ));Is the type cast needed?
Yes, otherwise there is warning.
Maybe the warning is justified and needs to be fixed instead of hidden ?
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
drivers/ddr/altera/sdram_s10.c:461:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘phys_size_t {aka volatile long long unsigned int}’ [-Wformat=]printf("DDR: %d MiB\n", gd->ram_size >> 20); ~^ ~~~~~~~~~~~~~~~~~~That's %lld then.
Same as %llx, tiny printf in SPL doesn't support %ll.
That shouldn't be hard to add, and it fixes a typecast which might hide bugs.
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/10 ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
Quoted 83 lines · Marek Vasut
Quoted 81 lines · Ley Foon Tan
Quoted 80 lines · Marek Vasut
Quoted 77 lines · Ley Foon Tan
Quoted 63 lines · Marek Vasut
Quoted 61 lines · Ley Foon Tan
Quoted 60 lines · Marek Vasut
Quoted 58 lines · Ley Foon Tan
Move SDRAM size check to SDRAM driver.
sdram_calculate_size()is called in SDRAM initialization already, avoid calling twice in size check function.Signed-off-by Ley Foon Tan <[email protected]>--- arch/arm/mach-socfpga/spl_s10.c | 11 ----------- drivers/ddr/altera/sdram_s10.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 11 deletions(-)arch/arm/mach-socfpga/spl_s10.c +0
-11@@ -181,17 +181,6 @@ void board_init_f(ulong dummy)hang (); } - gd->ram_size =sdram_calculate_size (); -printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 )); - -/* Sanity check ensure correct SDRAM size specified */ -debug ("DDR: Running SDRAM size sanity check\n" ); -if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { -puts ("DDR: SDRAM size check failed!\n" ); -hang (); - } -debug ("DDR: SDRAM size check passed!\n" ); -mbox_init ();#ifdef CONFIG_CADENCE_QSPI drivers/ddr/altera/sdram_s10.c +11
-0@@ -134,6 +134,17 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_size_check (void ) +{ +/* Sanity check ensure correct SDRAM size specified */ +debug ("DDR: Running SDRAM size sanity check\n" ); +if (get_ram_size (0 , gd->ram_size) != gd->ram_size) { +puts ("DDR: SDRAM size check failed!\n" ); +hang (); + } +debug ("DDR: SDRAM size check passed!\n" ); +} +/** * sdram_mmr_init_full() - Function to initialize SDRAM MMR * @@ -339,6 +350,8 @@ int sdram_mmr_init_full(unsigned int unused)else gd->ram_size = size;Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 353
Quoted 1 line
drivers/ddr/altera/sdram_s10.c +1
-0+printf ("DDR: %d MiB\n" , (int )(gd->ram_size >>20 ));Is the type cast needed?
Yes, otherwise there is warning.
Maybe the warning is justified and needs to be fixed instead of hidden ?
drivers/ddr/altera/sdram_s10.c:461:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘phys_size_t {aka volatile long long unsigned int}’ [-Wformat=]printf("DDR: %d MiB\n", gd->ram_size >> 20); ~^ ~~~~~~~~~~~~~~~~~~
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
That's %lld then.
Same as %llx, tiny printf in SPL doesn't support %ll.
That shouldn't be hard to add, and it fixes a typecast which might hide bugs.
I will send separate patch to add %ll support in tiny printf.
Regards
Ley Foon
PATCH 2/10 arm: socfpga: Add sdram_s10.h to sdram.h
In reply to Ley Foon TanIncludes Stratix10 SDRAM header file.
--- arch/arm/mach-socfpga/include/mach/sdram.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-socfpga/include/mach/sdram.h +2 -0
@@ -11,6 +11,8 @@#include <asm/arch/sdram_gen5.h> #elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10 )#include <asm/arch/sdram_arria10.h> +#elif defined(CONFIG_TARGET_SOCFPGA_STRATIX10 ) +#include <asm/arch/sdram_s10.h> #endif #endif
Signature · 1 line
2.19.0
PATCH 3/10 ddr: altera: s10: Add multiple memory banks support
In reply to Ley Foon TanSetup bank start address and size based on total SDRAM memory size calculated from hardware. Update sdram_size_check() to support multiple banks.
Stratix10 supports up to 2 memory banks.
Bank 0: Address 0, size 2GB
Bank 1: Address 0x100000000, size 124GB
--- .../arm/mach-socfpga/include/mach/sdram_s10.h | 1 + drivers/ddr/altera/sdram_s10.c | 93 ++++++++++++++++++- 2 files changed, 91 insertions(+), 3 deletions(-)
arch/arm/mach-socfpga/include/mach/sdram_s10.h +1 -0
@@ -10,6 +10,7 @@phys_size_t sdram_calculate_size (void );int sdram_mmr_init_full (unsigned int sdr_phy_reg);int sdram_calibration_full (void ); +void setup_memory_banks (phys_addr_t bank_addr[],phys_size_t bank_size[]);#define DDR_TWR 15#define DDR_READ_LATENCY_DELAY 40
drivers/ddr/altera/sdram_s10.c +90 -3
132 lines not on this page · raw message
Signature · 1 line
2.19.0
PATCH 3/10 ddr: altera: s10: Add multiple memory banks support
Quoted 11 lines · Ley Foon Tan
Setup bank start address and size based on total SDRAM memory size calculated from hardware. Update
sdram_size_check()to support multiple banks.Stratix10 supports up to 2 memory banks.
Bank 0: Address 0, size 2GB
Bank 1: Address0x100000000, size 124GBSigned-off-by Dalon Westergreen <[email protected]>Signed-off-by Ley Foon Tan <[email protected]>
Shouldn't Quartus generate some sort of DT which gives you all the DRAM layout information ? Then you won't need any of this CONFIG_NR_DRAM_BANKS stuff, but you would be able to extract such info from DT and apply the sanity check only on DRAM you know exists.
Signature · 2 lines
Best regards, Marek Vasut
Westergreen
PATCH 3/10 ddr: altera: s10: Add multiple memory banks support
Quoted 10 lines · Marek Vasut
Quoted 9 lines · Ley Foon Tan
Setup bank start address and size based on total SDRAM memory size calculated from hardware. Update
sdram_size_check()to support multiple banks.Stratix10 supports up to 2 memory banks.
Bank 0: Address 0, size 2GB
Bank 1: Address0x100000000, size 124GB
Quoted 8 lines
Quoted 2 lines
Signed-off-by Dalon Westergreen <[email protected]>Signed-off-by Ley Foon Tan <[email protected]>Shouldn't Quartus generate some sort of DT which gives you all the DRAM layout information ? Then you won't need any of this
CONFIG_NR_DRAM_BANKSstuff, but you would be able to extract such info from DT and apply the sanity check only on DRAM you know exists.
Yes, I think this can be much cleaner and the dts should provide the bank information rather than creating the banks from the determined dram size.
The determined dram size can just be a check to validate the bank configuration in the dts.
so
(quoted diff) +0 -0
b/arch/arm/dts/socfpga_stratix10_socdk.dts
index 6e8ddcd9f4..94c71bb0ed 100644
arch/arm/dts/socfpga_stratix10_socdk.dts +3 -1
@@ -36,7 +36,9 @@ memory { device_type = "memory"; - reg = <0 0 0 0x80000000>; /* 2GB */ + /* 4GB */ + reg = < 0 0x00000000 0 0x80000000 + 1 0x80000000 0 0x80000000>; u-boot,dm-pre-reloc; }; };
--dalon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3282 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190312/9315965d/attachment.bin>
PATCH 3/10 ddr: altera: s10: Add multiple memory banks support
Quoted 22 lines · Dalon
Quoted 12 lines · Marek Vasut
Quoted 10 lines · Ley Foon Tan
Setup bank start address and size based on total SDRAM memory size calculated from hardware. Update
sdram_size_check()to support multiple banks.Stratix10 supports up to 2 memory banks.
Bank 0: Address 0, size 2GB
Bank 1: Address0x100000000, size 124GBQuoted 9 lines
Quoted 2 lines
Signed-off-by Dalon Westergreen <[email protected]>Signed-off-by Ley Foon Tan <[email protected]>Shouldn't Quartus generate some sort of DT which gives you all the DRAM
layout information ? Then you won't need any of thisCONFIG_NR_DRAM_BANKSstuff, but you would be able to extract such info
from DT and apply the sanity check only on DRAM you know exists.
Quoted 8 lines
Yes, I think this can be much cleaner and the dts should provide the bank
information rather than creating the banks from the determined dram size.The determined dram size can just be a check to validate the bank configuration
in the dts.
Okay.Then user needs update memory node in dts for different SDRAM size.
Regards
Ley Foon
Quoted 24 lines
so
arch/arm/dts/socfpga_stratix10_socdk.dts +3
-2@@ -36,7 +36,9 @@ memory { device_type = "memory"; - reg = <0 0 0 0x80000000>; /* 2GB */ + /* 4GB */ + reg = < 0 0x00000000 0 0x80000000 + 1 0x80000000 0 0x80000000>; u-boot,dm-pre-reloc; }; }; --dalon
PATCH 3/10 ddr: altera: s10: Add multiple memory banks support
Quoted 28 lines · Ley Foon Tan
Quoted 27 lines · Dalon
Quoted 12 lines · Marek Vasut
Quoted 10 lines · Ley Foon Tan
Setup bank start address and size based on total SDRAM memory size calculated from hardware. Update
sdram_size_check()to support multiple banks.Stratix10 supports up to 2 memory banks.
Bank 0: Address 0, size 2GB
Bank 1: Address0x100000000, size 124GBQuoted 9 lines
Quoted 2 lines
Signed-off-by Dalon Westergreen <[email protected]>Signed-off-by Ley Foon Tan <[email protected]>Shouldn't Quartus generate some sort of DT which gives you all the DRAM
layout information ? Then you won't need any of thisCONFIG_NR_DRAM_BANKSstuff, but you would be able to extract such info
from DT and apply the sanity check only on DRAM you know exists.Yes, I think this can be much cleaner and the dts should provide the bank
information rather than creating the banks from the determined dram size.
Quoted 6 lines
Quoted 3 lines
The determined dram size can just be a check to validate the bank configuration
in the dts.Okay.Then user needs update memory node in dts for different SDRAM size.
The DT should describe hardware correctly, so yes.
Quoted 26 lines
Regards
Ley FoonQuoted 24 lines
so
arch/arm/dts/socfpga_stratix10_socdk.dts +3
-2@@ -36,7 +36,9 @@ memory { device_type = "memory"; - reg = <0 0 0 0x80000000>; /* 2GB */ + /* 4GB */ + reg = < 0 0x00000000 0 0x80000000 + 1 0x80000000 0 0x80000000>; u-boot,dm-pre-reloc; }; }; --dalon
Signature · 2 lines
Best regards, Marek Vasut
PATCH 4/10 arm: socfpga: Update dram_init_banksize() for Stratix10
In reply to Ley Foon TanSetup bi_dram struct based on returned from setup_memory_banks().
--- arch/arm/mach-socfpga/board.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/board.c +15 -1
@@ -12,6 +12,7 @@#include <asm/arch/clock_manager.h> #include <asm/arch/misc.h> #include <asm/io.h> +#include <asm/arch/sdram.h> #include <usb.h> #include <usb/dwc2_udc.h>
@@ -48,8 +49,21 @@ int board_init(void)int dram_init_banksize (void ) { -fdtdec_setup_memory_banksize (); +#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10 ) && defined(CONFIG_ALTERA_SDRAM ) +phys_addr_t bank_start[CONFIG_NR_DRAM_BANKS ]; +phys_size_t bank_size[CONFIG_NR_DRAM_BANKS ]; +int bank; + + gd->ram_size =sdram_calculate_size (); +setup_memory_banks (bank_start, bank_size); +for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { + gd->bd->bi_dram[bank].start = bank_start[bank]; + gd->bd->bi_dram[bank].size = bank_size[bank]; + } +#else +fdtdec_setup_memory_banksize (); +#endif return 0 ; }
Signature · 1 line
2.19.0
PATCH 4/10 arm: socfpga: Update dram_init_banksize() for Stratix10
Quoted 31 lines · Ley Foon Tan
Setup
bi_dramstruct based on returned fromsetup_memory_banks().Signed-off-by Ley Foon Tan <[email protected]>--- arch/arm/mach-socfpga/board.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)arch/arm/mach-socfpga/board.c +8
-1@@ -12,6 +12,7 @@#include <asm/arch/clock_manager.h> #include <asm/arch/misc.h> #include <asm/io.h> +#include <asm/arch/sdram.h> #include <usb.h> #include <usb/dwc2_udc.h> @@ -48,8 +49,21 @@ int board_init(void)int dram_init_banksize (void ) { -fdtdec_setup_memory_banksize (); +#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10 ) && defined(CONFIG_ALTERA_SDRAM ) +phys_addr_t bank_start[CONFIG_NR_DRAM_BANKS ]; +phys_size_t bank_size[CONFIG_NR_DRAM_BANKS ]; +int bank; + + gd->ram_size =sdram_calculate_size (); +setup_memory_banks (bank_start, bank_size);
arch/arm/mach-socfpga/board.c int board_init(void) · line 68
Quoted 10 lines
arch/arm/mach-socfpga/board.c +7
-0+for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { + gd->bd->bi_dram[bank].start = bank_start[bank]; + gd->bd->bi_dram[bank].size = bank_size[bank]; + } +#else +fdtdec_setup_memory_banksize (); +#endif return 0 ; }
Split this out into separate file if this really needs to be different, but can't you somehow use fdtdec_setup_memory_size() on S10 and then apply sanity checking instead ?
Signature · 2 lines
Best regards, Marek Vasut
Westergreen
PATCH 4/10 arm: socfpga: Update dram_init_banksize() for Stratix10
Quoted 34 lines · Marek Vasut
Quoted 33 lines · Ley Foon Tan
Setup
bi_dramstruct based on returned fromsetup_memory_banks().Signed-off-by Ley Foon Tan <[email protected]>--- arch/arm/mach-socfpga/board.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)arch/arm/mach-socfpga/board.c +8
-1@@ -12,6 +12,7 @@#include <asm/arch/clock_manager.h> #include <asm/arch/misc.h> #include <asm/io.h> +#include <asm/arch/sdram.h> #include <usb.h> #include <usb/dwc2_udc.h> @@ -48,8 +49,21 @@ int board_init(void)int dram_init_banksize (void ) { -fdtdec_setup_memory_banksize (); +#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10 ) && defined(CONFIG_ALTERA_SDRAM ) +phys_addr_t bank_start[CONFIG_NR_DRAM_BANKS ]; +phys_size_t bank_size[CONFIG_NR_DRAM_BANKS ]; +int bank; + + gd->ram_size =sdram_calculate_size (); +setup_memory_banks (bank_start, bank_size);
Quoted 14 lines
arch/arm/mach-socfpga/board.c int board_init(void) · line 68
Quoted 9 lines
arch/arm/mach-socfpga/board.c +7
-0+for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { + gd->bd->bi_dram[bank].start = bank_start[bank]; + gd->bd->bi_dram[bank].size = bank_size[bank]; + } +#else +fdtdec_setup_memory_banksize (); +#endif return 0 ; }Split this out into separate file if this really needs to be different, but can't you somehow use
fdtdec_setup_memory_size()on S10 and then apply sanity checking instead ?
yes, this can be done with fdtdec_setup_memory_size.
--dalon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3282 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190312/e8c39d02/attachment.bin>
PATCH 5/10 board: altera: Stratix10: Add board_get_usable_ram_top()
In reply to Ley Foon TanAdd board_get_usable_ram_top() function. Limit maximum usable ram top to 2GB.
--- board/altera/stratix10-socdk/socfpga.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
board/altera/stratix10-socdk/socfpga.c +12 -0
@@ -5,3 +5,15 @@*/ #include <common.h> +#include <asm/arch/sdram.h> +#include <linux/sizes.h> + +#ifdef CONFIG_ALTERA_SDRAM +ulong board_get_usable_ram_top (ulong total_size) +{ +if (sdram_calculate_size () >SZ_2G ) +return SZ_2G ; +else +return sdram_calculate_size (); +} +#endif
Signature · 1 line
2.19.0
PATCH 5/10 board: altera: Stratix10: Add board_get_usable_ram_top()
Quoted 2 lines · Ley Foon Tan
Add
board_get_usable_ram_top()function. Limit maximum usable ram top to 2GB.
Why ? There are ARM64 platforms which can access the entire DRAM range just fine, what's the problem ?
Quoted 27 lines
Signed-off-by Dalon Westergreen <[email protected]>Signed-off-by Ley Foon Tan <[email protected]>--- board/altera/stratix10-socdk/socfpga.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)board/altera/stratix10-socdk/socfpga.c +12
-0@@ -5,3 +5,15 @@*/ #include <common.h> +#include <asm/arch/sdram.h> +#include <linux/sizes.h> + +#ifdef CONFIG_ALTERA_SDRAM +ulong board_get_usable_ram_top (ulong total_size) +{ +if (sdram_calculate_size () >SZ_2G ) +return SZ_2G ; +else +return sdram_calculate_size (); +} +#endif
Signature · 2 lines
Best regards, Marek Vasut
Westergreen
PATCH 5/10 board: altera: Stratix10: Add board_get_usable_ram_top()
Quoted 7 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan
Add
board_get_usable_ram_top()function. Limit maximum usable ram top to 2GB.Why ? There are ARM64 platforms which can access the entire DRAM range just fine, what's the problem ?
The issue is the gap in memory between 2GB and 4GB. There is some trickery you can use to gain access to the memory in that range, but in general, you dont have access. I believe just setting the banks up in the dts will resolve this.
--dalon
Quoted 14 lines
Quoted 14 lines
Signed-off-by Dalon Westergreen <[email protected]>Signed-off-by Ley Foon Tan <[email protected]>--- board/altera/stratix10-socdk/socfpga.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)board/altera/stratix10-socdk/socfpga.c +0
-0@@ -5,3 +5,15 @@*/
Quoted 16 lines
Quoted 4 lines
board/altera/stratix10-socdk/socfpga.c +2
-0#include <common.h> +#include <asm/arch/sdram.h> +#include <linux/sizes.h> board/altera/stratix10-socdk/socfpga.c line 19
Quoted 10 lines
board/altera/stratix10-socdk/socfpga.c +10
-0+ +#ifdef CONFIG_ALTERA_SDRAM +ulong board_get_usable_ram_top (ulong total_size) +{ +if (sdram_calculate_size () >SZ_2G ) +return SZ_2G ; +else +return sdram_calculate_size (); +} +#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3282 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190312/7396aa26/attachment.bin>
PATCH 5/10 board: altera: Stratix10: Add board_get_usable_ram_top()
Quoted 5 lines · Dalon
Quoted 4 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan
Add
board_get_usable_ram_top()function. Limit maximum usable ram top to 2GB.
Quoted 8 lines
Quoted 3 lines
Why ? There are ARM64 platforms which can access the entire DRAM range just fine, what's the problem ?
The issue is the gap in memory between 2GB and 4GB. There is some trickery you can use to gain access to the memory in that range, but in general, you dont have access. I believe just setting the banks up in the dts will resolve this.
E.g. the R8A779{5..9}* platforms also have gaps in memory and it all works fine . So unless there's some other specialty, there should be no problem.
Signature · 2 lines
Best regards, Marek Vasut
PATCH 5/10 board: altera: Stratix10: Add board_get_usable_ram_top()
Quoted 11 lines · Marek Vasut
Quoted 9 lines · Dalon
Quoted 7 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan
Add
board_get_usable_ram_top()function. Limit maximum usable ram top to 2GB.Why ? There are ARM64 platforms which can access the entire DRAM range just fine, what's the problem ?
Quoted 9 lines
Quoted 4 lines
The issue is the gap in memory between 2GB and 4GB. There is some trickery you can use to gain access to the memory in that range, but in general, you dont have access. I believe just setting the banks up in the dts will resolve this.
E.g. the R8A779{5..9}* platforms also have gaps in memory and it all works fine . So unless there's some other specialty, there should be no problem.
Yes, we don't need this.
Regards
Ley Foon
PATCH 6/10 board: altera: Stratix10: Add ft_board_setup()
In reply to Ley Foon TanAdd ft_board_setup() function to setup memory banks before boot to Linux.
--- board/altera/stratix10-socdk/socfpga.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
board/altera/stratix10-socdk/socfpga.c +25 -0
@@ -5,6 +5,7 @@*/ #include <common.h> +#include <fdt_support.h> #include <asm/arch/sdram.h> #include <linux/sizes.h>
@@ -17,3 +18,27 @@ ulong board_get_usable_ram_top(ulong total_size) return sdram_calculate_size(); }#endif + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,bd_t *bd) +{ +int ret =0 ; +#ifdef CONFIG_OF_LIBFDT +int bank; +int actual_bank =0 ; +u64 start[CONFIG_NR_DRAM_BANKS ]; +u64 size[CONFIG_NR_DRAM_BANKS ]; + +for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { +if (bd->bi_dram[bank].size) { + start[actual_bank] = bd->bi_dram[bank].start; + size[actual_bank++] = bd->bi_dram[bank].size; + } + } + + ret =fdt_fixup_memory_banks (blob, start, size, actual_bank); +#endif /* CONFIG_OF_LIBFDT */ + +return ret; +} +#endif
Signature · 1 line
2.19.0
PATCH 6/10 board: altera: Stratix10: Add ft_board_setup()
Quoted 2 lines · Ley Foon Tan
Add
ft_board_setup()function to setup memory banks before boot to Linux.
Shouldn't bootm/booti be doing just that already ?
Quoted 46 lines
Signed-off-by Ley Foon Tan <[email protected]>--- board/altera/stratix10-socdk/socfpga.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)board/altera/stratix10-socdk/socfpga.c +25
-0@@ -5,6 +5,7 @@*/ #include <common.h> +#include <fdt_support.h> #include <asm/arch/sdram.h> #include <linux/sizes.h> @@ -17,3 +18,27 @@ ulong board_get_usable_ram_top(ulong total_size) return sdram_calculate_size(); }#endif + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,bd_t *bd) +{ +int ret =0 ; +#ifdef CONFIG_OF_LIBFDT +int bank; +int actual_bank =0 ; +u64 start[CONFIG_NR_DRAM_BANKS ]; +u64 size[CONFIG_NR_DRAM_BANKS ]; + +for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { +if (bd->bi_dram[bank].size) { + start[actual_bank] = bd->bi_dram[bank].start; + size[actual_bank++] = bd->bi_dram[bank].size; + } + } + + ret =fdt_fixup_memory_banks (blob, start, size, actual_bank); +#endif /* CONFIG_OF_LIBFDT */ + +return ret; +} +#endif
Signature · 2 lines
Best regards, Marek Vasut
PATCH 6/10 board: altera: Stratix10: Add ft_board_setup()
Quoted 6 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan
Add
ft_board_setup()function to setup memory banks before boot to Linux.Shouldn't bootm/booti be doing just that already ?
Don't need this if we use fdtdec_setup_memory_banksize().
Quoted 39 lines
Quoted 39 lines
Signed-off-by Ley Foon Tan <[email protected]>--- board/altera/stratix10-socdk/socfpga.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)board/altera/stratix10-socdk/socfpga.c +18
-0@@ -5,6 +5,7 @@*/ #include <common.h> +#include <fdt_support.h> #include <asm/arch/sdram.h> #include <linux/sizes.h> @@ -17,3 +18,27 @@ ulong board_get_usable_ram_top(ulong total_size)return sdram_calculate_size (); }#endif + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup (void *blob,bd_t *bd) +{ +int ret =0 ; +#ifdef CONFIG_OF_LIBFDT +int bank; +int actual_bank =0 ; +u64 start[CONFIG_NR_DRAM_BANKS ]; +u64 size[CONFIG_NR_DRAM_BANKS ]; + +for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { +if (bd->bi_dram[bank].size) { + start[actual_bank] = bd->bi_dram[bank].start; + size[actual_bank++] = bd->bi_dram[bank].size; + } + }
Quoted 8 lines
board/altera/stratix10-socdk/socfpga.c ulong board_get_usable_ram_top(ulong total_size) · line 44
Quoted 8 lines
board/altera/stratix10-socdk/socfpga.c +7
-0+ + ret =fdt_fixup_memory_banks (blob, start, size, actual_bank); +#endif /* CONFIG_OF_LIBFDT */ + + return ret; +} +#endif
Regards
Ley Foon
PATCH 7/10 arm: socfpga: Enable OF_BOARD_SETUP for Stratix 10
In reply to Ley Foon TanEnable OF_BOARD_SETUP for Stratix 10.
--- arch/arm/mach-socfpga/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-socfpga/Kconfig +1 -0
@@ -36,6 +36,7 @@ config TARGET_SOCFPGA_STRATIX10 select ARMV8_SET_SMPEN select ARMV8_SPIN_TABLE select FPGA_STRATIX10 + select OF_BOARD_SETUP choice prompt "Altera SOCFPGA board select"
Signature · 1 line
2.19.0
PATCH 8/10 configs: stratix10: Change CONFIG_NR_DRAM_BANKS to 2
In reply to Ley Foon TanStratix 10 SoC support 2 DRAM banks.
--- configs/socfpga_stratix10_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configs/socfpga_stratix10_defconfig +1 -1
@@ -6,7 +6,7 @@ CONFIG_TARGET_SOCFPGA_STRATIX10_SOCDK=y CONFIG_SPL=y CONFIG_IDENT_STRING="socfpga_stratix10" CONFIG_SPL_FS_FAT=y -CONFIG_NR_DRAM_BANKS=1 +CONFIG_NR_DRAM_BANKS=2 CONFIG_BOOTDELAY=5 CONFIG_SPL_SPI_LOAD=y CONFIG_HUSH_PARSER=y
Signature · 1 line
2.19.0
PATCH 9/10 arm: socfpga: stratix10: Add cpu_has_been_warmreset()
In reply to Ley Foon TanAdd helper function cpu_has_been_warmreset() to check if CPU is from warm reset boot.
--- arch/arm/mach-socfpga/include/mach/reset_manager_s10.h | 3 +++ arch/arm/mach-socfpga/reset_manager_s10.c | 9 +++++++++ 2 files changed, 12 insertions(+)
arch/arm/mach-socfpga/include/mach/reset_manager_s10.h +3 -0
@@ -9,6 +9,7 @@void reset_cpu (ulong addr);void reset_deassert_peripherals_handoff (void ); +int cpu_has_been_warmreset (void );void socfpga_bridges_reset (int enable);
@@ -47,6 +48,8 @@ struct socfpga_reset_manager {#define RSTMGR_MPUMODRST_CORE0 0#define RSTMGR_PER0MODRST_OCP_MASK 0x0020bf00#define RSTMGR_BRGMODRST_DDRSCH_MASK 0X00000040 +/* Watchdogs and MPU warm reset mask */ +#define RSTMGR_L4WD_MPU_WARMRESET_MASK 0x000F0F00/* * Define a reset identifier, from which a permodrst bank ID
arch/arm/mach-socfpga/reset_manager_s10.c +9 -0
@@ -103,3 +103,12 @@ void reset_deassert_peripherals_handoff(void)writel (~RSTMGR_PER0MODRST_OCP_MASK , &reset_manager_base->per0modrst);writel (0 , &reset_manager_base->per0modrst); } + +/* +* Return non-zero if the CPU has been warm reset +*/ +int cpu_has_been_warmreset (void ) +{ +return readl (&reset_manager_base->status) & +RSTMGR_L4WD_MPU_WARMRESET_MASK ; +}
Signature · 1 line
2.19.0
PATCH 10/10 ddr: altera: Stratix10: Add ECC memory scrubbing
In reply to Ley Foon TanScrub memory content if ECC is enabled and it is not from warm reset boot.
Enable icache and dcache before scrub memory and use "DC ZVA" instruction to clear memory to zeros. This instruction writes a cache line at a time and it can prevent false ECC error trigger if write cache line partially.
--- .../arm/mach-socfpga/include/mach/sdram_s10.h | 9 +++ drivers/ddr/altera/sdram_s10.c | 76 +++++++++++++++++++ 2 files changed, 85 insertions(+)
arch/arm/mach-socfpga/include/mach/sdram_s10.h +9 -0
@@ -23,6 +23,7 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define ECCCTRL1 0x100#define ECCCTRL2 0x104#define ERRINTEN 0x110 +#define ERRINTENS 0x114#define INTMODE 0x11c#define INTSTAT 0x120#define AUTOWB_CORRADDR 0x138
@@ -53,6 +54,10 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define DDR_HMC_SEQ2CORE_INT_RESP_MASK BIT(3)#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK 0x001f1f1f +#define DDR_HMC_ERRINTEN_INTMASK \ + (DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK | \ + DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK) +/* NOC DDR scheduler */ #define DDR_SCH_ID_COREID 0#define DDR_SCH_ID_REVID 0x4
@@ -181,4 +186,8 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define CALTIMING9_CFG_4_ACT_TO_ACT (x) \ (((x) >> 0) & 0xFF) +/* Firewall DDR scheduler MPFE */ +#define FW_HMC_ADAPTOR_REG_ADDR 0xf8020004 +#define FW_HMC_ADAPTOR_MPU_MASK BIT(0) +#endif /* _SDRAM_S10_H_ */
drivers/ddr/altera/sdram_s10.c +76 -0
94 lines not on this page · raw message
Signature · 1 line
2.19.0
PATCH 10/10 ddr: altera: Stratix10: Add ECC memory scrubbing
Quoted 61 lines · Ley Foon Tan
Scrub memory content if ECC is enabled and it is not from warm reset boot.
Enable icache and dcache before scrub memory and use "DC ZVA" instruction to clear memory to zeros. This instruction writes a cache line at a time and it can prevent false ECC error trigger if write cache line partially.
Signed-off-by Ley Foon Tan <[email protected]>--- .../arm/mach-socfpga/include/mach/sdram_s10.h | 9 +++ drivers/ddr/altera/sdram_s10.c | 76 +++++++++++++++++++ 2 files changed, 85 insertions(+)arch/arm/mach-socfpga/include/mach/sdram_s10.h +9
-0@@ -23,6 +23,7 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define ECCCTRL1 0x100#define ECCCTRL2 0x104#define ERRINTEN 0x110 +#define ERRINTENS 0x114#define INTMODE 0x11c#define INTSTAT 0x120#define AUTOWB_CORRADDR 0x138@@ -53,6 +54,10 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define DDR_HMC_SEQ2CORE_INT_RESP_MASK BIT(3)#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK 0x001f1f1f +#define DDR_HMC_ERRINTEN_INTMASK \ + (DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK | \ + DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK) +/* NOC DDR scheduler */ #define DDR_SCH_ID_COREID 0#define DDR_SCH_ID_REVID 0x4@@ -181,4 +186,8 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define CALTIMING9_CFG_4_ACT_TO_ACT (x) \ (((x) >> 0) & 0xFF) +/* Firewall DDR scheduler MPFE */ +#define FW_HMC_ADAPTOR_REG_ADDR 0xf8020004 +#define FW_HMC_ADAPTOR_MPU_MASK BIT(0) +#endif /* _SDRAM_S10_H_ */ drivers/ddr/altera/sdram_s10.c +2
-0@@ -22,6 +22,8 @@ static const struct socfpga_system_manager *sysmgr_regs =#define DDR_CONFIG (A ,B ,C ,R ) (((A) << 24) | ((B) << 16) | ((C) << 8) | (R)) +#define PGTABLE_OFF 0x4000 +/* The followring are the supported configurations */ u32 ddr_config[] = {/* DDR_CONFIG(Address order,Bank,Column,Row) */
drivers/ddr/altera/sdram_s10.c static int poll_hmc_clock_status(void) · line 146
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +7
-0@@ -135,6 +137,71 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_clear_mem (phys_addr_t addr,phys_size_t size) +{ +phys_size_t i; + +if (addr %CONFIG_SYS_CACHELINE_SIZE ) { +printf ("DDR: address 0x%lx not cacheline size aligned.\n" , + (ulong )addr);
Is the cast needed ?
Quoted 4 lines
drivers/ddr/altera/sdram_s10.c +4
-0+hang (); + } + +if (size %CONFIG_SYS_CACHELINE_SIZE ) {
drivers/ddr/altera/sdram_s10.c static int poll_hmc_clock_status(void) · line 160
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +10
-0+printf ("DDR: size 0x%lx not multiple of cacheline size\n" , + (ulong )size); +hang (); + } + +/* Use DC ZVA instruction to clear memory to zeros by a cache line */ +for (i =0 ; i < size; i = i +CONFIG_SYS_CACHELINE_SIZE ) { + asm("dc zva, %0" + : + :"r" (addr));
Should be asm volatile, so the compiler won't move this around. Also, you want memory clobber here I think ?
Quoted 16 lines
drivers/ddr/altera/sdram_s10.c +16
-0+ addr +=CONFIG_SYS_CACHELINE_SIZE ; + } +} + +static void sdram_init_ecc_bits (phys_addr_t *bank_start,phys_size_t *bank_size) +{ +phys_size_t size, size_init; +phys_addr_t start_addr; +int bank; +unsigned int start =get_timer (0 ); + +icache_enable (); + +for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { + start_addr = bank_start[bank]; + size = bank_size[bank];
drivers/ddr/altera/sdram_s10.c static int poll_hmc_clock_status(void) · line 186
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +10
-0+ +if (bank ==0 ) { +/* Initialize small block for page table */ +memset ((void *)start_addr,0 , +PGTABLE_SIZE +PGTABLE_OFF ); + gd->arch.tlb_addr = start_addr +PGTABLE_OFF ; + gd->arch.tlb_size =PGTABLE_SIZE ; + start_addr +=PGTABLE_SIZE +PGTABLE_OFF ; + size -= (PGTABLE_OFF +PGTABLE_SIZE ); +dcache_enable ();
If it's only done for bank0, pull this code out of the loop ?
Quoted 38 lines
drivers/ddr/altera/sdram_s10.c +27
-0+ } + +while (size) { + size_init =min ((phys_addr_t )SZ_1G , (phys_addr_t )size); +sdram_clear_mem (start_addr, size_init); + size -= size_init; + start_addr += size_init; +WATCHDOG_RESET (); + } + } + +dcache_disable (); +icache_disable (); + +printf ("SDRAM-ECC: Initialized success with %d ms\n" , + (unsigned int )get_timer (start)); +} +static void sdram_size_check (phys_addr_t bank_start[],phys_size_t bank_size[]) {phys_size_t total_ram_check =0 ;@@ -451,6 +518,15 @@ int sdram_mmr_init_full(unsigned int unused)setbits_le32 (SOCFPGA_SDR_ADDRESS +ECCCTRL2 , (DDR_HMC_ECCCTL2_RMW_EN_SET_MSK |DDR_HMC_ECCCTL2_AWB_EN_SET_MSK )); +writel (DDR_HMC_ERRINTEN_INTMASK , +SOCFPGA_SDR_ADDRESS +ERRINTENS ); + +/* Enable non-secure writes to HMC Adapter for SDRAM ECC */ +writel (FW_HMC_ADAPTOR_MPU_MASK ,FW_HMC_ADAPTOR_REG_ADDR ); + +/* Initialize memory content if not from warm reset */ +if (!cpu_has_been_warmreset ()) +sdram_init_ecc_bits (bank_start, bank_size); }else { clrbits_le32(SOCFPGA_SDR_ADDRESS + ECCCTRL1, (DDR_HMC_ECCCTL_AWB_CNT_RST_SET_MSK |
Signature · 2 lines
Best regards, Marek Vasut
PATCH 10/10 ddr: altera: Stratix10: Add ECC memory scrubbing
Quoted 66 lines · Marek Vasut
Quoted 64 lines · Ley Foon Tan
Scrub memory content if ECC is enabled and it is not from warm reset boot.
Enable icache and dcache before scrub memory and use "DC ZVA" instruction to clear memory to zeros. This instruction writes a cache line at a time and it can prevent false ECC error trigger if write cache line partially.
Signed-off-by Ley Foon Tan <[email protected]>--- .../arm/mach-socfpga/include/mach/sdram_s10.h | 9 +++ drivers/ddr/altera/sdram_s10.c | 76 +++++++++++++++++++ 2 files changed, 85 insertions(+)arch/arm/mach-socfpga/include/mach/sdram_s10.h +9
-0@@ -23,6 +23,7 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define ECCCTRL1 0x100#define ECCCTRL2 0x104#define ERRINTEN 0x110 +#define ERRINTENS 0x114#define INTMODE 0x11c#define INTSTAT 0x120#define AUTOWB_CORRADDR 0x138@@ -53,6 +54,10 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define DDR_HMC_SEQ2CORE_INT_RESP_MASK BIT(3)#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK 0x001f1f1f +#define DDR_HMC_ERRINTEN_INTMASK \ + (DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK | \ + DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK) +/* NOC DDR scheduler */ #define DDR_SCH_ID_COREID 0#define DDR_SCH_ID_REVID 0x4@@ -181,4 +186,8 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define CALTIMING9_CFG_4_ACT_TO_ACT (x) \ (((x) >> 0) & 0xFF) +/* Firewall DDR scheduler MPFE */ +#define FW_HMC_ADAPTOR_REG_ADDR 0xf8020004 +#define FW_HMC_ADAPTOR_MPU_MASK BIT(0) +#endif /* _SDRAM_S10_H_ */ drivers/ddr/altera/sdram_s10.c +2
-0@@ -22,6 +22,8 @@ static const struct socfpga_system_manager *sysmgr_regs =#define DDR_CONFIG (A ,B ,C ,R ) (((A) << 24) | ((B) << 16) | ((C) << 8) | (R)) +#define PGTABLE_OFF 0x4000 +/* The followring are the supported configurations */ u32 ddr_config[] = {/* DDR_CONFIG(Address order,Bank,Column,Row) */ @@ -135,6 +137,71 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); }
Quoted 9 lines
drivers/ddr/altera/sdram_s10.c static int poll_hmc_clock_status(void) · line 146
Quoted 7 lines
drivers/ddr/altera/sdram_s10.c +7
-0+static void sdram_clear_mem (phys_addr_t addr,phys_size_t size) +{ +phys_size_t i; + +if (addr %CONFIG_SYS_CACHELINE_SIZE ) { +printf ("DDR: address 0x%lx not cacheline size aligned.\n" , + (ulong )addr);Is the cast needed ?
Yes, SPL doesn't support %llx, we need cast to ulong %lx.
Quoted 17 lines
Quoted 5 lines
drivers/ddr/altera/sdram_s10.c +4
-0+hang (); + } + +if (size %CONFIG_SYS_CACHELINE_SIZE ) {drivers/ddr/altera/sdram_s10.c static int poll_hmc_clock_status(void) · line 160
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +10
-0+printf ("DDR: size 0x%lx not multiple of cacheline size\n" , + (ulong )size); +hang (); + } + +/* Use DC ZVA instruction to clear memory to zeros by a cache line */ +for (i =0 ; i < size; i = i +CONFIG_SYS_CACHELINE_SIZE ) { + asm("dc zva, %0" + : + :"r" (addr));Should be asm volatile, so the compiler won't move this around.
Okay.
Quoted 1 line
Also, you want memory clobber here I think ?
Yes, will add "memory" clobber here.
Quoted 21 lines
Quoted 21 lines
drivers/ddr/altera/sdram_s10.c +20
-0+ addr +=CONFIG_SYS_CACHELINE_SIZE ; + } +} + +static void sdram_init_ecc_bits (phys_addr_t *bank_start,phys_size_t *bank_size) +{ +phys_size_t size, size_init; +phys_addr_t start_addr; +int bank; +unsigned int start =get_timer (0 ); + +icache_enable (); + +for (bank =0 ; bank <CONFIG_NR_DRAM_BANKS ; bank++) { + start_addr = bank_start[bank]; + size = bank_size[bank]; + +if (bank ==0 ) { +/* Initialize small block for page table */ + memset((void *)start_addr, 0,
Quoted 8 lines
drivers/ddr/altera/sdram_s10.c static int poll_hmc_clock_status(void) · line 186
Quoted 6 lines
drivers/ddr/altera/sdram_s10.c +6
-0+ PGTABLE_SIZE + PGTABLE_OFF); + gd->arch.tlb_addr = start_addr +PGTABLE_OFF ; + gd->arch.tlb_size =PGTABLE_SIZE ; + start_addr +=PGTABLE_SIZE +PGTABLE_OFF ; + size -= (PGTABLE_OFF +PGTABLE_SIZE ); +dcache_enable ();If it's only done for bank0, pull this code out of the loop ?
Okay.
Quoted 44 lines
Quoted 29 lines
drivers/ddr/altera/sdram_s10.c +20
-0+ } + +while (size) { + size_init =min ((phys_addr_t )SZ_1G , (phys_addr_t )size); +sdram_clear_mem (start_addr, size_init); + size -= size_init; + start_addr += size_init; +WATCHDOG_RESET (); + } + } + +dcache_disable (); +icache_disable (); + +printf ("SDRAM-ECC: Initialized success with %d ms\n" , + (unsigned int )get_timer (start)); +} +static void sdram_size_check (phys_addr_t bank_start[],phys_size_t bank_size[]) {phys_size_t total_ram_check =0 ;@@ -451,6 +518,15 @@ int sdram_mmr_init_full(unsigned int unused)setbits_le32 (SOCFPGA_SDR_ADDRESS +ECCCTRL2 , (DDR_HMC_ECCCTL2_RMW_EN_SET_MSK |DDR_HMC_ECCCTL2_AWB_EN_SET_MSK )); +writel (DDR_HMC_ERRINTEN_INTMASK , +SOCFPGA_SDR_ADDRESS +ERRINTENS );drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 532
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +7
-0+ +/* Enable non-secure writes to HMC Adapter for SDRAM ECC */ +writel (FW_HMC_ADAPTOR_MPU_MASK ,FW_HMC_ADAPTOR_REG_ADDR ); + +/* Initialize memory content if not from warm reset */ +if (!cpu_has_been_warmreset ()) +sdram_init_ecc_bits (bank_start, bank_size); }else { clrbits_le32(SOCFPGA_SDR_ADDRESS + ECCCTRL1, (DDR_HMC_ECCCTL_AWB_CNT_RST_SET_MSK |--
Best regards,
Marek Vasut
PATCH 10/10 ddr: altera: Stratix10: Add ECC memory scrubbing
Quoted 76 lines · Ley Foon Tan
Quoted 66 lines · Marek Vasut
Quoted 64 lines · Ley Foon Tan
Scrub memory content if ECC is enabled and it is not from warm reset boot.
Enable icache and dcache before scrub memory and use "DC ZVA" instruction to clear memory to zeros. This instruction writes a cache line at a time and it can prevent false ECC error trigger if write cache line partially.
Signed-off-by Ley Foon Tan <[email protected]>--- .../arm/mach-socfpga/include/mach/sdram_s10.h | 9 +++ drivers/ddr/altera/sdram_s10.c | 76 +++++++++++++++++++ 2 files changed, 85 insertions(+)arch/arm/mach-socfpga/include/mach/sdram_s10.h +9
-0@@ -23,6 +23,7 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define ECCCTRL1 0x100#define ECCCTRL2 0x104#define ERRINTEN 0x110 +#define ERRINTENS 0x114#define INTMODE 0x11c#define INTSTAT 0x120#define AUTOWB_CORRADDR 0x138@@ -53,6 +54,10 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define DDR_HMC_SEQ2CORE_INT_RESP_MASK BIT(3)#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK 0x001f1f1f +#define DDR_HMC_ERRINTEN_INTMASK \ + (DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK | \ + DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK) +/* NOC DDR scheduler */ #define DDR_SCH_ID_COREID 0#define DDR_SCH_ID_REVID 0x4@@ -181,4 +186,8 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define CALTIMING9_CFG_4_ACT_TO_ACT (x) \ (((x) >> 0) & 0xFF) +/* Firewall DDR scheduler MPFE */ +#define FW_HMC_ADAPTOR_REG_ADDR 0xf8020004 +#define FW_HMC_ADAPTOR_MPU_MASK BIT(0) +#endif /* _SDRAM_S10_H_ */ drivers/ddr/altera/sdram_s10.c +2
-0@@ -22,6 +22,8 @@ static const struct socfpga_system_manager *sysmgr_regs =#define DDR_CONFIG (A ,B ,C ,R ) (((A) << 24) | ((B) << 16) | ((C) << 8) | (R)) +#define PGTABLE_OFF 0x4000 +/* The followring are the supported configurations */ u32 ddr_config[] = {/* DDR_CONFIG(Address order,Bank,Column,Row) */ @@ -135,6 +137,71 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); }Quoted 9 lines
drivers/ddr/altera/sdram_s10.c static int poll_hmc_clock_status(void) · line 146
Quoted 7 lines
drivers/ddr/altera/sdram_s10.c +7
-0+static void sdram_clear_mem (phys_addr_t addr,phys_size_t size) +{ +phys_size_t i; + +if (addr %CONFIG_SYS_CACHELINE_SIZE ) { +printf ("DDR: address 0x%lx not cacheline size aligned.\n" , + (ulong )addr);Is the cast needed ?
Quoted 1 line
Yes, SPL doesn't support %llx, we need cast to ulong %lx.
But that doesn't work for 64bit addresses ?
Isn't that limitation of tiny printf implementation instead of SPL ?
[...]
Signature · 2 lines
Best regards, Marek Vasut
PATCH 10/10 ddr: altera: Stratix10: Add ECC memory scrubbing
Quoted 78 lines · Marek Vasut
Quoted 76 lines · Ley Foon Tan
Quoted 75 lines · Marek Vasut
Quoted 61 lines · Ley Foon Tan
Scrub memory content if ECC is enabled and it is not from warm reset boot.
Enable icache and dcache before scrub memory and use "DC ZVA" instruction to clear memory to zeros. This instruction writes a cache line at a time and it can prevent false ECC error trigger if write cache line partially.
Signed-off-by Ley Foon Tan <[email protected]>--- .../arm/mach-socfpga/include/mach/sdram_s10.h | 9 +++ drivers/ddr/altera/sdram_s10.c | 76 +++++++++++++++++++ 2 files changed, 85 insertions(+)arch/arm/mach-socfpga/include/mach/sdram_s10.h +9
-0@@ -23,6 +23,7 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define ECCCTRL1 0x100#define ECCCTRL2 0x104#define ERRINTEN 0x110 +#define ERRINTENS 0x114#define INTMODE 0x11c#define INTSTAT 0x120#define AUTOWB_CORRADDR 0x138@@ -53,6 +54,10 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define DDR_HMC_SEQ2CORE_INT_RESP_MASK BIT(3)#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK 0x001f1f1f +#define DDR_HMC_ERRINTEN_INTMASK \ + (DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK | \ + DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK) +/* NOC DDR scheduler */ #define DDR_SCH_ID_COREID 0#define DDR_SCH_ID_REVID 0x4@@ -181,4 +186,8 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define CALTIMING9_CFG_4_ACT_TO_ACT (x) \ (((x) >> 0) & 0xFF) +/* Firewall DDR scheduler MPFE */ +#define FW_HMC_ADAPTOR_REG_ADDR 0xf8020004 +#define FW_HMC_ADAPTOR_MPU_MASK BIT(0) +#endif /* _SDRAM_S10_H_ */ drivers/ddr/altera/sdram_s10.c +2
-0@@ -22,6 +22,8 @@ static const struct socfpga_system_manager *sysmgr_regs =#define DDR_CONFIG (A ,B ,C ,R ) (((A) << 24) | ((B) << 16) | ((C) << 8) | (R)) +#define PGTABLE_OFF 0x4000 +/* The followring are the supported configurations */ u32 ddr_config[] = {/* DDR_CONFIG(Address order,Bank,Column,Row) */ drivers/ddr/altera/sdram_s10.c static int poll_hmc_clock_status(void) · line 146
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +7
-0@@ -135,6 +137,71 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_clear_mem (phys_addr_t addr,phys_size_t size) +{ +phys_size_t i; + +if (addr %CONFIG_SYS_CACHELINE_SIZE ) { +printf ("DDR: address 0x%lx not cacheline size aligned.\n" , + (ulong )addr);Is the cast needed ?
Quoted 5 lines
Quoted 1 line
Yes, SPL doesn't support %llx, we need cast to ulong %lx.
But that doesn't work for 64bit addresses ?
Isn't that limitation of tiny printf implementation instead of SPL ?
%lx still work for 64 bit address.
Yes, I think it is limitation of tiny printf in SPL.
Regards
Ley Foon
PATCH 10/10 ddr: altera: Stratix10: Add ECC memory scrubbing
Quoted 79 lines · Ley Foon Tan
Quoted 78 lines · Marek Vasut
Quoted 76 lines · Ley Foon Tan
Quoted 75 lines · Marek Vasut
Quoted 61 lines · Ley Foon Tan
Scrub memory content if ECC is enabled and it is not from warm reset boot.
Enable icache and dcache before scrub memory and use "DC ZVA" instruction to clear memory to zeros. This instruction writes a cache line at a time and it can prevent false ECC error trigger if write cache line partially.
Signed-off-by Ley Foon Tan <[email protected]>--- .../arm/mach-socfpga/include/mach/sdram_s10.h | 9 +++ drivers/ddr/altera/sdram_s10.c | 76 +++++++++++++++++++ 2 files changed, 85 insertions(+)arch/arm/mach-socfpga/include/mach/sdram_s10.h +9
-0@@ -23,6 +23,7 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define ECCCTRL1 0x100#define ECCCTRL2 0x104#define ERRINTEN 0x110 +#define ERRINTENS 0x114#define INTMODE 0x11c#define INTSTAT 0x120#define AUTOWB_CORRADDR 0x138@@ -53,6 +54,10 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define DDR_HMC_SEQ2CORE_INT_RESP_MASK BIT(3)#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK 0x001f1f1f +#define DDR_HMC_ERRINTEN_INTMASK \ + (DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK | \ + DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK) +/* NOC DDR scheduler */ #define DDR_SCH_ID_COREID 0#define DDR_SCH_ID_REVID 0x4@@ -181,4 +186,8 @@ void setup_memory_banks(phys_addr_t bank_addr[], phys_size_t bank_size[]);#define CALTIMING9_CFG_4_ACT_TO_ACT (x) \ (((x) >> 0) & 0xFF) +/* Firewall DDR scheduler MPFE */ +#define FW_HMC_ADAPTOR_REG_ADDR 0xf8020004 +#define FW_HMC_ADAPTOR_MPU_MASK BIT(0) +#endif /* _SDRAM_S10_H_ */ drivers/ddr/altera/sdram_s10.c +2
-0@@ -22,6 +22,8 @@ static const struct socfpga_system_manager *sysmgr_regs =#define DDR_CONFIG (A ,B ,C ,R ) (((A) << 24) | ((B) << 16) | ((C) << 8) | (R)) +#define PGTABLE_OFF 0x4000 +/* The followring are the supported configurations */ u32 ddr_config[] = {/* DDR_CONFIG(Address order,Bank,Column,Row) */ drivers/ddr/altera/sdram_s10.c static int poll_hmc_clock_status(void) · line 146
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +7
-0@@ -135,6 +137,71 @@ static int poll_hmc_clock_status(void) SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false); } +static void sdram_clear_mem (phys_addr_t addr,phys_size_t size) +{ +phys_size_t i; + +if (addr %CONFIG_SYS_CACHELINE_SIZE ) { +printf ("DDR: address 0x%lx not cacheline size aligned.\n" , + (ulong )addr);Is the cast needed ?
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Yes, SPL doesn't support %llx, we need cast to ulong %lx.
But that doesn't work for 64bit addresses ?
Isn't that limitation of tiny printf implementation instead of SPL ?%lx still work for 64 bit address.
Yes, I think it is limitation of tiny printf in SPL.
Can the tiny printf be fixed ? I think it should be easy.
Signature · 2 lines
Best regards, Marek Vasut
cover Update Stratix 10 SDRAM driver
In reply to Ley Foon TanQuoted 9 lines · Ley Foon Tan
This patchset update Stratix 10 SDRAM driver to support:
- Multi-banks memory (Patch [1-8])
- Stratix 10 support up to 2 memory banks:
Bank 0: Address 0, size 2GB
Bank 1: Address0x100000000, size 124GB
- Add warm reset boot checking function, to use in patch [10] (Patch[9])
- Add ECC memory scrubbing support (Patch [10])
- Use cache enabled + "DC ZVA" instruction to clear memory to zeros
When working on this, would it make sense to move the S10 SDRAM driver to DM, using UCLASS_RAM, like I did for gen5 (see Marek's 'next' branch:
http://git.denx.de/?p=u-boot/u-boot-socfpga.git;a=commit;h=4796a7d5a7fd965c02cf290edec17acb2c9af766)
That might allow us to combine more of the code in mach-socfpga again in the future...
Regards,
Simon
Quoted 32 lines
Ley Foon Tan (10):
ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
arm: socfpga: Addsdram_s10.htosdram.h
ddr: altera: s10: Add multiple memory banks support
arm: socfpga: Updatedram_init_banksize()for Stratix10
board: altera: Stratix10: Addboard_get_usable_ram_top()
board: altera: Stratix10: Addft_board_setup()
arm: socfpga: EnableOF_BOARD_SETUPfor Stratix 10
configs: stratix10: ChangeCONFIG_NR_DRAM_BANKSto 2
arm: socfpga: stratix10: Addcpu_has_been_warmreset()
ddr: altera: Stratix10: Add ECC memory scrubbingarch/arm/mach-socfpga/Kconfig | 1 + arch/arm/mach-socfpga/board.c | 16 +- .../include/mach/reset_manager_s10.h | 3 + arch/arm/mach-socfpga/include/mach/sdram.h | 2 + .../arm/mach-socfpga/include/mach/sdram_s10.h | 10 + arch/arm/mach-socfpga/reset_manager_s10.c | 9 + arch/arm/mach-socfpga/spl_s10.c | 11 -- board/altera/stratix10-socdk/socfpga.c | 37 ++++ configs/socfpga_stratix10_defconfig | 2 +- drivers/ddr/altera/sdram_s10.c | 178 ++++++++++++++++++ 10 files changed, 256 insertions(+), 13 deletions(-)--
2.19.0_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
cover Update Stratix 10 SDRAM driver
Quoted 21 lines · Simon Goldschmidt
Quoted 12 lines · Ley Foon Tan
This patchset update Stratix 10 SDRAM driver to support:
- Multi-banks memory (Patch [1-8])
- Stratix 10 support up to 2 memory banks:
Bank 0: Address 0, size 2GB
Bank 1: Address0x100000000, size 124GB
- Add warm reset boot checking function, to use in patch [10] (Patch[9])
- Add ECC memory scrubbing support (Patch [10])
- Use cache enabled + "DC ZVA" instruction to clear memory to zerosWhen working on this, would it make sense to move the S10 SDRAM driver
to DM, usingUCLASS_RAM, like I did for gen5 (see Marek's 'next' branch:
http://git.denx.de/?p=u-boot/u-boot-socfpga.git;a=commit;h=4796a7d5a7fd965c02cf290edec17acb2c9af766)
Quoted 2 lines
That might allow us to combine more of the code in mach-socfpga again in the future...
Sure, I will look into this. But will be in separate series.
Thanks.
Regards
Ley Foon
Quoted 38 lines
Regards,
SimonQuoted 34 lines
Ley Foon Tan (10):
ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
arm: socfpga: Addsdram_s10.htosdram.h
ddr: altera: s10: Add multiple memory banks support
arm: socfpga: Updatedram_init_banksize()for Stratix10
board: altera: Stratix10: Addboard_get_usable_ram_top()
board: altera: Stratix10: Addft_board_setup()
arm: socfpga: EnableOF_BOARD_SETUPfor Stratix 10
configs: stratix10: ChangeCONFIG_NR_DRAM_BANKSto 2
arm: socfpga: stratix10: Addcpu_has_been_warmreset()
ddr: altera: Stratix10: Add ECC memory scrubbingarch/arm/mach-socfpga/Kconfig | 1 + arch/arm/mach-socfpga/board.c | 16 +- .../include/mach/reset_manager_s10.h | 3 + arch/arm/mach-socfpga/include/mach/sdram.h | 2 +
.../arm/mach-socfpga/include/mach/sdram_s10.h| 10 + arch/arm/mach-socfpga/reset_manager_s10.c | 9 + arch/arm/mach-socfpga/spl_s10.c | 11 -- board/altera/stratix10-socdk/socfpga.c | 37 ++++ configs/socfpga_stratix10_defconfig | 2 +- drivers/ddr/altera/sdram_s10.c | 178
++++++++++++++++++10 files changed, 256 insertions(+), 13 deletions(-)--
2.19.0_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
cover Update Stratix 10 SDRAM driver
Quoted 23 lines · Ley Foon Tan
Quoted 21 lines · Simon Goldschmidt
Quoted 12 lines · Ley Foon Tan
This patchset update Stratix 10 SDRAM driver to support:
- Multi-banks memory (Patch [1-8])
- Stratix 10 support up to 2 memory banks:
Bank 0: Address 0, size 2GB
Bank 1: Address0x100000000, size 124GB
- Add warm reset boot checking function, to use in patch [10] (Patch[9])
- Add ECC memory scrubbing support (Patch [10])
- Use cache enabled + "DC ZVA" instruction to clear memory to
zerosWhen working on this, would it make sense to move the S10 SDRAM driver
to DM, usingUCLASS_RAM, like I did for gen5 (see Marek's 'next' branch:
http://git.denx.de/?p=u-boot/u-boot-socfpga.git;a=commit;h=4796a7d5a7fd965c02cf290edec17acb2c9af766)
Quoted 3 lines
Quoted 2 lines
That might allow us to combine more of the code in mach-socfpga again in the future...
Sure, I will look into this. But will be in separate series.
Yes, it's a separate issue. It just came to mind when reading this series.
Regards,
Simon
Quoted 38 lines
Thanks.
Regards
Ley FoonQuoted 33 lines
Regards,
SimonQuoted 29 lines
Ley Foon Tan (10):
ddr: altera: stratix10: Move SDRAM size check to SDRAM driver
arm: socfpga: Addsdram_s10.htosdram.h
ddr: altera: s10: Add multiple memory banks support
arm: socfpga: Updatedram_init_banksize()for Stratix10
board: altera: Stratix10: Addboard_get_usable_ram_top()
board: altera: Stratix10: Addft_board_setup()
arm: socfpga: EnableOF_BOARD_SETUPfor Stratix 10
configs: stratix10: ChangeCONFIG_NR_DRAM_BANKSto 2
arm: socfpga: stratix10: Addcpu_has_been_warmreset()
ddr: altera: Stratix10: Add ECC memory scrubbingarch/arm/mach-socfpga/Kconfig | 1 + arch/arm/mach-socfpga/board.c | 16 +- .../include/mach/reset_manager_s10.h | 3 + arch/arm/mach-socfpga/include/mach/sdram.h | 2 + .../arm/mach-socfpga/include/mach/sdram_s10.h | 10 + arch/arm/mach-socfpga/reset_manager_s10.c | 9 + arch/arm/mach-socfpga/spl_s10.c | 11 -- board/altera/stratix10-socdk/socfpga.c | 37 ++++ configs/socfpga_stratix10_defconfig | 2 +- drivers/ddr/altera/sdram_s10.c | 178 ++++++++++++++++++ 10 files changed, 256 insertions(+), 13 deletions(-)--
2.19.0