public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Brian Sune <briansune@gmail.com>
To: Chee Tien Fong <tienfong.chee@altera.com>,
	Tom Rini <trini@konsulko.com>,
	u-boot@lists.denx.de
Subject: [PATCH v1 3/3] sync sdram ecc support to mainstream
Date: Tue, 16 Dec 2025 04:27:12 +0800	[thread overview]
Message-ID: <20251215202712.175-3-briansune@gmail.com> (raw)
In-Reply-To: <20251215202712.175-1-briansune@gmail.com>

It 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.

Signed-off-by: Brian Sune <briansune@gmail.com>
---
 drivers/ddr/altera/sdram_gen5.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/ddr/altera/sdram_gen5.c b/drivers/ddr/altera/sdram_gen5.c
index 3c79bb11802..07d8087fc7e 100644
--- a/drivers/ddr/altera/sdram_gen5.c
+++ b/drivers/ddr/altera/sdram_gen5.c
@@ -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;
 
-- 
2.34.1


      parent reply	other threads:[~2025-12-15 20:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 20:27 [PATCH v1 1/3] sync sdram ecc support to mainstream Brian Sune
2025-12-15 20:27 ` [PATCH v1 2/3] " Brian Sune
2026-01-27  7:45   ` Chee, Tien Fong
2025-12-15 20:27 ` Brian Sune [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251215202712.175-3-briansune@gmail.com \
    --to=briansune@gmail.com \
    --cc=tienfong.chee@altera.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox