From patchwork Thu Nov 7 05:42:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vabhav Sharma X-Patchwork-Id: 13865814 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2062.outbound.protection.outlook.com [40.107.241.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DEF2192590 for ; Thu, 7 Nov 2024 05:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730958172; cv=fail; b=Qdxegen+Et01vtJZQfNPPo/fspH5yiaHCCVFQpH+jbp0HaF8tGdzLSFrRzY801iTFSd8JPtS3GDimqRi/0wwKDioa1sAgM8eNBUbe1ZMDwduIKRDPNerS12VGWPlDN4iy74QaPhzezB03yzfaGFNV9MSWt+cjBr9h9/+4J9et2o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730958172; c=relaxed/simple; bh=ivoi9ar5X+xjANUIH6gyC/gfN1b8Jbl67jo4vegvQqg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=lsXVXIT+p6MlZYGvcOuW//WUk/E57t7PhkMqO5zELw4Qt9M3AuR38ginnU/xjt5uwUtmmqm3vo2ZUM46q0Ou+gP1g9PFTx7lDq5rZFN/d0McXD6LhNSiX8XzaIdXlJM3HSJdyxU1GrgioxzPpSwR213VUa+przyfworCW7oh6ZI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Ir0vdmY9; arc=fail smtp.client-ip=40.107.241.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Ir0vdmY9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IFRA4ggV+SkJdqvjDo9Px6+J/UB16Lll6eo0AMye63xD0ZVW8Fh3qOJaFVT1vC4bNqwitaKO1Pl9tvGEtuldLZGgWYESkjU4SWuAU/Ao/cfzPAewjfdIG/EYZ//mhQ4Am1gKmv0dpEG/F/T+XEmVWrikFzcCt0ITcf0BkBDiYhFnmj1ZRrLwWcaMSMSxoW6IZExboMdGboKWBfcMPfMCwtGL5BPzStaV13AJrUpTx+4ChPy+2dHB/lEq9sWoFvuSzSZutDcpg4h5d2R36yJ4UIpT3C2eKJqHncWLJ+BeGrGr66sfMtfrzBcG7dveAebMBRJMUkcz6SdAYCRTSS/aJA== 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=vg4SPtxy/2UAd0wMlLzldmusRgTeeUO7+lUD8JB27Ho=; b=kjxUHMUEyxRpdPUpWHA2Kn3cbjU+ZzxRbDfe9smsq18qmolhcxvhk8O4oV9uyQFWYvNRcpgB9y0Axj1erUiE9ZSyq0OAEYpkLBj8OZuSmuOqYNOj5Zn7mxhnWsd6dc0R4OJfthT5/cV26oQhG2oSbxfFESShEgRHh92NexJ1dsaiwWQMc18AL6O2DvZ99k3Yep0B+3meXRViBtWxSu0cUK+PR+Vf8J/OPLKoKH/aB/5DZZeowcB3B+gCNnq2ryrMMu+m5gIsIJjtqQ9tWDhkqbNqT5ElU2ZhI2qd+a/opHdCvl1ss7mnDgqUUVUeUuDQ4+uRd3TrycSu/k50ccRlWA== 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=vg4SPtxy/2UAd0wMlLzldmusRgTeeUO7+lUD8JB27Ho=; b=Ir0vdmY9JMhrSzEHYaJU7/wCa2XDOUb7uNhoUcDA9tHJz7SrlTD+tCClFBFsmJSZiYA25B8zLx7dQx+a/4JFbybkLs8Ruj853vXT/YYXPJ0iyquG32ZBqqw3PZl/zVEfcMsJ1HkN/uFGvYzQdSjz3o2V9AJJcdwRPGzdHyTaVzwB+WljerarozFNw6jiK7iZWzvO8D+EmPCvByKuhLI3D/IchN6k7EmIwjtXMKWF1MGgSmOLNzTH6MZ/kXGKRII4p3f1P5jnLVOP0mipW2qD3crQ+Cd3EaOugKd/3rUiQlSfm8d7X+XwsDPiJq9Nhb3AH+a1vbQ8dlJgx6Pyvxp6NA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9354.eurprd04.prod.outlook.com (2603:10a6:10:36c::10) by AS8PR04MB8434.eurprd04.prod.outlook.com (2603:10a6:20b:406::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 05:42:46 +0000 Received: from DB9PR04MB9354.eurprd04.prod.outlook.com ([fe80::3cd3:1ff0:8bae:a7ab]) by DB9PR04MB9354.eurprd04.prod.outlook.com ([fe80::3cd3:1ff0:8bae:a7ab%4]) with mapi id 15.20.8114.028; Thu, 7 Nov 2024 05:42:46 +0000 From: Vabhav Sharma Date: Thu, 07 Nov 2024 06:42:39 +0100 Subject: [PATCH v3 1/4] dt-bindings: firmware: imx: add nvmem phandle Message-Id: <20241107-secvio-v3-1-ea27f1e9ced4@nxp.com> References: <20241107-secvio-v3-0-ea27f1e9ced4@nxp.com> In-Reply-To: <20241107-secvio-v3-0-ea27f1e9ced4@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Dong Aisheng , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, frank.li@nxp.com, pankaj.gupta@nxp.com, daniel.baluta@nxp.com, silvano.dininno@nxp.com, V.Sethi@nxp.com, meenakshi.aggarwal@nxp.com, Vabhav Sharma X-Mailer: b4 0.13.0 X-ClientProxiedBy: AS4P192CA0010.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::17) To DB9PR04MB9354.eurprd04.prod.outlook.com (2603:10a6:10:36c::10) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9354:EE_|AS8PR04MB8434:EE_ X-MS-Office365-Filtering-Correlation-Id: 932ce2e2-42f8-4991-011c-08dcfeef01de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?auY7L/SootaoeOmr/EuPaYa/0HGniZT?= =?utf-8?q?9D2zCAI+ViLqcshDoQ/N5CjmxLcTv1GyEX8LcHhMfA3aDWPJiep7sUOW41bLO3vlH?= =?utf-8?q?hmWpOWvVx4C15cQtg5YVFRaEUuLl+XjCWayNecHTpt+NWssdomddsDhfa99aJDMlw?= =?utf-8?q?Qd0BtlxuESbhL6vGQmFbDvVEYhNvRXgcE4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vUpD6ZDY4FouxuhujSa2vZHkyd2CAHhFo?= =?utf-8?q?iKgKfZuwhUxqD1Uam9nnsvxQYXHRy/SD8Q8VUolJ2uxYfcZI0vijEEF03YUFRpDn/?= =?utf-8?q?H97hw0r5LED6ZsVIFxLbwGY+0a64dGNtcKa2HbWjZclIP9WeICcEUaklEsSXVYx3u?= =?utf-8?q?ePSYut1qyxf9lQNV9QULanDsnh3cepoHHs/FtqVmzjFKtO8a0/5WiTVi+N/Z4forB?= =?utf-8?q?nmJ8SG2geUIBTOlPXkLvMZopmgvTeRkO0FHpKDW7tBHWWZNCIbGZ5M4k=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9354.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?1zc5PsDgj9n3UG9BfB2T4955XTt+?= =?utf-8?q?hxOKdDd8ofD03Yl86GgC5f2AIA5j8cVkF8GaOt/deDGhmB8mSpz/JQMApT2UK4sS+?= =?utf-8?q?WFu+c3YZPHsWtjtQL2TEIwhVgkjZ3Y4nU3Ydw9XgqeljPLLPTaVp+/Crwi0jL8vkk?= =?utf-8?q?m9Ci5qYb/Da8b6+srpZa9dq04mzeXvO8QW20SwHvg+MckpNgZP/Tl+1io4FEqxLSZ?= =?utf-8?q?M9VarDth0bdAc57T6Uj3jDt+ZGx2mGI/6CdlpERj1pHAnME+blA2EJKRwX/Kw6rEB?= =?utf-8?q?yIebaxyub4D5bAhuK5YHVp+7HkXofZTf+p641/7nDdqyoLI4PZjJiguqnUdD+RNQl?= =?utf-8?q?BcLVHlgw19E4VbK3nf83vxOKOCikF4qa4+QkSjxeyuT0kkQPN/qKoMzRrdbpAX3bT?= =?utf-8?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5/zF?= =?utf-8?q?05XUHm+6UgYtsq1b7FRiwuhpY7eI+k6PjNGA688fE2AF9aY0f4ip16El7aun2wqyn?= =?utf-8?q?wI2xHlM/Rmv7XGPQL2Gg2QDQvAbc/RL+19MUZAZkgwRY50qumcgv5ZUpCD9/1NAhb?= =?utf-8?q?GidhwlFzBGUUvudy8k9Ho1WgLEFzpruOPXogEeDU6IserzlFH0nvRWctVYzu6DrPO?= =?utf-8?q?p6uufhuiTQziaUrNyLg+UaWTgP+VbT1U1VEGVBuk6XpiBd15RcwPBJy39CZknDLuI?= =?utf-8?q?AgxFx2D/FIGQ?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 932ce2e2-42f8-4991-011c-08dcfeef01de X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9354.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 05:42:46.4165 (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: XPKtmlcy9ZskKl73Cs3UtCAr0S0outFszhp7+5Y4dd0mWPav/rWwRCUWD1tmcKy467Vf9+KyHzIySG2Bt36YWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8434 nvmem phandle is required by secvio driver to read fuse. Signed-off-by: Vabhav Sharma --- Documentation/devicetree/bindings/firmware/fsl,scu.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/firmware/fsl,scu.yaml b/Documentation/devicetree/bindings/firmware/fsl,scu.yaml index 557e524786c2..1cc86fed6c27 100644 --- a/Documentation/devicetree/bindings/firmware/fsl,scu.yaml +++ b/Documentation/devicetree/bindings/firmware/fsl,scu.yaml @@ -112,6 +112,9 @@ properties: - const: rx2 - const: rx3 - const: gip3 + nvmem: + description: + phandle of NVMEM driver provided by the SCU pinctrl: description: From patchwork Thu Nov 7 05:42:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vabhav Sharma X-Patchwork-Id: 13865815 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2062.outbound.protection.outlook.com [40.107.241.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B296A192D8C for ; Thu, 7 Nov 2024 05:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730958174; cv=fail; b=st5UuWtFdK9bF7fwVBK+PqoEBtlmcNs33/2xCui7ZytTH6ouy3O+mX9E01dSCVjVuf1N0AeNzqYTH0c3NDAEzWvlfQWG8JUy+h2pWua1x0CxfH4LrO6l1kpjPa4q9uul9JnsgZJNqcYBDfwBllFvQGv60k3r2Hsn3viy9Lzj7k4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730958174; c=relaxed/simple; bh=34FF491ZJSDO129ZCMtrnaGbCyv6wFF+EMeynPpwbFY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=p6StFreeA997E+ROGpST0jTXAxszl+O/M6u5uXpPyiQK+2nq+pvgnw0tjq1oEDpuH3kS+A7b7/1tH9FlPGsp8qAdYPnfggFzPpsq/UdsZanr4yF3+e/G2jFE5vqR67XAfyhauOnQBkFOGGcsO2+6lS7LFXpyQFl9CtGNtUFqTRA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=lTAOHMml; arc=fail smtp.client-ip=40.107.241.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="lTAOHMml" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dCMQirRTfbRsEzeb7GiP9ileXxmsjMzOWJSVDGli0YApL2p9FYNpPY2FCmonQBUfbR+SxwUbWlr+8HyYgx3eDUaMY3lp+FAOTLRp1mF8RF7sYF/THKScdBlJZxOl9qF9Eh8quL2UysESLmDR+v6OI/NIxLOQqjaekfVOnNAD/aOQkuBAWY6oi+rfXgymU5ke9Sg53rhR1qeKirCizmROifG8hAkgqByk+6QhtX9kCY+GT5Yy3ejyHbpBuvb+dXlxLsAvnnzoahFBLYmtUMH7etELJS+Avsyr0zWr0ynBQLfZpK0rlp8kIRMI6UhZCdLDOeJMZx7h4WItEDSBsl5WBg== 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=ZbLAgjXjhD46oGKQLWhlHSclrDOmmgRZNY+dScF3B/M=; b=hO9UNwFkVQYzRTqzIq2AzE0pZmaRhQDvUsySGmJmyAPQyfZ7XQaRLCharqhfTAttqHFdGaVT9fYD0J0fEdQVKNmv0/qyOOcLsUPlwezch2YmrQhXJzd9yiKUVv4zi8ufSw59BUb3Hj7+uKkW9UesSNojK7uh2WAQbWudDOReQCi/O/qK6chhIUXSJ4dgRWF6zrWA71OVyPrud6ebsUvoQ5srqfI/ZqEb7n8HMW32n2D/A6la5vJX5Gq0aubbsYi3zVLO37pXQu9FEy1W2TLrb+1CzvTGsVf5MfAzOsqBoSvhdgkgdayl8eQhEzMJDZ01WU+AxYYyNqLHPH1Eahl8VA== 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=ZbLAgjXjhD46oGKQLWhlHSclrDOmmgRZNY+dScF3B/M=; b=lTAOHMml4QuHTb2wMBxhUm2sn4tHPnkP8NFoFQWF31sap3+3egJ3H7AYF/uDbFNJc0AuNJejTljiZzO89032CFNvZgoDqSIQ1Qfw1lJL58uUWRbyf4z6Tp+Ew73wnQ5UPKi5m137Mzf/cwEBnBySWVRGDvkaM3OHt76M19MHy9j0l8T3Yy1zq4RDthxpLCysoGk9jTj+vLdFZru2CxAwgpu364GPvnsx/hbL4GmR5kgPlKuxxicAmT/GlaYw/ZerRhKM3XXOtpGZCRTPC97I2uTuS4ByTtS08xq0oM6hAQpHBPyjWmHY5SXCTy5bhDirxVtzldVrudZl8/pw2Jxqfw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9354.eurprd04.prod.outlook.com (2603:10a6:10:36c::10) by AS8PR04MB8434.eurprd04.prod.outlook.com (2603:10a6:20b:406::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 05:42:47 +0000 Received: from DB9PR04MB9354.eurprd04.prod.outlook.com ([fe80::3cd3:1ff0:8bae:a7ab]) by DB9PR04MB9354.eurprd04.prod.outlook.com ([fe80::3cd3:1ff0:8bae:a7ab%4]) with mapi id 15.20.8114.028; Thu, 7 Nov 2024 05:42:47 +0000 From: Vabhav Sharma Date: Thu, 07 Nov 2024 06:42:40 +0100 Subject: [PATCH v3 2/4] arm64: dts: imx8qxp: add node for nvmem property Message-Id: <20241107-secvio-v3-2-ea27f1e9ced4@nxp.com> References: <20241107-secvio-v3-0-ea27f1e9ced4@nxp.com> In-Reply-To: <20241107-secvio-v3-0-ea27f1e9ced4@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Dong Aisheng , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, frank.li@nxp.com, pankaj.gupta@nxp.com, daniel.baluta@nxp.com, silvano.dininno@nxp.com, V.Sethi@nxp.com, meenakshi.aggarwal@nxp.com, Vabhav Sharma X-Mailer: b4 0.13.0 X-ClientProxiedBy: AS4P192CA0010.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::17) To DB9PR04MB9354.eurprd04.prod.outlook.com (2603:10a6:10:36c::10) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9354:EE_|AS8PR04MB8434:EE_ X-MS-Office365-Filtering-Correlation-Id: 983bc40b-8116-4fad-fb7c-08dcfeef0246 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?jia/zMC+aKY+qcNPLXBAt5ATldj2Sgg?= =?utf-8?q?/v0l01DwZDRelzPMG7bR71qXwE/qbLrIk7NmhVD5s2KzPPdLe4UwgjVRML2apNZAQ?= =?utf-8?q?fkFpOXnZTwCcUmMRthCG/Nctf3YOJnpoTU1UnB6lHg+7c0e1ho9zgr05D6qRU8gm0?= =?ut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?q?oKkE9YEyuiJ3bv+9sBkGtqJVbloGYBgwmRwsPgQcl5LAcpURe0fPGDujEz6AAL7OY?= =?utf-8?q?908LVw82amXTxJvH1ojJAnGVnEjEwUixlfvgB1seOVGGwiXWXzXq1zrlGUxIqJj9o?= =?utf-8?q?lVAlDChdNNpojDfrq/vfmNo/O/mutlYlh/v/R2gpRbGTx8duh3hIg+OsTXXTV/uXM?= =?utf-8?q?63kqu8a/5QMYbkCveQOd7u7z6j+5cQ0bCdtWPNpeoxI5qc3+lcXHJg6Krirp694m2?= =?utf-8?q?YXX/fJoFkeq+CJxJbzH+GGQ+D0SkTjPFBBklycX9WOQeYbNr5jmW6XKo=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9354.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ZNgP8RfGMV2tsl4OG/mw3aKkdplw?= =?utf-8?q?rGhhY4J8lmH4PQKaVjwegL4EmBhKCEu1OBdN731HFJZ+xArg69LSYP9DqOig7v4Cq?= =?utf-8?q?qoLj2UoRiEgf9FTO++tAp3t+BB2R0HmHmIFALvYHbszIqPYhaYXFNAJE6r6n121ex?= =?utf-8?q?elCHtufIbzxrtn0bPWivBYf0Uqg4EZv8A113QCbi9GzmSk7HmzYc1pT3wti4fIwwZ?= =?utf-8?q?S543Xbz0Boye+wrwbnZ//GtSBIaIfyG52YwRnUtzpKPpyKwh0tcN+67wO1I7L7e2j?= =?utf-8?q?9WMcgsItokTVuj/PDa2nFm2SAbE0cDX7/jyciYZ6JZvZ7Rxd2IDv/xpFhSXt/ZoCl?= =?utf-8?q?w4OK2xenLG8Lnv2FUwSqQIurPAO7xAU353TCdPRqa8b75t4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xpxm4C3oqa?= =?utf-8?q?b/qTLKJ1BwlxqfggOZncefHsRzUxGI4qdCIdGUB0zrKa4a8wWESUDK+xWc2IFVlRM?= =?utf-8?q?rUeEBk94xuG1PFKcq/qmaGXGnlN2i4dAGS3mTHhlEBzJQLFc4tlGja9Cb2fe3+OpI?= =?utf-8?q?GbKOQpplr1h4qmEIVhbQ0XeEOY1s5U9arIo7hbaqzp9m7yxHWFAxYwMl8xR/xTwNC?= =?utf-8?q?HCbGxkjx6m/SiQL8TKMZE6cBlhPfEvKrnNng5DxyJkianLIAzOL1Y6I4ify7F2OkG?= =?utf-8?q?FoM9i6lX8Rl2?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 983bc40b-8116-4fad-fb7c-08dcfeef0246 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9354.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 05:42:47.0516 (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: BrQ6BwpfVYggoXPW+kCyYYHGhAwIWsGMfeOYWpdujNOFywYmZP43UBxNWnxVpqsc2MYBDshs+PGabFiNTw+3pg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8434 Add nvmem property to be used by secvio driver. Signed-off-by: Vabhav Sharma --- arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/freescale/imx8qxp.dtsi b/arch/arm64/boot/dts/freescale/imx8qxp.dtsi index 0313f295de2e..2b1dd0addb50 100644 --- a/arch/arm64/boot/dts/freescale/imx8qxp.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8qxp.dtsi @@ -210,6 +210,7 @@ system-controller { mboxes = <&lsio_mu1 0 0 &lsio_mu1 1 0 &lsio_mu1 3 3>; + nvmem = <&ocotp>; pd: power-controller { compatible = "fsl,imx8qxp-scu-pd", "fsl,scu-pd"; From patchwork Thu Nov 7 05:42:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vabhav Sharma X-Patchwork-Id: 13865816 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2062.outbound.protection.outlook.com [40.107.241.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCEE5194137 for ; Thu, 7 Nov 2024 05:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730958177; cv=fail; b=l2OO9Lg3NgfWKv3jnNkXe43SRcnS+gnxbV3BBUrx9SO9oXavS3ldci5HvYoarL/9T1SkWeNPRutN7Kf054vjlRivp3KwZOfGoIrpwdFetl7kZKzL4MRlMud3ZoP/CJn19usXEcr9HDQBiqwmhJ8sbfEu1Q4lDkmCcOh3OT8DIrg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730958177; c=relaxed/simple; bh=un9iXQ5xghbtZREQMJotfWmXPPOY7jR+nhscSRxZpvg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=E5VBAJUfU5hVeFOMAakrj2+04Ga3nHiArOvU3TScFevaXMYTzzbchTCyqCKpi+3qQfia8U1DAdKIi+j3fRGG3BAB9Kh1CCKAxDq9yi1xRYdyvarqskNzDYTADICCfP5iwEWXkpb83TGt4xjhIdl6mj8cK/ycsjPqNGGJXsQX8HM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Kby7q8b5; arc=fail smtp.client-ip=40.107.241.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Kby7q8b5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nRZav1oIoAxJtfp5yNkcoOfLUmPMxBkbfq2lJhHWeXJ1f1r//O34o8UJxyeZ0F61utatm/nCs5mpSjTRqCT6DntYYe3Un53l70+mElMeplE1O0shiVDq66RkLFxLzsR6Be2k7G5AjGa0E5mizHhBfEesOpD6jl7mkO/MgsA0fAMQHFiIucA5RY7QmsGar36xtxHa6GrCdIbxhQrkqsQjLYFv5w03sSwAqlt4ZFdxW1i5cBbuDHM01cwBMKTWoU3E4rk/bwW6RkY9sZXAZcg4NpWnWbyBhQeSueSqMoDprPoPAqdTf0xs9Zk8xEL1Brf6oDlM8HgFMmniL8oKA+RGjg== 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=G7veCpghGih4EyT0+UxUfwK10HmZpxhIQyYrVveOB7c=; b=ItaS3tHiwUS3uCndAtMvCzu9wCS5g7gisnGCtMiR8jFw5IB6xziwQARnaF0rpdYUajpdviLfjhn87irxVfI1dRpAtqiGqb46XRDtSpANt7jXMnm/Zj7/v5kQe1lQXI9usSvL9GMq9PHn14r9KmqEz3C+98Roq/fIaGNVPpMxfO5GMIfemPCTif0+aj18+GV0PGTnHLq92Nuch7UWk08kqpkwzIKnjH3svn9azicnGBFaezm/NytjToXhvgIEdS3wrKAgzcf1E1VHPVCjGn8Y1Z867VvUVDk/9BybUkUqVupmVQKXXmJ0xq8E9Hzu9UTHCJWqnLSik6CwcdLEz3L5Cg== 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=G7veCpghGih4EyT0+UxUfwK10HmZpxhIQyYrVveOB7c=; b=Kby7q8b5Q/y6R99jjrdo++7rrkf9D7ZbSwPzBfzp4Di8n5WVu6P1GeolX7wu2vf+MzDx21eqGP7KNEvm5463xV8ZUxpizedMrVVuUwOoj7jqcZibxCWq5QYhlq7tce+U19N6E62zEoN6dXApFsUEgY6uKpZQ5ywtkIsafqnyMyyIZEB+VktjvxFJCU1TG+jUIxP0AIw9PJAlR8lfv1NCVSE3Txa4vtOqxZV0Ds51rxLdXegNhrPnO/IaSHlhn1X5/WaI+uaT4btfh8ltBo0w32xYtAhqwzrsNjktyONMNbboJOBwoc1LMSBuiuceseh6ffR+UEbgeanZfnwIGoiVTg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9354.eurprd04.prod.outlook.com (2603:10a6:10:36c::10) by AS8PR04MB8434.eurprd04.prod.outlook.com (2603:10a6:20b:406::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 05:42:47 +0000 Received: from DB9PR04MB9354.eurprd04.prod.outlook.com ([fe80::3cd3:1ff0:8bae:a7ab]) by DB9PR04MB9354.eurprd04.prod.outlook.com ([fe80::3cd3:1ff0:8bae:a7ab%4]) with mapi id 15.20.8114.028; Thu, 7 Nov 2024 05:42:47 +0000 From: Vabhav Sharma Date: Thu, 07 Nov 2024 06:42:41 +0100 Subject: [PATCH v3 3/4] firmware: imx: Add SC APIs required for secvio module Message-Id: <20241107-secvio-v3-3-ea27f1e9ced4@nxp.com> References: <20241107-secvio-v3-0-ea27f1e9ced4@nxp.com> In-Reply-To: <20241107-secvio-v3-0-ea27f1e9ced4@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Dong Aisheng , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, frank.li@nxp.com, pankaj.gupta@nxp.com, daniel.baluta@nxp.com, silvano.dininno@nxp.com, V.Sethi@nxp.com, meenakshi.aggarwal@nxp.com, Vabhav Sharma , Franck LENORMAND , Iuliana Prodan , Horia Geanta X-Mailer: b4 0.13.0 X-ClientProxiedBy: AS4P192CA0010.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::17) To DB9PR04MB9354.eurprd04.prod.outlook.com (2603:10a6:10:36c::10) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9354:EE_|AS8PR04MB8434:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cb56b9a-b29d-4547-6cac-08dcfeef02b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ZB0+EovLJqVNPDUX4y2RXeZmyF8YvFw?= =?utf-8?q?BVF41Xhar4BxHJrBLYQQlpLj4HPREo27We56w7wMfST8B+Xe6pfYJz/655QRsKzCe?= =?utf-8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TdImjnT9yfS6YmQkrv96jcPo7c4uVkLkiX2SsC7ETC7w9nu8Hwovzpa4KmHv7gk4f?= =?utf-8?q?pK+temMP3DleBKxw1m44UjSSUB0QwJJY/ybLcK8AgflPRwtD6ylDRR3KIpmtol0VB?= =?utf-8?q?h/cqy7QEFXe5AquypkIbq5V5e0zf5xHw6cQPgM1VXUKFsB65y5smUQR91VPr3npIE?= =?utf-8?q?C68i5R1WCP08njNfzK62V0JrCqvHDNJw3zxUNAb1iAKgxSxFryjeZNVdmq+au7d3A?= =?utf-8?q?lwpRFI8csltpbNIR++Pu2MmmDH3szgXRCz1jZBzrksKOAKUlmSZAsn594gZzYJ1om?= =?utf-8?q?QGoG6KY6gAe6cG2vRhgszKUpRorxdNVhxFA7dB/zwb3v4z6qAxNGfx9A=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9354.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3HVBBX71p5HmWtZIQR5FGMmyPQgC?= =?utf-8?q?EKFBsvq9YAfBeG3jz2TKziyoU0owC5L+UvsmdxqF1KKKUUzjbbA0etsielhI7Cppq?= =?utf-8?q?Qu931PPUlTH3ce1bbFNcHUy0XnHO7afwOWn8navAiJiGC8KHo3N9pTu+OI8hnJ12e?= =?utf-8?q?IPXHEN18MI3Nucg5DmCnQksgogmqCW1hFoLoZKUmnYAdx0oybOye4ZBclE9IJkoUS?= =?utf-8?q?88xtmulFEx4SLVZRnvnErPjgEJntFqtg5c4D/BVFwAJON2P0IqDaX9QDFDxWrsmti?= =?utf-8?q?jxUaSAIUT3SPch7J1fIsQO6A3/dVGfG/p3uqL1MxQAcHfcFxrQV1OAQ6pYC+Bx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=?utf-8?q?5WbTqbz+enlsiSZQtk6bcHP0rmShfZP/moaeKrKDOrrFzL2OiQ3ZiAhkRwJl1loWn?= =?utf-8?q?c/Zmu06DTg1uu7rnYTiUQTZvhJAX0f30figlzcSFXnNFdXWFRkA83EFv8TeEc8Aob?= =?utf-8?q?JzjnjUDAtXC1md/2MSuWZZxkEYOJMKavOSJsHlYQYXOAJAVHQrnZWQ3qDXi8iEMuP?= =?utf-8?q?P+Xo+5TtWCJRSdXuxvZo/TMnET2fGcw2x9xghgtTWgQsVAmOY8Fo+8SfuqnEwNH/V?= =?utf-8?q?VOq9keJUCnkjGJckb04ole6CK0U6hRc2Fl/x2/nfTTP9Rq+06NzUBaSHBwYJTl3n9?= =?utf-8?q?K5YvWuBgWcZb?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1cb56b9a-b29d-4547-6cac-08dcfeef02b3 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9354.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 05:42:47.6981 (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: 74fvoQnsMgpdZiqGIj6kyzRj6h+mF0odvvhO1dRrD4JIYZWXq6Po387YA8FwTsAoeV4WHvc8dsTgLIw9p/9rmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8434 The Security Violation module requires below System Controller Security controller API to interact with SNVS block via SCFW - imx_sc_seco_build_info - imx_sc_seco_secvio_enable - imx_sc_seco_secvio_config - imx_sc_seco_secvio_dgo_config Signed-off-by: Franck LENORMAND Reviewed-by: Iuliana Prodan Reviewed-by: Horia Geanta Signed-off-by: Dong Aisheng Signed-off-by: Vabhav Sharma --- drivers/firmware/imx/Makefile | 2 +- drivers/firmware/imx/imx-scu.c | 4 +- drivers/firmware/imx/seco.c | 216 ++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/ipc.h | 1 + include/linux/firmware/imx/sci.h | 4 + include/linux/firmware/imx/svc/seco.h | 69 +++++++++++ 6 files changed, 294 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 8d046c341be8..7aaecf570c56 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_IMX_DSP) += imx-dsp.o -obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o +obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o seco.o obj-${CONFIG_IMX_SCMI_MISC_DRV} += sm-misc.o diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c index 1dd4362ef9a3..c96dc73689a8 100644 --- a/drivers/firmware/imx/imx-scu.c +++ b/drivers/firmware/imx/imx-scu.c @@ -242,9 +242,11 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) * APIs are defined as void function in SCU firmware, so they * should be treated as return success always. */ - if ((saved_svc == IMX_SC_RPC_SVC_MISC) && + if (((saved_svc == IMX_SC_RPC_SVC_MISC) && (saved_func == IMX_SC_MISC_FUNC_UNIQUE_ID || saved_func == IMX_SC_MISC_FUNC_GET_BUTTON_STATUS)) + || (saved_svc == IMX_SC_RPC_SVC_SECO && + saved_func == IMX_SC_SECO_FUNC_BUILD_INFO)) ret = 0; } diff --git a/drivers/firmware/imx/seco.c b/drivers/firmware/imx/seco.c new file mode 100644 index 000000000000..2d6bf301ac87 --- /dev/null +++ b/drivers/firmware/imx/seco.c @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020, 2024 NXP + * + * File containing client-side RPC functions for the SECO service. These + * function are ported to clients that communicate to the SC. + */ + +#include + +struct imx_sc_msg_seco_get_build_id { + struct imx_sc_rpc_msg hdr; + u32 version; + u32 commit; +} __packed __aligned(4); + +int imx_sc_seco_build_info(struct imx_sc_ipc *ipc, uint32_t *version, + uint32_t *commit) +{ + struct imx_sc_msg_seco_get_build_id msg; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + int ret; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_SECO; + hdr->func = IMX_SC_SECO_FUNC_BUILD_INFO; + hdr->size = 1; + + ret = imx_scu_call_rpc(ipc, &msg, true); + if (ret) + return ret; + + if (version) + *version = msg.version; + if (commit) + *commit = msg.commit; + + return 0; +} +EXPORT_SYMBOL(imx_sc_seco_build_info); + +int imx_sc_seco_secvio_enable(struct imx_sc_ipc *ipc) +{ + struct imx_sc_rpc_msg msg; + struct imx_sc_rpc_msg *hdr = &msg; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_SECO; + hdr->func = IMX_SC_SECO_FUNC_SECVIO_ENABLE; + hdr->size = 1; + + return imx_scu_call_rpc(ipc, &msg, true); +} +EXPORT_SYMBOL(imx_sc_seco_secvio_enable); + +struct imx_sc_msg_req_seco_config { + struct imx_sc_rpc_msg hdr; + u32 data0; + u32 data1; + u32 data2; + u32 data3; + u32 data4; + u8 id; + u8 access; + u8 size; +} __packed __aligned(4); + +struct imx_sc_msg_resp_seco_config { + struct imx_sc_rpc_msg hdr; + u32 data0; + u32 data1; + u32 data2; + u32 data3; + u32 data4; +} __packed __aligned(4); + +int imx_sc_seco_secvio_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data0, u32 *data1, u32 *data2, u32 *data3, + u32 *data4, u8 size) +{ + struct imx_sc_msg_req_seco_config msg; + struct imx_sc_msg_resp_seco_config *resp; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + int ret; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_SECO; + hdr->func = IMX_SC_SECO_FUNC_SECVIO_CONFIG; + hdr->size = 7; + + /* Check the pointers on data are valid and set it if doing a write */ + switch (size) { + case 5: + if (data4) { + if (access) + msg.data4 = *data4; + } else { + return -EINVAL; + } + fallthrough; + case 4: + if (data3) { + if (access) + msg.data3 = *data3; + } else { + return -EINVAL; + } + fallthrough; + case 3: + if (data2) { + if (access) + msg.data2 = *data2; + } else { + return -EINVAL; + } + fallthrough; + case 2: + if (data1) { + if (access) + msg.data1 = *data1; + } else { + return -EINVAL; + } + fallthrough; + case 1: + if (data0) { + if (access) + msg.data0 = *data0; + } else { + return -EINVAL; + } + break; + default: + return -EINVAL; + } + + msg.id = id; + msg.access = access; + msg.size = size; + + ret = imx_scu_call_rpc(ipc, &msg, true); + if (ret) + return ret; + + resp = (struct imx_sc_msg_resp_seco_config *)&msg; + + /* Pointers already checked so we just copy the data if reading */ + if (!access) + switch (size) { + case 5: + *data4 = resp->data4; + fallthrough; + case 4: + *data3 = resp->data3; + fallthrough; + case 3: + *data2 = resp->data2; + fallthrough; + case 2: + *data1 = resp->data1; + fallthrough; + case 1: + *data0 = resp->data0; + } + + return 0; +} +EXPORT_SYMBOL(imx_sc_seco_secvio_config); + +struct imx_sc_msg_req_seco_dgo_config { + struct imx_sc_rpc_msg hdr; + u32 data; + u8 id; + u8 access; +} __packed __aligned(4); + +struct imx_sc_msg_resp_seco_dgo_config { + struct imx_sc_rpc_msg hdr; + u32 data; +} __packed __aligned(4); + +int imx_sc_seco_secvio_dgo_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data) +{ + struct imx_sc_msg_req_seco_dgo_config msg; + struct imx_sc_msg_resp_seco_dgo_config *resp; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + int ret; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_SECO; + hdr->func = IMX_SC_SECO_FUNC_SECVIO_DGO_CONFIG; + hdr->size = 3; + + if (access) { + if (data) + msg.data = *data; + else + return -EINVAL; + } + + msg.access = access; + msg.id = id; + + ret = imx_scu_call_rpc(ipc, &msg, true); + if (ret) + return ret; + + resp = (struct imx_sc_msg_resp_seco_dgo_config *)&msg; + + if (!access && data) + *data = resp->data; + + return 0; +} +EXPORT_SYMBOL(imx_sc_seco_secvio_dgo_config); diff --git a/include/linux/firmware/imx/ipc.h b/include/linux/firmware/imx/ipc.h index 0b4643571625..df38ab8e7e2e 100644 --- a/include/linux/firmware/imx/ipc.h +++ b/include/linux/firmware/imx/ipc.h @@ -25,6 +25,7 @@ enum imx_sc_rpc_svc { IMX_SC_RPC_SVC_PAD = 6, IMX_SC_RPC_SVC_MISC = 7, IMX_SC_RPC_SVC_IRQ = 8, + IMX_SC_RPC_SVC_SECO = 9, }; struct imx_sc_rpc_msg { diff --git a/include/linux/firmware/imx/sci.h b/include/linux/firmware/imx/sci.h index df17196df5ff..947e49d8bebc 100644 --- a/include/linux/firmware/imx/sci.h +++ b/include/linux/firmware/imx/sci.h @@ -15,6 +15,10 @@ #include #include #include +#include + +#define IMX_SC_IRQ_SECVIO BIT(6) /* Security violation */ +#define IMX_SC_IRQ_GROUP_WAKE 3 /* Wakeup interrupts */ #if IS_ENABLED(CONFIG_IMX_SCU) int imx_scu_enable_general_irq_channel(struct device *dev); diff --git a/include/linux/firmware/imx/svc/seco.h b/include/linux/firmware/imx/svc/seco.h new file mode 100644 index 000000000000..508444c02d39 --- /dev/null +++ b/include/linux/firmware/imx/svc/seco.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020, 2024 NXP + * + * Header file containing the public API for the System Controller (SC) + * Security Controller (SECO) function. + * + * SECO_SVC (SVC) Security Controller Service + * + * Module for the Security Controller (SECO) service. + */ + +#ifndef _SC_SECO_API_H +#define _SC_SECO_API_H + +#include +#include + +/* + * This type is used to indicate RPCs/RM/SECO function calls. + */ +enum imx_sc_seco_func { + IMX_SC_SECO_FUNC_UNKNOWN = 0, + IMX_SC_SECO_FUNC_BUILD_INFO = 16, + IMX_SC_SECO_FUNC_SECVIO_ENABLE = 25, + IMX_SC_SECO_FUNC_SECVIO_CONFIG = 26, + IMX_SC_SECO_FUNC_SECVIO_DGO_CONFIG = 27, +}; + +#if IS_ENABLED(CONFIG_IMX_SCU) +int imx_sc_seco_build_info(struct imx_sc_ipc *ipc, uint32_t *version, + uint32_t *commit); +int imx_sc_seco_secvio_enable(struct imx_sc_ipc *ipc); +int imx_sc_seco_secvio_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data0, u32 *data1, u32 *data2, u32 *data3, + u32 *data4, u8 size); +int imx_sc_seco_secvio_dgo_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data); +#else /* IS_ENABLED(CONFIG_IMX_SCU) */ +static inline +int imx_sc_seco_build_info(struct imx_sc_ipc *ipc, uint32_t *version, + uint32_t *commit) +{ + return -EOPNOTSUPP; +} + +static inline +int imx_sc_seco_secvio_enable(struct imx_sc_ipc *ipc) +{ + return -EOPNOTSUPP; +} + +static inline +int imx_sc_seco_secvio_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data0, u32 *data1, u32 *data2, u32 *data3, + u32 *data4, u8 size) +{ + return -EOPNOTSUPP; +} + +static inline +int imx_sc_seco_secvio_dgo_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data) +{ + return -EOPNOTSUPP; +} +#endif /* IS_ENABLED(CONFIG_IMX_SCU) */ + +#endif /* _SC_SECO_API_H */ From patchwork Thu Nov 7 05:42:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vabhav Sharma X-Patchwork-Id: 13865817 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2062.outbound.protection.outlook.com [40.107.241.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98CBA194137 for ; Thu, 7 Nov 2024 05:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730958180; cv=fail; b=CDFrnuvH+SuQLIqN3ihJnHBP3tYE8yoddGgYU59UKbVhTZjaO4V4f9NM3LEO9FVjTgsd/X/z/bO2xMO9/UVcOVahuxtYswYMfBwYLKdxlOHctd+hz53Pe8BGL5lIZX/+R2iqHhezqygWmwLKxiVGoJZhycvMr8gwcBS8WDGpNx0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730958180; c=relaxed/simple; bh=6Wh1nnvOZxSB2zqYpBzrBf+rgP9lyzP2CZ6qk4kVRhg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=PsflAKFZoe/hClHScpwDKWo23kJGFGUBCZbXkNVWlxRfDGqW7bL8+kYMuMtOMtayM1wpb9NzZXaao/xUnTo1G/0YZGtTEEMBbV+gNQO18PGYZy1LRGxsgMmzwKSJd0uuiUDDBLsSYwsUxjoWqyn/5hSiY/q57HsmZo8UtNcsG/4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=BYVUZW27; arc=fail smtp.client-ip=40.107.241.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="BYVUZW27" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wbRplHVrBJHdbKgypomsVzkcqNXJecR9S6LNQTZkvjae43SohcctGPBVItn/ctIotqP3WhLoQ8MRLYQBpBbIPIBSUFLY4ZzsSntfLk1uQGmn+nncpwwsVGCoB5o9xrRmfKhYHXdh7MfSty4p9uqglOeUEQDx3OtDYt3jkE34WiIsQ5TefGktG0mU1dV1nwJg8H0N3ksVtFtex+8qs1+mvSKq2qX1YltCkBiNnOGgmIujbX/c2lFk87oTFpmuGIqvLGencrJi0wd04g1Gm1wPJNHrFNTGbYfbmsyuQvIP9qXiRFCpRIXERGv7LxE2dpTwTo1ZKtvbPG2gsliwj5lmCQ== 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=lbsNMMSEdEySZREFxqPanmzzEK6cL/wppYKkEF+Gfv0=; b=PQELNmXDygp3QEjBu74SYoSy5wWO/CS/6PxvuSFcGR7YrzzmjYPjHZs2rnwifbfRTF3DesLJ3nmtF5tupb3l/xm8yDEo1ohG0A/b5e7GmmjpXpgR7nDqipyRkvIWB5t484/XQyQJuMdpoYM6NYvDuhX/lG2WP0J3nft8btcSykTeweDo+hrGLees8vPQMZFk1o3NPbKElpho7FCzd4I1Lu0W9WN53zobsTVJu+IlRZBjeSmRGouximFi9eyQhkWXQ6UzqThFwDuCjv3YJZ9vcIfiTcBsbht7NJixdDdRyYHmy+l2Cjsbzlq+3TocNIv+QF9HsDys5814wGCbL801Ng== 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=lbsNMMSEdEySZREFxqPanmzzEK6cL/wppYKkEF+Gfv0=; b=BYVUZW27KWHZTrqVw6jUC3YoeErJvjRRHP5xxWaIBfaIfVBuIX6Obpbp5udkHsrrjXuP9SJsJTYTlCNaYDXuH5I/yIHJMDBr87tw2kuWQMYTF1AxdbQFSm0DjRmvDxO+w7Ywj3BzIcK/fH8xpeCoQmSSLThxZyAPalCCTmEls1iNmRSfQ1e6g6PH8oqr+teFePZteePvcUOVCIAMWtoCgn7nn1Xb9CGXxsDwxjd6I9qbNOYCp/0JpNDpIRf53BcB6RjZeDwd+JwgwchrylImV+IOGiepWpsw7suK4MAQwrJ8mgmqWzgyW3VxJLlsq/65qAmcQCUeT8iHg5j96Uyc9g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9354.eurprd04.prod.outlook.com (2603:10a6:10:36c::10) by AS8PR04MB8434.eurprd04.prod.outlook.com (2603:10a6:20b:406::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 05:42:48 +0000 Received: from DB9PR04MB9354.eurprd04.prod.outlook.com ([fe80::3cd3:1ff0:8bae:a7ab]) by DB9PR04MB9354.eurprd04.prod.outlook.com ([fe80::3cd3:1ff0:8bae:a7ab%4]) with mapi id 15.20.8114.028; Thu, 7 Nov 2024 05:42:48 +0000 From: Vabhav Sharma Date: Thu, 07 Nov 2024 06:42:42 +0100 Subject: [PATCH v3 4/4] firmware: imx: secvio: Add support for SNVS secvio and tamper via SCFW Message-Id: <20241107-secvio-v3-4-ea27f1e9ced4@nxp.com> References: <20241107-secvio-v3-0-ea27f1e9ced4@nxp.com> In-Reply-To: <20241107-secvio-v3-0-ea27f1e9ced4@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Dong Aisheng , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, frank.li@nxp.com, pankaj.gupta@nxp.com, daniel.baluta@nxp.com, silvano.dininno@nxp.com, V.Sethi@nxp.com, meenakshi.aggarwal@nxp.com, Vabhav Sharma , Franck LENORMAND X-Mailer: b4 0.13.0 X-ClientProxiedBy: AS4P192CA0010.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::17) To DB9PR04MB9354.eurprd04.prod.outlook.com (2603:10a6:10:36c::10) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9354:EE_|AS8PR04MB8434:EE_ X-MS-Office365-Filtering-Correlation-Id: c39fdae9-b766-41e8-7a43-08dcfeef0319 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?cup1QMwYiM+6S+SH3fdCyZeulvsQUYP?= =?utf-8?q?b5iHLZJV+4maVHZ77/YkLp7ydf07O5+qhUr/6eeHN7ZBg2NSYJU7aRkLxIRnlVOir?= =?utf-8?q?f/Iu+8zZBHMgCBbc4Y6GgOkCQsqqE/1uaYCUvXt3p/dApQnmHsRYlHqYgcXec2C82?= =?utf-8?q?ZROSbmoeCf4GnJfZafhE5mejTfNsOA/D+svsvCrK/fLwQG9AiTs22TmH10HrXHsKa?= =?utf-8?q?z6EImxO0l2n3ZTtcxgmCUhSZx1fksZEnloRtbaj0MbrRbR9xo5tJQokONA0gKIGRZ?= =?utf-8?q?A8WpuAikBQWM1q9mQLZJHE+ms1CeJ+/4FUsVhVsJjbfePUGybsU4jdTfuTR/B2Eoc?= =?utf-8?q?oYc8q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+kCsw24Fd56oGcfUkGyPMSG6M6ATmmuQlI9auD8VvjmLk4qmi5NrzrG9/+UsLFvN?= =?utf-8?q?3dD/CAuooW+5wYaUeFINLlNdxjbXKmSAo77YJ7QiFbtnDUc0DlZMHQmU=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9354.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?4bOMbnr6Z7afU+EcmkWDWz0wqAYM?= =?utf-8?q?QvX5Tm6R39jmUnUspjiyMsP18i0xltrcWrvF08EiRSNEWy8WM9r8VcWw2YEWcR6DX?= =?utf-8?q?XtCDK20r3lmRWIM8W+lazBg78C8sbsA8sO7J35O7tLnrqUQutl+XvzPYE/a2FOOIO?= =?utf-8?q?PdKZc1b2lXnkYkkDNHExxXIHj35U2GAujrwaHPa7Hbb59UJ2ImxMwjVn95IViTfWW?= =?utf-8?q?v9Cdkj9im5FOVfsE6FYYNbVWNCJvuOdaeeIMgHI6wx3X1piSELzB3Gl1ODmOC2aN9?= =?utf-8?q?DoOTJqn1fAxQXovs7WsYv0tX23bXrmayGapyD5SrkrrCl6wLlCPtjSAh2ApmYk7xr?= =?utf-8?q?9lEE5wp0zVrbeDF6O9oBjjOM70cFOEebW0EpTKQkRraR47bed3NUugw1PpM38Aqe9?= =?utf-8?q?r+CHeh70a0EDG48Frx811ZGB2dwsmWN5P6ah/vRRb8xQeThJBRUs+EQeViGF4/aSP?= =?utf-8?q?wiaFSCGCJYCkaHpMXVmT3RQQEgq52/QCSuNMtZU6D+vziDa1yTRvQsoz768ltVV1u?= =?utf-8?q?uC0cAIGSAB8r3n0bJKycaFJyZCtlJwlQnMj8HsRmaKoRpYvekjEf01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SZsA?= =?utf-8?q?WoNGi2DKx4nQaiy1Zz9JbGgoZ8YV5LrcZtMAZAxYmNgwbYvQdl+LCbjwhUBEHASWR?= =?utf-8?q?4DH7vaALXmTd?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c39fdae9-b766-41e8-7a43-08dcfeef0319 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9354.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 05:42:48.4315 (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: 7tHmPzrcN6OCvzdNReNXakDq/TQzjxcmIffgDv9N0KTn3YEooI+pSkue+jcE0dZmASj4NuUqGoNZKHKYDoz1UA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8434 The i.MX8QXP SoC contains the Secure Non-Volatile Storage (SNVS) block. This block can detect specific hardware attacks.This block can only be accessible using the SCFW API. This module interact with the SCU which relay request to/from the SNVS block to detect if security violation occurred. The driver register an IRQ handle to SCU for security violation interrupt. When an interruption is fired, the driver inform the user. Signed-off-by: Franck LENORMAND Signed-off-by: Vabhav Sharma --- drivers/firmware/imx/Kconfig | 11 + drivers/firmware/imx/Makefile | 2 + drivers/firmware/imx/imx-scu-secvio-debugfs.c | 274 +++++++++++ drivers/firmware/imx/imx-scu-secvio.c | 618 +++++++++++++++++++++++++ drivers/firmware/imx/imx-scu.c | 4 + include/linux/firmware/imx/sci.h | 5 + include/linux/firmware/imx/svc/imx-secvio-sc.h | 216 +++++++++ 7 files changed, 1130 insertions(+) diff --git a/drivers/firmware/imx/Kconfig b/drivers/firmware/imx/Kconfig index 477d3f32d99a..14976bd9f5c6 100644 --- a/drivers/firmware/imx/Kconfig +++ b/drivers/firmware/imx/Kconfig @@ -33,3 +33,14 @@ config IMX_SCMI_MISC_DRV core that could provide misc functions such as board control. This driver can also be built as a module. + +config SECVIO_SC + tristate "NXP SC secvio support" + depends on IMX_SCU + default y + help + If you say yes here you get support for the NXP SNVS security + violation module. It includes the possibility to read information + related to security violations and tampers. It also gives the + possibility to register user callbacks when a security violation + occurs. diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 7aaecf570c56..80a2bd4bbc2d 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -2,3 +2,5 @@ obj-$(CONFIG_IMX_DSP) += imx-dsp.o obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o seco.o obj-${CONFIG_IMX_SCMI_MISC_DRV} += sm-misc.o +obj-$(CONFIG_SECVIO_SC) += imx-scu-secvio.o +obj-$(CONFIG_DEBUG_FS) += imx-scu-secvio-debugfs.o diff --git a/drivers/firmware/imx/imx-scu-secvio-debugfs.c b/drivers/firmware/imx/imx-scu-secvio-debugfs.c new file mode 100644 index 000000000000..55bce7d0b7b4 --- /dev/null +++ b/drivers/firmware/imx/imx-scu-secvio-debugfs.c @@ -0,0 +1,274 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019, 2024 NXP + */ + +/* + * The module exposes below files in debugfs: + * - secvio/info: + * * Read: It returns the value of the fuses and SNVS registers which are + * readable and related to secvio and tampers. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include + +static int fuse_reader(struct device *dev, u32 id, u32 *value, u8 mul) +{ + struct imx_secvio_sc_data *data = dev_get_drvdata(dev); + u32 size_to_read = mul * sizeof(u32); + int ret; + + ret = nvmem_device_read(data->nvmem, id, size_to_read, value); + if (ret < 0) { + dev_err(data->dev, "Failed to read fuse %d: %d\n", id, ret); + return ret; + } + + if (ret != size_to_read) { + dev_err(data->dev, "Read only %d instead of %d\n", ret, + size_to_read); + return -ENOMEM; + } + + return 0; +} + +static int snvs_reader(struct device *dev, u32 id, u32 *value, u8 mul) +{ + int ret; + u32 *v1, *v2, *v3, *v4, *v5; + struct imx_secvio_sc_data *data; + + data = dev_get_drvdata(dev); + v1 = NULL; + v2 = NULL; + v3 = NULL; + v4 = NULL; + v5 = NULL; + + switch (mul) { + case 5: + v5 = &value[4]; + fallthrough; + case 4: + v4 = &value[3]; + fallthrough; + case 3: + v3 = &value[2]; + fallthrough; + case 2: + v2 = &value[1]; + fallthrough; + case 1: + v1 = &value[0]; + break; + default: + return -EINVAL; + } + + ret = imx_sc_seco_secvio_config(data->ipc_handle, id, SECVIO_CONFIG_READ, + v1, v2, v3, v4, v5, mul); + if (ret < 0) + dev_err(dev, "Failed to read snvs reg %d: %d\n", id, ret); + + return ret; +} + +static int snvs_dgo_reader(struct device *dev, u32 id, u32 *value, u8 mul) +{ + struct imx_secvio_sc_data *data = dev_get_drvdata(dev); + int ret; + + if (mul != 1) + return -EINVAL; + + ret = imx_sc_seco_secvio_dgo_config(data->ipc_handle, id, + SECVIO_CONFIG_READ, value); + if (ret) + dev_err(dev, "Failed to read snvs dgo reg %d: %d\n", id, ret); + + return ret; +} + +static const struct imx_secvio_info_entry { + int (*reader)(struct device *dev, u32 id, u32 *value, u8 mul); + const char *type; + const char *name; + u32 id; + u8 mul; +} gs_imx_secvio_info_list[] = { + {fuse_reader, "fuse", "trim", 30, 1}, + {fuse_reader, "fuse", "trim2", 31, 1}, + {fuse_reader, "fuse", "ctrim1", 260, 1}, + {fuse_reader, "fuse", "ctrim2", 261, 1}, + {fuse_reader, "fuse", "ctrim3", 262, 1}, + {fuse_reader, "fuse", "ctrim4", 263, 1}, + {fuse_reader, "fuse", "OSC_CAP", 768, 1}, + + {snvs_reader, "snvs", "HPLR", 0x0, 1}, + {snvs_reader, "snvs", "LPLR", 0x34, 1}, + {snvs_reader, "snvs", "HPSICR", 0xc, 1}, + {snvs_reader, "snvs", "HPSVCR", 0x10, 1}, + {snvs_reader, "snvs", "HPSVS", 0x18, 1}, + {snvs_reader, "snvs", "LPSVC", 0x40, 1}, + {snvs_reader, "snvs", "LPTDC", 0x48, 2}, + {snvs_reader, "snvs", "LPSR", 0x4c, 1}, + {snvs_reader, "snvs", "LPTDS", 0xa4, 1}, + {snvs_reader, "snvs", "LPTGFC", 0x44, 3}, + {snvs_reader, "snvs", "LPATCTL", 0xe0, 1}, + {snvs_reader, "snvs", "LPATCLK", 0xe4, 1}, + {snvs_reader, "snvs", "LPATRC1", 0xe8, 2}, + {snvs_reader, "snvs", "LPMKC", 0x3c, 1}, + {snvs_reader, "snvs", "LPSMC", 0x5c, 2}, + {snvs_reader, "snvs", "LPPGD", 0x64, 1}, + {snvs_reader, "snvs", "HPVID", 0xf8, 2}, + + {snvs_dgo_reader, "dgo", "Offset", 0x0, 1}, + {snvs_dgo_reader, "dgo", "PUP/PD", 0x10, 1}, + {snvs_dgo_reader, "dgo", "Anatest", 0x20, 1}, + {snvs_dgo_reader, "dgo", "T trim", 0x30, 1}, + {snvs_dgo_reader, "dgo", "Misc", 0x40, 1}, + {snvs_dgo_reader, "dgo", "Vmon", 0x50, 1}, +}; + +struct imx_secvio_sc_info_seq_data { + struct device *dev; + const struct imx_secvio_info_entry *list; + int size; +}; + +static void *imx_secvio_sc_info_seq_start(struct seq_file *m, loff_t *pos) +{ + struct imx_secvio_sc_info_seq_data *data = m->private; + + /* Check we are not out of bound */ + if (*pos >= data->size) + return NULL; + + return (void *)pos; +} + +static void *imx_secvio_sc_info_seq_next(struct seq_file *m, void *v, loff_t *pos) +{ + /* Increment the counter */ + ++*pos; + + /* call the start function which will check the index */ + return imx_secvio_sc_info_seq_start(m, pos); +} + +static void imx_secvio_sc_info_seq_stop(struct seq_file *m, void *v) +{ +} + +static int imx_secvio_sc_info_seq_show(struct seq_file *m, void *v) +{ + struct imx_secvio_sc_info_seq_data *data = m->private; + const struct imx_secvio_info_entry *e; + int ret; + u32 vals[5]; + int idx; + + idx = *(loff_t *)v; + e = &data->list[idx]; + + /* Read the values */ + ret = e->reader(data->dev, e->id, (u32 *)&vals, e->mul); + if (ret) { + dev_err(data->dev, "Fail to read %s %s (idx %d)\n", e->type, + e->name, e->id); + return 0; + } + + seq_printf(m, "%5s/%-10s(%.3d):", e->type, e->name, e->id); + + /* Loop over the values */ + for (idx = 0; idx < e->mul; idx++) + seq_printf(m, " %.8x", vals[idx]); + + seq_puts(m, "\n"); + + return 0; +} + +static const struct seq_operations imx_secvio_sc_info_seq_ops = { + .start = imx_secvio_sc_info_seq_start, + .next = imx_secvio_sc_info_seq_next, + .stop = imx_secvio_sc_info_seq_stop, + .show = imx_secvio_sc_info_seq_show, +}; + +static int imx_secvio_sc_info_open(struct inode *inode, struct file *file) +{ + struct imx_secvio_sc_info_seq_data *data; + + data = __seq_open_private(file, &imx_secvio_sc_info_seq_ops, sizeof(*data)); + if (!data) + return -ENOMEM; + + data->dev = inode->i_private; + data->list = gs_imx_secvio_info_list; + data->size = ARRAY_SIZE(gs_imx_secvio_info_list); + + return 0; +} + +static const struct file_operations imx_secvio_sc_info_ops = { + .owner = THIS_MODULE, + .open = imx_secvio_sc_info_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release_private, +}; + +static void if_debugfs_remove_recursive(void *dentry) +{ + debugfs_remove_recursive(dentry); +} + +int imx_secvio_sc_debugfs(struct device *dev) +{ + struct imx_secvio_sc_data *data = dev_get_drvdata(dev); + struct dentry *dir; + int ret = 0; + + /* Create a folder */ + dir = debugfs_create_dir(dev_name(dev), NULL); + if (IS_ERR(dir)) { + dev_err(dev, "Failed to create dfs dir\n"); + ret = PTR_ERR(dir); + goto exit; + } + data->dfs = dir; + + ret = devm_add_action(dev, if_debugfs_remove_recursive, data->dfs); + if (ret) { + dev_err(dev, "Failed to add managed action to disable IRQ\n"); + goto remove_fs; + } + + /* Create the file to read info and write to reg */ + dir = debugfs_create_file("info", 0x666, data->dfs, dev, + &imx_secvio_sc_info_ops); + if (IS_ERR(dir)) { + dev_err(dev, "Failed to add info to debugfs\n"); + ret = PTR_ERR(dir); + goto exit; + } + +exit: + return ret; + +remove_fs: + debugfs_remove_recursive(data->dfs); + goto exit; +} diff --git a/drivers/firmware/imx/imx-scu-secvio.c b/drivers/firmware/imx/imx-scu-secvio.c new file mode 100644 index 000000000000..87bd0aade088 --- /dev/null +++ b/drivers/firmware/imx/imx-scu-secvio.c @@ -0,0 +1,618 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019, 2024 NXP + * + */ + +/* + * The i.MX8QXP SoC contains the Secure Non-Volatile Storage (SNVS) block. This + * block can detect specific hardware attacks.This block can only be accessible + * using the SCFW API. + * + * This module interact with the SCU which relay request to/from the SNVS block + * to detect if security violation occurred. + * + * The module exports an API to add processing when a SV is detected: + * - register_imx_secvio_sc_notifier + * - unregister_imx_secvio_sc_notifier + * - imx_secvio_sc_check_state + * - imx_secvio_sc_clear_state + * - imx_secvio_sc_enable_irq + * - imx_secvio_sc_disable_irq + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +/* Reference on the driver_device */ +static struct device *imx_secvio_sc_dev; + +/* Register IDs for sc_seco_secvio_config API */ +#define HPSVS_ID 0x18 +#define LPS_ID 0x4c +#define LPTDS_ID 0xa4 +#define HPVIDR_ID 0xf8 + +#define SECO_MINOR_VERSION_SUPPORT_SECVIO_TAMPER 0x53 +#define SECO_VERSION_MINOR_MASK GENMASK(15, 0) + +static struct platform_driver imx_secvio_sc_driver; +struct platform_device *pdev; +struct device *scdev; + +/* Notifier list for new CB */ +static BLOCKING_NOTIFIER_HEAD(imx_secvio_sc_notifier_chain); + +int register_imx_secvio_sc_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&imx_secvio_sc_notifier_chain, + nb); +} +EXPORT_SYMBOL(register_imx_secvio_sc_notifier); + +int unregister_imx_secvio_sc_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&imx_secvio_sc_notifier_chain, + nb); +} +EXPORT_SYMBOL(unregister_imx_secvio_sc_notifier); + +static void if_imx_scu_irq_register_notifier(void *nb) +{ + imx_scu_irq_register_notifier(nb); +} + +static void if_unregister_imx_secvio_sc_notifier(void *nb) +{ + unregister_imx_secvio_sc_notifier(nb); +} + +static +int imx_secvio_sc_notifier_call_chain(struct secvio_sc_notifier_info *info) +{ + return blocking_notifier_call_chain(&imx_secvio_sc_notifier_chain, 0, + (void *)info); +} + +int imx_secvio_sc_get_state(struct device *dev, + struct secvio_sc_notifier_info *info) +{ + int ret, err = 0; + struct imx_secvio_sc_data *data; + + dev = imx_secvio_sc_dev; + if (!dev) + return -EINVAL; + + data = dev_get_drvdata(dev); + + /* Read secvio status */ + ret = imx_sc_seco_secvio_config(data->ipc_handle, HPSVS_ID, SECVIO_CONFIG_READ, + &info->hpsvs, NULL, NULL, NULL, NULL, 1); + if (ret) { + err = ret; + dev_err(dev, "Fail read secvio config status %d\n", ret); + } + info->hpsvs &= HPSVS_ALL_SV_MASK; + + /* Read tampers status */ + ret = imx_sc_seco_secvio_config(data->ipc_handle, LPS_ID, SECVIO_CONFIG_READ, + &info->lps, NULL, NULL, NULL, NULL, 1); + if (ret) { + err = ret; + dev_err(dev, "Fail read tamper 1 status: %d\n", ret); + } + info->lps &= LPS_ALL_TP_MASK; + + ret = imx_sc_seco_secvio_config(data->ipc_handle, LPTDS_ID, SECVIO_CONFIG_READ, + &info->lptds, NULL, NULL, NULL, NULL, 1); + if (ret) { + err = ret; + dev_err(dev, "Fail read tamper 2 status: %d\n", ret); + } + info->lptds &= LPTDS_ALL_TP_MASK; + + dev_dbg(dev, "Status: %.8x, %.8x, %.8x\n", info->hpsvs, + info->lps, info->lptds); + + return err; +} +EXPORT_SYMBOL(imx_secvio_sc_get_state); + +int imx_secvio_sc_check_state(struct device *dev) +{ + struct secvio_sc_notifier_info info; + int ret; + + dev = imx_secvio_sc_dev; + + ret = imx_secvio_sc_get_state(dev, &info); + if (ret) { + dev_err(dev, "Failed to get secvio state\n"); + return ret; + } + + /* Call chain of CB registered to this module if status detected */ + if (info.hpsvs || info.lps || info.lptds) + if (imx_secvio_sc_notifier_call_chain(&info)) + dev_warn(dev, + "Issues when calling the notifier chain\n"); + + return ret; +} +EXPORT_SYMBOL(imx_secvio_sc_check_state); + +static int imx_secvio_sc_disable_irq(struct device *dev) +{ + int ret; + + if (!dev) + return -EINVAL; + + /* Disable the IRQ */ + ret = imx_scu_irq_group_enable(IMX_SC_IRQ_GROUP_WAKE, IMX_SC_IRQ_SECVIO, + false); + if (ret) { + dev_err(dev, "Cannot disable SCU IRQ: %d\n", ret); + return ret; + } + + return ret; +} + +static int imx_secvio_sc_enable_irq(struct device *dev) +{ + int ret = 0, err; + u32 irq_status; + struct imx_secvio_sc_data *data; + + if (!dev) + return -EINVAL; + + data = dev_get_drvdata(dev); + + /* Enable the IRQ */ + ret = imx_scu_irq_group_enable(IMX_SC_IRQ_GROUP_WAKE, IMX_SC_IRQ_SECVIO, + true); + if (ret) { + dev_err(dev, "Cannot enable SCU IRQ: %d\n", ret); + goto exit; + } + + /* Enable interrupt */ + ret = imx_sc_seco_secvio_enable(data->ipc_handle); + if (ret) { + dev_err(dev, "Cannot enable SNVS irq: %d\n", ret); + goto exit; + } + + /* Unmask interrupt */ + ret = imx_scu_irq_get_status(IMX_SC_IRQ_GROUP_WAKE, &irq_status); + if (ret) { + dev_err(dev, "Cannot unmask irq: %d\n", ret); + goto exit; + } + +exit: + if (ret) { + err = imx_secvio_sc_disable_irq(dev); + if (err) + dev_warn(dev, "Failed to disable the IRQ\n"); + } + + return ret; +} + +static int imx_secvio_sc_notify(struct notifier_block *nb, + unsigned long event, void *group) +{ + struct imx_secvio_sc_data *data = + container_of(nb, struct imx_secvio_sc_data, + irq_nb); + struct device *dev = data->dev; + int ret; + + /* Filter event for us */ + if (!((event & IMX_SC_IRQ_SECVIO) && + (*(u8 *)group == IMX_SC_IRQ_GROUP_WAKE))) + return 0; + + dev_warn(dev, "secvio security violation detected\n"); + + ret = imx_secvio_sc_check_state(dev); + + /* Re-enable interrupt */ + ret = imx_secvio_sc_enable_irq(dev); + if (ret) + dev_err(dev, "Failed to enable IRQ\n"); + + return ret; +} + +int imx_secvio_sc_clear_state(struct device *dev, u32 hpsvs, u32 lps, u32 lptds) +{ + int ret; + struct imx_secvio_sc_data *data; + + dev = imx_secvio_sc_dev; + if (!dev) + return -EINVAL; + + data = dev_get_drvdata(dev); + + ret = imx_sc_seco_secvio_config(data->ipc_handle, HPSVS_ID, SECVIO_CONFIG_WRITE, + &hpsvs, NULL, NULL, NULL, NULL, 1); + if (ret) { + dev_err(dev, "Fail to clear secvio status: %d\n", ret); + return ret; + } + + ret = imx_sc_seco_secvio_config(data->ipc_handle, LPS_ID, SECVIO_CONFIG_WRITE, + &lps, NULL, NULL, NULL, NULL, 1); + if (ret) { + dev_err(dev, "Fail to clear tamper 1 status: %d\n", ret); + return ret; + } + + ret = imx_sc_seco_secvio_config(data->ipc_handle, LPTDS_ID, SECVIO_CONFIG_WRITE, + &lptds, NULL, NULL, NULL, NULL, 1); + if (ret) { + dev_err(dev, "Fail to clear tamper 2 status: %d\n", ret); + return ret; + } + + return ret; +} +EXPORT_SYMBOL(imx_secvio_sc_clear_state); + +static int report_to_user_notify(struct notifier_block *nb, + unsigned long status, void *notif_info) +{ + struct secvio_sc_notifier_info *info = notif_info; + struct imx_secvio_sc_data *data = + container_of(nb, struct imx_secvio_sc_data, + report_nb); + struct device *dev = data->dev; + + /* Information about the security violation */ + if (info->hpsvs & HPSVS_LP_SEC_VIO_MASK) + dev_info(dev, "SNVS secvio: LPSV\n"); + if (info->hpsvs & HPSVS_SW_LPSV_MASK) + dev_info(dev, "SNVS secvio: SW LPSV\n"); + if (info->hpsvs & HPSVS_SW_FSV_MASK) + dev_info(dev, "SNVS secvio: SW FSV\n"); + if (info->hpsvs & HPSVS_SW_SV_MASK) + dev_info(dev, "SNVS secvio: SW SV\n"); + if (info->hpsvs & HPSVS_SV5_MASK) + dev_info(dev, "SNVS secvio: SV 5\n"); + if (info->hpsvs & HPSVS_SV4_MASK) + dev_info(dev, "SNVS secvio: SV 4\n"); + if (info->hpsvs & HPSVS_SV3_MASK) + dev_info(dev, "SNVS secvio: SV 3\n"); + if (info->hpsvs & HPSVS_SV2_MASK) + dev_info(dev, "SNVS secvio: SV 2\n"); + if (info->hpsvs & HPSVS_SV1_MASK) + dev_info(dev, "SNVS secvio: SV 1\n"); + if (info->hpsvs & HPSVS_SV0_MASK) + dev_info(dev, "SNVS secvio: SV 0\n"); + + /* Information about the tampers */ + if (info->lps & LPS_ESVD_MASK) + dev_info(dev, "SNVS tamper: External SV\n"); + if (info->lps & LPS_ET2D_MASK) + dev_info(dev, "SNVS tamper: Tamper 2\n"); + if (info->lps & LPS_ET1D_MASK) + dev_info(dev, "SNVS tamper: Tamper 1\n"); + if (info->lps & LPS_WMT2D_MASK) + dev_info(dev, "SNVS tamper: Wire Mesh 2\n"); + if (info->lps & LPS_WMT1D_MASK) + dev_info(dev, "SNVS tamper: Wire Mesh 1\n"); + if (info->lps & LPS_VTD_MASK) + dev_info(dev, "SNVS tamper: Voltage\n"); + if (info->lps & LPS_TTD_MASK) + dev_info(dev, "SNVS tamper: Temperature\n"); + if (info->lps & LPS_CTD_MASK) + dev_info(dev, "SNVS tamper: Clock\n"); + if (info->lps & LPS_PGD_MASK) + dev_info(dev, "SNVS tamper: Power Glitch\n"); + if (info->lps & LPS_MCR_MASK) + dev_info(dev, "SNVS tamper: Monotonic Counter rollover\n"); + if (info->lps & LPS_SRTCR_MASK) + dev_info(dev, "SNVS tamper: Secure RTC rollover\n"); + if (info->lps & LPS_LPTA_MASK) + dev_info(dev, "SNVS tamper: Time alarm\n"); + + if (info->lptds & LPTDS_ET10D_MASK) + dev_info(dev, "SNVS tamper: Tamper 10\n"); + if (info->lptds & LPTDS_ET9D_MASK) + dev_info(dev, "SNVS tamper: Tamper 9\n"); + if (info->lptds & LPTDS_ET8D_MASK) + dev_info(dev, "SNVS tamper: Tamper 8\n"); + if (info->lptds & LPTDS_ET7D_MASK) + dev_info(dev, "SNVS tamper: Tamper 7\n"); + if (info->lptds & LPTDS_ET6D_MASK) + dev_info(dev, "SNVS tamper: Tamper 6\n"); + if (info->lptds & LPTDS_ET5D_MASK) + dev_info(dev, "SNVS tamper: Tamper 5\n"); + if (info->lptds & LPTDS_ET4D_MASK) + dev_info(dev, "SNVS tamper: Tamper 4\n"); + if (info->lptds & LPTDS_ET3D_MASK) + dev_info(dev, "SNVS tamper: Tamper 3\n"); + + return 0; +} + +static void if_imx_secvio_sc_disable_irq(void *dev) +{ + imx_secvio_sc_disable_irq(dev); +} + +static int imx_secvio_sc_open(struct inode *node, struct file *filp) +{ + filp->private_data = node->i_private; + + return 0; +} + +static long imx_secvio_sc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct device *dev = file->private_data; + struct secvio_sc_notifier_info info; + int ret; + + switch (cmd) { + case IMX_SECVIO_SC_GET_STATE: + ret = imx_secvio_sc_get_state(dev, &info); + if (ret) + return ret; + + ret = copy_to_user((void *)arg, &info, sizeof(info)); + if (ret) { + dev_err(dev, "Fail to copy info to user\n"); + return -EFAULT; + } + break; + case IMX_SECVIO_SC_CHECK_STATE: + ret = imx_secvio_sc_check_state(dev); + if (ret) + return ret; + break; + case IMX_SECVIO_SC_CLEAR_STATE: + ret = copy_from_user(&info, (void *)arg, sizeof(info)); + if (ret) { + dev_err(dev, "Fail to copy info from user\n"); + return -EFAULT; + } + + ret = imx_secvio_sc_clear_state(dev, info.hpsvs, info.lps, + info.lptds); + if (ret) + return ret; + break; + default: + ret = -ENOIOCTLCMD; + } + + return ret; +} + +static const struct file_operations imx_secvio_sc_fops = { + .owner = THIS_MODULE, + .open = imx_secvio_sc_open, + .unlocked_ioctl = imx_secvio_sc_ioctl, +}; + +static void if_misc_deregister(void *miscdevice) +{ + misc_deregister(miscdevice); +} + +int imx_scu_secvio_init(struct device *np) +{ + int ret; + + scdev = np; + + pdev = platform_device_alloc("imx-secvio-sc", -1); + if (!pdev) { + pr_err("%s: secvio: Failed to allocate secvio device\n", __func__); + return -ENOMEM; + } + + ret = platform_device_add(pdev); + if (ret != 0) { + pr_err("%s: secvio: Failed to add secvio device\n", __func__); + platform_device_put(pdev); + return ret; + } + + ret = platform_driver_register(&imx_secvio_sc_driver); + if (ret != 0) { + pr_err("%s: secvio: Failed to register secvio driver\n", __func__); + platform_device_unregister(pdev); + return ret; + } + + return 0; +} + +static int imx_secvio_sc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct imx_secvio_sc_data *data; + u32 seco_version = 0; + bool own_secvio; + u32 irq_status; + int ret; + + /* Allocate private data */ + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + if (!devres_open_group(dev, NULL, GFP_KERNEL)) + return -ENOMEM; + + data->dev = dev; + + dev_set_drvdata(dev, data); + + data->nvmem = devm_nvmem_device_get(scdev, NULL); + if (IS_ERR(data->nvmem)) { + ret = PTR_ERR(data->nvmem); + + if (ret != -EPROBE_DEFER) + dev_err_probe(dev, ret, "Failed to retrieve nvmem\n"); + + goto clean; + } + + /* Get a handle */ + ret = imx_scu_get_handle(&data->ipc_handle); + if (ret) { + dev_err(dev, "cannot get handle to scu: %d\n", ret); + goto clean; + } + + /* Check the version of the SECO */ + ret = imx_sc_seco_build_info(data->ipc_handle, &seco_version, NULL); + if (ret) { + dev_err(dev, "Failed to get seco version\n"); + goto clean; + } + + if ((seco_version & SECO_VERSION_MINOR_MASK) < + SECO_MINOR_VERSION_SUPPORT_SECVIO_TAMPER) { + dev_err(dev, "SECO version %.8x doesn't support all secvio\n", + seco_version); + ret = -EOPNOTSUPP; + goto clean; + } + + /* Init debug FS */ + ret = imx_secvio_sc_debugfs(dev); + if (ret) { + dev_err(dev, "Failed to set debugfs\n"); + goto clean; + } + + /* Check we own the SECVIO */ + ret = imx_sc_rm_is_resource_owned(data->ipc_handle, IMX_SC_R_SECVIO); + if (ret < 0) { + dev_err(dev, "Failed to retrieve secvio ownership\n"); + goto clean; + } + + own_secvio = ret > 0; + if (!own_secvio) { + dev_err(dev, "Secvio resource is not owned\n"); + ret = -EPERM; + goto clean; + } + + /* Check IRQ exists and enable it */ + ret = imx_scu_irq_get_status(IMX_SC_IRQ_GROUP_WAKE, &irq_status); + if (ret) { + dev_err(dev, "Cannot get IRQ state: %d\n", ret); + goto clean; + } + + ret = imx_secvio_sc_enable_irq(dev); + if (ret) { + dev_err(dev, "Failed to enable IRQ\n"); + goto clean; + } + + ret = devm_add_action_or_reset(dev, if_imx_secvio_sc_disable_irq, dev); + if (ret) { + dev_err(dev, "Failed to add managed action to disable IRQ\n"); + goto clean; + } + + /* Register the notifier for IRQ from SNVS */ + data->irq_nb.notifier_call = imx_secvio_sc_notify; + ret = imx_scu_irq_register_notifier(&data->irq_nb); + if (ret) { + dev_err(dev, "Failed to register IRQ notification handler\n"); + goto clean; + } + + ret = devm_add_action_or_reset(dev, if_imx_scu_irq_register_notifier, + &data->irq_nb); + if (ret) { + dev_err(dev, "Failed to add action to remove irq notif\n"); + goto clean; + } + + /* Register the notification for reporting to user */ + data->report_nb.notifier_call = report_to_user_notify; + ret = register_imx_secvio_sc_notifier(&data->report_nb); + if (ret) { + dev_err(dev, "Failed to register report notif handler\n"); + goto clean; + } + + ret = devm_add_action_or_reset(dev, if_unregister_imx_secvio_sc_notifier, + &data->report_nb); + if (ret) { + dev_err(dev, "Failed to add action to remove report notif\n"); + goto clean; + } + + /* Register misc device for IOCTL */ + data->miscdev.name = devm_kstrdup(dev, "secvio-sc", GFP_KERNEL); + data->miscdev.minor = MISC_DYNAMIC_MINOR; + data->miscdev.fops = &imx_secvio_sc_fops; + data->miscdev.parent = dev; + ret = misc_register(&data->miscdev); + if (ret) { + dev_err(dev, "failed to register misc device\n"); + return ret; + } + + ret = devm_add_action_or_reset(dev, if_misc_deregister, &data->miscdev); + if (ret) { + dev_err(dev, "Failed to add action to unregister miscdev\n"); + goto clean; + } + + imx_secvio_sc_dev = dev; + + /* Process current state of the secvio and tampers */ + imx_secvio_sc_check_state(dev); + + devres_remove_group(dev, NULL); + + return ret; + +clean: + devres_release_group(dev, NULL); + + return ret; +} + +static struct platform_driver imx_secvio_sc_driver = { + .driver = { + .name = "imx-secvio-sc", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .probe = imx_secvio_sc_probe, +}; diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c index c96dc73689a8..5c27a767fe2f 100644 --- a/drivers/firmware/imx/imx-scu.c +++ b/drivers/firmware/imx/imx-scu.c @@ -339,6 +339,10 @@ static int imx_scu_probe(struct platform_device *pdev) dev_warn(dev, "failed to enable general irq channel: %d\n", ret); + ret = imx_scu_secvio_init(dev); + if (ret) + dev_warn(dev, "failed to initialize secvio: %d\n", ret); + dev_info(dev, "NXP i.MX SCU Initialized\n"); return devm_of_platform_populate(dev); diff --git a/include/linux/firmware/imx/sci.h b/include/linux/firmware/imx/sci.h index 947e49d8bebc..08237fa47c3d 100644 --- a/include/linux/firmware/imx/sci.h +++ b/include/linux/firmware/imx/sci.h @@ -27,7 +27,12 @@ int imx_scu_irq_unregister_notifier(struct notifier_block *nb); int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable); int imx_scu_irq_get_status(u8 group, u32 *irq_status); int imx_scu_soc_init(struct device *dev); +int imx_scu_secvio_init(struct device *dev); #else +static inline int imx_scu_secvio_init(struct device *dev) +{ + return -EOPNOTSUPP; +} static inline int imx_scu_soc_init(struct device *dev) { return -EOPNOTSUPP; diff --git a/include/linux/firmware/imx/svc/imx-secvio-sc.h b/include/linux/firmware/imx/svc/imx-secvio-sc.h new file mode 100644 index 000000000000..d8c9208217fe --- /dev/null +++ b/include/linux/firmware/imx/svc/imx-secvio-sc.h @@ -0,0 +1,216 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019, 2024 NXP + */ + +#ifndef _MISC_IMX_SECVIO_SC_H_ +#define _MISC_IMX_SECVIO_SC_H_ + +#include +#include +#include + +/* Bitmask of the security violation status bit in the HPSVS register */ +#define HPSVS_LP_SEC_VIO_MASK BIT(31) +#define HPSVS_SW_LPSV_MASK BIT(15) +#define HPSVS_SW_FSV_MASK BIT(14) +#define HPSVS_SW_SV_MASK BIT(13) +#define HPSVS_SV5_MASK BIT(5) +#define HPSVS_SV4_MASK BIT(4) +#define HPSVS_SV3_MASK BIT(3) +#define HPSVS_SV2_MASK BIT(2) +#define HPSVS_SV1_MASK BIT(1) +#define HPSVS_SV0_MASK BIT(0) + +/* Bitmask of all security violation status bit in the HPSVS register */ +#define HPSVS_ALL_SV_MASK (HPSVS_LP_SEC_VIO_MASK | \ + HPSVS_SW_LPSV_MASK | \ + HPSVS_SW_FSV_MASK | \ + HPSVS_SW_SV_MASK | \ + HPSVS_SV5_MASK | \ + HPSVS_SV4_MASK | \ + HPSVS_SV3_MASK | \ + HPSVS_SV2_MASK | \ + HPSVS_SV1_MASK | \ + HPSVS_SV0_MASK) + +/* + * Bitmask of the security violation and tampers status bit in the LPS register + */ +#define LPS_ESVD_MASK BIT(16) +#define LPS_ET2D_MASK BIT(10) +#define LPS_ET1D_MASK BIT(9) +#define LPS_WMT2D_MASK BIT(8) +#define LPS_WMT1D_MASK BIT(7) +#define LPS_VTD_MASK BIT(6) +#define LPS_TTD_MASK BIT(5) +#define LPS_CTD_MASK BIT(4) +#define LPS_PGD_MASK BIT(3) +#define LPS_MCR_MASK BIT(2) +#define LPS_SRTCR_MASK BIT(1) +#define LPS_LPTA_MASK BIT(0) + +/* + * Bitmask of all security violation and tampers status bit in the LPS register + */ +#define LPS_ALL_TP_MASK (LPS_ESVD_MASK | \ + LPS_ET2D_MASK | \ + LPS_ET1D_MASK | \ + LPS_WMT2D_MASK | \ + LPS_WMT1D_MASK | \ + LPS_VTD_MASK | \ + LPS_TTD_MASK | \ + LPS_CTD_MASK | \ + LPS_PGD_MASK | \ + LPS_MCR_MASK | \ + LPS_SRTCR_MASK | \ + LPS_LPTA_MASK) + +/* + * Bitmask of the security violation and tampers status bit in the LPTDS + * register + */ +#define LPTDS_ET10D_MASK BIT(7) +#define LPTDS_ET9D_MASK BIT(6) +#define LPTDS_ET8D_MASK BIT(5) +#define LPTDS_ET7D_MASK BIT(4) +#define LPTDS_ET6D_MASK BIT(3) +#define LPTDS_ET5D_MASK BIT(2) +#define LPTDS_ET4D_MASK BIT(1) +#define LPTDS_ET3D_MASK BIT(0) + +/* + * Bitmask of all security violation and tampers status bit in the LPTDS + * register + */ +#define LPTDS_ALL_TP_MASK (LPTDS_ET10D_MASK | \ + LPTDS_ET9D_MASK | \ + LPTDS_ET8D_MASK | \ + LPTDS_ET7D_MASK | \ + LPTDS_ET6D_MASK | \ + LPTDS_ET5D_MASK | \ + LPTDS_ET4D_MASK | \ + LPTDS_ET3D_MASK) + +/* Access for sc_seco_secvio_config API */ +#define SECVIO_CONFIG_READ 0 +#define SECVIO_CONFIG_WRITE 1 + +/* Internal Structure */ +struct imx_secvio_sc_data { + struct device *dev; + + struct imx_sc_ipc *ipc_handle; + + struct notifier_block irq_nb; + struct notifier_block report_nb; + + struct nvmem_device *nvmem; + + struct miscdevice miscdev; + +#ifdef CONFIG_DEBUG_FS + struct dentry *dfs; +#endif + + u32 version; +}; + +/* Struct for notification */ +/** + * struct secvio_sc_notifier_info - Information about the status of the SNVS + * @hpsvs: status from register HPSVS + * @lps: status from register LPS + * @lptds: status from register LPTDS + */ +struct secvio_sc_notifier_info { + u32 hpsvs; + u32 lps; + u32 lptds; +}; + +/** + * register_imx_secvio_sc_notifier() - Register a notifier + * + * @nb: The notifier block structure + * + * Register a function to notify to the imx-secvio-sc module. The function + * will be notified when a check of the state of the SNVS happens: called by + * a user or triggered by an interruption form the SNVS. + * + * The struct secvio_sc_notifier_info is passed as data to the notifier. + * + * Return: 0 in case of success + */ +int register_imx_secvio_sc_notifier(struct notifier_block *nb); + +/** + * unregister_imx_secvio_sc_notifier() - Unregister a notifier + * + * @nb: The notifier block structure + * + * Return: 0 in case of success + */ +int unregister_imx_secvio_sc_notifier(struct notifier_block *nb); + +/** + * imx_secvio_sc_get_state() - Get the state of the SNVS + * + * @dev: Pointer to the struct device of secvio + * @info: The structure containing the state of the SNVS + * + * Return: 0 in case of success + */ +int imx_secvio_sc_get_state(struct device *dev, struct secvio_sc_notifier_info *info); + +/** + * imx_secvio_sc_check_state() - Check the state of the SNVS + * + * If a security violation or a tamper is detected, the list of notifier + * (registered using register_imx_secvio_sc_notifier() ) will be called + * + * @dev: Pointer to the struct device of secvio + * + * Return: 0 in case of success + */ +int imx_secvio_sc_check_state(struct device *dev); + +/** + * imx_secvio_sc_clear_state() - Clear the state of the SNVS + * + * @dev: Pointer to the struct device of secvio + * @hpsvs: Value to write to HPSVS register + * @lps: Value to write to LPS register + * @lptds: Value to write to LPTDSregister + * + * The function will write the value provided to the corresponding register + * which will clear the status of the bits set. + * + * Return: 0 in case of success + */ +int imx_secvio_sc_clear_state(struct device *dev, u32 hpsvs, u32 lps, u32 lptds); + +/* Commands of the ioctl interface */ +enum ioctl_cmd_t { + GET_STATE, + CHECK_STATE, + CLEAR_STATE, +}; + +/* Definition for the ioctl interface */ +#define IMX_SECVIO_SC_GET_STATE _IOR('S', GET_STATE, \ + struct secvio_sc_notifier_info) +#define IMX_SECVIO_SC_CHECK_STATE _IO('S', CHECK_STATE) +#define IMX_SECVIO_SC_CLEAR_STATE _IOW('S', CLEAR_STATE, \ + struct secvio_sc_notifier_info) + +#ifdef CONFIG_DEBUG_FS +int imx_secvio_sc_debugfs(struct device *dev); +#else +static inline +int imx_secvio_sc_debugfs(struct device *dev) +{ + return 0; +} +#endif /* CONFIG_DEBUG_FS */ +#endif /* _MISC_IMX_SECVIO_SC_H_ */