ram/aspeed: Re-init ECC if requested but not enabled
Joel Stanley
maintainerPATCH 1/1 ram/aspeed: Re-init ECC if requested but not enabled
If a machine has a new u-boot installed that enables ECC, but it has not had a power cycle since being updated, the DDR will not re-initalise and ECC will stay disabled.
Similarly for the reverse case, where ECC was enabled but a new u-boot disables it.
Detect if ECC has been requested by the firmware and check against the hardware state. If it does not match, and the DDR has already been initialised, proceed as if the DDR has not been set up.
Signed-off-by Joel Stanley <[email protected]>
---
This is untested on hardware, but attempts to solve a problem when upgrading firmware to enable ECC.
Aspeed, is it okay to re-init DRAM like this?
drivers/ram/aspeed/sdram_ast2600.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/ram/aspeed/sdram_ast2600.c +22 -2
@@ -891,6 +891,27 @@ static void ast2600_sdrammc_ecc_enable(struct dram_info *info, u32 conf_size_mb)writel (0 , ®s->intr_ctrl); } +static bool ast2600_sdrammc_init_required (struct udevice *dev) +{ +struct dram_info *priv =dev_get_priv (dev); +struct ast2600_sdrammc_regs *regs = priv->regs; +bool ecc_requested; +bool ecc_enabled; +bool dram_ready; + + ecc_requested =dev_read_bool (dev,"aspeed,ecc-enabled" ); + ecc_enabled =readl (®s->config) &SDRAM_CONF_ECC_SETUP ; + dram_ready =readl (priv->scu +AST_SCU_HANDSHAKE ) &SCU_SDRAM_INIT_READY_MASK ; + +if (!dram_ready) +return true; + +if (ecc_requested != ecc_enabled) +return true; + +return false; +} +static int ast2600_sdrammc_probe (struct udevice *dev) {struct dram_info *priv = (struct dram_info *)dev_get_priv (dev);
@@ -913,8 +934,7 @@ static int ast2600_sdrammc_probe(struct udevice *dev)return PTR_ERR (priv->scu); } - reg =readl (priv->scu +AST_SCU_HANDSHAKE ); -if (reg &SCU_SDRAM_INIT_READY_MASK ) { +if (ast2600_sdrammc_init_required (dev)) {printf ("already initialized, " );setbits_le32 (priv->scu +AST_SCU_HANDSHAKE ,SCU_HANDSHAKE_MASK );ast2600_sdrammc_update_size (priv);
Signature · 1 line
2.35.1