sync sdram ecc support to mainstream
PATCH 1/3 sync sdram ecc support to mainstream
It is been a while that the DDR ECC is missing.
Pull from Altera trunk and sync to mainstream.
--- drivers/ddr/altera/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ddr/altera/Makefile +2 -2
@@ -7,8 +7,8 @@ # Copyright (C) 2014-2025 Altera Corporation <www.altera.com> ifdef CONFIG_$(PHASE_)ALTERA_SDRAM -obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram_gen5.o sequencer.o -obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += sdram_arria10.o +obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram_soc32.o sdram_gen5.o sequencer.o +obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += sdram_soc32.o sdram_arria10.o obj-$(CONFIG_TARGET_SOCFPGA_STRATIX10) += sdram_soc64.o sdram_s10.o obj-$(CONFIG_TARGET_SOCFPGA_AGILEX) += sdram_soc64.o sdram_agilex.o obj-$(CONFIG_TARGET_SOCFPGA_N5X) += sdram_soc64.o sdram_n5x.o
Signature · 1 line
2.34.1
PATCH 2/3 sync sdram ecc support to mainstream
It is been a while that the DDR ECC is missing.
Pull from Altera trunk and sync to mainstream.
This sdram_soc32 introduce the ecc setup.
Modifications are done to support dts memory@0
while old memory will work properly on gd->bd
Real ECC supported board test is required.
--- drivers/ddr/altera/sdram_soc32.c | 71 ++++++++++++++++++++++++++++++++ drivers/ddr/altera/sdram_soc32.h | 11 +++++ 2 files changed, 82 insertions(+) create mode 100644 drivers/ddr/altera/sdram_soc32.c create mode 100644 drivers/ddr/altera/sdram_soc32.h
drivers/ddr/altera/sdram_soc32.c new file +71 -0
@@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020 Intel Corporation <www.intel.com> +*/ + +#include <cpu_func.h> +#include <dm.h> +#include <asm/system.h> +#include <linux/sizes.h> +#include "sdram_soc32.h" +#include <watchdog.h> +#include <wait_bit.h> +#if !defined(CONFIG_HW_WATCHDOG ) +#include <asm/arch/reset_manager.h> +#endif + +#define PGTABLE_OFF 0x4000 + +/* Initialize SDRAM ECC bits to avoid false DBE */ +void sdram_init_ecc_bits (unsigned long long sdram_size) +{ +u32 start; +phys_addr_t start_addr; +phys_size_t size, size_init; + + start =get_timer (0 ); + + start_addr =0 ; + size = sdram_size; + +printf ("DDRCAL: Scrubbing ECC RAM (%ld MiB).\n" , size >>20 ); + +memset ((void *)start_addr,0 ,PGTABLE_SIZE +PGTABLE_OFF ); + start_addr +=PGTABLE_SIZE +PGTABLE_OFF ; + size -=PGTABLE_OFF +PGTABLE_SIZE ; + +dcache_enable (); + +while (size >0 ) { + size_init =min ((phys_addr_t )SZ_1G , (phys_addr_t )size); +memset ((void *)start_addr,0 , size_init); + size -= size_init; + start_addr += size_init; + +debug ("%s: %d\n" , __func__, __LINE__); + +#ifdef CONFIG_HW_WATCHDOG +/* +* In case the watchdog is enabled, +* make sure to (re-)configure watchdog +* so that the defined timeout is valid. +*/ +hw_watchdog_init (); +#else +/* +* If the HW watchdog is NOT enabled, +* make sure it is not running, because +* it is enabled in the preloader and +* causing boot loop if is not handled. +*/ +socfpga_per_reset (SOCFPGA_RESET (L4WD0 ),1 ); +socfpga_per_reset (SOCFPGA_RESET (L4WD0 ),0 ); +#endif + } + +dcache_disable (); + +printf ("DDRCAL: SDRAM-ECC initialized success with %d ms\n" , + (u32 )get_timer (start)); +} +
drivers/ddr/altera/sdram_soc32.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020 Intel Corporation <www.intel.com> +*/ + +#ifndef _SDRAM_SOC32_H_ +#define _SDRAM_SOC32_H_ + +void sdram_init_ecc_bits (unsigned long long sdram_size); + +#endif /* _SDRAM_SOC32_H_ */
Signature · 1 line
2.34.1
Hi Brian,
Quoted 9 lines · Brian Sune
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
It is been a while that the DDR ECC is missing. Pull from Altera trunk and sync to mainstream. This
sdram_soc32introduce the ecc setup. Modifications are done to support dts memory@0 while old memory will work properly ongd->bdReal ECC supported board test is required.
Quoted 7 lines
Signed-off-by Brian Sune <[email protected]>--- drivers/ddr/altera/sdram_soc32.c | 71 ++++++++++++++++++++++++++++++++ drivers/ddr/altera/sdram_soc32.h | 11 +++++ 2 files changed, 82 insertions(+)create mode 100644
drivers/ddr/altera/sdram_soc32.ccreate mode 100644drivers/ddr/altera/sdram_soc32.h
Thanks for working on this series patches.
This is covered by Alif’s more complete submission, so I’ll mark yours as superseded:
https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
If you spot gaps in Alif’s version, please add review comments or a follow-up patch.
Best regards,
Tien Fong
PATCH 3/3 sync sdram ecc support to mainstream
In reply to Brian SuneIt is been a while that the DDR ECC is missing. Pull from Altera trunk and sync to mainstream. Modifications are done to check ECC is on and only add necessary ECC code to SDRAM driver.
--- drivers/ddr/altera/sdram_gen5.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/ddr/altera/sdram_gen5.c +15 -0
@@ -19,6 +19,7 @@#include <dm/device_compat.h> #include "sequencer.h" +#include "sdram_soc32.h" #ifdef CONFIG_XPL_BUILD
@@ -562,6 +563,12 @@ static unsigned long sdram_calculate_size(struct socfpga_sdr_ctrl *sdr_ctrl)return temp; } +static int sdram_is_ecc_enabled (struct socfpga_sdr_ctrl *sdr_ctrl) +{ +return !!(readl (&sdr_ctrl->ctrl_cfg) & +SDR_CTRLGRP_CTRLCFG_ECCEN_MASK ); +} +static int altera_gen5_sdram_of_to_plat (struct udevice *dev) {struct altera_gen5_sdram_plat *plat =dev_get_plat (dev);
@@ -610,6 +617,14 @@ static int altera_gen5_sdram_probe(struct udevice *dev) goto failed; } +if (sdram_is_ecc_enabled (sdr_ctrl)) { +printf ("DDR: ECC is enabled\n" ); +/* Must set USEECCASDATA to 0 if ECC is enabled */ +clrbits_le32 (&sdr_ctrl->static_cfg, +SDR_CTRLGRP_STATICCFG_USEECCASDATA_MASK ); +sdram_init_ecc_bits (sdram_size); + } + priv->info.base =0 ; priv->info.size = sdram_size;
Signature · 1 line
2.34.1