From patchwork Fri Oct 11 15:31:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13832695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1D86D0EE05 for ; Fri, 11 Oct 2024 15:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mxG0yqWh7JOJe4yZxrUWXuSBYgE7RS5YP+66smYxrH4=; b=o7BIcJNAxY3rgJ0wYgwqnBDZJ2 1sLUHUzlmnRnRy5518ASjDjPmkITgrUaEfRwKPRCaM/r2ntyltM9jgicf8CH78zKwfHo7gZtpeQ6x hsNTk58rrX3U5GwHu+/UvesBB9yK1/MwHaC66uc0iFT9FTBAVhvmDjxQoHDslto2vi1rFNjuDPlVh d4waQIWojepuQpmTIfNwJoxKVQBl0V4SPWYg6Fsf84UPLh4hDXx8uZ4Q8/LMQgdCW/uc1Cwm/xsoQ eoO5drhrjlpxkn7MP61SqntHTeYGKBgROLICWKljCZ+hxd5QoKM9LVWSQ+8CEngKK1fYq0HIm5Jw9 rpnEhpEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1szHnE-0000000Gpwv-1x92; Fri, 11 Oct 2024 15:43:04 +0000 Received: from mail-am7eur03on2075.outbound.protection.outlook.com ([40.107.105.75] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1szHco-0000000GoO2-3lE7 for linux-arm-kernel@lists.infradead.org; Fri, 11 Oct 2024 15:32:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jcLEpqRJuzlGlA3iCLpBg0/IxZNqCuW0pKav7l3Stly/ABlQwtEAEyMpDloOjijXVMHh/iJ1osmpBz6DGlFlKMtgZAnRGWFoz0TqC+fRY2YjWDd+tB5mW1CmEa7zSrSO4n7j+ILLOd2j+TTEGIE9TG2K3vbof9EBaGn5puOT+8kmwD5/qJuacdydUx3ofWMKDKDKOQeFjhuDomCHosrEW40T2EQ8DvySy79u8AdqI/ShzHaUnJH+GQLNE3L7yxralF1PA58EeHIuGkUVNgPjI6lai0XJFMXMfkl2iHoVkzg5cMj0zx1Z5VGveMorEefm4yHkTYnV3yA1OgxzD1k0UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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; bh=mxG0yqWh7JOJe4yZxrUWXuSBYgE7RS5YP+66smYxrH4=; b=eMyA8FCBU72m1skytn6Q3jI4wxNe+qcSmh1mdni7IvGezY1rhM8CfTmHCEimZTW0VMzGFxRqn8D8/wvQLRyaDzGEGuDmL44JgLqcA2Jkork4SHGApaYuVqW4nwXvz1UpmKjtzP69b1QlG15v2j1B80Z2oTBJ7ct6RkgjVDaGkW05TpdDi01eP/MPWxd6mds2zzokiapJCJ27S/ap2gSvp25lzVV54Uz3rTGhTOcv87rktrHHjmNm0miYNhqRGMoeSxEoS6nGjt3x2Z8N2eJ/qxQwawXmIdj7Mhstv3RnPM/8UeDNfxeWv124J8L5142dTzxA2LJJZJIq4FhH4SRGSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mxG0yqWh7JOJe4yZxrUWXuSBYgE7RS5YP+66smYxrH4=; b=aay3Dn2jnbWT2/c1UmxcgJeUjgkggG6D7a0qkmO4uYWGI44lYJEqQFuyH0Wn5aj5I6Pg75IRWLT5jgtF7juC9ReRAqrAeCP4VPq74iQYJTeWLwNz9mFXNeemBaEKwfvJKu3400CGA3R+F7bNNrHQ7wKRrTHNzg1jk54zgQuxpqUhxhjdk4datZl4m+gVP+sTsfjVnR285i7+Ao8TEAuMXypARzRiCoEgP2PhToyG6AsvIhoYO+uK3y6a2t8JJs7WiC25XbzOJt8ydowEcyhTkLyq126lt95sGmIpuyJSEZWMgBQEz4QjMj6192u8liWXQx7ATMbSoupPBNPtQFRK3A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by VE1PR04MB7360.eurprd04.prod.outlook.com (2603:10a6:800:1a3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Fri, 11 Oct 2024 15:32:16 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8048.013; Fri, 11 Oct 2024 15:32:16 +0000 From: Frank Li Date: Fri, 11 Oct 2024 11:31:33 -0400 Subject: [PATCH v2 5/6] EDAC/fsl_ddr: Add support for i.MX9 DDR controller Message-Id: <20241011-imx95_edac-v2-5-011b68290951@nxp.com> References: <20241011-imx95_edac-v2-0-011b68290951@nxp.com> In-Reply-To: <20241011-imx95_edac-v2-0-011b68290951@nxp.com> To: York Sun , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Krzysztof Kozlowski , Rob Herring , Conor Dooley , Krzysztof Kozlowski , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Frank Li , Ye Li , Peng Fan X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1728660703; l=5954; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=M8I8hajo7XY5xWGLxmn0PTrzPVpEdSTe8Q2nAI4GQg0=; b=7h4BJZ3mCnPCp/AD4A6vgkBR47ZLFq3MbXdu65ZwN022GV3hyVKXT7toQyBv/9i4bctjP0Ft0 aj4V27sIwQsDXUdWxSpOFedzyS1TwYkXpKBShyGiDlE4goRrDDvTEmo X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY3PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:217::19) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|VE1PR04MB7360:EE_ X-MS-Office365-Filtering-Correlation-Id: d0c13928-fb2c-4cce-5701-08dcea09e2eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|366016|7416014|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?5nO46jgCH9LgVFacymnf+RYaw+TfeOO?= =?utf-8?q?ScRvti4PMhd2sRu4AbY7LUEHjgNgkNbG9C0Hd0GUFJQOfMCFUEe7UPMWKgq8Chkj9?= =?utf-8?q?p7LiJyYRS7PQXpfhw1CbXaprpaA63m6B3BHFh3mPNdkBGv7UD1vta7YCrqrPDngzL?= =?utf-8?q?zZ+zfwPH8TDjhelYu1Bplo2P0QwIYAZ5sKpl5yAgbd7+q2XqdpycD5a3vK7h1yqOq?= =?utf-8?q?yh7FxXcJGEa6EjPD1IW2T0rGeEaCHYOMd4kOH0zC1XSnTC/9NDdds4Z9Zb1FmnL9z?= =?utf-8?q?0szNs3XRW60RtfjGMCCVqljThD7tNyTOvaCNhxo4odmAbjEKWUTGYX2cseqKFfuXc?= =?utf-8?q?ySACycqkaoAC6+Gb5encfd6J8Ik3A2yR4GJuzaDADxizRkomiJdwThquQNKfc8/Le?= =?utf-8?q?lDuC6IJ2DCy6im+kFxzolXOTikLuKWHk7ybBcEfT1v08773shYpYM3Xvywq5VleWO?= =?utf-8?q?CydjbuA003glegm/GHQwWPFYxadlOeLEVY+wQyDOa39p++AIWkmBwRQxZDig1cxNh?= =?utf-8?q?xRmSKwcpQmeAaaStQ08KrW2+nS6EA+qSapHdQli+qbtVBJWZlzss4cErj+E7/GFxf?= =?utf-8?q?kOJMtMCElPGbiF1p4R4VO1zJ2I6NP8rEvRMKUiRZtmYY+mDhd8h+fVIpbPrj6Kbb3?= =?utf-8?q?fVbjadZYRmNQO01BNLeiZBQLNqUlfdCXL7RVNAgNhClY0MdqEk3WRoEm5Bn4nHb+T?= =?utf-8?q?HtyF7QQ5A45Ll4LR/lCxpLS0acTi0mqC0Ayspj6/tO4ynqNOTeKLEF4wXCNKI1RD7?= =?utf-8?q?8sNThjNG4ZU8ubUtwTnllGLzuVpfeFheGqSNILbrMijyPaZmnB5SSY27sTCanxtKO?= =?utf-8?q?12IG/CfFWR7td/+vnTFl+REtbYCx5MjODBMUNPoYaoYS7XkY4b+t1tr0Uc9ZgqgyU?= =?utf-8?q?cwN3+j1Nm9iRrD2SgJkuz/W0x59Fks83+EF89cTE/Bl8KrH4fMHRbB2U3njBClmH8?= =?utf-8?q?reG/VP751n4U5V/DRTc6lVOhpVK9V5Oik+oe43WrUA7CzFATw5B4wh30tApbNDI6N?= =?utf-8?q?UiaRKu6lYuQanBzd+MgLoQSB/O3/XeLTFeW8PQMpjj0nvymyBVH0OcpUnVfUoOv3G?= =?utf-8?q?ntPoKYyQtgKX5tU4sqiw4xCPcwZS770/m2tQzcEgoPG/q0MhLUVCzDxM4kqQHPsOz?= =?utf-8?q?cCnIPs3+O0sgrkOaX9FFOeuFhO4Q6KUehwciNJlPnWHh5RwIucVqx4zgXsChg0BSL?= =?utf-8?q?uBdjugrFWHaDVdVqBNfJll4Wf4cCV/jZTH6aH5EZVLUn8tCpFoGR981pZRqbgfuF+?= =?utf-8?q?FgSNcjr/Ag4cmXfYjyAnBKZtZx3RMESke0E7/EMLyfMNZJNyUcJQkq9o=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(366016)(7416014)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?rRGChV4Ff69a0iR36DKdjzfFvHv1?= =?utf-8?q?Et5kusbXu0pejxFM+jjR1YLVtelyUfjolTwb+pHgIaaPpZL92Wbo/bWFGdd7UyD/6?= =?utf-8?q?HwN578NC4Kz4Wdj7z3sNp7OYrJHm523Ix6BIMyTl5JJxKlXhr2+DIbkrfWo97J7Pg?= =?utf-8?q?sddgXRTPkjwTSFjSAgdQRzViYN9zan4uD+V6fxb9iV39uiOrxVpDHcsV6KHFFHeo+?= =?utf-8?q?PBxqHKyKxc5h6x1tA2ICrlSeR+VLfVrs+4n14O+XjoGvBN90THRCvUcmn1tDsYnrZ?= =?utf-8?q?Y5tqMV3pSKgtClNwTH3TNzH1/avi0Kjp5O9E+O4nKwZ4hTHz3i0YUS3tLEJVVK4WD?= =?utf-8?q?GhG75jNZm+NBvwujCUlnldPnxxtkYHEu++3bhwAxevpwRdNFPfdKaS9LGw8mhFNeM?= =?utf-8?q?oX7dMuouD80iTEq7kNDbhBxu+Zm8wYPugEdHsVbq3ultomfdASdL/3nUqL0o1Mdib?= =?utf-8?q?qIz8U/0r8lKd5aaGkndwFxM3eNX98/pcxXEnojSRVxBUI7Mt31pJ/7NLRiuAJZzym?= =?utf-8?q?lb+4Jq6ONc4ZAGdBFFUZs0722F964qT1JcfEVZRxe9Aw3v6u9PPYkfuFBoXxZDG1x?= =?utf-8?q?A+z1T61ob66iDOAl3QPmVWAU9Y92sd9Wm91wUO0v25h2yL7UQa6agBc7SGGL1k3Yx?= =?utf-8?q?Rn4L1Xx76WHOJvvkAw3Gz+yJXJ09EOTc13ijyaK/mkeyZkKHPZUacQ8XiUc4AfpJb?= =?utf-8?q?cITVQTUmhgzoQfdjm3rdBsnO7G4fiIUsWk31D9LJBsytU5cRBVDQOTW1qHWvJvhyu?= =?utf-8?q?fkxWhOXDIvvA1OzH7rHp570RESe0BaazIgHAsT2rpeLCPO56a/1qdIbwSRxEUntPZ?= =?utf-8?q?Ap3+SlFCQqbl08fWLaPsMEZ8c6xySm2JgnNv6Dx/vSR2sDgos+qvAjtF5U1MbpgML?= =?utf-8?q?fQoNOov+dEfuuQ0+WHbe7rjhUCbdSJ6RiQbw3OT1atE4ikwAvgsZzRyC8NY5BIZrT?= =?utf-8?q?DpwCizcrwyHGCcYQytJnaHfPpLzlr9YmIvRNnysPORD6kUeEqPwEmjk8JZFEiEzxX?= =?utf-8?q?sWHsHaKFf9iTcbIT4c8Xb3UERARRvayNd07SxO26IUT6QK6I5swPbQCutrK77pntn?= =?utf-8?q?rAFlFXDG7dbimggqH7wzbLoEda0VLuymlCNqWOOWgwWEEre5tZmUxLwpFboiBuq4U?= =?utf-8?q?r/0qsJ4c7gVHxtCqNxdAj30hDXHQp4DhE181Gk9jBqfFgpZ/TfImBEuSu3VKT/5Fq?= =?utf-8?q?bRuM0AibvHPfU1WirX5LspdcLvqBvF0YADuHoXp038fRpvwro8SwVUnvvCNeCwvR5?= =?utf-8?q?GlGZpU892BW71IGjOU1uMT/rQPG64BQP1mepsqfufCL6h70HEmhRquSuhGqMSq2Oo?= =?utf-8?q?Y2mjKVIA1r6UTgaKYnPfK7j7e8jCEgJLOPIrzMUjcTMLFublWU7t5dpknSSnXS8Ty?= =?utf-8?q?etOb1Sx34pqXiMmD78Wv5hdRPCUmKLZgkrvaBuyxYMvAbY4sEVLLEMGG9LgGJH5WB?= =?utf-8?q?TJLnJXGt0PfNNbOSAGcKgV76NOJr+GBwZEdNnwIVr2QkgdujORa+CJn/lA/KMBzvy?= =?utf-8?q?umhiqbbYjcSA?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0c13928-fb2c-4cce-5701-08dcea09e2eb X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2024 15:32:16.3282 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CM6a9wDgmT5mkqJx3mQ2KWmar3yeGEkA/uyOv60TPEmbr6WPJLnksdh+qTMyqDSYVX1Bb37il+3vCXL6w5g3aQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7360 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241011_083219_238628_2ED3E2FE X-CRM114-Status: GOOD ( 22.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ye Li Add support for the i.MX9 DDR controller, which has different register offsets and some function changes compared to the existing fsl_ddr controller. The ECC and error injection functions are almost the same, so update and reuse the driver for i.MX9. A special type 'TYPE_IMX9' is added specifically for the i.MX9 controller to distinguish the differences. Signed-off-by: Ye Li Reviewed-by: Peng Fan Signed-off-by: Frank Li --- drivers/edac/fsl_ddr_edac.c | 48 ++++++++++++++++++++++++++++++++++++------ drivers/edac/fsl_ddr_edac.h | 10 +++++++++ drivers/edac/layerscape_edac.c | 1 + 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/drivers/edac/fsl_ddr_edac.c b/drivers/edac/fsl_ddr_edac.c index ccc13c2adfd6f..3e4c2869a07cd 100644 --- a/drivers/edac/fsl_ddr_edac.c +++ b/drivers/edac/fsl_ddr_edac.c @@ -31,16 +31,28 @@ static int edac_mc_idx; +static inline void __iomem *ddr_reg_addr(struct fsl_mc_pdata *pdata, unsigned int off) +{ + if (pdata->flag == TYPE_IMX9 && off >= FSL_MC_DATA_ERR_INJECT_HI && off <= FSL_MC_ERR_SBE) + return pdata->inject_vbase + off - FSL_MC_DATA_ERR_INJECT_HI + + IMX9_MC_DATA_ERR_INJECT_OFF; + + if (pdata->flag == TYPE_IMX9 && off >= IMX9_MC_ERR_EN) + return pdata->inject_vbase + off - IMX9_MC_ERR_EN; + + return pdata->mc_vbase + off; +} + static inline u32 ddr_in32(struct fsl_mc_pdata *pdata, unsigned int off) { - void __iomem *addr = pdata->mc_vbase + off; + void __iomem *addr = ddr_reg_addr(pdata, off); return pdata->little_endian ? ioread32(addr) : ioread32be(addr); } static inline void ddr_out32(struct fsl_mc_pdata *pdata, unsigned int off, u32 value) { - void __iomem *addr = pdata->mc_vbase + off; + void __iomem *addr = ddr_reg_addr(pdata, off); if (pdata->little_endian) iowrite32(value, addr); @@ -438,6 +450,9 @@ static void fsl_ddr_init_csrows(struct mem_ctl_info *mci) case 0x05000000: mtype = MEM_DDR4; break; + case 0x04000000: + mtype = MEM_LPDDR4; + break; default: mtype = MEM_UNKNOWN; break; @@ -471,7 +486,9 @@ static void fsl_ddr_init_csrows(struct mem_ctl_info *mci) dimm->grain = 8; dimm->mtype = mtype; dimm->dtype = DEV_UNKNOWN; - if (sdram_ctl & DSC_X32_EN) + if (pdata->flag == TYPE_IMX9) + dimm->dtype = DEV_X16; + else if (sdram_ctl & DSC_X32_EN) dimm->dtype = DEV_X32; dimm->edac_mode = EDAC_SECDED; } @@ -483,6 +500,7 @@ int fsl_mc_err_probe(struct platform_device *op) struct edac_mc_layer layers[2]; struct fsl_mc_pdata *pdata; struct resource r; + u32 ecc_en_mask; u32 sdram_ctl; int res; @@ -510,6 +528,8 @@ int fsl_mc_err_probe(struct platform_device *op) mci->ctl_name = pdata->name; mci->dev_name = pdata->name; + pdata->flag = (unsigned long)device_get_match_data(&op->dev); + /* * Get the endianness of DDR controller registers. * Default is big endian. @@ -538,8 +558,23 @@ int fsl_mc_err_probe(struct platform_device *op) goto err; } - sdram_ctl = ddr_in32(pdata, FSL_MC_DDR_SDRAM_CFG); - if (!(sdram_ctl & DSC_ECC_EN)) { + if (pdata->flag == TYPE_IMX9) { + pdata->inject_vbase = devm_platform_ioremap_resource_byname(op, "inject"); + if (IS_ERR(pdata->inject_vbase)) { + res = -ENOMEM; + goto err; + } + } + + if (pdata->flag == TYPE_IMX9) { + sdram_ctl = ddr_in32(pdata, IMX9_MC_ERR_EN); + ecc_en_mask = ERR_ECC_EN | ERR_INLINE_ECC; + } else { + sdram_ctl = ddr_in32(pdata, FSL_MC_DDR_SDRAM_CFG); + ecc_en_mask = DSC_ECC_EN; + } + + if ((sdram_ctl & ecc_en_mask) != ecc_en_mask) { /* no ECC */ pr_warn("%s: No ECC DIMMs discovered\n", __func__); res = -ENODEV; @@ -550,7 +585,8 @@ int fsl_mc_err_probe(struct platform_device *op) mci->mtype_cap = MEM_FLAG_DDR | MEM_FLAG_RDDR | MEM_FLAG_DDR2 | MEM_FLAG_RDDR2 | MEM_FLAG_DDR3 | MEM_FLAG_RDDR3 | - MEM_FLAG_DDR4 | MEM_FLAG_RDDR4; + MEM_FLAG_DDR4 | MEM_FLAG_RDDR4 | + MEM_FLAG_LPDDR4; mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; mci->edac_cap = EDAC_FLAG_SECDED; mci->mod_name = EDAC_MOD_STR; diff --git a/drivers/edac/fsl_ddr_edac.h b/drivers/edac/fsl_ddr_edac.h index de66f9822fba1..73618f79e587f 100644 --- a/drivers/edac/fsl_ddr_edac.h +++ b/drivers/edac/fsl_ddr_edac.h @@ -39,6 +39,9 @@ #define FSL_MC_CAPTURE_EXT_ADDRESS 0x0e54 #define FSL_MC_ERR_SBE 0x0e58 +#define IMX9_MC_ERR_EN 0x1000 +#define IMX9_MC_DATA_ERR_INJECT_OFF 0x100 + #define DSC_MEM_EN 0x80000000 #define DSC_ECC_EN 0x20000000 #define DSC_RD_EN 0x10000000 @@ -46,6 +49,9 @@ #define DSC_DBW_32 0x00080000 #define DSC_DBW_64 0x00000000 +#define ERR_ECC_EN 0x80000000 +#define ERR_INLINE_ECC 0x40000000 + #define DSC_SDTYPE_MASK 0x07000000 #define DSC_X32_EN 0x00000020 @@ -65,14 +71,18 @@ #define DDR_EDI_SBED 0x4 /* single-bit ECC error disable */ #define DDR_EDI_MBED 0x8 /* multi-bit ECC error disable */ +#define TYPE_IMX9 0x1 /* MC used by iMX9 having registers changed */ + struct fsl_mc_pdata { char *name; int edac_idx; void __iomem *mc_vbase; + void __iomem *inject_vbase; int irq; u32 orig_ddr_err_disable; u32 orig_ddr_err_sbe; bool little_endian; + unsigned long flag; }; int fsl_mc_err_probe(struct platform_device *op); void fsl_mc_err_remove(struct platform_device *op); diff --git a/drivers/edac/layerscape_edac.c b/drivers/edac/layerscape_edac.c index 0d42c1238908b..9a0c92ebbc3c4 100644 --- a/drivers/edac/layerscape_edac.c +++ b/drivers/edac/layerscape_edac.c @@ -21,6 +21,7 @@ static const struct of_device_id fsl_ddr_mc_err_of_match[] = { { .compatible = "fsl,qoriq-memory-controller", }, + { .compatible = "nxp,imx9-memory-controller", .data = (void *)TYPE_IMX9, }, {}, }; MODULE_DEVICE_TABLE(of, fsl_ddr_mc_err_of_match);