{"id":2229290,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229290/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260428033230.7777-4-alif.zakuan.yuslaimi@altera.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.1/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260428033230.7777-4-alif.zakuan.yuslaimi@altera.com>","date":"2026-04-28T03:32:30","name":"[v2,3/3] ddr: socfpga: Add ECC DRAM scrubbing support for Gen5/Arria10","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0b51adc0ec2941fce49c58752fbb88fb25d93001","submitter":{"id":90458,"url":"http://patchwork.ozlabs.org/api/1.1/people/90458/?format=json","name":"YUSLAIMI, ALIF ZAKUAN","email":"alif.zakuan.yuslaimi@altera.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260428033230.7777-4-alif.zakuan.yuslaimi@altera.com/mbox/","series":[{"id":501756,"url":"http://patchwork.ozlabs.org/api/1.1/series/501756/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=501756","date":"2026-04-28T03:32:27","name":"SoCFPGA: Update DDR Support for Gen5/Arria10 in U-Boot","version":2,"mbox":"http://patchwork.ozlabs.org/series/501756/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229290/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229290/checks/","tags":{},"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=altera.com header.i=@altera.com header.a=rsa-sha256\n header.s=selector2 header.b=htJn5S7n;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=pass (p=reject dis=none) header.from=altera.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=altera.com header.i=@altera.com header.b=\"htJn5S7n\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=reject dis=none) header.from=altera.com","phobos.denx.de;\n spf=pass smtp.mailfrom=alif.zakuan.yuslaimi@altera.com","dkim=none (message not signed)\n header.d=none;dmarc=none action=none header.from=altera.com;"],"Received":["from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4QyK6YM5z1yHv\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 13:33:45 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 0688284394;\n\tTue, 28 Apr 2026 05:32:47 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id 50FBA84355; Tue, 28 Apr 2026 05:32:45 +0200 (CEST)","from MW6PR02CU001.outbound.protection.outlook.com\n (mail-westus2azlp170120002.outbound.protection.outlook.com\n [IPv6:2a01:111:f403:c007::2])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id DEA5884383\n for <u-boot@lists.denx.de>; Tue, 28 Apr 2026 05:32:41 +0200 (CEST)","from PH7PR03MB7063.namprd03.prod.outlook.com (2603:10b6:510:2a4::6)\n by BN9PR03MB5996.namprd03.prod.outlook.com (2603:10b6:408:135::10)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.36; Tue, 28 Apr\n 2026 03:32:38 +0000","from PH7PR03MB7063.namprd03.prod.outlook.com\n ([fe80::f6cf:4203:1cbc:cd21]) by PH7PR03MB7063.namprd03.prod.outlook.com\n ([fe80::f6cf:4203:1cbc:cd21%4]) with mapi id 15.20.9846.021; Tue, 28 Apr 2026\n 03:32:38 +0000"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,\n SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2","ARC-Seal":"i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=WvySJuDECq533RC5cTjd/MkdzraVwE0+dagmkn3PbBcNFc8s4jWaA4o3Yva1/KPe4PJDkpleZ3cRay3xUdCtNVTOx8p/DsLm3z/vaD5DOFKlLvXepBJAg+freG4yEO0rcvoGiNRD43EYA9mTMz6R54emoVt8I6jLxmpIgg6+uDAjmrQN76Isu2wJxI59P2Atwn5S+RtNwnikR0fE20MJpIFLpf+ZOxbLznPns80Z0P8xOadg2jEKD4HErwT+Vt6g4VQNiWAGcaXfnufFURe2KdxtOXqDRYdJMTOmwYGqgDE2BrW85I7pD7KVycOjrsbaEWJCT7nW6YCUiPXNe5aFzQ==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=Z1ZQFGzlDDqlTG4AnQ8uYpkAoDVyZ3IzTYd93LOWaFM=;\n b=gG6bYGFeu2ayVbRH92Qx6sJHBBtlVXUltj/qGhUrj04uUHJGZNNhWTUHwgrJDFo8w33ZaN979psZ/ogwoF0GFmxXy+znC8nVVI0UpHv4Cuyhzt6vaDr/sLMbWYpKYII+k6amB/vDsk3IvfadbXCY+MU/wmXnW/FAEVQ75RnEDc5GWd/Zq+O8cuebAzuyokWq+SW2aPkCF+xeZL3OCjRyarc/+jVOSetlizJVUMK8Qpe+UdfO0vH6jyf0/X+c/U+ZhlDKMw3NvhhfeFabHLbGfL/3AduGWvl9Rj542S+FT94Go2F5hPDP/oaFKRFL/xZo+ap3YuPMXdW5onMtN6MiyA==","ARC-Authentication-Results":"i=1; mx.microsoft.com 1; spf=pass\n smtp.mailfrom=altera.com; dmarc=pass action=none header.from=altera.com;\n dkim=pass header.d=altera.com; arc=none","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=altera.com;\n s=selector2;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=Z1ZQFGzlDDqlTG4AnQ8uYpkAoDVyZ3IzTYd93LOWaFM=;\n b=htJn5S7n5HKbg7itZ83jh/qsTaJ1y7eVd19Z+feP0iMhiH5JOBUbPgf0V6JaXSouEWKmwUq8MyIPQMHy836ZCkXDeBm3l+n0VtvGD1a37pRAQRJn1agBNKcHITSXDgrCW8TwVfgBG+hdUD6SylSTLNRr9WSAONwv8dWe/MyekaxpSqE4KX1JThfItvLsgtQAcGpmh4WhKVZXiKTdK3O+8X/bdVCFrcCz09qKiDqBn1MDfCi42LBXC7/9vzLaYSjmDEDk1N+rEJGbwbhaWzw+ZjA0MhChApp0rnRSykCno9ZOIsrh2+W5e2e7qLyglubnPsVSem9kFAg+P9Wh+JSmzg==","From":"alif.zakuan.yuslaimi@altera.com","To":"u-boot@lists.denx.de","Cc":"Marek Vasut <marex@denx.de>,\n Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>,\n Tien Fong Chee <tien.fong.chee@altera.com>, Tom Rini <trini@konsulko.com>,\n Brian Sune <briansune@gmail.com>, Yao Zi <me@ziyao.cc>,\n Patrice Chotard <patrice.chotard@foss.st.com>, Peng Fan <peng.fan@nxp.com>,\n Simon Glass <sjg@chromium.org>,\n Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com>","Subject":"[PATCH v2 3/3] ddr: socfpga: Add ECC DRAM scrubbing support for\n Gen5/Arria10","Date":"Mon, 27 Apr 2026 20:32:30 -0700","Message-ID":"<20260428033230.7777-4-alif.zakuan.yuslaimi@altera.com>","X-Mailer":"git-send-email 2.43.7","In-Reply-To":"<20260428033230.7777-1-alif.zakuan.yuslaimi@altera.com>","References":"<20260428033230.7777-1-alif.zakuan.yuslaimi@altera.com>","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain","X-ClientProxiedBy":"SJ0PR03CA0039.namprd03.prod.outlook.com\n (2603:10b6:a03:33e::14) To PH7PR03MB7063.namprd03.prod.outlook.com\n (2603:10b6:510:2a4::6)","MIME-Version":"1.0","X-MS-PublicTrafficType":"Email","X-MS-TrafficTypeDiagnostic":"PH7PR03MB7063:EE_|BN9PR03MB5996:EE_","X-MS-Office365-Filtering-Correlation-Id":"efd666dc-a647-4e67-91ba-08dea4d6cbc3","X-MS-Exchange-AtpMessageProperties":"SA","X-MS-Exchange-SenderADCheck":"1","X-MS-Exchange-AntiSpam-Relay":"0","X-Microsoft-Antispam":"BCL:0;\n ARA:13230040|366016|376014|1800799024|55112099003|13003099007|22082099003|56012099003|18002099003;","X-Microsoft-Antispam-Message-Info":"\n 7kCNpV8ygiLkQg/1sF9NRzL3UbJKSR0dgRyuGDWvHC6qtYA6/E31UVw2tLwZwdOVWl2Jz2WXWgoZ+dbO359rsHxpmDw3FuK7CjRD2xigyDgwSO80g+M9Gdh5BaNYYxfrDK6mglwl+xWTeF5Y7lfYZVNHy0Ur1tiKDa0HOGa4/TMFmhIanrrJoUenzQ6LxZg8yyIoMWIibnWtK8hiOicLB84HPPE2kb2f0OXuTLG/quAy1r+loDKQB55//yGV44E3lSq22gW7H22g1yXDKz8cH2CxGlZ1YFWibTOrgQh9yaVoT1yaNDL3gbIWjZAGDUy8adZ9w1lpQysRaVBPOlctFlYqZUiiwQ/Bry0t6e6i/JBp+acIezeyXccrq+gRdkJsU4gd43//VXg81FA3R9+3zTATdteGfQZ1NEIf9eF6h4rPZnl6+P9e8K0vQKdl+3VxOcXO9LfLHj4E53eGKtO4DQLZ6RIIyOzbRFflCUS4Ax/M9hnRbEuF6ExjlyeKjpQRJMP99hChKnclh/Jahw75Fm8sTvFbpx/dDihHa+5N5XLHRoAlXDp6glW8rmoJkfm3xavnP6+RFYKF9N2NLgUFtWJ+YhvozNzFqWgT48Q9zYQ/D55kzbC5ZlSoBMIODJsJhgibe1Ah52V4P7TyE4YUOgUZ4Tf8mjuFMh2OFF+Ea9yatAPuLqmaqyRrK6cw9A9M","X-Forefront-Antispam-Report":"CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n IPV:NLI; SFV:NSPM; H:PH7PR03MB7063.namprd03.prod.outlook.com; PTR:; CAT:NONE;\n SFS:(13230040)(366016)(376014)(1800799024)(55112099003)(13003099007)(22082099003)(56012099003)(18002099003);\n DIR:OUT; SFP:1101;","X-MS-Exchange-AntiSpam-MessageData-ChunkCount":"1","X-MS-Exchange-AntiSpam-MessageData-0":"\n doaQmogo2bXQZ9pVSpAP3vtcKruhAJnbbqErOrsRwLfw1/XLKDWQO+gW+7xRM6A1BqPWPC+5+VDSwTIbHP3ajzSavMYiWX+MPJDo6ION7VRXR4Eq/dTIJlCAPO6XVgoBHHApsgdPat+EpU6RXkxq6DVFszfs6xcQqaCcxgXBH9LKapSE2eXgonK9A9/JEg9Hyd+PV/W3l1oVvv+iEpYrt621Q8r+mrUGdxNWhzA33AyIPAiLcPv24SLZ4Hv9vcbFwSvBAPooOH51Fy4I7ITiE/49UOPKD/mJ1bDmR95YoPHWsHu81Yj24TnAIdQRwaCegeszVrlJYofmNhxaq7T+1Phw7cFar5HHoFki+ysGFH5OwmJU5VIr5IK8DrMC5fheARixnzToF8oqkIHHMZMQEyJkG1yiazx/y+hdOpbE+fIGimjRNus27g08N20nUgVR9yC3gIPdHymsUlK5UYzmscb7aXQDc6E1AqOakraBS9POLV8K7UI7IdfNMkEahkq69i90iAglRIChSpnad9r/JDWbqqR85LP6bj6EpFS0Ederg2m5e/0MgORMiVz7hkfvW4sBETcb7zCddh+jOiS0DyPG6OBoGSjZDJKGwV+moIjTtiY0YRhR1f/3ET59uTiA/pO/JbQtHnKzldK0MkM02XDDuPhwvWq1lTTkI+6YbTst5UhTimSxWTkYaNNJBDgi8eIz4ZstyEZ0SWZwn0vEtPDuyRu1ZzstIoVhAQjIjHpiAXO4I9StS/lWGf0b3MRfF5tRMYDOc15uz9nlZGZ2bSY207q1zYoxWMzI/KN7172HC5JPeMFVbl4jHSC+t2iNIrvQLdjC9ydAzJxtQp/YPJU6nUDNqaM/+NuHSzqrz6NB5Lz4sasODpiZmNsLzo/KvfbNX+wDMtZwWcydREmidLQ7GP3LiXjtJ7gGtMHgv9x8jSKE/j8ZoUiijkCpQZZgibKlZgOuBgF9o+qO8X3DQvuayyor00J/gpKzjSS8uYTvO4DS33uV7xRXSs3icZbOcL2dZXCVFLHyE97g2Ld7jCnGCj882qRxU6W/3P7NKlRgn7AqAN2iciUFkQU3Yp+d1vjhqOzPXRGFW1HgQstZMWmrY29cXJLniZ6FL6OYwLTEC9m5UHZTdPwL3O1oXNTtopYOypSPHJPQWVz1WzIoMm7FxCjjMWLq+ZPOPNkJg/TUmCsoYoh/CJn/zi3Ug4CBMvH8vqD2J/Kt3RJ9XfIYIdkB7ziSmtCIY9+QduOQp4S40dfCEFrVjwj6FbXxWVTXrCbZtyHUFL9I+I4MLuloQhqf3RQyCJT+JCdSX7siruFi2EpSTVSdV2P92UAcvxY4R2YUae2ZFpawR0PXUzu0n0eZG4hWWlZnhDMBuVERudaTOsP5Ixi1UsSNnrbndsHnXHnmBJefjol1hBt0qqfW94Wo3bLcYZ/aieMiQm1A8+slyqKRRYdo2nQhGv19GS/hW25rB4M+uem7PaxZ/CuEPFR2cj6sHNCar+aGC+aHOrBYLC2VJI3ppT37trSClwqSiV65HgG2k+Mb6bFgPsOCQ0pCZyTZ/jdUPRuONclm7uEflSAZPs1iCLdJ6SROBT2sY9QSEVaJ5kZrKI+33KHIW7yJiHpRu2le4iV9MsITQFA5fyoLYQisWCznltyAiHZpQAo+RG4Xy2Jb4lfB9Sg5WG8lQDwyv/O1iKiPGQMYaMAsmIpM0BApFXqUILEw2KlCMiH2F4Aseg0Iex+f72xIpzqEK/i6R8WS+rqSlYzjEq4=","X-OriginatorOrg":"altera.com","X-MS-Exchange-CrossTenant-Network-Message-Id":"\n efd666dc-a647-4e67-91ba-08dea4d6cbc3","X-MS-Exchange-CrossTenant-AuthSource":"PH7PR03MB7063.namprd03.prod.outlook.com","X-MS-Exchange-CrossTenant-AuthAs":"Internal","X-MS-Exchange-CrossTenant-OriginalArrivalTime":"28 Apr 2026 03:32:38.3744 (UTC)","X-MS-Exchange-CrossTenant-FromEntityHeader":"Hosted","X-MS-Exchange-CrossTenant-Id":"fbd72e03-d4a5-4110-adce-614d51f2077a","X-MS-Exchange-CrossTenant-MailboxType":"HOSTED","X-MS-Exchange-CrossTenant-UserPrincipalName":"\n 3ruDIrAAX5UR9DKppPdpNVjZT6IOxwBDPEPNbI02ZyWHzbx1GBTLSEujpeusufnER01IEn1VwRsm7e7RkLEgUBt5G3Coj9NmIi8IxPP1hj4=","X-MS-Exchange-Transport-CrossTenantHeadersStamped":"BN9PR03MB5996","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"From: Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com>\n\nThe SDRAM must first be rewritten by zeroes if ECC is used to initialize\nthe ECC metadata. Make the CPU overwrite the DRAM with zeroes in such a\ncase.\n\nThis implementation turns the caches on temporarily, then overwrites the\nwhole RAM with zeroes, flushes the caches and turns them off again.\nThis provides satisfactory performance.\n\nMove common code sdram_init_ecc_bits() to new common file sdram_soc32.c.\nPreparation for Gen5 uses the same memory initialization function as\nArria10.\n\nNew Kconfig is introduced to enable this implementation only on the default\nArria10 and CycloneV boards as this will increase the SPL size which\nwill exceed some Gen5 devices' SPL size limit.\n\nSigned-off-by: Tien Fong Chee <tien.fong.chee@altera.com>\nSigned-off-by: Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com>\n---\n arch/arm/mach-socfpga/Kconfig      | 13 ++++-\n arch/arm/mach-socfpga/spl_a10.c    |  4 ++\n arch/arm/mach-socfpga/spl_gen5.c   | 17 ++++++\n drivers/ddr/altera/Makefile        |  4 +-\n drivers/ddr/altera/sdram_arria10.c | 34 +++++-------\n drivers/ddr/altera/sdram_gen5.c    | 41 ++++++++++++--\n drivers/ddr/altera/sdram_soc32.c   | 85 ++++++++++++++++++++++++++++++\n drivers/ddr/altera/sdram_soc32.h   | 15 ++++++\n 8 files changed, 187 insertions(+), 26 deletions(-)\n create mode 100644 drivers/ddr/altera/sdram_soc32.c\n create mode 100644 drivers/ddr/altera/sdram_soc32.h","diff":"diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig\nindex 830585a72cc..dd71691b724 100644\n--- a/arch/arm/mach-socfpga/Kconfig\n+++ b/arch/arm/mach-socfpga/Kconfig\n@@ -6,6 +6,13 @@ config ERR_PTR_OFFSET\n config NR_DRAM_BANKS\n \tdefault 1\n \n+config SOCFPGA_ECC_SUPPORT\n+\tbool \"Enable ECC support for DRAM\"\n+\thelp\n+\t Adds CPU-based ECC support for DRAM at boot. This will initialize\n+\t all DRAM ECC metadata to zero, preventing false ECC errors and\n+\t improving reliability.\n+\n config SOCFPGA_DRAM_SIZE_CHECK\n \tbool \"Enable DRAM size checking for safety\"\n \thelp\n@@ -105,6 +112,7 @@ config ARCH_SOCFPGA_ARRIA10\n \tselect ETH_DESIGNWARE_SOCFPGA\n \timply FPGA_SOCFPGA\n \timply SPL_USE_TINY_PRINTF\n+\tselect SOCFPGA_ECC_SUPPORT\n \n config SOCFPGA_ARRIA10_ALWAYS_REPROGRAM\n \tbool \"Always reprogram Arria 10 FPGA\"\n@@ -117,6 +125,9 @@ config SOCFPGA_ARRIA10_ALWAYS_REPROGRAM\n config ARCH_SOCFPGA_CYCLONE5\n \tbool\n \tselect ARCH_SOCFPGA_GEN5\n+\tselect SOCFPGA_ECC_SUPPORT if \\\n+\t  !TARGET_SOCFPGA_TERASIC_SOCKIT && !TARGET_SOCFPGA_EBV_SOCRATES \\\n+\t  && !TARGET_SOCFPGA_SOFTING_VINING_FPGA\n \tselect SOCFPGA_DRAM_SIZE_CHECK if !TARGET_SOCFPGA_TERASIC_SOCKIT \\\n \t  && !TARGET_SOCFPGA_EBV_SOCRATES && \\\n \t  !TARGET_SOCFPGA_SOFTING_VINING_FPGA\n@@ -124,7 +135,7 @@ config ARCH_SOCFPGA_CYCLONE5\n config ARCH_SOCFPGA_GEN5\n \tbool\n \tselect SPL_ALTERA_SDRAM\n-\tselect SPL_CACHE if SPL\n+\tselect SPL_CACHE if SPL && SOCFPGA_ECC_SUPPORT\n \timply FPGA_SOCFPGA\n \timply SPL_SIZE_LIMIT_SUBTRACT_GD\n \timply SPL_SIZE_LIMIT_SUBTRACT_MALLOC\ndiff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c\nindex c20376f7f8e..4d0696bbaf6 100644\n--- a/arch/arm/mach-socfpga/spl_a10.c\n+++ b/arch/arm/mach-socfpga/spl_a10.c\n@@ -25,6 +25,7 @@\n #include <asm/sections.h>\n #include <fdtdec.h>\n #include <watchdog.h>\n+#include <wdt.h>\n #include <asm/arch/pinmux.h>\n #include <asm/arch/fpga_manager.h>\n #include <mmc.h>\n@@ -265,6 +266,9 @@ void board_init_f(ulong dummy)\n \t/* Configure the clock based on handoff */\n \tcm_basic_init(gd->fdt_blob);\n \n+\tif (CONFIG_IS_ENABLED(WDT))\n+\t\tinitr_watchdog();\n+\n #ifdef CONFIG_HW_WATCHDOG\n \t/* release osc1 watchdog timer 0 from reset */\n \tsocfpga_reset_deassert_osc1wd0();\ndiff --git a/arch/arm/mach-socfpga/spl_gen5.c b/arch/arm/mach-socfpga/spl_gen5.c\nindex 08b756db2ca..530863b1564 100644\n--- a/arch/arm/mach-socfpga/spl_gen5.c\n+++ b/arch/arm/mach-socfpga/spl_gen5.c\n@@ -6,6 +6,7 @@\n #include <hang.h>\n #include <init.h>\n #include <log.h>\n+#include <asm/global_data.h>\n #include <asm/io.h>\n #include <asm/utils.h>\n #include <image.h>\n@@ -21,9 +22,17 @@\n #include <debug_uart.h>\n #include <fdtdec.h>\n #include <watchdog.h>\n+#include <wdt.h>\n #include <dm/uclass.h>\n #include <linux/bitops.h>\n \n+DECLARE_GLOBAL_DATA_PTR;\n+\n+#if IS_ENABLED(CONFIG_SOCFPGA_ECC_SUPPORT) || \\\n+\tIS_ENABLED(CONFIG_SOCFPGA_DRAM_SIZE_CHECK)\n+static struct bd_info bdata __attribute__ ((section(\".data\")));\n+#endif\n+\n u32 spl_boot_device(void)\n {\n \tconst u32 bsel = readl(socfpga_get_sysmgr_addr() +\n@@ -106,6 +115,9 @@ void board_init_f(ulong dummy)\n \tif (cm_basic_init(cm_default_cfg))\n \t\thang();\n \n+\tif (CONFIG_IS_ENABLED(WDT))\n+\t\tinitr_watchdog();\n+\n \t/* Enable bootrom to configure IOs. */\n \tsysmgr_config_warmrstcfgio(1);\n \n@@ -143,6 +155,11 @@ void board_init_f(ulong dummy)\n \t/* enable console uart printing */\n \tpreloader_console_init();\n \n+#if IS_ENABLED(CONFIG_SOCFPGA_ECC_SUPPORT) || \\\n+\tIS_ENABLED(CONFIG_SOCFPGA_DRAM_SIZE_CHECK)\n+\tgd->bd = &bdata;\n+#endif\n+\n \tret = uclass_get_device(UCLASS_RAM, 0, &dev);\n \tif (ret) {\n \t\tdebug(\"DRAM init failed: %d\\n\", ret);\ndiff --git a/drivers/ddr/altera/Makefile b/drivers/ddr/altera/Makefile\nindex 8259ab04a7e..ece6a131897 100644\n--- a/drivers/ddr/altera/Makefile\n+++ b/drivers/ddr/altera/Makefile\n@@ -7,8 +7,8 @@\n # Copyright (C) 2014-2025 Altera Corporation <www.altera.com>\n \n ifdef CONFIG_$(PHASE_)ALTERA_SDRAM\n-obj-$(CONFIG_ARCH_SOCFPGA_GEN5) += sdram_gen5.o sequencer.o\n-obj-$(CONFIG_ARCH_SOCFPGA_ARRIA10) += sdram_arria10.o\n+obj-$(CONFIG_ARCH_SOCFPGA_GEN5) += sdram_soc32.o sdram_gen5.o sequencer.o\n+obj-$(CONFIG_ARCH_SOCFPGA_ARRIA10) += sdram_soc32.o sdram_arria10.o\n obj-$(CONFIG_ARCH_SOCFPGA_STRATIX10) += sdram_soc64.o sdram_s10.o\n obj-$(CONFIG_ARCH_SOCFPGA_AGILEX) += sdram_soc64.o sdram_agilex.o\n obj-$(CONFIG_ARCH_SOCFPGA_N5X) += sdram_soc64.o sdram_n5x.o\ndiff --git a/drivers/ddr/altera/sdram_arria10.c b/drivers/ddr/altera/sdram_arria10.c\nindex c281f711fdf..09d3526603e 100644\n--- a/drivers/ddr/altera/sdram_arria10.c\n+++ b/drivers/ddr/altera/sdram_arria10.c\n@@ -22,9 +22,13 @@\n #include <linux/bitops.h>\n #include <linux/delay.h>\n #include <linux/kernel.h>\n+#include <linux/sizes.h>\n+#include \"sdram_soc32.h\"\n \n DECLARE_GLOBAL_DATA_PTR;\n \n+#define PGTABLE_OFF\t0x4000\n+\n static void sdram_mmr_init(void);\n static u64 sdram_size_calc(void);\n \n@@ -193,24 +197,6 @@ static int sdram_is_ecc_enabled(void)\n \t\t  ALT_ECC_HMC_OCP_ECCCTL_ECC_EN_SET_MSK);\n }\n \n-/* Initialize SDRAM ECC bits to avoid false DBE */\n-static void sdram_init_ecc_bits(u32 size)\n-{\n-\ticache_enable();\n-\n-\tmemset(0, 0, 0x8000);\n-\tgd->arch.tlb_addr = 0x4000;\n-\tgd->arch.tlb_size = PGTABLE_SIZE;\n-\n-\tdcache_enable();\n-\n-\tprintf(\"DDRCAL: Scrubbing ECC RAM (%i MiB).\\n\", size >> 20);\n-\tmemset((void *)0x8000, 0, size - 0x8000);\n-\tflush_dcache_all();\n-\tprintf(\"DDRCAL: Scrubbing ECC RAM done.\\n\");\n-\tdcache_disable();\n-}\n-\n /* Function to startup the SDRAM*/\n static int sdram_startup(void)\n {\n@@ -735,8 +721,16 @@ int ddr_calibration_sequence(void)\n \tif (of_sdram_firewall_setup(gd->fdt_blob))\n \t\tputs(\"FW: Error Configuring Firewall\\n\");\n \n-\tif (sdram_is_ecc_enabled())\n-\t\tsdram_init_ecc_bits(gd->ram_size);\n+\tif (sdram_is_ecc_enabled()) {\n+#if IS_ENABLED(CONFIG_SOCFPGA_ECC_SUPPORT)\n+\t\tsdram_init_ecc_bits();\n+\t}\n+#else\n+\t\tputs(\"DDR: Enable CONFIG_SOCFPGA_ECC_SUPPORT when SDRAM \");\n+\t\tputs(\"ECC is enabled.\\n\");\n+\t\thang();\n+\t}\n+#endif\n \n \tsdram_size_check();\n \ndiff --git a/drivers/ddr/altera/sdram_gen5.c b/drivers/ddr/altera/sdram_gen5.c\nindex 1c3c70ea8ae..76effb264e2 100644\n--- a/drivers/ddr/altera/sdram_gen5.c\n+++ b/drivers/ddr/altera/sdram_gen5.c\n@@ -2,6 +2,7 @@\n /*\n  * Copyright Altera Corporation (C) 2014-2015\n  */\n+#include <cpu_func.h>\n #include <dm.h>\n #include <errno.h>\n #include <div64.h>\n@@ -19,8 +20,11 @@\n #include <asm/global_data.h>\n #include <asm/io.h>\n #include <dm/device_compat.h>\n-\n+#include <linux/sizes.h>\n #include \"sequencer.h\"\n+#include \"sdram_soc32.h\"\n+\n+#define PGTABLE_OFF\t0x4000\n \n #ifdef CONFIG_XPL_BUILD\n \n@@ -566,6 +570,19 @@ static unsigned long sdram_calculate_size(struct socfpga_sdr_ctrl *sdr_ctrl)\n \treturn temp;\n }\n \n+#if IS_ENABLED(CONFIG_SOCFPGA_ECC_SUPPORT)\n+static int sdram_is_ecc_enabled(struct socfpga_sdr_ctrl *sdr_ctrl)\n+{\n+\treturn !!(readl(&sdr_ctrl->ctrl_cfg) &\n+\t\t  SDR_CTRLGRP_CTRLCFG_ECCEN_MASK);\n+}\n+#else\n+static int sdram_is_ecc_enabled(struct socfpga_sdr_ctrl *sdr_ctrl)\n+{\n+    return 0;\n+}\n+#endif\n+\n static int altera_gen5_sdram_of_to_plat(struct udevice *dev)\n {\n \tstruct altera_gen5_sdram_plat *plat = dev_get_plat(dev);\n@@ -608,10 +625,13 @@ static int altera_gen5_sdram_probe(struct udevice *dev)\n \tsdram_size = sdram_calculate_size(sdr_ctrl);\n \tdebug(\"SDRAM: %ld MiB\\n\", sdram_size >> 20);\n \n-#if IS_ENABLED(CONFIG_SOCFPGA_DRAM_SIZE_CHECK)\n+#if IS_ENABLED(CONFIG_SOCFPGA_DRAM_SIZE_CHECK) || \\\n+    IS_ENABLED(CONFIG_SOCFPGA_ECC_SUPPORT)\n \t/* setup the dram info within bd */\n \tdram_init_banksize();\n+#endif\n \n+#if IS_ENABLED(CONFIG_SOCFPGA_DRAM_SIZE_CHECK)\n \tif (sdram_size != gd->bd->bi_dram[0].size) {\n \t\tprintf(\"DDR: Warning: DRAM size from device tree (%lu MiB)\\n\",\n \t\t       (ulong)(gd->bd->bi_dram[0].size >> 20));\n@@ -626,8 +646,23 @@ static int altera_gen5_sdram_probe(struct udevice *dev)\n \t}\n #endif\n \n+\tif (sdram_is_ecc_enabled(sdr_ctrl)) {\n+#if IS_ENABLED(CONFIG_SOCFPGA_ECC_SUPPORT)\n+\t\t/* Must set USEECCASDATA to 0 if ECC is enabled */\n+\t\tclrbits_le32(&sdr_ctrl->static_cfg,\n+\t\t\t     SDR_CTRLGRP_STATICCFG_USEECCASDATA_MASK);\n+\t\tsdram_init_ecc_bits();\n+#else\n+\t\tputs(\"DDR: Enable CONFIG_SOCFPGA_ECC_SUPPORT when SDRAM \");\n+\t\tputs(\"ECC is enabled.\\n\");\n+\t\tputs(\"DDR: Without scrub, false ECC errors may occur.\\n\");\n+\t\thang();\n+#endif\n+}\n+\n \t/* Sanity check ensure correct SDRAM size specified */\n-#if IS_ENABLED(CONFIG_SOCFPGA_DRAM_SIZE_CHECK)\n+#if IS_ENABLED(CONFIG_SOCFPGA_DRAM_SIZE_CHECK) || \\\n+    IS_ENABLED(CONFIG_SOCFPGA_ECC_SUPPORT)\n \tif (get_ram_size(0, gd->bd->bi_dram[0].size) !=\n \t    gd->bd->bi_dram[0].size) {\n #else\ndiff --git a/drivers/ddr/altera/sdram_soc32.c b/drivers/ddr/altera/sdram_soc32.c\nnew file mode 100644\nindex 00000000000..7556d4933f4\n--- /dev/null\n+++ b/drivers/ddr/altera/sdram_soc32.c\n@@ -0,0 +1,85 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/*\n+ * Copyright (C) 2026 Altera Corporation <www.altera.com>\n+ */\n+\n+#include \"sdram_soc32.h\"\n+#include <string.h>\n+#include <hang.h>\n+#include <linux/sizes.h>\n+#include <cpu_func.h>\n+#include <watchdog.h>\n+#include <wait_bit.h>\n+#include <asm/global_data.h>\n+#include <asm/system.h>\n+#if !defined(CONFIG_HW_WATCHDOG)\n+#include <asm/arch/reset_manager.h>\n+#endif\n+\n+DECLARE_GLOBAL_DATA_PTR;\n+\n+#define PGTABLE_OFF\t0x4000\n+#define PGTABLE_RESERVE (PGTABLE_OFF + PGTABLE_SIZE)\n+\n+#if IS_ENABLED(CONFIG_SOCFPGA_ECC_SUPPORT)\n+static void socfpga_prepare_watchdog_for_long_op(void)\n+{\n+#if !IS_ENABLED(CONFIG_WATCHDOG)\n+\t/*\n+\t * No DM watchdog support enabled. Previous boot stage may have left\n+\t * L4WD0 running, so stop it once before long DDR scrub operation.\n+\t */\n+\tsocfpga_per_reset(SOCFPGA_RESET(L4WD0), 1);\n+\tsocfpga_per_reset(SOCFPGA_RESET(L4WD0), 0);\n+#endif\n+}\n+\n+/* Initialize SDRAM ECC bits to avoid false DBE */\n+void sdram_init_ecc_bits(void)\n+{\n+\tu32 start;\n+\tphys_addr_t start_addr;\n+\tphys_size_t size, size_init;\n+\n+\tstart = get_timer(0);\n+\n+\tstart_addr = gd->bd->bi_dram[0].start;\n+\tsize = gd->bd->bi_dram[0].size;\n+\n+\tprintf(\"DDRCAL: Scrubbing ECC RAM (%lu MiB).\\n\",\n+\t       (ulong)(size >> 20));\n+\n+\tif (size <= PGTABLE_RESERVE) {\n+\t\tprintf(\"DDRCAL: Error: DRAM size %#llx smaller than scrub reserve %#x\\n\",\n+\t\t       (unsigned long long)size, PGTABLE_RESERVE);\n+\t\thang();\n+\t}\n+\n+\tmemset((void *)start_addr, 0, PGTABLE_RESERVE);\n+\tgd->arch.tlb_addr = start_addr + PGTABLE_OFF;\n+\tgd->arch.tlb_size = PGTABLE_SIZE;\n+\tstart_addr += PGTABLE_RESERVE;\n+\tsize -= PGTABLE_RESERVE;\n+\n+\tdcache_enable();\n+\n+\tsocfpga_prepare_watchdog_for_long_op();\n+\n+\twhile (size > 0) {\n+\t\tsize_init = min_t(phys_size_t, (phys_size_t)SZ_1G, size);\n+\t\tmemset((void *)start_addr, 0, size_init);\n+\t\tsize -= size_init;\n+\t\tstart_addr += size_init;\n+\n+#if IS_ENABLED(CONFIG_WATCHDOG)\n+\t\t/* Service DM watchdog cyclic callbacks */\n+\t\tschedule();\n+#endif\n+\t}\n+\n+\tdcache_disable();\n+\n+\tprintf(\"DDRCAL: SDRAM-ECC initialized success with %u ms\\n\",\n+\t       (u32)get_timer(start));\n+}\n+#endif\ndiff --git a/drivers/ddr/altera/sdram_soc32.h b/drivers/ddr/altera/sdram_soc32.h\nnew file mode 100644\nindex 00000000000..2cfc583b5f5\n--- /dev/null\n+++ b/drivers/ddr/altera/sdram_soc32.h\n@@ -0,0 +1,15 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/*\n+ * Copyright (C) 2026 Altera Corporation <www.altera.com>\n+ */\n+\n+#ifndef\t_SDRAM_SOC32_H_\n+#define\t_SDRAM_SOC32_H_\n+\n+#if IS_ENABLED(CONFIG_SOCFPGA_ECC_SUPPORT)\n+void sdram_init_ecc_bits(void);\n+#else\n+static inline void sdram_init_ecc_bits(void) { }\n+#endif\n+\n+#endif /* _SDRAM_SOC32_H_ */\n","prefixes":["v2","3/3"]}