From patchwork Mon Oct 30 09:58:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440334 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 5E29EC4332F for ; Mon, 30 Oct 2023 10:00:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HUizLNkR1lX9ac5gdn2PqX+yDkFziCu+X1kDdk0nqa4=; b=IKU7d9FoUJUB7m FMFmCBqN7KzOFwHUWWhnLVj52+zghZwBcV6I7tRdJCfBBV/N1VrWAZLOrdHCsk2KhVZL0ae+OyeaP l7vtTlMVv+BJoy2djgRFYy6Kq1j/iSDk1nuuCCQzmyk626rHAYD0B8nNh9FpH7qHXwXP9GYrUnf9g OXKCyX1YA9E+T6kllc1vhEJNIe8yszlIh3oEgU5Xrq0gs57PXD0aezpZDfOQlv1xwrIoSQJHUogs+ liXT0kzLm5XS+l7R+YGjSyfe5vPW9LWAptLdsFmnVIRpBFjawoUin5IYbRLU21CVyvGyWHvaT8Eaa tlWXi05SCvm6tiRKFh3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxP3i-002xi1-2n; Mon, 30 Oct 2023 09:59:46 +0000 Received: from mail-db5eur01on0629.outbound.protection.outlook.com ([2a01:111:f400:fe02::629] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP3Z-002xfA-0R for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 09:59:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IXEk5emtCANSm/GQFZzFecoDBbL7OrfQKPtxM/9tgcfD8LBIKP5Zvnu2BqQb/ZkACiHhTozpAifvQFSnhgJOKql+KhDJta80RVLNNpgUs51jL2XW3WBjYjBofMZWlWpNjrtDZ/oILmhNK/+YUejyEFiykuQABxo7rEyPaN0nLNNeqk5YqWOt/s6RqlL9vVq0z+s05lgTlBzb3q1GMdjqRbet9pN3nne4U68C+OE+cTD+rLJvujcMjFik26etMt/p+qrRaaYHsZS/drxFP3h/L+jrKobHyu1VBrtawCC7tctPnCIlsdjqpy+q9qGfZkePYZouZOhZSZzCrnYn+3Xf+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=G4Qg/nbJczaWykdnPsCprrI5TVjM058N/677FUPGEhU=; b=If2mqbR015EsVROkB90PJkimzcX7EixobjwA8gdLL2Yuyri90Vm84VL3e6WmIb3++s3Uen7BJgigU6b2t6tNuDoOXax1EHI9YBUQxkWAktWho6FEnSmJK6IAJxmOOmz9yvMoEuPLUaT0LJoNG9au91qHeLUSc3okXpfBMezTrWhzztoM9tzVUFOaEbqP8u5YfmEqf1OwYz0K/+J1S/NsTWxAkFpnEV0Btk9bw88oMCYONzi6CbUXJLkoZOY64ss7f+FoKj3ux3Ytr1VtSeQSwJqq7AA8/psZ4jQ5+wNAKJd31g15sVKogiolGQRYpCKKWudzFDy/MOVoRJC3rlS0mA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G4Qg/nbJczaWykdnPsCprrI5TVjM058N/677FUPGEhU=; b=S/mPxkRJ/9RAqP2196VOphhtoS0TVPK8pD9uJkRJVHMNqqgf1NlRaYwzSEyL3y8QQvhcgEmfLO3WDPwtZekB+BWKP8AQA7S6Wz2cWk9igSXXHOazyCBaMxWvUYBgjOyhZPXFsH0c2/vQ5OBo2vv07Z4/4aMsgft+i28oKE17wCg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB8513.eurprd04.prod.outlook.com (2603:10a6:20b:340::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Mon, 30 Oct 2023 09:59:33 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 09:59:33 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta Subject: [PATCH v7 01/11] Documentation/firmware: added imx/se-fw to other_interfaces Date: Mon, 30 Oct 2023 15:28:39 +0530 Message-Id: <20231030095849.3456820-2-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8513:EE_ X-MS-Office365-Filtering-Correlation-Id: 53b115ca-6c50-4a36-6ad9-08dbd92eeae6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BpffQoUJgjg5PEsGLsAWqBG9Lr5vV8WGKipRKVv8aPWxbErWpKug7DxU6kc91TAMAA5Z4KAfRDs/lYR+XnqJ7BzQ1/DI0TYVrTheZkOFv7lvxtBUJsW0tZzEC36wn0A1Sn1bwZxff4jpuLul9BaEubueiObkYM+v2Qsn3su3Cmdd/AzFw84KrT4jod8fkA2fhIcKv0zRHVG6ogqYsCz47VjdgISwdrcEF0i5PIT3FJIOrL122kb1lpF0T3xgJRZb6KvYYWVq1+mERAYhGIj/SO8Bss4xr2MTg5TUjbcD4/QLae830JaSMgrPdVZzOF3k98Jkbz91JxUMwxCIjxPtiqR4hn9FP0hyjcYr/Nl5a9j+nrVABMg+2c8rtNwCf8ogXUznjbjphJDCCckqYJ7Y0+bu0NHZh5s+2Xexhjv8fsVg2O+JIEwSFwxVfk7CURzzbzAxmWDD9L5ERvThvo/sZqQhVMl4HRTjATUEBweJzdCHe5bKC5YF4QmklSpxn5RH6GAjcn4AJGTBiT8py7kJZk6EoA9vKRAEcWXM9u/Kx1KLfUzdpL+IcvcZ3/YxEa4W4JaUnvNPg8adngj5XGWtcFlsw8I0V2EDMELw1RfQvOP1lEyhleq+8ZbHjpQykjAIjiJ0IwFBRJw1qayTf94VzQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(396003)(39860400002)(376002)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(478600001)(66946007)(6486002)(6506007)(83380400001)(36756003)(38100700002)(66556008)(1076003)(2616005)(66476007)(2906002)(41300700001)(26005)(52116002)(6512007)(44832011)(86362001)(38350700005)(921008)(6636002)(8676002)(4326008)(5660300002)(8936002)(316002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0UKeSRMtVnI8ldhlJzyEnPfm3fKES/GOPwEY9MVj40MXOGwsk2RecPIC/AcSYHmXtsaNkEh9LAhxn68zJzFcLB3GHM8tbEEnEUSeHp+J9d4BOcUKEoyaH69BgNzPYaEnXy5uCRhxq8H6rkTpokbXMA8+gsLeHCh9+Eov0AdNJbm/OYo7ILBtetWxnnHpn1e5ItlXry1qLkjad+/nMz/Ozqt+EEYgRIcEL6O4jIqD0ty/7zZGFxgst+XWg2MTwfKn8Oeb34Q2g+X2IVAjUq30VS7APTkEWhfRUbROFWHl2e8UZzKrdR3TQ6Wb8bwwi5z8kgtLpPRYEqj6DiMh2myo+ougULLrJDAuRmN4/min7CmehauDInbL7YbYTMpwukF+EBG+yGocHMLvue2bP0NFZpBrB8uZUyVp6iNlz9yj0aZkc2jaupeM01kEx8MVhgDbFB0UWWadjuSsyb96X1Hg2E1nLDa3dG8Q4TsOkw81OCf2flF071EqR+D8lxbsQhbovP+aHPsDd867lSkI/4BA0WQngKLVMBOrEY6IZMItbKaD9ieBrdqSIny1cT49fMp938vQ6cJ+jUFQzx5PM6LFfZ2KQuPru8/DQMHSkIHo+Wdas1MSxKCIy5ndxPM25spVpgAIixCti4kaBYeWJzWeNFN0wGcPZ+neEu4KQRl8ddU5ul2Ephaii7A2zcQt0qmHxtY2r/4s6HWLKhCTslIk7l13vw9C0RKvA89I7rtMJFwRILjWCOpZmZRC/b3Mmv3A3gv4Dporigd8UAyAcof2OgvQe6hsF/TWmtfPRgfeB/BM4WSKbZTUg9Eyx9WNpvdV4Eqon6zlWNDsGAHEIjTRz0O3QwdZJADHLQLVAf7qnCa4JnHTwtXNa2o/J91bY2TpUW0EjMIdBcf2H/u7Ze8PgxFz2/Dskq72mwPs7WKSCrjMTCqeUuYrLvgJfp2osuvX+gGxG7Vw+rbJco3N0Jt17sMSOK2EbJJSoqMSmhjdpB/y5G3vXjZy1d8xp04Y5rhbZFOZdat1jzJCGtaS7A/+kfITOYZfKUsfyw6ArcQl6rjH24aubDE1jJ9l3bF80ScNXtgmKuYlDCd3dcAIv7OrDJ3tln4uFj+s85c4CN9GATFXmlZgUrDZ61xvXD82Zisv91rf5lqnpcLXE3BObYs3JBj8Vr2mn8pZ2rJTDyGxYNfsLv/arWcKrRmzMdwLuZP27lLymOFHvq34DMHenpHHf7+W2A/FWxGupLXvCvn9NnRHCe1GMd2zY5Yrty2eRAHPCfnW8cWl8Wy982nrZzwkgeEmP/fImIyko8mpBcQol2CTcsMkNSxa21E1PS7nvcgmHVuAEcdSG5neXrNcxxIrX6aAVq+PLif1R8rDtC9JI/hjluaSXESNaB+wNKe4zAWiEfdFxOctnQR7WB7WBvbMJXQapsOMdFfPgQb34qE4dur+mFDQHXfPWSBpHXEo3CAD/C3fzJHifVD52F9QImFyC7BEvgHk56A5JyG9PH39x5iwMewGryDrud68Yt7AXgt040Nt1OqTyNXWzF0lsvviLeTy8EC1C6IfxvY93Tcfx+OGm9YRPkwWiRsasqJWMhi/ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53b115ca-6c50-4a36-6ad9-08dbd92eeae6 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 09:59:33.7683 (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: zoBg5LCOtPkQr08EUsiYEsoj3Y/yokmrFSd9j9uNQu/zlzZn7rqTjgjXkWMm5n03d5h2nBJcLRy71WkhQqgIHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8513 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_025937_177831_DF963793 X-CRM114-Status: GOOD ( 12.49 ) 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 Documented i.MX SoC's Service layer and C_DEV driver for SoC(s) enabled with hardware IP for secure-enclaves like: - edgelock enclave on i.MX93 & i.MX8ULP Signed-off-by: Pankaj Gupta --- .../driver-api/firmware/other_interfaces.rst | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/Documentation/driver-api/firmware/other_interfaces.rst b/Documentation/driver-api/firmware/other_interfaces.rst index 06ac89adaafb..1d21b88ef20e 100644 --- a/Documentation/driver-api/firmware/other_interfaces.rst +++ b/Documentation/driver-api/firmware/other_interfaces.rst @@ -49,3 +49,70 @@ of the requests on to a secure monitor (EL3). .. kernel-doc:: drivers/firmware/stratix10-svc.c :export: + +NXP i.MX Secure Enclave Enabled SoC Service layer and C_DEV driver +------------------------------------------------------------------ +The NXP's i.MX HW IP like EdgeLock-Enclave, creating an embedded secure +enclave within the SoC boundary to enable features like + - HSM + - SHE + - V2X + +SoC enabled with the NXP i.MX secure enclave IP(s) like EdgeLock-Enclave(ELE), +are: i.MX93, i.MX8ULP. + +This driver exposes two interfaces: +- service layer: This layer takes the two mutex locks: + "mu_cmd_lock" is taken to ensure one service is processed at a time. This + lock is not unlocked, till one service processing is complete. Multiple + messages can be exchanged with FW as part of one service processing. + "mu_lock" is taken to ensure one message is sent over MU at a time. This + lock is unlocked, post sending the message. + +- c_dev: + This driver configures multiple misc-devices on the MU, to exchange + messages from User-space application and NXP's Edgelocke Enclave firmware. + The driver ensures that the messages must follow the following protocol + defined. + + Non-Secure + Secure + | + | + +---------+ +-------------+ | + | se_fw.c +<---->+imx-mailbox.c| | + | | | mailbox.c +<-->+------+ +------+ + +---+-----+ +-------------+ | MU X +<-->+ ELE | + | +------+ +------+ + +----------------+ | + | | | + v v | + logical logical | + receiver waiter | + + + | + | | | + | | | + | +----+------+ | + | | | | + | | | | + device_ctx device_ctx device_ctx | + | + User 0 User 1 User Y | + +------+ +------+ +------+ | + |misc.c| |misc.c| |misc.c| | + kernel space +------+ +------+ +------+ | + | + +------------------------------------------------------ | + | | | | + userspace /dev/ele_muXch0 | | | + /dev/ele_muXch1 | | + /dev/ele_muXchY | + | + +When a user sends a command to the firmware, it registers its device_ctx +as waiter of a response from firmware. + +Enclave's Firmware owns the storage management, over linux filesystem. +For this c_dev provisions a dedicated slave device called "receiver". + +.. kernel-doc:: drivers/firmware/imx/se_fw.c + :export: From patchwork Mon Oct 30 09:58:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440335 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 D305CC4332F for ; Mon, 30 Oct 2023 10:00:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jz+1iCnHZEO8U333s/9ZPJy1/D+yQ60w3z/xXKGeHHM=; b=ZFYmr6xpe7lYwo /GgEDE135yVLzq0RBNFtWHfa9BqUa3/HSquzN2f0Q8JGikzJ3N3DhpnPcNxjNV8LchYktLc+LC35H 9itWGHm8Czrc6qkB2uiISwddGsPbTM6T5oo43Ewqpjez6PWOZr2MqW0/dhI+7Twkn+pQxGx+8dqLC Kx9HUpPMS2Kip+siAXgj68njEtKOjJph9p5z6/nIBjd/3KMsdR80EloaGYlkaDrRq0h9ZnNagMLqP 8njBsTP5DpmjdYvgmViAmPBzuARm5Z1TMZRzPii0YyvVi0l5b3te8Mm7C4C75sUOdQHtvsD6xsp0w niMMrwnN+z70io1PW5Jw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxP3s-002xlM-2q; Mon, 30 Oct 2023 09:59:56 +0000 Received: from mail-vi1eur05on2062f.outbound.protection.outlook.com ([2a01:111:f400:7d00::62f] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP3l-002xiI-2T for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 09:59:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m/jolEP+1HesFZNAFFM/atIcfHGSWRRRCP+3Vj20Jt+92C7/5xV09rLAQ7Bkp8nF1nq9VSuHiKlLFHzvvRxj9Tohfn8I+J+RxqTeHir4fw5Fbyh5bS9wKHHIhQjY8AybYXzFwC1q+YxZ8WxJ9U+Otz8gWwFqgKUsoLXiDft+SOHRurBPfecFGBST9w2pGZxzkilaQBvAQ+BOXojDPQDTttPGURY2hQlm42W8VKstrybLZTwTWXF51HntMykzDuWgcu5ZBKDGphkJO7obdqqy0mnqi70RWy7XJYiC0qHFiMo9Ywuv7Dc5CviDTvSyWYydWfCnElV2hKthdP4xS/v7hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=8jOsfYW5YiYUH97W+EJOHzghkLPb11X94CYd1L8+SDc=; b=oPWb66prv1+Eb/oVTbFhL3251IHYxmS3nDzMCE/qod++wz9mAy34UnyNRYK0INUjt+w8s1H3nLZ0PF4IJ0bRzZoNAJ1wnP2jztMpIMO/IOL1nemukWLvRCCP0kt/U/+xc8X1AQmSv3Ez3Q06EWwPMcCW9bsvXF5IXyy4tRWs2oz2amJQdngZBVgd8XkPPgg7Gq0e2gY2OAQzQDG7gGpnslM/67wYT9nEIS5IVaPQuqKI3pxh8YHIwEsA77DRthKvlVFNlQaA+Ju6vDG8ziC5LnDqIgC8F+984KsqPc30PfwC+1OrYW/qKTw5bUWbdlHP5Y6PnXh5GPDBHYxy0yUNUg== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8jOsfYW5YiYUH97W+EJOHzghkLPb11X94CYd1L8+SDc=; b=FNHwWN745riyWT3aiWWxMQ5tGdld5UjQ5EVMakVH9/Ep/X5VPPR48tXLTh+k8hUSOKi81Q/uOejlmivt8mRPQTUZP/7Sn0Z7AOY56eyZoXBQx32/nBrBrBvORrHUGk/LWltSzspzvDdW7AMn/iLLBLiHa8XUXsb64XAW9rMcdnk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB8513.eurprd04.prod.outlook.com (2603:10a6:20b:340::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Mon, 30 Oct 2023 09:59:39 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 09:59:39 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta Subject: [PATCH v7 02/11] dt-bindings: arm: fsl: add imx-se-fw binding doc Date: Mon, 30 Oct 2023 15:28:40 +0530 Message-Id: <20231030095849.3456820-3-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8513:EE_ X-MS-Office365-Filtering-Correlation-Id: 83d74eea-b453-43f9-b611-08dbd92eee8a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pAZtpw/N2g5H2lovU5fWQK0TBM2ylQ4S6eXV0oGrjXxgAZU4WZNK582itZpETGPD/kqvl62Mk8pn7ixeXt8AUvxq2osTS3WE9etCKQ2akNciH7XCT9rNNvxH1F+1CZIOh34rclcNkDWzUHLJPv3OvncC/uC4BcN5/O+n+tM0vE4J7DfELXGmg9rs4On2CaI08D9IXyvdxQOqBfDcmmylRU3HF+4kV3RpK/qwWfeAnf4sigvVel7dCCxIFfZmaSGrVjrcMmh+tP3/5eVeFIKF5Gl+yiDVaOTx6ln/TsvUuBwaWZCi+2YIZutyfTWM24odmZZOvO3QKG49zu3mOsThkwHdPqk6mPL3ig+T/H+4RoEt+betKjvkBLbte3VRQm8emrgQ5hVZNwmcjyLDOC+c+0zQipSTaMuXpzQIG6SjOkDOX0uARrle3cqyNpLPWnw9GFzrxt7pjntO9riloy1PV1xSOhg4u2v8bhegc2QCTfyT+aGy1C7mt+PGA10nXpCE7t4sWEGHhVU38ctxHBNYcwEbD+GdjCF1bEs4XXU/1soS7YC8ISSDSu40vdsOt/Cm2scUwzC5j0nwragFUlLv7oPxeAVWCFUta/OXa6XJMHRtSr0v4wCGw4tvrbA8gI00 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(396003)(39860400002)(376002)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(478600001)(6666004)(66946007)(6486002)(6506007)(966005)(83380400001)(36756003)(38100700002)(66556008)(1076003)(2616005)(66476007)(2906002)(41300700001)(26005)(52116002)(6512007)(44832011)(86362001)(38350700005)(921008)(6636002)(8676002)(4326008)(5660300002)(8936002)(316002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z53vTJG0RwtGr1wNtL0B79vUF9NlMRHtCuGKwny+OVY3ognefYnYI+1qOQf8lw80sj5c72EXcAhPY90N+JtgNA3kwuThgnbCz3RfG8pNheO6oyN062hAy/1EuckDe5cwMdOzQZTR77MCALWt4wkc+ZYC1EOwmHlFsRLt4uW/+ZNOvJ9IIoEqGfAwrG1QY8ktJ5qdXiqBN274XhOW/6YRs0pfVZLgUxNicBCCLI8A4bioQIedaMirzFGXjdYb8zAmi5uPzrrmn1tcK8py55QhivGa283i+e/swirMM6kJEuwUreO4wjRL6XtjoL2uVnU2ws2+fwufCjI9ldIqLd6YAshBYWyqkVFmXmxpXusj2oJWRhNT7SMK5gfsMiZazfumgiCUiOxU/g+sghof11HcpFNiltHDBkDktRtfHvFepAPQddTUZ1dkQBEYppYROjkcgLJH5nk7kaLB+QbX43tMeeaGVUkAQk2pOjX6hkMP/znRf9a/76gpeONQWavez0mk43AzxtS4ekpbGame0d7JAeYZzYA1+N5jarYaI+1CW9no09yfSXXpV7kNcwbV9pxFlj7pqE7N04+gD+LfWFZi4ErZ4MdX/WxfodYPKhsqI0WawmL+OwnXV6UDSQqXqo1+JSu8QvBN5XQAlXAYI8k1WyeuvhDydQimNslP27WTLbLrxPgKRl2sols7yH+uhaCADEayB61tE3M13XwfiVPamKQLyAiUtIAsmLN6N/NT6haK9vHYjMKZqM9U0F9v7haCoXUcB5UGQRziQO0Kb91SWzLsg+L/ulTo6+wLF+0DLPjyb6FWRdS/73kbFulESKNiL6NWsl23lICBzi2JGKAOye+Ps3h7Q392eAB6PEBG47MkTecvLx8AT2jUl4aI4oO4FmaP2MdutEmqQjnkZZgNZBwFcas2RLiVLIdxTZ/Af0lZz+P0YvubJ0vuN+t3yTjuSG5QKYFfqH+ZW6hdiE4Qpp0B14kuZput/O1O99VNZDdYwcRT2fTiMxrROl/2pDUtRIZh7kREJuE29bxHJFqU+4OkMuS1FpABGwOCkixYQY2jAg3mMYdlaOjwkp6XnG0+EJ3eORp0SOx1KSot5hccUB+JLnbw8utQfNy3V6dU0nchPJpGH6ktkNb9HxqtFGOxxrwkAYljsDBeZ8gNB86IcD05LTnhZrKBuat/3inta+PNpQrARblFv6NunmnjEKNvO4ZgaPUYdEh3rfHbvZitpo6H6BmdehEOepuOYfFKLYt3YYnalPWbsA9ePE6zqvayoPRAAepMPrQpWk6LDU73DtTZqdH9OSVujOgoudgsQy0qJUtUuu+f4KpD73R640C7ekip4+ORDK911IqG/kNOGL4rwNy2KzdxgH+50e4hdFY7kZebKLLYv8xIwXj7uXASOKBFXTHITj7tO252wnR/4V3naKxbnTxd5UWHjN6ip6HyHf5vJZwD503GKZWL7s1YsyHym2mfk2jRAChhx6EVB+JV1c6zCTaBOWC7q1drD4PxLtWLzvO9wv6iOSI/eunIGCJZIR1gNYg0tKdpp0aTzDX1sO0vlbLt6x8lOXNv9wxTxGgrFAA5xB5XHeHHeFDW X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83d74eea-b453-43f9-b611-08dbd92eee8a X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 09:59:39.8562 (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: J9GBS6bPy3ClENZqCC8UoAH/l2ZcWyhDyB16wPd+d/Qo+rsVU3R+JO/MCZKu0/o/4bm6xKc08f7L1heCUw3jEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8513 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_025949_809124_21613226 X-CRM114-Status: GOOD ( 14.47 ) 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 The NXP's i.MX EdgeLock Enclave, a HW IP creating an embedded secure enclave within the SoC boundary to enable features like - HSM - SHE - V2X Communicates via message unit with linux kernel. This driver is enables communication ensuring well defined message sequence protocol between Application Core and enclave's firmware. Driver configures multiple misc-device on the MU, for multiple user-space applications can communicate on single MU. It exists on some i.MX processors. e.g. i.MX8ULP, i.MX93 etc. Signed-off-by: Pankaj Gupta --- .../bindings/firmware/fsl,imx-se-fw.yaml | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml diff --git a/Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml b/Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file mode 100644 index 000000000000..0503ea497d61 --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/firmware/fsl,imx-se-fw.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP i.MX EdgeLock Enclave Firmware (ELEFW) + +maintainers: + - Pankaj Gupta + +description: + The NXP's i.MX EdgeLock Enclave, a HW IP creating an embedded + secure enclave within the SoC boundary to enable features like + - HSM + - SHE + - V2X + + It uses message unit to communicate and coordinate to pass messages + (e.g., data, status and control) through its interfaces. + +properties: + compatible: + enum: + - fsl,imx8ulp-se-fw + - fsl,imx93-se-fw + + mboxes: + description: + All MU channels must be within the same MU instance. Cross instances are + not allowed. Users need to ensure that used MU instance does not conflict + with other execution environments. + items: + - description: TX0 MU channel + - description: RX0 MU channel + + mbox-names: + items: + - const: tx + - const: rx + + memory-region: + items: + - description: Reserved memory region that can be accessed by firmware. Used for + exchanging the buffers between driver and firmware. + + sram: + description: Phandle to the device SRAM + $ref: /schemas/types.yaml#/definitions/phandle-array + +required: + - compatible + - mboxes + - mbox-names + +allOf: + # memory-region + - if: + properties: + compatible: + contains: + enum: + - fsl,imx8ulp-se-fw + - fsl,imx93-se-fw + then: + required: + - memory-region + else: + not: + required: + - memory-region + +additionalProperties: false + +examples: + - | + se-fw2 { + compatible = "fsl,imx8ulp-se-fw"; + mbox-names = "tx", "rx"; + mboxes = <&s4muap 0 0>, <&s4muap 1 0>; + }; + +... From patchwork Mon Oct 30 09:58:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440337 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 231B9C4332F for ; Mon, 30 Oct 2023 10:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4tEufcF6yWnlNo8d3Pb+AnOrcCdFvWfihYqVb5OZEFg=; b=bonpqISLMGjXqJ 9iG7aFoiU0LodKMty++Hvre2m0XGjCKoehsGxwt4uUvlnLdOaVntiX2n8+Bq6fK4shjS2RFl2igV7 R9+1l0VCXlVylh168W0iJH4lIg/fKi7AZSNJjEnYNgEh2EOQdz15Uc4K1ZUtjeuopk7eZDVxWccrc OeiD11Tm6+G+xFAqeMHZL8MjntImEXklEyJPm58prCEn7uZ5M6PfmgFyOlAkl7ZiuS+22O8f5p8M8 wajwvYOKpYd0gWHHTAN1Kd1JUltZ2jMCILdDVr0SRYmNsVARQFxlgUH81tHv4A/u/x7boxghr/SUX +fAKNm/zQvpMYLzxPKIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxP3t-002xlj-1N; Mon, 30 Oct 2023 09:59:57 +0000 Received: from mail-vi1eur05on2062f.outbound.protection.outlook.com ([2a01:111:f400:7d00::62f] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP3n-002xiI-2R for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 09:59:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WQ5qGShrg3YjVoZ1ebBXNGDEuBjb2YPcV7oZjDdRPkukeyhbYiZWvjZdcwzx/tMQvsaIzdr/5KVuqWb8WXnEb0JlwAXsXaO16sFGT5nc2Z1VqAQYtE+ord1SpAMYm1PVUs8W76rgy4u9hHqChpIW9fcYBJEl3CyInUUJMDg33GO+60OylCySaXsjiKzORvq50pw14BAy1K7fcOFxH8+jYbjBB9JdtFBhdXCHVnZ3CcAZGvkvtS2fi3rW+GFmWxW+3KVPCFqE+96XcadgUxQtMFXaOSVBjd9BU/vQWK4il0t+c+SeGjGJHmCY4bR1JIKhYjQmUKHZq4TleXQl3aqzyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=akBPLowOSUrhs+oLGHxOe6fnx90X1v7778B2B188qTg=; b=jgUDuKxfPFHzx9BbRx227W/NuzIxpp5oKR3/aS6DQYIeQoE6QJ/52GigmJL5eH2AaWNV8eNsRe549EpKbvQlKNzlzl9ic2Q9ZeRtmfJGtYsSegafjDniJVybbW5kaDbyxImEkaN9tnoyuWor1GW01MAlwvloUedzLz7cHayByPqhYVO4snFyQxYoIOM4NyJ9pGg6e5WmN/CR8dRoGHAu4tO9G04pxPCycA5U+6uj1gKZXSwbubBqv9dhDb8LiaISvQhWXiKjnEznB9IRpDGRUFsJo1GuJe9EyGX1dLQLdBMaCs6O5JvEC1V4Ty9Um9mo9GknlFx5vdyJD92bgXaHAw== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=akBPLowOSUrhs+oLGHxOe6fnx90X1v7778B2B188qTg=; b=XWvNtVc3vxcqrLd/TTPS/XBC/x2va9fWMEI4Eq8lqIVWf4ianQjq2U3AdIFe7hzX0gfxm6MT8o83EId2V3zmIltmUPmLy/s3RuZudE8JRIOkgHb+zdvKV+a5Alz98kmfJJj1Ims2KxxbsZ+2rogwez687Dwf5eT1uSLcNidU6xI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB8513.eurprd04.prod.outlook.com (2603:10a6:20b:340::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Mon, 30 Oct 2023 09:59:45 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 09:59:45 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta Subject: [PATCH v7 03/11] arm64: dts: imx8ulp-evk: added nxp secure enclave firmware Date: Mon, 30 Oct 2023 15:28:41 +0530 Message-Id: <20231030095849.3456820-4-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8513:EE_ X-MS-Office365-Filtering-Correlation-Id: d6ca4284-c0f3-4df2-dd3a-08dbd92ef1ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kbNmNfaGGiMY+m3C3yFH5TlzXnWUUvHZuv8fy7q3vuMeJW4hJ8ZhbncI89044IJNk/8unAOS16LQ4w3RQBAxGHeigO2Cn2wuewrvaRNryWkMoNkOZdbCr+FWXm00Wx3sUHJJO88ELAqyr/4+iQKYGFLYN6473LbaHBMex+cDz3DikqV7RPubb3vwjsoIi7RmeTK+I7aimg7wZkSf+586qYtf5mr1J1FakgLeAymmw+7Y4er5sr0gVDhd0JtrR7hfNZIiwrgKhdIKNOV7iJWgzT/52U0cRJEWZnh5YTAHi0MJGbHz+N5oZdDy97kV2LM1yJxALeySfdCcjN5AKLTv1a48SprNHqovsATGO4rpPRrUVRaLwcYbnX3N6JRzDWF0nZfgmzRfjYAyKhGt6lf/rhcwdJu7itD1IZfe7u40BdLGXfQzb9VU0QBhnKJcJ3GhRA54mLdso6uMJqEQ68ie2254pNu3r3PWIZK6F4dP6PWEAP6S8yv5YlXiqrqJYQgmHZt9we7J7idAHn00nHBXCBv87/vBcgqxX5AcEh/9Kd/A5VGqtcfInfZCoXbFSuA6zMLo2PkPMo3Xq8gHubVosUPgzB4/vRokc6557mF/45PKCTOwd39L6L4FFw4RQEzmB6NBeAgDt+oCtH9xejZePAzSIa62ebOLbHM7ap5YLP4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(396003)(39860400002)(376002)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(478600001)(6666004)(66946007)(6486002)(6506007)(83380400001)(36756003)(38100700002)(66556008)(1076003)(2616005)(66476007)(2906002)(41300700001)(26005)(52116002)(6512007)(44832011)(86362001)(38350700005)(921008)(4744005)(6636002)(8676002)(4326008)(5660300002)(8936002)(316002)(7416002)(32563001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w6oZH6O8sIsYRlyE6F5rmLX7KpKm6tR8cRGLzdIyGLGgWZqsMFnhSdZDqeWsSRls0KIIokdzz/QvhSMx13lnxmrbXHS3ZQQ13ZGG4QTdQyCLhMx8dDZy5XNK/LrE47GGKayaveVvv9YFbOdQYM+htkc9pk7/0laHvOc0hmd9DhcJUWT2sTRb3iNdcjt884ELK8wEMAH6bUKEdcCZDosuMcLBqZnueAvVqu3Jq7vhcvmTCNUTmTmvpg6hoJc5njyzV10lELzwKQN+b3DI8Jgkr3W5HIi3CdKfq9P3acSKvi6Xot63mFNrxO2BMS+WbBKCNtkmWjLB5pGiOZH3F7Jeme0qUAEIkzhVzq11cB2zBcRhDM2QkWi2Pq14DBOxYPjQXA6IDDHxi9UCEX4+DFtyNQt97Z+VYV6sApi4Z9P5EoHnvV5cABCkZyNUX+CroDVQyfgvjd657xf5gIyG/2rZV7VHobbTQQ8P6h0APQnJZO3+YndOclWDyOxfPqVy/V6ajqvXkZPz7FV/GuCEdav5/r184ktUDiPyd+EMVraMgBi8puKWRAFNugn7D6+engy+7QDbGPfSxiX/TtH6VyRORg9gzzYBHVlrta/KFXdAmvnNVFMJMCMY7Lh9V0O2FCPijjcwWbKu4LtchEzOhTW3nfQrbqS8PQFV4q4MYtAUndS8EN0nhd9zxPoh9NgcrDu/xfsNKm8720fYNYbnMDAf45xYFm0VMP+7x8eyUXbxwucI+8oKSspHUnC0Q/PCC8K0QBbkuYYL36CNb4lw9+ERB4xWyTxD/0QOEY50sQdghcMR1So9VmtykwLUeU7t69o7dlMfCy24PcQ/t2GTv+7Rm8x6SJ5zWTQxJnI3sAo4oLWfAUWYSYAHVgWx9NMeSZC0qRe1UjMy9jzdLk8GthM3V0jt5LFx07B7Y+owTICwErLRtGI51TPVdy49ZfL39S4W+RE8mDQcRbZ46F3aryo84p3P3ZCzYBxDt+BSI3gxnW1YE040KIbZ5MaRvJtjBISt6IhRXcJuQntieR0/l+waKY8rn0C5zTB1K0Te3oTxJMncMpSEt8EvQuS1DyfHl3SfHT7nxm0L9eNwLY5rC7iZQqsSNjL4i33KfXEg/dDAd3unBRZL4tIeNCVILoRk3lePCAe6Ijt8cnCzRE9xqhF4j5JLDrpxFmq88KDUgoJy2qbKeu+4fJUekxchvpy4LfJEB45xLn5dQKTV4VH0svxiGSpnLCCfhHoRHK4TBhPnUDuAmqQmxK+tpZCKHFD4Nq6Rt/eBYMk0+woHqUxL9KTvGTQjO/3XKK1TMDTrpk35NLezJ6ifDKkArPb4U7sJsTAQkdUuuZVVPs7EpyloOZvdoy3NR37A+mzWKF+GZHwjt2Mrd7MgdQCKsFBULnNcU+FqcdARxdYmV+F7TwdpLAcntB6/3P0Vh3iEQ/G0TStk6MJuTn/K+izt7ctwY96uRrXPgBuC/1EmmhDgcRFTt/dT5F4hjbkyPJBDLJZz3OIGmbyNhVgSIw323q/xkCVhehpqSZ+9DVoHiFZ9VdyUxfxIccFkV5r+N1YtKDar4p2YCrmSN46atlDsvH3cGQswyOCe X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6ca4284-c0f3-4df2-dd3a-08dbd92ef1ab X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 09:59:45.2538 (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: bqYTdtqt2W9uFVXMmttSJy4IXkgfQ/z/tdfg3KEsx9tGBPZdGzprLLGIGyOUB2y1DF+vMTLXO0lI9+ntY+XgkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8513 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_025951_797081_6CE1C3C8 X-CRM114-Status: GOOD ( 10.75 ) 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 Added support for NXP secure enclave called EdgeLock Enclave firmware (se-fw) for imx8ulp-evk. Signed-off-by: Pankaj Gupta --- arch/arm64/boot/dts/freescale/imx8ulp.dtsi | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi b/arch/arm64/boot/dts/freescale/imx8ulp.dtsi index 946f2b68d16f..7b66de3a392d 100644 --- a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8ulp.dtsi @@ -152,7 +152,7 @@ sosc: clock-sosc { #clock-cells = <0>; }; - sram@2201f000 { + sram0: sram@2201f000 { compatible = "mmio-sram"; reg = <0x0 0x2201f000 0x0 0x1000>; @@ -578,4 +578,12 @@ gpiod: gpio@2e200080 { gpio-ranges = <&iomuxc1 0 0 24>; }; }; + + ele_fw2: se-fw2 { + compatible = "fsl,imx8ulp-se-fw"; + mbox-names = "tx", "rx"; + mboxes = <&s4muap 0 0>, <&s4muap 1 0>; + sram = <&sram0>; + }; + }; From patchwork Mon Oct 30 09:58:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440336 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 1518FC4167B for ; Mon, 30 Oct 2023 10:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=muKa0H+b2Rn0dRWwW4u9u4OLKomrmXchRtvpT02Dktk=; b=IvYmIsvGpsSntI 8rHO6BOUtEliNIEOvoqRl+i00nKeGDs9hWRAw5aU0mZc+QuFP2uU2Hn90PnVA9ZwAiD8oCnLINtn3 P4f90Heo2tqk9CCvqjf3cAVwB6qJ/y6becGyVszwnu4BIPR/tVzUBx+ruukDJ9vtPSzs0gcfI40LX EPuWfl6bA6mRhCe9zaDGpwKdWf4eEjJ/TDh02HqQTibDqzkr/x14Z+UmYbrbisTFG5hN9awHn/uMg OF+9L8YC4OxWn/9T3ABcOvBmcY5mzevT6U8ikysHYCFCom4B3E5gboV4Xnnce8LoYXWo5yXMNIdna 2RE8HRjTCx5F762IUJqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxP3t-002xmC-37; Mon, 30 Oct 2023 09:59:57 +0000 Received: from mail-vi1eur05on2062f.outbound.protection.outlook.com ([2a01:111:f400:7d00::62f] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP3p-002xiI-1B for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 09:59:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WxMoh2YJZMcydYvrOCvwAYS2C0xMl6SawD+Mdl0rfLB7ZNLlld20z/e7ldgffih0tLZ/tblVeHL7+s67EpiGmzikrHcXjvLf0k+9CtPN+819pQWLcA9Fm++9hSbwyPfPRJ42F33MNeACEA9Me/aeHVcDEiaEGju4WvhH10Qsaxy0DQ7Dgn7vt0tFHnN0gVjHJj3nSmCvyVe6z7Fx86Azl2iG+kAe+4eW8eqGInHDEiNlF4gOBj/ZM+qrRnNCIsPa1t6V4V117yAtANjLZo4EC93MtSwPaWI8tJ2A4219EJBwf+6tnqFzhAX+fmDUqvSdBCK/PR79Gtmy/QxJZv1Qrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=6ooInUKYhlujOhjindkRtW27/T2+Byib8g/PKDo99Fw=; b=IZrh7rky55+Ez/OrcwM38lZy4CnGpOxhnR8YgCe9uAyGmYKgGfF4bHQ3WBk7RX8PdqLv4lmnjQEnDiJCoY1jG5Fh1/SUhAIzwN4BYiou/J7yRpnSInvrtbv2ZNnEl3yliObI2IVuxV9og1Zld8us57yk775a9n8uWflAz+GChZ03QvLx5JiLfAeMryBCfKNLz+vrbUk7frYRqdqIQifISzYJAbzyklY8zrl0D6DOB3k8fYunAIvQQRtfxhIU38OpqXJguA7+AZbCXsAcYiutHey7E19QWBRdqLG01STEg1bHBZDj7Uv4Ab0I/BjgjDc3pvFD53V67DhLBPnlBc09iQ== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6ooInUKYhlujOhjindkRtW27/T2+Byib8g/PKDo99Fw=; b=YOiIKVTwj/udy40yuLbGLSUXw21jrMcimCR1r7Lmff7ikU4vic/jmaxailDdd5l4GiT2iJno7S4YMr61GWZy9EnFyTqJOdcNWUH17G7m3mRxNZj2oB7VbN4Vegxo2xTn9AHRDRiW4ZsdHfgKsrewob5YbrHRnYKR9N5C/tgcPso= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB8513.eurprd04.prod.outlook.com (2603:10a6:20b:340::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Mon, 30 Oct 2023 09:59:50 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 09:59:50 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta , Dong Aisheng Subject: [PATCH v7 04/11] arm64: dts: imx8ulp-evk: reserved mem-ranges to constrain ele_fw dma-range Date: Mon, 30 Oct 2023 15:28:42 +0530 Message-Id: <20231030095849.3456820-5-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8513:EE_ X-MS-Office365-Filtering-Correlation-Id: fdbf59ea-f00b-43db-3eaf-08dbd92ef506 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QkjKCFfEuKEKfGzYjS591omXozceLFrAXy294Z0wI8iYQ2HkrwXSpMC89GBEg4zfdt8B+evMVZfboIRnq8oNceEV1Nu7mFPviphyFQyWyE/Ht7JGLgtZKNQvisWCDiUDRjgGuTyafqI9ZsujBCejtt9EVJhdyvBQraKgyu5fc+jmu4ZFVGmGnRharN7oBJwqCPLgcUchmx+SyIlqHxz9D1NPdyDsNEi/pOKFAvSqG5drr/cKhImWkrJgLvo+T5aOAngf7teVMu0jTIzOhdhfXkoZXip55EeKcCxP51myEYZMsyc6RzDxuKng5uKlZ+RdMDXMPQK3DsoQLFYcMLhyYDI0+k3q7YGaQQa21LQNNK24a1yri0M87vqEDEPaiHY6wvsntp4kXl+tJMjuEHOoTXkB7V2zk4WKQ3xYLy8EBONpeLEm3/Uh2RWYDV19QW8K/HO1DPIN6M66R/QiWGMYF4TkQgBFbrUryztBYgGHwECLMykiP18OZuASItHKkyUUakXVgVQLVyaNoKd94IjTNF/Jdqv5KLJ0AlLZwP7Dvg7tQKEOIEp6AZv0EMJ92pzzlef/r6EIkjhhK5vUNCO2Cz8zMxo1/H4dxc9fewbTtVsyRNavXDb9C13IRNiviLFFCCyFq39hGrfePI6ECs7IWRXIoVJEDU/yTBrumwxNBcI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(396003)(39860400002)(376002)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(478600001)(6666004)(66946007)(6486002)(6506007)(83380400001)(36756003)(38100700002)(66556008)(1076003)(2616005)(66476007)(2906002)(41300700001)(26005)(52116002)(6512007)(44832011)(86362001)(38350700005)(921008)(54906003)(6636002)(8676002)(4326008)(5660300002)(8936002)(316002)(7416002)(32563001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5gwHXxNAJykZhnTkv1p2zB0fVPCfeXV4HwKyf3HiF8pljMCz0aaNRBgv8jwRxKIMPfgHkz91yfeBuQAEyeNK/dyWl0eriJRrSZh64oLfkqxlq0JXdpcibm60beg9Xft0wsu8fn8jG1bPWRuMOwJl4CW0d8A+80dJp0dOp867z0XKIuEwNS4Wc7Y58GAW3bs5WFsT6rkWW/rDjYDmSLFhqiuCzAQmRFnDyK9xnV3OvYlmUOyZ/oThkWE0t8acJ8Yt7tfzqWHhTVx/OLfdByFIw8/zOnxCi8F9mbbA7oMA5EWOVulLPoQMgBIoO7PNgmjJdPq9IunVTRIXZf22ZUNtWwjqql0yX9UqM4H2wIatV5dnURDwFBYhyO7a5sXhkI/tPVFdypEPucvByIBprGKiP3sgHXTp63UTqA3FSSb1qMxWrlhniIOGiuj+BAr8Fhkk6hi4oktw/DMFHYNmadUoTbnvQGJ6W2TxYUrTSwtBjwzj6/RM80Q+Oc/Kx1/e+QljdHz4ChpH9C3Pd1oI38XZ5G2c/Htx7oXCbWBBMoXRUf54k4aGeAmjo1WX4S0l9mgcpCcu1CwIfVDjFoTKtqfitz0mGfHZMOvOQGsahbFOFjKKQRRHW70VypoC/XJ3e0mxIWnT0VCKZjXYhMtw+7ePOgoGb7WbnwVxt9xobLRmttEML2o4rksL7qs8no7KMWnKuKdNEPByU58HHZuygvJ1R/c2PCk0MpgMGR1XZBQIDEFPPl5zld9iUaAYQRyLEjkY2vvo+5EJMs6vu+5vBJMSsPlL4s61eGYlbDs1wXom0oqiOXHMh+dhNV24MBSfeK5Ly7LmmrCDgUleI7YCJCV2XX+LVElBieIP/wIQM6JBM6VjenhrnHhl6FzVRVn+wbmffK75Beb0Ec6N5lJAeJQb5JwSi3Yb3GMpwsQVRzAZoXCwLEX2ptzIxYGQ+v9yh1qefgOa6lwrFxg1NI5LulCvyWxIPDJYViZgaFnx87J91fHiTUVb4MRK2pxpOeTqxyDFZ8zj0z4/7zic/Nc9UWUo8S22RUT5PNkhQsvSe2Cm6TabSiSywH1RZRFkThP8igt/DByJgrDsuF1D6Wgp/E7KBokGldOOZkJF+pVP6zkqFC6iTvcDzVI5PSqAOimMNEwsDAHGwXpIIfnuj58UNkWykNp7eca5bYEgV/6AP+LBE0oeqorklsNiI/J78bcoHCe9kEy9JHzkd/PqkCLxrmbblkb1v9Y8xDDqtGPuoSzXSxqnBcta1IWDN854sgbjSBl0WYw1MuzMw2qz9nbWzawWPFRvfxIq0eCh+SA37JQRF9fN/ytPxcgi5bC/oZmK64VzrAdSK4q5GH1VmH13jEeRhphETeov7RHHOys1rMYKIbqYrqjKNFLQWC5uDeyR3nNzsPgf6iBCiwkRDcqKa30MtgZG9tQTktV1p0ELeyP+sbQDDW9wpPriS3jSrKqG/dgLVdtxc5sXYlYcl/5I0YXZMZIRJ1/rrXovcKMnzsB+gWiuUTjaC+le42GPsDmTFDdggHmsOdm/FjM1aeXmrZKJbihI6PPAWftzIE8EHpKG7Ov/sjbHQkNuYeTxHoAdGcYD X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fdbf59ea-f00b-43db-3eaf-08dbd92ef506 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 09:59:50.8638 (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: 5bIYz+C90jnIpDjapDsKMcH5FH/VTd+1XM7EXxL79Y38TL/5AGp4nqvf52qJqL9taL+FK/OYDZQO3cGe5WvKDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8513 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_025953_421861_635C3272 X-CRM114-Status: UNSURE ( 9.93 ) X-CRM114-Notice: Please train this message. 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 EdgeLock Enclave are has a hardware limitation of restricted access to the DDR memory range: - 0x90000000 - 0xAFFFFFFF ELE-FW driver requireis 1MB of memory. In this patch the we are reserving 1MB of ddr memory region from the lower 32-bit range. Signed-off-by: Dong Aisheng Signed-off-by: Pankaj Gupta --- arch/arm64/boot/dts/freescale/imx8ulp-evk.dts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/imx8ulp-evk.dts b/arch/arm64/boot/dts/freescale/imx8ulp-evk.dts index 69dd8e31027c..d5cdce62a760 100644 --- a/arch/arm64/boot/dts/freescale/imx8ulp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8ulp-evk.dts @@ -19,6 +19,17 @@ memory@80000000 { device_type = "memory"; reg = <0x0 0x80000000 0 0x80000000>; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + ele_reserved: ele-reserved@90000000 { + compatible = "shared-dma-pool"; + reg = <0 0x90000000 0 0x100000>; + no-map; + }; + }; reserved-memory { #address-cells = <2>; @@ -146,6 +157,10 @@ &usdhc0 { status = "okay"; }; +&ele_fw2 { + memory-region = <&ele_reserved>; +}; + &fec { pinctrl-names = "default", "sleep"; pinctrl-0 = <&pinctrl_enet>; From patchwork Mon Oct 30 09:58:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440338 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 A13C5C4167B for ; Mon, 30 Oct 2023 10:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2w4O1yT3fGjozLR+cP4T/PlfR0B61ivvDwjxWj/fCnY=; b=mZoTVyvWvLpjzT kObhpYsM02370b8IMtax5F7LDMmYmAtQ0uueqDgTW3+N0ouoGgP1qdClrg60NBB3jqfJMmXbQ4hhw Bg1uL/ybKQf7tKupvvCcCt1cCHZ7xr7UyzRqHM/nRuj8QoXo70MZ+XSPQjMrT96YnZLOSxz4q3Rqv yjlR8vNipDO3smizw7DZdyugcnXid1WRhK+E/5oEJqcUCnUF4PXRMhF5A/FF+y9MIAhm3auZXPLeN aI2FPeiYVki7M+RdAZjcuRZeJqfG5kqd2bYqsnxgIwi+SsToI0keoNQdM2GUMeismIHpElwHytEBv iIpHqY1Da+usRxi2cKGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxP4G-002xvY-3A; Mon, 30 Oct 2023 10:00:21 +0000 Received: from mail-db5eur01on060b.outbound.protection.outlook.com ([2a01:111:f400:fe02::60b] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP41-002xn5-1O for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 10:00:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eBFQsBHK6ojYarZctqK1u2quUbOIALz5DIhlkAbWcXvEuV/ZQhBD1zQjp5ZHLuF69AgJKHrONxo8ZGf5v7GO0wGHas9LiT6T3gKMKC/vZuU+k7ajbAnugRMZMyDBi5U7oZwiM7Cf4MpKricNOfWRm2okPnPhkmUPw27Hi88B6UZgY1PX0HhQLHrHFvftsZUdbXmb/sl6HSaBmb3lP/JaTp6BMQsw+ttc3rcH46NML5n+Rl7lcca/7Hg1u1Hv8Z8u5dsxHz0OLYptvR3nIt4NHypWheXIyN3T0rGTBCk4it/NrQ5KawqxGRRZYTfi6IzfU6cy1RxAvSNBxAARRKuxSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=9Gklodh0vkB7vwDw9W5uxt3dyUvkdL1vVF0c17lTVEQ=; b=Vibiddq4yDyJ1/nFj5a16TKdjeO/vz7YEHDiUyQG8HRipSCAS9WTNWka5NJZG+ik4jhXaoqfg345sFvHRB+pOzqNR5cErbMU/iAiB3a/CXIsBVWU2aiXsaTcMihRPzEhN+g6g9cPLg1KQ3SqUGcJLSFBNpe5xU/OE6ohrww6C18bLv2vaIpHIeEy/A00EBNSQghI1HIAbkTDQAcQlt//Mj5U1+n25j2TIs9wibfzSlIIjt+foMvW88Dne7LR+4WRoHvzfvSvjqo6fFysqG5IvuJPGZGCot9TJnJTM+xHpDd2/p8uVPNI35pd8wgG1xCDLoRboz88FDMF9cHG8EEfNw== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Gklodh0vkB7vwDw9W5uxt3dyUvkdL1vVF0c17lTVEQ=; b=WuOUcBENxz4lu4xl9+CKJzIWvUKOBT1FnT0ohxHqDylTWApOpZVmRM23hf/Q6jFJKWY5VmBLQSwakBVuSR5BipFC8RoiBd3X0ckFVRsDky82BYC4M41Un+U+AT5r98OjEFzwRQXZkWPqmAikGuk3/Ue1PAUxZzWfObuLuO8Wa4c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB8513.eurprd04.prod.outlook.com (2603:10a6:20b:340::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Mon, 30 Oct 2023 09:59:56 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 09:59:56 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta Subject: [PATCH v7 05/11] arm64: dts: imx93-11x11-evk: added nxp secure enclave fw Date: Mon, 30 Oct 2023 15:28:43 +0530 Message-Id: <20231030095849.3456820-6-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8513:EE_ X-MS-Office365-Filtering-Correlation-Id: ad1db519-5fef-4b32-eebe-08dbd92ef830 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I8VR1FHQCYZG6CIsVv7dwludIJKVihc9WQrKtlZderZD6IhSOtoySCpacEFQVGxw0/IGKHTGSA+AgiUChWSh7Z3/UCBSgz3Ymso5mCeSNOSp3UMIOfDjp5nIt3PdNWyuKnrolw2OEnMft/zNceVbUJpb+xACE33EHckwcbdFqmgn68nORmntX/zczAN0aCRYieG+xvG3Cbgo3Hn0/PGaNTdLxarCcfszz+HzSGoFaGc8uD6zl5KITgUkIC5/VAhPzY3wqobCH3H95YgQUSWNMy1UcUKLIKyw3ERufLdfs1JX/s1T3RBatN7C9qaAxEZdjnWZ2VyKQNYzMiSSk+XSfnmon0/+1ZtKXUT6nLGFq+pQRcbTkLrtwqnmgAoww95pD1T5MRaMvoKj5BwJ1dscYtHZFKy6P6KUj2blVYi9O0xHyRC4jCbq4pRw47bG/7mJSivwIHLMxNhEdKddyqtaWe278CvFqLnf8G1bX5giYs0mxn8co2oDv9gFmmAH4O6tlfEIHEIg45xJvOLER0f+RqRdfXQrFC2gyv5V6VJB00qa91WySgljGlF4e+6nwHPZwkvZtK1lP6fNj7ixHM4drpQWtrqlql3U5lcX0Y/UW0wvG5f/h32VxbeCYo+FZVMrH4QT/PbTtPbtKnkpQ1pNSA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(396003)(39860400002)(376002)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(478600001)(6666004)(66946007)(6486002)(6506007)(83380400001)(36756003)(38100700002)(66556008)(1076003)(2616005)(66476007)(2906002)(41300700001)(26005)(52116002)(6512007)(44832011)(86362001)(38350700005)(921008)(4744005)(6636002)(8676002)(4326008)(5660300002)(8936002)(316002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6IyaLI1mtZMGnUfLiupGzAYcN7JrKBqzRa/dUZIxaaGlOxj0Ap7ApT2dSDr/d+vCmejW+byRoytJZ5JMEg+Ck6Bo4oFVNBaXTnzMniFgam8jUM6et5/svZCBfufBgVoy6CJoxbDBch5z5+7l8xsNc5a2M97Q7JXxHlGM9J/q3W85hDu/UMQakSOQowJxt77F6mh3okXwM/0Id0cHLElg1rS0qcKD4VMuPwgEMEZcCz0U95XdiEKqqa3F9KBbUXlLvZZJrH3yGFBxzp0uqRApmnKOLFtMvJEa/wus9nO0rpUbioeimLKGSdHv9GY4m8zw34+MF7IgTtn6nBmRDOm/Is09jSrKB7cfknJocPUTANoVXujRjLrMSfv1GGf2CJdLmHI1gkLsxEx7qL1nD1Ww+iwgiU93h2zJiLMQuNxlJ44wy2JX65zvSF6K7AkOo8w9olg/sld2sG8AXEnYdiRrhAHFqJN42leIpfVnl/SBEsyp1bKytz7lfeMVivXHekzGGICaDdic8m+MNCY9jqH/YUoGJ9pFZYGyh13h4jyWvPj6QQ3lQiUwCSoXVFz0jtqllreudBsIxQSPETGlYe1BT8cwXfhsxlPHa4RJydGgFWez2yk78yzCQPlkBUhONumeNr6bonciXdy5pSfdoNQ3Xmi/jAfRpDs+CuxUc0vHOYh7+p5vEcgBUpT1FLnTHDCg4H7rn2tSl2i0IirAr/FoOoWVzdp6fatR8WU3SffnZiFc9XVOk2JJn63KdTtcmljIJNaVPL5Fo1/3VZtxdJtE0UeWp/VczA+cEwPwCUgKLUhZeU1qIOjn4/hZBpHOWsjomOt1Psdxu+Fv1kBj7EM29Yf5xT6x48AM4ctjEToKpYF+8mypbnoRCh4kO41cTAaNIpTsD0p/4N1ppADhHIahxNnYxl5zN1CED19/tRw3stuzL+n8oHMDucRMkGQp8ChUIalA2LPHo9F3vAl6Ye/rxoj4X+KruSeXeIk3PDOCr4TORirl4HbKDIuT0eAXHDKJ/h0B2+oDq0jIz+2z3kpNddsQjMeaIzbVR6MtiZQmjgIGYFr7SYTH+Avbgnp4dyGoXg7rwEqD3LNS6PYOisiTSjgQR9O3XHB2Pzr+6YM2v8cnOR0gKa/BuMkhVHTFbGCeqxxrSSmbA900iznDwGzC44zRP4uY5x8wq2l86SMy4Fb6+biPej1paQcHLMRAbUpJ+Y8MNhnw2zH0EgAc8QqB9sxwU6zHSKvAqQI5B69pAYCC2TxZVP20k8YtFNCMlfX7dA+AgELu3gGYnigkOZDt/qNC0vQvVCsRI/B7eoyk2xIyrPx/6YhJFCe6B90r+ic81Ag6pj3WnTRbzEhbusl8FVSiwYHt1bYCBH4Wkcma7Mir6btbJQIKHQJUQdTZwoxpkVBJVy6up23wGzoQOOwMaAMdgQ0OZC2PpJcjWQOsLYvxVTyxgYCgnpj83ahM5Bxa+Cskt8hy7n/auahc9f9ssiNbR47EBVEwW8Rlckc9Lf6v1hNSZ5b2uLmIkAL5YlNUSTa7gEyFagmXdkVGkGtPrlnUsKusdGk/yHZF8qor6JdZZMpMLqMWn4gsfYOCCzcj X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad1db519-5fef-4b32-eebe-08dbd92ef830 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 09:59:56.1913 (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: Ul3hK0tM/trBPRb8RV/F45q8PXWcQ9Q2Z8uCOZ7G3w8LSkEsRpe4avQndtcWnb8virXqGHvftJ4dD6ElqON5+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8513 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_030005_476234_A487AA8A X-CRM114-Status: GOOD ( 10.21 ) 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 Added support for NXP secure enclave called EdgeLock Enclave firmware (se-fw) for imx93-11x11-evk. Signed-off-by: Pankaj Gupta --- arch/arm64/boot/dts/freescale/imx93.dtsi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/freescale/imx93.dtsi b/arch/arm64/boot/dts/freescale/imx93.dtsi index dcf6e4846ac9..197de680fd27 100644 --- a/arch/arm64/boot/dts/freescale/imx93.dtsi +++ b/arch/arm64/boot/dts/freescale/imx93.dtsi @@ -1,6 +1,6 @@ // SPDX-License-Identifier: (GPL-2.0+ OR MIT) /* - * Copyright 2022 NXP + * Copyright 2022-2023 NXP */ #include @@ -925,4 +925,10 @@ ddr-pmu@4e300dc0 { interrupts = ; }; }; + + ele_fw2: se-fw2 { + compatible = "fsl,imx93-se-fw"; + mbox-names = "tx", "rx"; + mboxes = <&s4muap 0 0>, <&s4muap 1 0>; + }; }; From patchwork Mon Oct 30 09:58:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440339 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 A1ABFC4167D for ; Mon, 30 Oct 2023 10:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=slHYEJ8DzjeNH5KjDybuMSAd08TkNrBP2UEQDlpsUJY=; b=xElomJqugE3YLz kNrQS2bFa65O1MUL3+smWegeXErHlWr92SsC99wDimSKniOQBO0eXmaE2h2RIzQ3iDhb1k+F/IPn5 qutcFbFtE+zU4jtPmIatYXMpxbqM1SlSfPqLlqC3nrXoUF0Cq3muwRpG9Wh+zJSTsIwyGTECh3Xs4 IXfuWUi3ZrYrKkq/CDzuzBZra2m/KYmpx7hRX4641Ut+O+bbL4mqRulzoldCbc8MsZEZSNVem84k4 jQRqV4cW32MYC446ILrLgvk7KUyYH6Z4+2uJy7uXxrdEj3CeP4ZsuVACZwUv/yKhS0SAzpSyx4xRG BL1h1kSy07hhEyyxvVmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxP4H-002xvv-28; Mon, 30 Oct 2023 10:00:21 +0000 Received: from mail-db5eur01on060b.outbound.protection.outlook.com ([2a01:111:f400:fe02::60b] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP43-002xn5-01 for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 10:00:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LSYl6ZGLYirKSmJp84sIDUB3rsmUqgT7kO305+Uu+xgzstghhPOXVY7OdjoIELYrWNIOIUNFq77+xBYErKD4skT61Lp7JHPcl0XViAim2oTSf4sHN7v4cMh9hyf0Ir98u4JNsQ2rYoGMXLaHPuesDiu009/AQC/+47vByxJ7RBHZ+c5U+8pksySMkaza8czUqne09ZJFnhaPIstWojFOkKRfbwI32tP2ONlgY+0lkwYjuU6hdt/BxHmUgBCQUUJkjikBCfk30SYrEK6Xp8FsI3GPd8gpKALQzVmnFrm3t/jQjCFA/DnrziN1AfPdcwdMpeeA9EpYlIzZWfAcSgtjvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=kkxK78kc0GzJ1PAmyygOuLjTJ7Q7J4gC8xHgZpVpz5g=; b=J+fY4uqiyu7OnqtqhFcaotoBj5HmBSqIqaLxcwNL3PniUftNdl23isvhp3LmlVA84Gv8hWeLS+zKt8hFcGfkzq+1FEH3glw1ZO+Qq+escdONFd6bhKVMixjz1Hy++2b9sdTC2UQs3qxrXQD5oSZvmvP4S86Ovycl0Gn96sbbSIPybtb0iyVmjXGDkUDcHRpTbVVPlyP9krecQFHd2WylPN3/kAgtcqNI6tFxa9MrcGGAQVSlTJhntlN2xKO/lbxXFGm4KCSSGfqEQgLWZaSAuuCHjlfvoyGDIExKmM8U0PL1QNWd5oJwPMqKCfhaGWGWCmgJcWQe3AoELUXITBQSAg== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kkxK78kc0GzJ1PAmyygOuLjTJ7Q7J4gC8xHgZpVpz5g=; b=baeBXbhgbaVoyikyHQEY6AeMl480xKnF3HGa+rW6bvAJ1tk9YHxGN0GZJgrdAT5Ot96C0xkCn5FU/fdh7mRdcoQSsX5MAUSpRYJgANK+OIjGew8LduIE3pZ7KesQqtb50032E1raarNohMbTrePwoFVakfImVrGcR7U3tX5u2ZM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB8513.eurprd04.prod.outlook.com (2603:10a6:20b:340::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Mon, 30 Oct 2023 10:00:01 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 10:00:01 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta , Dong Aisheng Subject: [PATCH v7 06/11] arm64: dts: imx93-11x11-evk: reserved mem-ranges Date: Mon, 30 Oct 2023 15:28:44 +0530 Message-Id: <20231030095849.3456820-7-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8513:EE_ X-MS-Office365-Filtering-Correlation-Id: a102e838-5927-43f6-6382-08dbd92efb7f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3e338KJ1PIA5YruDphHsqxuItJimJ6/LBDseMFS3sfqplLo6R9muSnowYp6dRjepKLqXWCFuPnBtcVU7NVJVHXp0TBb7Q4IWIsy+1CnwQbSoJqXqaDtwckv0EmItEBtpPQiltqSPrAdRzmrq2RzHkHb4lDJR2SlUOCmHRz/TZwO9dY9WYQD9d4v1LWaUltfrWqmXMRIf/QO+bjkvGjzGFnsmwShGTcECFQl3Fw4QF201N7R6CrmZdVl2btdzqj56gvBrWclllKVUj03VqqxzY+f/sxeo37p5vXk9Dqb+D1YsFp7HldUoTnwPLiNxQ+7nBR0KKKNwU91SFdlWiFStLlq61igCW/q7pnWbBT62WWKWZo4UpymURF36ParGVGqMBM6vZ2zWrR+makhacsulU2bOiaR6WJ/F9DlQwPrivS2LXESugqaGx1psERKakVDq7okeYURDt6tGvUjPGPoAushDJfwJ5HNGqwx2lT+KEWnlbJm/YdHFUoMUlIr37MWpewV03nC8aLijBdLBR4J7/62IP5b8eLUDGFaRSeZWCfBxvB8owBc3ZaDNsvEeWk/jCNoio5LdB/FAKm/i2AWQ2HCtLtP/btkwovqvfio2yrGS9jr1DYxxiqd0yCBtxY1xdouuojmkxvTggpKkUHsJDg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(396003)(39860400002)(376002)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(478600001)(6666004)(66946007)(6486002)(6506007)(83380400001)(36756003)(38100700002)(66556008)(1076003)(2616005)(66476007)(2906002)(41300700001)(26005)(52116002)(6512007)(44832011)(86362001)(38350700005)(921008)(54906003)(6636002)(8676002)(4326008)(5660300002)(8936002)(316002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lJohgmzjIswe418Nth3jSCvPHhjqIqKsYFITdq2LIOdOQ/7hCl0/7MTmDNsxxZVRIvDlv12wBeJbBQi6KiyZVU2o4W7MBm0JdqZRX9p3pmGv01jOSCAmMU9BEZ261isU2sSXzBL8UyOIQaDTyBFpL59EXwDVxZPrx+KBmpP4FwJwI6o2IFgfN7JYH0tc7FL5pvlMqPPLRkjqJnKECzhdTJuVyt4EFdk93bsTEow9Ke0iH/F7qJXXIJcYNoR/+G0xW1ZUdWJOp323HkFpF2Zpibu30nI0Fp+fBlTmlIOvNoOdNqD1BGnr7QkR+sRBodfCmxylSx/VT4IUlxp1vJgTlSrXxrHHRrDwTdpcqEox+IQ6ir6leU8Ub0yNqjPgsqu1s/MfE2Vchty1WWiuvJPVT/kEzD+3EeI9X36yiCx8z+pwumv9OoLpQc6w3ZNJ1X0kVTi7Jr19NmOqPbxUy1s92AmBTcENeqOPaBM2s7yHoAa5YkvwZENlFdvYbPkiMUnYyod9iGnS3TfqOsyhqONMBgrtwtkkIfvaIKVhKTxxODRxMQhDQ59fEFd5NeDaqOTn/aJ+qmOf84K6gFCG4v3uSkj/QAT25xHV1V+Zxm3yf9mVfHkW60yQOJeOPdjVYCEhOMSKxSGcZN3R03hYldRuF1Hkhg4lhvU28o/zmr+EYUPaAxlTuDZEztoErZkDr6TUHGDlwDZS3T/wuPfEtH/TnsHXQbos235sx9gtteY/G6RIT+opojH8fSRIBYo8/eKieqFXP12s33BI0T9D4Gv1gb4wlBTpHAEc44U3jXoJ5lLYv/CKaaiacn5xYUaf+WIfpY7lYh1eo6ZOmdPcUAE66anaLmuq9T3IwvLzNhDgquTFEPLNN/U+hbPdv9OC/a3XXPW5OjLIaZDlT0simsv7pszl64iMdCgIa7fPnoX6JXe6RPwBhOougystmxC3nAMQuscFm2SyxZCSArizfxcYJq3PJDx5mhQhzLpO8MJO/r7S6wc1VMzjnGg44csonGhIbHXhxINnjI/q8iuIg1iGULoXEDiE6FqaP+3uvAAHMI6kDz2byOa4WOHu15W0kISALTEoMqpEtoR517nNZyNtPFXneGvihsq1LajsTNoMVc84ssItV6daVTsxxsjc8sisA3JBU0YjTG0dJmSg+GEYj4BzWaS8d7TtW6EMXS9IRGfCW+TuJgazVWlJahE/5KZtqACOZU3CscDuAA/GWipbh/3vmGkcArZMxGlIncVNXM0X5hDkuci18XgJmtTTVeYIwnxZkGjFUE5einEm1+Ust68nLqcBf1s1IxHbNFTJZmslg6AYK94JCk0VbKQS0jcwRroxvbD+g3XPhNLHjF2KEs9SWoKffpFmL87/UfD9D1o3jMwnLFSHx3Q4WOjnYtq9fbF2uLXwlnMa9i384V358CmSp/7X4w5FM8QIamKDcRh/doMDqIv6WLY7IeRP5anklZLebE7odeF+41+eZNpH0pl+23+2DRghNidCBrzp9dzDcjKLfGTFygRABB3GFc7bSjqMhEUuW09cUDh6n6bfon7Es0hHzMiri3oTTn8JhEgwXp/1VKkCb9KDzPAaYltG X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a102e838-5927-43f6-6382-08dbd92efb7f X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 10:00:01.7355 (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: nGbw5P/LMNABCTZePFH9f+ri60wUG6paNmqbri86YYunwa9OFnrPrX3hDW7Sss8o5VcnGMPBHR+xfCtc8s2ONg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8513 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_030007_046482_4B292A59 X-CRM114-Status: UNSURE ( 9.94 ) X-CRM114-Notice: Please train this message. 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 EdgeLock Enclave are has a hardware limitation of restricted access to the DDR memory range: - 0x80000000 0x9FFFFFFF ELE-MU driver requireis 1MB of memory. In this patch, reserving 1MB of ddr memory region from the lower 32-bit range. Signed-off-by: Dong Aisheng Signed-off-by: Pankaj Gupta --- arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts b/arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts index cafd39130eb8..bcb4ae931c64 100644 --- a/arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts @@ -7,6 +7,10 @@ #include "imx93.dtsi" +&ele_fw2 { + memory-region = <&ele_reserved>; +}; + / { model = "NXP i.MX93 11X11 EVK board"; compatible = "fsl,imx93-11x11-evk", "fsl,imx93"; @@ -68,6 +72,17 @@ reg_vref_1v8: regulator-adc-vref { regulator-max-microvolt = <1800000>; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + ele_reserved: ele-reserved@a4120000 { + compatible = "shared-dma-pool"; + reg = <0 0xa4120000 0 0x100000>; + no-map; + }; + }; + reg_usdhc2_vmmc: regulator-usdhc2 { compatible = "regulator-fixed"; pinctrl-names = "default"; From patchwork Mon Oct 30 09:58:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440506 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 E163DC4332F for ; Mon, 30 Oct 2023 11:15:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YvIlhe62usvFf2pD3auMz1R261U1j9o4nA5rHGF52js=; b=D8SSeG+KGyR7xz c4Lh49qR8l8AskiWZo0Tx/EZW9z6eD7j3cJ9SinnwhJs1Fzhw+X9pUNg07e33BP+2l7s9Mw6W9py2 +S2Ul6vS/ssI/Z47Qt/wryrK/fYZPhAJQ6nfjGT/zstc6batpKH4qscneDc+0NmwQU08LIVcORliw 7xGyOrA/kk0vxUXinha6zC9pi+k3SAloDWj3FDmys4hHHyzCxLuVGzOgSmU2PtXl24TcdUSwVhQ/s 4VLYqVqTWA8jXaZKajozML0Nw4zBPJ2a/837pbDmbKcjnuCZ3cS/kcUkFaNPwbQLPtDQ5dd18tCuj AMF9eUJs5+tbk93lsyuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxQEn-003FFL-0B; Mon, 30 Oct 2023 11:15:17 +0000 Received: from mail-db5eur01on0623.outbound.protection.outlook.com ([2a01:111:f400:fe02::623] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP4A-002xrY-2O for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 10:00:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kOs+qjtxwsTuF0NOEYHDSytF735xVn3gGMfmzhkjAHIXrW6+IRtNwBnO5ocgjBT3LDbJP7dYLGEUA6GXc5aRDorng48CaWipysBvJ0a/FjqnXBez66MukP1Cdy4MfwkSMUydkN9E1iNX3N6L/kbWJBbJPCro1EU/jYDsA8jfbkTEO3jIe61yTG6H0kO8SEnKYkiZO3H4fBiR24Wjz4DsM42lPm0dSDpgZFXYrcOb0o5oiRoweiTv44JSu5Ue77DgPmiNuJqNYPnGVzo3IFAHDgQUHuTCSIBBZixgd/QsfPopTjGf6yRLntMnlWd8myL5tpNrircp1SI8IeYhsxLBiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=HKdaMP7yCkMydLv97b+nZ2ZdA3o4q7nE/MeY1h5Fgm0=; b=RFgvxdJPWV0TMtxvD6+XJAMzvIH0Ptt9oCnRkPbogcuJfa6CDUS5A6tK5e30+G2T+a3QBPNeH02XWyLSI009SNs6uFLGyjKGUgMKL38v/cLAe6h1qAK0O63uXRKoW+U5+c2A/2knf25ILmj5cbNA9zXpDY0iegeO8muoGGnOpV/ereeoJ2btJPCsbS3wE5JyvWVkuPyYUZ1pmSXsWcqxp1sb4ftDh9lO+lqK1ZTgggS3Z6xI+BEeLk6jKMCw+151R/CfP8XVvFKiGfGTfV5GlMcydxFCJ1jGECFA4NP7echJDm9cktk6wem/z7yXFXa1Dq/Lgq/O7pLMqbWR9wSH/w== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HKdaMP7yCkMydLv97b+nZ2ZdA3o4q7nE/MeY1h5Fgm0=; b=ghZOl1n19qIeaSGpLQus6uX+CGFlTCoW+4u7uN20rhILVoSjKp1KZ1hWW0BzJ3cYdbwpiukkOJ968ZGbY2y0FpWYPKiRPzCO5FllX0Kuit7ENkrD2eMNMgEOzFDn4HO9LG+tX5LD1aSWERceal63/k3+UG0VdzfcXLTnhPN/yYQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB8513.eurprd04.prod.outlook.com (2603:10a6:20b:340::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Mon, 30 Oct 2023 10:00:08 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 10:00:08 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta Subject: [PATCH v7 07/11] firmware: imx: add driver for NXP EdgeLock Enclave Date: Mon, 30 Oct 2023 15:28:45 +0530 Message-Id: <20231030095849.3456820-8-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8513:EE_ X-MS-Office365-Filtering-Correlation-Id: 5afe8604-d54b-448d-6200-08dbd92efed7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UGnd0gdV8F+VaUwjhcM3X/OlN5iUqlsDOUieqEJEGbnv5pbQ4U7RgNwRhFoCmhMQnH8ej/v54BLAt5BRKWoArfdZuqrxoOU9JSus4bxgK1oT8YyoLCQntkCgQtQ5I/kb0qstaiS3x+BF9QZS+KeLesdTwepjPCfr0ey+vPhyEgTbS75PwunjOgLDs3e2a62SSx+Zk7e0MnWHYBqVbae5rNHDXV5EizdxGJ47VRyfTdjtiLj9L4u/xew72fDQrTkRPEcWGyQPJawA2Rd9p7ON4HCL51+6dVmTdPCkKWyYy7v/gS/IT9OcIbOCVTNoGg2pn5GDr8Vn7BFVy7XRbVFH1yw8PKzDRKtiw0yfGkaZLLsz6P6fi9OzlOuPN7NzYJzTdYKy8Jqxa160NhjnfoGP697L0iZfAtomX89SXv6Z4gzb4QmoWNFRIgybeVMdsbGXnwAkjECBp6G6eXoS4NT+ABN2ixvR/3L+VvYChrC30ePcJNQPhujd5iYZnTCXC4F+X8IMWv+IcfzPO8VZ2sWKGn0PWYLHIXguWI5Y9JKZgafEgbv+4FZcgO3JEUpk5LoEvxcgwPeAtbiDabub32qvKcXvuKXlD8IQou+07wORaGyAfz/XK8iOZI9mVDdHNe1O X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(396003)(39860400002)(376002)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(66899024)(478600001)(6666004)(66946007)(6486002)(6506007)(966005)(83380400001)(36756003)(38100700002)(66556008)(1076003)(2616005)(66476007)(2906002)(41300700001)(26005)(52116002)(6512007)(44832011)(86362001)(38350700005)(921008)(6636002)(8676002)(30864003)(4326008)(5660300002)(8936002)(316002)(7416002)(579004)(559001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HE4PmQuD+w3S93sLHQzsayNa7f6ixUEZkPFUg2tkljfe8yg8FT5DcJ03bndm4w4JFzJacIngr/oyKw5RXo79upaS4VbccoYy367aOBuYcAnlGBl8uMZyVqbJrswsy+fG6JTmla+rOXuYEqBDN1Occv8bI3wVfO3EGxuP9ul9ktOuijjp8dQozRDdfnsVmX4KQi7DR6EgAWLa1POvPSQeu+APIJfupCeyHibZ50a3P230migK/hv3Z22A5k9RdzyGfI3VTHM2fhQSiSMu/URs8iia+fLtQVC4IyIFpe5TN8nBejFPxmOtsg74d1eA7NDNsOo7cawcG0wyNJsT4fn/Hjw8+eg+iA4fB6xJ1nPlGHCXkTxWJmPY1r9OuDn8w4DE0Rg3f4K1vChg7mLSt+96J92JOAJ6n5kHRWyxvZuHG8ANqzHkpQM1JNtcQC/wf0cXrb+YZ1NNuwMncLJAhqwnfjxw7KSp5cIKC+p2hYLNEnDaJFS86H21LlRXfe2nrTHdS0tFJAp3wG+V5umOeMkwee5pyzl5XWCnt5Z2/XpJfA9oH1gAQ1t9bLr+AyictRXPfVwfaO+f91eDinidvTJtyNUjQwyZUxBqNZvO+UeqR/4cY1+XGfnxFgrouJ+HQxndGdIkremsV42aDVQyv7RzvJizBaiLcJoPg94c3hU2RA/rM4DOV0Ne2XexLYfTPd+tCuo/ux99oEPAlHeJ+edt6Qh0RxkOiSPNbcUBF6nHVXsLtieYgIOhz5mXUK6uk42BPfm/EdXeqzksB2WSWqWOw6KSeHiXVS6XFqJBhC8aGvE3cwrpJdzCcXeGlCFU3nIbAsOtOSgbAOIVYyADczcUomV0Bto0Kbuyko6D6k1e4iHYAtiLkpwYVErNpyDTMvw3PvJPsqhoNc94v1dMSOQCpikXckOxRC7ZVr28bpCXw3EcNKg3dqOFNu/Y/YXr/IWyJJn9xOwKtT3fTBnWaE+jN9NsKDIOEXP2Vy1TTP7z4+CtJ/hH3NMWqChmRu47VwdDhPdGFmLPeMuUUf8mMlUYS/9xkLL4iAyjuXvGjljWl1UUdhO2AXoCpWsmzAWYA4Z/86JA1/WW7r79BWu/cftwABFC6ALLMRF1vuT0/Efv3B+ZnkJa8GmgPAEWB1dxUWGD4dXXFffBqYtd15QwbK/NJXGtoOsoriniSD3pByYO51kPpSTEhqMMgObch2eEMfQRQP2OB1hCw8k6AYvYAHVyBsX9l/TDm5N2YEXfELLllZ6F5DQz1dW5AGuyroskTh6Bn6oX/Pzbjo/7OOsgFic23Brob3YcC2sOynJ6G04XpeejVeQ+x83awIRQ2Xng+CnZQ7xXPuqNThv25CwI0ETf/PvuPCPupfPWz9GH+JbfllNBF+1BR9G+RDqyWY6wR4nJk7iEOCh66uT0asbv3qFt7S7UVroukzba/ySA30nojqXb2512OrX/SQC1qi9sexY8+5aIwwcCKx7gAIVBfGStuJGFpzpyq/VNFhjA65AJyJTbyq16kmq1F9/EuPriYyVuhwLOaCJegWiALgggBQKIXcq+aE81GZDws5D147/wp8WQoXT5+rVUbaPvg+byq9vK X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5afe8604-d54b-448d-6200-08dbd92efed7 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 10:00:08.1070 (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: bHyglLZjBawnb7nl0FtNXW8Y8/OVL1ntYnJrUb5bnivRsQsSSsQgh5lydeClNScqi74cgz22Ss3Ro0u4//MQ3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8513 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_030015_090906_A15F5081 X-CRM114-Status: GOOD ( 25.74 ) 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 The Edgelock Enclave , is the secure enclave embedded in the SoC to support the features like HSM, SHE & V2X, using message based communication channel. ELE FW communicates on a dedicated MU with application core where kernel is running. It exists on specific i.MX processors. e.g. i.MX8ULP, i.MX93. User-space library using this driver: - i.MX Secure Enclave library: -- URL: https://github.com/nxp-imx/imx-secure-enclave.git, - i.MX Secure Middle-Ware: -- URL: https://github.com/nxp-imx/imx-smw.git Signed-off-by: Pankaj Gupta --- Documentation/ABI/testing/se-cdev | 41 + drivers/firmware/imx/Kconfig | 12 + drivers/firmware/imx/Makefile | 2 + drivers/firmware/imx/ele_base_msg.c | 101 ++ drivers/firmware/imx/ele_common.c | 139 +++ drivers/firmware/imx/ele_common.h | 30 + drivers/firmware/imx/se_fw.c | 1308 +++++++++++++++++++++ drivers/firmware/imx/se_fw.h | 154 +++ include/linux/firmware/imx/ele_base_msg.h | 40 + include/linux/firmware/imx/ele_mu_ioctl.h | 74 ++ 10 files changed, 1901 insertions(+) create mode 100644 Documentation/ABI/testing/se-cdev create mode 100644 drivers/firmware/imx/ele_base_msg.c create mode 100644 drivers/firmware/imx/ele_common.c create mode 100644 drivers/firmware/imx/ele_common.h create mode 100644 drivers/firmware/imx/se_fw.c create mode 100644 drivers/firmware/imx/se_fw.h create mode 100644 include/linux/firmware/imx/ele_base_msg.h create mode 100644 include/linux/firmware/imx/ele_mu_ioctl.h diff --git a/Documentation/ABI/testing/se-cdev b/Documentation/ABI/testing/se-cdev new file mode 100644 index 000000000000..14a7143fcaf3 --- /dev/null +++ b/Documentation/ABI/testing/se-cdev @@ -0,0 +1,41 @@ +What: /dev/_mu[0-9]+_ch[0-9]+ +Date: August 2023 +KernelVersion: 6.6 +Contact: linux-imx@nxp.com, pankaj.gupta@nxp.com +Description: + NXP offers multiple hardware IP(s) for secure-enclaves like EdgeLock- + Enclave(ELE), SECO. The character device file-descriptors + /dev/_mu*_ch* are the interface between user-space NXP's secure- + enclave shared-library and the kernel driver. + + The ioctl(2)-based ABI is defined and documented in + [include] + ioctl(s) are used primarily for: + - shared memory management + - allocation of I/O buffers + - get mu info + - setting a dev-ctx as receiver that is slave to fw + + The following file operations are supported: + + open(2) + Currently the only useful flags are O_RDWR. + + read(2) + Every read() from the opened character device context is waiting on + wakeup_intruptible, that gets set by the registered mailbox callback + function; indicating a message received from the firmware on message- + unit. + + write(2) + Every write() to the opened character device context needs to acquire + mailbox_lock, before sending message on to the message unit. + + close(2) + Stops and free up the I/O contexts that was associated + with the file descriptor. + +Users: https://github.com/nxp-imx/imx-secure-enclave.git, + https://github.com/nxp-imx/imx-smw.git + crypto/skcipher, + drivers/nvmem/imx-ocotp-ele.c diff --git a/drivers/firmware/imx/Kconfig b/drivers/firmware/imx/Kconfig index c027d99f2a59..2822e5d4b24c 100644 --- a/drivers/firmware/imx/Kconfig +++ b/drivers/firmware/imx/Kconfig @@ -28,3 +28,15 @@ config IMX_SCU_PD depends on IMX_SCU help The System Controller Firmware (SCFW) based power domain driver. + +config IMX_SEC_ENCLAVE + tristate "i.MX Embedded Secure Enclave - EdgeLock Enclave Firmware driver." + depends on IMX_MBOX && ARCH_MXC && ARM64 + default m if ARCH_MXC + + help + It is possible to use APIs exposed by the iMX Secure Enclave HW IP called: + - EdgeLock Enclave Firmware (for i.MX8ULP, i.MX93), + like base, HSM, V2X & SHE using the SAB protocol via the shared Messaging + Unit. This driver exposes these interfaces via a set of file descriptors + allowing to configure shared memory, send and receive messages. diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 8f9f04a513a8..77ec0f922788 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,3 +1,5 @@ # 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 +sec_enclave-objs = se_fw.o ele_common.o ele_base_msg.o +obj-${CONFIG_IMX_SEC_ENCLAVE} += sec_enclave.o diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele_base_msg.c new file mode 100644 index 000000000000..813f769f7bc3 --- /dev/null +++ b/drivers/firmware/imx/ele_base_msg.c @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2021-2023 NXP + */ + +#include +#include + +#include +#include + +#include "ele_common.h" + +int ele_get_info(struct device *dev, phys_addr_t addr, u32 data_size) +{ + struct ele_mu_priv *priv = dev_get_drvdata(dev); + int ret; + unsigned int status; + + ret = imx_se_alloc_tx_rx_buf(priv); + if (ret) + return ret; + + ret = plat_fill_cmd_msg_hdr(priv, + (struct mu_hdr *)&priv->tx_msg->header, + ELE_GET_INFO_REQ, + ELE_GET_INFO_REQ_MSG_SZ, + true); + if (ret) + goto exit; + + priv->tx_msg->data[0] = upper_32_bits(addr); + priv->tx_msg->data[1] = lower_32_bits(addr); + priv->tx_msg->data[2] = data_size; + ret = imx_ele_msg_send_rcv(priv); + if (ret < 0) + goto exit; + + ret = validate_rsp_hdr(priv, + priv->rx_msg->header, + ELE_GET_INFO_REQ, + ELE_GET_INFO_RSP_MSG_SZ, + true); + if (ret) + goto exit; + + status = RES_STATUS(priv->rx_msg->data[0]); + if (status != priv->success_tag) { + dev_err(dev, "Command Id[%d], Response Failure = 0x%x", + ELE_GET_INFO_REQ, status); + ret = -1; + } + +exit: + imx_se_free_tx_rx_buf(priv); + + return ret; +} + +int ele_ping(struct device *dev) +{ + struct ele_mu_priv *priv = dev_get_drvdata(dev); + int ret; + unsigned int status; + + ret = imx_se_alloc_tx_rx_buf(priv); + if (ret) + return ret; + + ret = plat_fill_cmd_msg_hdr(priv, + (struct mu_hdr *)&priv->tx_msg->header, + ELE_PING_REQ, ELE_PING_REQ_SZ, + true); + if (ret) { + pr_err("Error: plat_fill_cmd_msg_hdr failed.\n"); + goto exit; + } + + ret = imx_ele_msg_send_rcv(priv); + if (ret) + goto exit; + + ret = validate_rsp_hdr(priv, + priv->rx_msg->header, + ELE_PING_REQ, + ELE_PING_RSP_SZ, + true); + if (ret) + goto exit; + + status = RES_STATUS(priv->rx_msg->data[0]); + if (status != priv->success_tag) { + dev_err(dev, "Command Id[%d], Response Failure = 0x%x", + ELE_PING_REQ, status); + ret = -1; + } +exit: + imx_se_free_tx_rx_buf(priv); + + return ret; +} diff --git a/drivers/firmware/imx/ele_common.c b/drivers/firmware/imx/ele_common.c new file mode 100644 index 000000000000..4410245a19ec --- /dev/null +++ b/drivers/firmware/imx/ele_common.c @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2023 NXP + */ + +#include "ele_common.h" +#include "se_fw.h" + +int imx_se_alloc_tx_rx_buf(struct ele_mu_priv *priv) +{ + int ret = 0; + + priv->tx_msg = devm_kzalloc(priv->dev, + sizeof(*priv->tx_msg), + GFP_KERNEL); + if (!priv->tx_msg) { + ret = -ENOMEM; + dev_err(priv->dev, "Fail allocate mem for tx_msg.\n"); + return ret; + } + + priv->rx_msg = devm_kzalloc(priv->dev, + sizeof(*priv->rx_msg), + GFP_KERNEL); + + if (!priv->rx_msg) { + ret = -ENOMEM; + dev_err(priv->dev, "Fail allocate mem for rx_msg.\n"); + return ret; + } + + return ret; +} + +void imx_se_free_tx_rx_buf(struct ele_mu_priv *priv) +{ + if (priv->tx_msg) + devm_kfree(priv->dev, priv->tx_msg); + + if (priv->rx_msg) + devm_kfree(priv->dev, priv->rx_msg); +} + +int imx_ele_msg_send_rcv(struct ele_mu_priv *priv) +{ + unsigned int wait; + int err; + + mutex_lock(&priv->mu_cmd_lock); + mutex_lock(&priv->mu_lock); + + err = mbox_send_message(priv->tx_chan, priv->tx_msg); + if (err < 0) { + pr_err("Error: mbox_send_message failure.\n"); + mutex_unlock(&priv->mu_lock); + mutex_unlock(&priv->mu_cmd_lock); + return err; + } + err = 0; + + mutex_unlock(&priv->mu_lock); + + wait = msecs_to_jiffies(1000); + if (!wait_for_completion_timeout(&priv->done, wait)) { + pr_err("Error: wait_for_completion timed out.\n"); + err = -ETIMEDOUT; + } + + mutex_unlock(&priv->mu_cmd_lock); + + return err; +} + +/* Fill a command message header with a given command ID and length in bytes. */ +int plat_fill_cmd_msg_hdr(struct ele_mu_priv *priv, + struct mu_hdr *hdr, + uint8_t cmd, + uint32_t len, + bool is_base_api) +{ + hdr->tag = priv->cmd_tag; + hdr->ver = (is_base_api) ? priv->base_api_ver : priv->fw_api_ver; + hdr->command = cmd; + hdr->size = len >> 2; + + return 0; +} + +int validate_rsp_hdr(struct ele_mu_priv *priv, unsigned int header, + uint8_t msg_id, uint8_t sz, bool is_base_api) +{ + unsigned int tag, command, size, ver; + int ret = -EINVAL; + + tag = MSG_TAG(header); + command = MSG_COMMAND(header); + size = MSG_SIZE(header); + ver = MSG_VER(header); + + do { + if (tag != priv->rsp_tag) { + dev_err(priv->dev, + "MSG[0x%x] Hdr: Resp tag mismatch. (0x%x != 0x%x)", + msg_id, tag, priv->rsp_tag); + break; + } + + if (command != msg_id) { + dev_err(priv->dev, + "MSG Header: Cmd id mismatch. (0x%x != 0x%x)", + command, msg_id); + break; + } + + if (size != (sz >> 2)) { + dev_err(priv->dev, + "MSG[0x%x] Hdr: Cmd size mismatch. (0x%x != 0x%x)", + msg_id, size, (sz >> 2)); + break; + } + + if (is_base_api && (ver != priv->base_api_ver)) { + dev_err(priv->dev, + "MSG[0x%x] Hdr: Base API Vers mismatch. (0x%x != 0x%x)", + msg_id, ver, priv->base_api_ver); + break; + } else if (!is_base_api && ver != priv->fw_api_ver) { + dev_err(priv->dev, + "MSG[0x%x] Hdr: FW API Vers mismatch. (0x%x != 0x%x)", + msg_id, ver, priv->fw_api_ver); + break; + } + + ret = 0; + + } while (false); + + return ret; +} diff --git a/drivers/firmware/imx/ele_common.h b/drivers/firmware/imx/ele_common.h new file mode 100644 index 000000000000..284b7f66d8e3 --- /dev/null +++ b/drivers/firmware/imx/ele_common.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2023 NXP + */ + + +#ifndef __ELE_COMMON_H__ +#define __ELE_COMMON_H__ + +#include "se_fw.h" + +int imx_ele_msg_send_rcv(struct ele_mu_priv *priv); +void imx_se_free_tx_rx_buf(struct ele_mu_priv *priv); +int imx_se_alloc_tx_rx_buf(struct ele_mu_priv *priv); +int validate_rsp_hdr(struct ele_mu_priv *priv, unsigned int header, + uint8_t msg_id, uint8_t sz, bool is_base_api); +int plat_fill_cmd_msg_hdr(struct ele_mu_priv *priv, + struct mu_hdr *hdr, + uint8_t cmd, + uint32_t len, + bool is_base_api); +#ifdef CONFIG_IMX_ELE_TRNG +int ele_trng_init(struct device *dev); +#else +static inline int ele_trng_init(struct device *dev) +{ + return 0; +} +#endif +#endif diff --git a/drivers/firmware/imx/se_fw.c b/drivers/firmware/imx/se_fw.c new file mode 100644 index 000000000000..fc06e9076d00 --- /dev/null +++ b/drivers/firmware/imx/se_fw.c @@ -0,0 +1,1308 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2021-2023 NXP + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "se_fw.h" + +#define SOC_ID_OF_IMX8ULP 0x084D +#define SOC_ID_OF_IMX93 0x9300 +#define SOC_VER_MASK 0xFFFF0000 +#define SOC_ID_MASK 0x0000FFFF +#define RESERVED_DMA_POOL BIT(1) + +struct imx_info { + const uint8_t pdev_name[2][20]; + bool socdev; + uint8_t mu_did; + uint8_t max_dev_ctx; + uint8_t cmd_tag; + uint8_t rsp_tag; + uint8_t success_tag; + uint8_t base_api_ver; + uint8_t fw_api_ver; + uint8_t *se_name; + uint8_t *mbox_tx_name; + uint8_t *mbox_rx_name; + uint8_t *pool_name; + bool reserved_dma_ranges; +}; + +struct imx_info_list { + uint8_t num_mu; + struct imx_info info[]; +}; + +static LIST_HEAD(priv_data_list); + +static const struct imx_info_list imx8ulp_info = { + .num_mu = 1, + .info = { + { + .pdev_name = {"se-fw2", "mu2"}, + .socdev = true, + .mu_did = 7, + .max_dev_ctx = 4, + .cmd_tag = 0x17, + .rsp_tag = 0xe1, + .success_tag = 0xd6, + .base_api_ver = MESSAGING_VERSION_6, + .fw_api_ver = MESSAGING_VERSION_7, + .se_name = "ele", + .mbox_tx_name = "tx", + .mbox_rx_name = "rx", + .pool_name = "sram", + .reserved_dma_ranges = true, + }, + }, +}; + +static const struct imx_info_list imx93_info = { + .num_mu = 1, + .info = { + { + .pdev_name = {"se-fw2", "mu2"}, + .socdev = true, + .mu_did = 3, + .max_dev_ctx = 4, + .cmd_tag = 0x17, + .rsp_tag = 0xe1, + .success_tag = 0xd6, + .base_api_ver = MESSAGING_VERSION_6, + .fw_api_ver = MESSAGING_VERSION_7, + .se_name = "ele", + .mbox_tx_name = "tx", + .mbox_rx_name = "rx", + .pool_name = NULL, + .reserved_dma_ranges = true, + }, + }, +}; + +static const struct of_device_id se_fw_match[] = { + { .compatible = "fsl,imx8ulp-se-fw", .data = (void *)&imx8ulp_info}, + { .compatible = "fsl,imx93-se-fw", .data = (void *)&imx93_info}, + {}, +}; + +static struct imx_info *get_imx_info(struct imx_info_list *info_list, + const uint8_t *pdev_name, + uint8_t len) +{ + int i = 0; + + for (i = 0; i < info_list->num_mu; i++) + if (!memcmp(info_list->info[i].pdev_name[0], pdev_name, len)) + return &info_list->info[i]; + + return NULL; +} + +/* + * Callback called by mailbox FW when data are received + */ +static void ele_mu_rx_callback(struct mbox_client *c, void *msg) +{ + struct device *dev = c->dev; + struct ele_mu_priv *priv = dev_get_drvdata(dev); + struct ele_mu_device_ctx *dev_ctx; + bool is_response = false; + int msg_size; + struct mu_hdr header; + + /* The function can be called with NULL msg */ + if (!msg) { + dev_err(dev, "Message is invalid\n"); + return; + } + + header.tag = ((u8 *)msg)[TAG_OFFSET]; + header.command = ((u8 *)msg)[CMD_OFFSET]; + header.size = ((u8 *)msg)[SZ_OFFSET]; + header.ver = ((u8 *)msg)[VER_OFFSET]; + + /* Incoming command: wake up the receiver if any. */ + if (header.tag == priv->cmd_tag) { + dev_dbg(dev, "Selecting cmd receiver\n"); + dev_ctx = priv->cmd_receiver_dev; + } else if (header.tag == priv->rsp_tag) { + if (priv->waiting_rsp_dev) { + dev_dbg(dev, "Selecting rsp waiter\n"); + dev_ctx = priv->waiting_rsp_dev; + is_response = true; + } else { + /* + * Reading the EdgeLock Enclave response + * to the command, sent by other + * linux kernel services. + */ + spin_lock(&priv->lock); + if (priv->rx_msg) + memcpy(priv->rx_msg, msg, header.size << 2); + else + dev_err(dev, "No RX buffer to save response.\n"); + + complete(&priv->done); + spin_unlock(&priv->lock); + return; + } + } else { + dev_err(dev, "Failed to select a device for message: %.8x\n", + *((u32 *) &header)); + return; + } + + if (!dev_ctx) { + dev_err(dev, "No device context selected for message: %.8x\n", + *((u32 *)&header)); + return; + } + /* Init reception */ + msg_size = header.size; + if (msg_size > MAX_RECV_SIZE) { + dev_err(dev, "%s: Message is too big (%d > %d)", + dev_ctx->miscdev.name, + msg_size, + MAX_RECV_SIZE); + return; + } + + memcpy(dev_ctx->temp_resp, msg, msg_size << 2); + dev_ctx->temp_resp_size = msg_size; + + /* Allow user to read */ + dev_ctx->pending_hdr = dev_ctx->temp_resp[0]; + wake_up_interruptible(&dev_ctx->wq); + + if (is_response) + priv->waiting_rsp_dev = NULL; + +} + +phys_addr_t get_phy_buf_mem_pool(struct device *dev, + char *mem_pool_name, + u32 **buf, + uint32_t size) +{ + struct device_node *of_node = dev->of_node; + struct gen_pool *mem_pool = of_gen_pool_get(of_node, + mem_pool_name, 0); + if (!mem_pool) { + dev_err(dev, "Unable to get sram pool\n"); + return 0; + } + + *buf = (u32 *)gen_pool_alloc(mem_pool, size); + if (!buf) { + dev_err(dev, "Unable to alloc sram from sram pool\n"); + return 0; + } + + return gen_pool_virt_to_phys(mem_pool, (ulong)*buf); +} + +void free_phybuf_mem_pool(struct device *dev, + char *mem_pool_name, + u32 *buf, + uint32_t size) +{ + struct device_node *of_node = dev->of_node; + struct gen_pool *mem_pool = of_gen_pool_get(of_node, + mem_pool_name, 0); + + if (!mem_pool) + dev_err(dev, "%s failed: Unable to get sram pool.\n", __func__); + + gen_pool_free(mem_pool, (unsigned long)buf, size); +} + +static int imx_soc_device_register(struct device *dev, + struct imx_info *info) +{ + struct soc_device_attribute *attr; + struct soc_device *sdev = NULL; + phys_addr_t get_info_addr = 0; + u32 *get_info_data = NULL; + u8 major_ver, minor_ver; + int err; + + if (info->pool_name) { + get_info_addr = get_phy_buf_mem_pool(dev, + info->pool_name, + &get_info_data, + DEVICE_GET_INFO_SZ); + } else { + get_info_data = dmam_alloc_coherent(dev, + DEVICE_GET_INFO_SZ, + &get_info_addr, + GFP_KERNEL); + } + if (!get_info_addr) { + dev_err(dev, "Unable to alloc buffer for device info.\n"); + return -ENOMEM; + } + + attr = kzalloc(sizeof(*attr), GFP_KERNEL); + if (!attr) + return -ENOMEM; + + err = ele_get_info(dev, get_info_addr, ELE_GET_INFO_READ_SZ); + if (err) { + attr->revision = kasprintf(GFP_KERNEL, "A0"); + } else { + major_ver = (get_info_data[GET_INFO_SOC_INFO_WORD_OFFSET] + & SOC_VER_MASK) >> 24; + minor_ver = ((get_info_data[GET_INFO_SOC_INFO_WORD_OFFSET] + & SOC_VER_MASK) >> 16) & 0xFF; + if (minor_ver) + attr->revision = kasprintf(GFP_KERNEL, + "%x.%x", + major_ver, + minor_ver); + else + attr->revision = kasprintf(GFP_KERNEL, + "%x", + major_ver); + + switch (get_info_data[GET_INFO_SOC_INFO_WORD_OFFSET] + & SOC_ID_MASK) { + case SOC_ID_OF_IMX8ULP: + attr->soc_id = kasprintf(GFP_KERNEL, + "i.MX8ULP"); + break; + case SOC_ID_OF_IMX93: + attr->soc_id = kasprintf(GFP_KERNEL, + "i.MX93"); + break; + } + } + + err = of_property_read_string(of_root, "model", + &attr->machine); + if (err) { + kfree(attr); + return -EINVAL; + } + attr->family = kasprintf(GFP_KERNEL, "Freescale i.MX"); + + attr->serial_number + = kasprintf(GFP_KERNEL, "%016llX", + (u64)get_info_data[GET_INFO_SL_NUM_MSB_WORD_OFF] << 32 + | get_info_data[GET_INFO_SL_NUM_LSB_WORD_OFF]); + + if (info->pool_name) { + free_phybuf_mem_pool(dev, info->pool_name, + get_info_data, DEVICE_GET_INFO_SZ); + } else { + dmam_free_coherent(dev, + DEVICE_GET_INFO_SZ, + get_info_data, + get_info_addr); + } + + sdev = soc_device_register(attr); + if (IS_ERR(sdev)) { + kfree(attr->soc_id); + kfree(attr->serial_number); + kfree(attr->revision); + kfree(attr->family); + kfree(attr->machine); + kfree(attr); + return PTR_ERR(sdev); + } + + return 0; +} + +/* + * File operations for user-space + */ + +/* Write a message to the MU. */ +static ssize_t ele_mu_fops_write(struct file *fp, const char __user *buf, + size_t size, loff_t *ppos) +{ + struct ele_mu_device_ctx *dev_ctx + = container_of(fp->private_data, + struct ele_mu_device_ctx, + miscdev); + struct ele_mu_priv *ele_mu_priv = dev_ctx->priv; + u32 nb_words = 0; + struct mu_hdr header; + int err; + + dev_dbg(ele_mu_priv->dev, + "%s: write from buf (%p)%zu, ppos=%lld\n", + dev_ctx->miscdev.name, + buf, size, ((ppos) ? *ppos : 0)); + + if (down_interruptible(&dev_ctx->fops_lock)) + return -EBUSY; + + if (dev_ctx->status != MU_OPENED) { + err = -EINVAL; + goto exit; + } + + if (size < ELE_MU_HDR_SZ) { + dev_err(ele_mu_priv->dev, + "%s: User buffer too small(%zu < %d)\n", + dev_ctx->miscdev.name, + size, ELE_MU_HDR_SZ); + err = -ENOSPC; + goto exit; + } + + if (size > MAX_MESSAGE_SIZE_BYTES) { + dev_err(ele_mu_priv->dev, + "%s: User buffer too big(%zu > %d)\n", + dev_ctx->miscdev.name, + size, + MAX_MESSAGE_SIZE_BYTES); + err = -ENOSPC; + goto exit; + } + + /* Copy data to buffer */ + if (copy_from_user(dev_ctx->temp_cmd, buf, size)) { + err = -EFAULT; + dev_err(ele_mu_priv->dev, + "%s: Fail copy message from user\n", + dev_ctx->miscdev.name); + goto exit; + } + + print_hex_dump_debug("from user ", DUMP_PREFIX_OFFSET, 4, 4, + dev_ctx->temp_cmd, size, false); + + header = *((struct mu_hdr *) (&dev_ctx->temp_cmd[0])); + + /* Check the message is valid according to tags */ + if (header.tag == ele_mu_priv->cmd_tag) { + /* + * Command-lock will be unlocked in ele_mu_fops_read + * when the response to this command, is read. + * + * This command lock is taken to serialize + * the command execution over an MU. + * + * A command execution considered completed, when the + * response to the command is received. + */ + mutex_lock(&ele_mu_priv->mu_cmd_lock); + ele_mu_priv->waiting_rsp_dev = dev_ctx; + } else if (header.tag == ele_mu_priv->rsp_tag) { + /* Check the device context can send the command */ + if (dev_ctx != ele_mu_priv->cmd_receiver_dev) { + dev_err(ele_mu_priv->dev, + "%s: Channel not configured to send resp to FW.", + dev_ctx->miscdev.name); + err = -EPERM; + goto exit; + } + } else { + dev_err(ele_mu_priv->dev, + "%s: The message does not have a valid TAG\n", + dev_ctx->miscdev.name); + err = -EINVAL; + goto exit; + } + + /* + * Check that the size passed as argument matches the size + * carried in the message. + */ + nb_words = header.size; + if (nb_words << 2 != size) { + dev_err(ele_mu_priv->dev, + "%s: User buffer too small\n", + dev_ctx->miscdev.name); + goto exit; + } + + mutex_lock(&ele_mu_priv->mu_lock); + + /* Send message */ + dev_dbg(ele_mu_priv->dev, + "%s: sending message\n", + dev_ctx->miscdev.name); + err = mbox_send_message(ele_mu_priv->tx_chan, dev_ctx->temp_cmd); + if (err < 0) { + dev_err(ele_mu_priv->dev, + "%s: Failed to send message\n", + dev_ctx->miscdev.name); + goto unlock; + } + + err = nb_words << 2; + +unlock: + mutex_unlock(&ele_mu_priv->mu_lock); + +exit: + if (err < 0) + mutex_unlock(&ele_mu_priv->mu_cmd_lock); + up(&dev_ctx->fops_lock); + return err; +} + +/* + * Read a message from the MU. + * Blocking until a message is available. + */ +static ssize_t ele_mu_fops_read(struct file *fp, char __user *buf, + size_t size, loff_t *ppos) +{ + struct ele_mu_device_ctx *dev_ctx + = container_of(fp->private_data, + struct ele_mu_device_ctx, + miscdev); + struct ele_mu_priv *ele_mu_priv = dev_ctx->priv; + u32 data_size = 0, size_to_copy = 0; + struct ele_buf_desc *b_desc; + int err; + struct mu_hdr header = {0}; + + dev_dbg(ele_mu_priv->dev, + "%s: read to buf %p(%zu), ppos=%lld\n", + dev_ctx->miscdev.name, + buf, size, ((ppos) ? *ppos : 0)); + + if (down_interruptible(&dev_ctx->fops_lock)) + return -EBUSY; + + if (dev_ctx->status != MU_OPENED) { + err = -EINVAL; + goto exit; + } + + /* Wait until the complete message is received on the MU. */ + err = wait_event_interruptible(dev_ctx->wq, dev_ctx->pending_hdr != 0); + if (err) { + dev_err(ele_mu_priv->dev, + "%s: Err[0x%x]:Interrupted by signal.\n", + dev_ctx->miscdev.name, err); + goto exit; + } + + dev_dbg(ele_mu_priv->dev, + "%s: %s %s\n", + dev_ctx->miscdev.name, + __func__, + "message received, start transmit to user"); + + /* + * Check that the size passed as argument is larger than + * the one carried in the message. + */ + data_size = dev_ctx->temp_resp_size << 2; + size_to_copy = data_size; + if (size_to_copy > size) { + dev_dbg(ele_mu_priv->dev, + "%s: User buffer too small (%zu < %d)\n", + dev_ctx->miscdev.name, + size, size_to_copy); + size_to_copy = size; + } + + /* + * We may need to copy the output data to user before + * delivering the completion message. + */ + while (!list_empty(&dev_ctx->pending_out)) { + b_desc = list_first_entry_or_null(&dev_ctx->pending_out, + struct ele_buf_desc, + link); + if (!b_desc) + continue; + + if (b_desc->usr_buf_ptr && b_desc->shared_buf_ptr) { + + dev_dbg(ele_mu_priv->dev, + "%s: Copy output data to user\n", + dev_ctx->miscdev.name); + if (copy_to_user(b_desc->usr_buf_ptr, + b_desc->shared_buf_ptr, + b_desc->size)) { + dev_err(ele_mu_priv->dev, + "%s: Failure copying output data to user.", + dev_ctx->miscdev.name); + err = -EFAULT; + goto exit; + } + } + + if (b_desc->shared_buf_ptr) + memset(b_desc->shared_buf_ptr, 0, b_desc->size); + + __list_del_entry(&b_desc->link); + devm_kfree(dev_ctx->dev, b_desc); + } + + header = *((struct mu_hdr *) (&dev_ctx->temp_resp[0])); + + /* Copy data from the buffer */ + print_hex_dump_debug("to user ", DUMP_PREFIX_OFFSET, 4, 4, + dev_ctx->temp_resp, size_to_copy, false); + if (copy_to_user(buf, dev_ctx->temp_resp, size_to_copy)) { + dev_err(ele_mu_priv->dev, + "%s: Failed to copy to user\n", + dev_ctx->miscdev.name); + err = -EFAULT; + goto exit; + } + + err = size_to_copy; + + /* free memory allocated on the shared buffers. */ + dev_ctx->secure_mem.pos = 0; + dev_ctx->non_secure_mem.pos = 0; + + dev_ctx->pending_hdr = 0; + +exit: + /* + * Clean the used Shared Memory space, + * whether its Input Data copied from user buffers, or + * Data received from FW. + */ + while (!list_empty(&dev_ctx->pending_in) || + !list_empty(&dev_ctx->pending_out)) { + if (!list_empty(&dev_ctx->pending_in)) + b_desc = list_first_entry_or_null(&dev_ctx->pending_in, + struct ele_buf_desc, + link); + else + b_desc = list_first_entry_or_null(&dev_ctx->pending_out, + struct ele_buf_desc, + link); + + if (!b_desc) + continue; + + if (b_desc->shared_buf_ptr) + memset(b_desc->shared_buf_ptr, 0, b_desc->size); + + __list_del_entry(&b_desc->link); + devm_kfree(dev_ctx->dev, b_desc); + } + if (header.tag == ele_mu_priv->rsp_tag) + mutex_unlock(&ele_mu_priv->mu_cmd_lock); + + up(&dev_ctx->fops_lock); + return err; +} + +/* Give access to EdgeLock Enclave, to the memory we want to share */ +static int ele_mu_setup_ele_mem_access(struct ele_mu_device_ctx *dev_ctx, + u64 addr, u32 len) +{ + /* Assuming EdgeLock Enclave has access to all the memory regions */ + int ret = 0; + + if (ret) { + dev_err(dev_ctx->priv->dev, + "%s: Fail find memreg\n", dev_ctx->miscdev.name); + goto exit; + } + + if (ret) { + dev_err(dev_ctx->priv->dev, + "%s: Fail set permission for resource\n", + dev_ctx->miscdev.name); + goto exit; + } + +exit: + return ret; +} + +static int ele_mu_ioctl_get_mu_info(struct ele_mu_device_ctx *dev_ctx, + unsigned long arg) +{ + struct ele_mu_priv *priv = dev_get_drvdata(dev_ctx->dev); + struct ele_mu_ioctl_get_mu_info info; + int err = -EINVAL; + + info.ele_mu_id = 0; + info.interrupt_idx = 0; + info.tz = 0; + info.did = priv->ele_mu_did; + + dev_dbg(priv->dev, + "%s: info [mu_idx: %d, irq_idx: %d, tz: 0x%x, did: 0x%x]\n", + dev_ctx->miscdev.name, + info.ele_mu_id, info.interrupt_idx, info.tz, info.did); + + if (copy_to_user((u8 *)arg, &info, sizeof(info))) { + dev_err(dev_ctx->priv->dev, + "%s: Failed to copy mu info to user\n", + dev_ctx->miscdev.name); + err = -EFAULT; + goto exit; + } + +exit: + return err; +} + +/* + * Copy a buffer of data to/from the user and return the address to use in + * messages + */ +static int ele_mu_ioctl_setup_iobuf_handler(struct ele_mu_device_ctx *dev_ctx, + unsigned long arg) +{ + struct ele_buf_desc *b_desc; + struct ele_mu_ioctl_setup_iobuf io = {0}; + struct ele_shared_mem *shared_mem; + int err = 0; + u32 pos; + + if (copy_from_user(&io, (u8 *)arg, sizeof(io))) { + dev_err(dev_ctx->priv->dev, + "%s: Failed copy iobuf config from user\n", + dev_ctx->miscdev.name); + err = -EFAULT; + goto exit; + } + + dev_dbg(dev_ctx->priv->dev, + "%s: io [buf: %p(%d) flag: %x]\n", + dev_ctx->miscdev.name, + io.user_buf, io.length, io.flags); + + if (io.length == 0 || !io.user_buf) { + /* + * Accept NULL pointers since some buffers are optional + * in FW commands. In this case we should return 0 as + * pointer to be embedded into the message. + * Skip all data copy part of code below. + */ + io.ele_addr = 0; + goto copy; + } + + /* Select the shared memory to be used for this buffer. */ + if (io.flags & ELE_MU_IO_FLAGS_USE_SEC_MEM) { + /* App requires to use secure memory for this buffer.*/ + dev_err(dev_ctx->priv->dev, + "%s: Failed allocate SEC MEM memory\n", + dev_ctx->miscdev.name); + err = -EFAULT; + goto exit; + } else { + /* No specific requirement for this buffer. */ + shared_mem = &dev_ctx->non_secure_mem; + } + + /* Check there is enough space in the shared memory. */ + if (shared_mem->size < shared_mem->pos + || io.length >= shared_mem->size - shared_mem->pos) { + dev_err(dev_ctx->priv->dev, + "%s: Not enough space in shared memory\n", + dev_ctx->miscdev.name); + err = -ENOMEM; + goto exit; + } + + /* Allocate space in shared memory. 8 bytes aligned. */ + pos = shared_mem->pos; + shared_mem->pos += round_up(io.length, 8u); + io.ele_addr = (u64)shared_mem->dma_addr + pos; + + if ((io.flags & ELE_MU_IO_FLAGS_USE_SEC_MEM) && + !(io.flags & ELE_MU_IO_FLAGS_USE_SHORT_ADDR)) { + /*Add base address to get full address.*/ + dev_err(dev_ctx->priv->dev, + "%s: Failed allocate SEC MEM memory\n", + dev_ctx->miscdev.name); + err = -EFAULT; + goto exit; + } + + memset(shared_mem->ptr + pos, 0, io.length); + if ((io.flags & ELE_MU_IO_FLAGS_IS_INPUT) || + (io.flags & ELE_MU_IO_FLAGS_IS_IN_OUT)) { + /* + * buffer is input: + * copy data from user space to this allocated buffer. + */ + if (copy_from_user(shared_mem->ptr + pos, io.user_buf, + io.length)) { + dev_err(dev_ctx->priv->dev, + "%s: Failed copy data to shared memory\n", + dev_ctx->miscdev.name); + err = -EFAULT; + goto exit; + } + } + + b_desc = devm_kmalloc(dev_ctx->dev, sizeof(*b_desc), GFP_KERNEL); + if (!b_desc) { + err = -ENOMEM; + dev_err(dev_ctx->priv->dev, + "%s: Failed allocating mem for pending buffer\n", + dev_ctx->miscdev.name); + goto exit; + } + + b_desc->shared_buf_ptr = shared_mem->ptr + pos; + b_desc->usr_buf_ptr = io.user_buf; + b_desc->size = io.length; + + if (io.flags & ELE_MU_IO_FLAGS_IS_INPUT) { + /* + * buffer is input: + * add an entry in the "pending input buffers" list so + * that copied data can be cleaned from shared memory + * later. + */ + list_add_tail(&b_desc->link, &dev_ctx->pending_in); + } else { + /* + * buffer is output: + * add an entry in the "pending out buffers" list so data + * can be copied to user space when receiving ELE + * response. + */ + list_add_tail(&b_desc->link, &dev_ctx->pending_out); + } + +copy: + /* Provide the EdgeLock Enclave address to user space only if success.*/ + if (copy_to_user((u8 *)arg, &io, sizeof(io))) { + dev_err(dev_ctx->priv->dev, + "%s: Failed to copy iobuff setup to user\n", + dev_ctx->miscdev.name); + err = -EFAULT; + goto exit; + } +exit: + return err; +} + +/* Open a char device. */ +static int ele_mu_fops_open(struct inode *nd, struct file *fp) +{ + struct ele_mu_device_ctx *dev_ctx + = container_of(fp->private_data, + struct ele_mu_device_ctx, + miscdev); + int err; + + /* Avoid race if opened at the same time */ + if (down_trylock(&dev_ctx->fops_lock)) + return -EBUSY; + + /* Authorize only 1 instance. */ + if (dev_ctx->status != MU_FREE) { + err = -EBUSY; + goto exit; + } + + /* + * Allocate some memory for data exchanges with S40x. + * This will be used for data not requiring secure memory. + */ + dev_ctx->non_secure_mem.ptr = dmam_alloc_coherent(dev_ctx->dev, + MAX_DATA_SIZE_PER_USER, + &dev_ctx->non_secure_mem.dma_addr, + GFP_KERNEL); + if (!dev_ctx->non_secure_mem.ptr) { + err = -ENOMEM; + dev_err(dev_ctx->priv->dev, + "%s: Failed to map shared memory with FW.\n", + dev_ctx->miscdev.name); + goto exit; + } + + err = ele_mu_setup_ele_mem_access(dev_ctx, + dev_ctx->non_secure_mem.dma_addr, + MAX_DATA_SIZE_PER_USER); + if (err) { + err = -EPERM; + dev_err(dev_ctx->priv->dev, + "%s: Failed to share access to shared memory\n", + dev_ctx->miscdev.name); + goto free_coherent; + } + + dev_ctx->non_secure_mem.size = MAX_DATA_SIZE_PER_USER; + dev_ctx->non_secure_mem.pos = 0; + dev_ctx->status = MU_OPENED; + + dev_ctx->pending_hdr = 0; + + goto exit; + +free_coherent: + dmam_free_coherent(dev_ctx->priv->dev, MAX_DATA_SIZE_PER_USER, + dev_ctx->non_secure_mem.ptr, + dev_ctx->non_secure_mem.dma_addr); + +exit: + up(&dev_ctx->fops_lock); + return err; +} + +/* Close a char device. */ +static int ele_mu_fops_close(struct inode *nd, struct file *fp) +{ + struct ele_mu_device_ctx *dev_ctx = container_of(fp->private_data, + struct ele_mu_device_ctx, miscdev); + struct ele_mu_priv *priv = dev_ctx->priv; + struct ele_buf_desc *b_desc; + + /* Avoid race if closed at the same time */ + if (down_trylock(&dev_ctx->fops_lock)) + return -EBUSY; + + /* The device context has not been opened */ + if (dev_ctx->status != MU_OPENED) + goto exit; + + /* check if this device was registered as command receiver. */ + if (priv->cmd_receiver_dev == dev_ctx) + priv->cmd_receiver_dev = NULL; + + /* check if this device was registered as waiting response. */ + if (priv->waiting_rsp_dev == dev_ctx) { + priv->waiting_rsp_dev = NULL; + mutex_unlock(&priv->mu_cmd_lock); + } + + /* Unmap secure memory shared buffer. */ + if (dev_ctx->secure_mem.ptr) + devm_iounmap(dev_ctx->dev, dev_ctx->secure_mem.ptr); + + dev_ctx->secure_mem.ptr = NULL; + dev_ctx->secure_mem.dma_addr = 0; + dev_ctx->secure_mem.size = 0; + dev_ctx->secure_mem.pos = 0; + + /* Free non-secure shared buffer. */ + dmam_free_coherent(dev_ctx->priv->dev, MAX_DATA_SIZE_PER_USER, + dev_ctx->non_secure_mem.ptr, + dev_ctx->non_secure_mem.dma_addr); + + dev_ctx->non_secure_mem.ptr = NULL; + dev_ctx->non_secure_mem.dma_addr = 0; + dev_ctx->non_secure_mem.size = 0; + dev_ctx->non_secure_mem.pos = 0; + + while (!list_empty(&dev_ctx->pending_in) || + !list_empty(&dev_ctx->pending_out)) { + if (!list_empty(&dev_ctx->pending_in)) + b_desc = list_first_entry_or_null(&dev_ctx->pending_in, + struct ele_buf_desc, + link); + else + b_desc = list_first_entry_or_null(&dev_ctx->pending_out, + struct ele_buf_desc, + link); + + if (!b_desc) + continue; + + if (b_desc->shared_buf_ptr) + memset(b_desc->shared_buf_ptr, 0, b_desc->size); + + __list_del_entry(&b_desc->link); + devm_kfree(dev_ctx->dev, b_desc); + } + + dev_ctx->status = MU_FREE; + +exit: + up(&dev_ctx->fops_lock); + return 0; +} + +/* IOCTL entry point of a char device */ +static long ele_mu_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) +{ + struct ele_mu_device_ctx *dev_ctx + = container_of(fp->private_data, + struct ele_mu_device_ctx, + miscdev); + struct ele_mu_priv *ele_mu_priv = dev_ctx->priv; + int err = -EINVAL; + + /* Prevent race during change of device context */ + if (down_interruptible(&dev_ctx->fops_lock)) + return -EBUSY; + + switch (cmd) { + case ELE_MU_IOCTL_ENABLE_CMD_RCV: + if (!ele_mu_priv->cmd_receiver_dev) { + ele_mu_priv->cmd_receiver_dev = dev_ctx; + err = 0; + } + break; + case ELE_MU_IOCTL_GET_MU_INFO: + err = ele_mu_ioctl_get_mu_info(dev_ctx, arg); + break; + case ELE_MU_IOCTL_SETUP_IOBUF: + err = ele_mu_ioctl_setup_iobuf_handler(dev_ctx, arg); + break; + default: + err = -EINVAL; + dev_dbg(ele_mu_priv->dev, + "%s: IOCTL %.8x not supported\n", + dev_ctx->miscdev.name, + cmd); + } + + up(&dev_ctx->fops_lock); + return (long)err; +} + +/* Char driver setup */ +static const struct file_operations ele_mu_fops = { + .open = ele_mu_fops_open, + .owner = THIS_MODULE, + .release = ele_mu_fops_close, + .unlocked_ioctl = ele_mu_ioctl, + .read = ele_mu_fops_read, + .write = ele_mu_fops_write, +}; + +/* interface for managed res to free a mailbox channel */ +static void if_mbox_free_channel(void *mbox_chan) +{ + mbox_free_channel(mbox_chan); +} + +/* interface for managed res to unregister a char device */ +static void if_misc_deregister(void *miscdevice) +{ + misc_deregister(miscdevice); +} + +static int ele_mu_request_channel(struct device *dev, + struct mbox_chan **chan, + struct mbox_client *cl, + const char *name) +{ + struct mbox_chan *t_chan; + int ret = 0; + + t_chan = mbox_request_channel_byname(cl, name); + if (IS_ERR(t_chan)) { + ret = PTR_ERR(t_chan); + if (ret != -EPROBE_DEFER) + dev_err(dev, + "Failed to request chan %s ret %d\n", name, + ret); + goto exit; + } + + ret = devm_add_action(dev, if_mbox_free_channel, t_chan); + if (ret) { + dev_err(dev, "failed to add devm removal of mbox %s\n", name); + goto exit; + } + + *chan = t_chan; + +exit: + return ret; +} + +static int se_probe_cleanup(struct platform_device *pdev) +{ + int ret; + int i; + struct device *dev = &pdev->dev; + struct ele_mu_priv *priv; + + priv = dev_get_drvdata(dev); + + if (!priv) { + ret = -EINVAL; + dev_err(dev, "Invalid ELE-MU Priv data"); + return ret; + } + + if (priv->tx_chan) + mbox_free_channel(priv->tx_chan); + if (priv->rx_chan) + mbox_free_channel(priv->rx_chan); + + if (priv->flags & RESERVED_DMA_POOL) { + of_reserved_mem_device_release(dev); + priv->flags &= (~RESERVED_DMA_POOL); + } + + if (priv->ctxs) { + for (i = 0; i < priv->max_dev_ctx; i++) { + if (priv->ctxs[i]) + devm_kfree(dev, priv->ctxs[i]); + } + devm_kfree(dev, priv->ctxs); + } + + __list_del_entry(&priv->priv_data); + + devm_kfree(dev, priv); + return ret; +} + +static int se_fw_probe(struct platform_device *pdev) +{ + struct ele_mu_device_ctx *dev_ctx; + struct device *dev = &pdev->dev; + struct ele_mu_priv *priv; + const struct of_device_id *of_id = of_match_device(se_fw_match, dev); + struct imx_info *info = NULL; + char *devname; + int ret; + int i; + struct device_node *np; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) { + ret = -ENOMEM; + dev_dbg(dev, "Fail allocate mem for private data\n"); + return ret; + } + memset(priv, 0x0, sizeof(*priv)); + priv->dev = dev; + dev_set_drvdata(dev, priv); + + list_add_tail(&priv->priv_data, &priv_data_list); + + /* + * Get the address of MU. + */ + np = pdev->dev.of_node; + if (!np) { + dev_dbg(dev, "Cannot find entry in device tree\n"); + ret = -EOPNOTSUPP; + goto exit; + } + + /* Initialize the mutex. */ + mutex_init(&priv->mu_cmd_lock); + mutex_init(&priv->mu_lock); + + priv->cmd_receiver_dev = NULL; + priv->waiting_rsp_dev = NULL; + + /* Mailbox client configuration */ + priv->ele_mb_cl.dev = dev; + priv->ele_mb_cl.tx_block = false; + priv->ele_mb_cl.knows_txdone = true; + priv->ele_mb_cl.rx_callback = ele_mu_rx_callback; + + info = get_imx_info((struct imx_info_list *)of_id->data, + pdev->name, strlen(pdev->name) + 1); + + if (!info) { + dev_dbg(dev, "Cannot find matching dev-info.\n"); + ret = -EOPNOTSUPP; + goto exit; + } + + priv->info = info; + memcpy(priv->pdev_name, pdev->name, strlen(pdev->name) + 1); + priv->max_dev_ctx = info->max_dev_ctx; + priv->cmd_tag = info->cmd_tag; + priv->rsp_tag = info->rsp_tag; + priv->success_tag = info->success_tag; + priv->base_api_ver = info->base_api_ver; + priv->fw_api_ver = info->fw_api_ver; + + ret = ele_mu_request_channel(dev, &priv->tx_chan, + &priv->ele_mb_cl, info->mbox_tx_name); + if (ret) { + if (ret == -EPROBE_DEFER) + dev_dbg(dev, "Mailbox tx channel, is not ready.\n"); + else + dev_dbg(dev, "Failed to request tx channel\n"); + + goto exit; + } + + ret = ele_mu_request_channel(dev, &priv->rx_chan, + &priv->ele_mb_cl, info->mbox_rx_name); + if (ret) { + if (ret == -EPROBE_DEFER) + dev_dbg(dev, "Mailbox rx channel, is not ready.\n"); + else + dev_dbg(dev, "Failed to request rx channel\n"); + + goto exit; + } + + priv->ctxs = devm_kzalloc(dev, sizeof(dev_ctx) * priv->max_dev_ctx, + GFP_KERNEL); + + if (!priv->ctxs) { + ret = -ENOMEM; + dev_dbg(dev, "Fail allocate mem for private dev-ctxs.\n"); + goto exit; + } + + /* Create users */ + for (i = 0; i < priv->max_dev_ctx; i++) { + dev_ctx = devm_kzalloc(dev, sizeof(*dev_ctx), GFP_KERNEL); + if (!dev_ctx) { + ret = -ENOMEM; + dev_dbg(dev, + "Fail to allocate memory for device context\n"); + goto exit; + } + + dev_ctx->dev = dev; + dev_ctx->status = MU_FREE; + dev_ctx->priv = priv; + + priv->ctxs[i] = dev_ctx; + + /* Default value invalid for an header. */ + init_waitqueue_head(&dev_ctx->wq); + + INIT_LIST_HEAD(&dev_ctx->pending_out); + INIT_LIST_HEAD(&dev_ctx->pending_in); + sema_init(&dev_ctx->fops_lock, 1); + + devname = devm_kasprintf(dev, GFP_KERNEL, "%s_%s_ch%d", + info->se_name, + info->pdev_name[1], i); + if (!devname) { + ret = -ENOMEM; + dev_dbg(dev, + "Fail to allocate memory for misc dev name\n"); + goto exit; + } + + dev_ctx->miscdev.name = devname; + dev_ctx->miscdev.minor = MISC_DYNAMIC_MINOR; + dev_ctx->miscdev.fops = &ele_mu_fops; + dev_ctx->miscdev.parent = dev; + ret = misc_register(&dev_ctx->miscdev); + if (ret) { + dev_err(dev, "failed to register misc device %d\n", + ret); + goto exit; + } + + ret = devm_add_action(dev, if_misc_deregister, + &dev_ctx->miscdev); + if (ret) { + dev_err(dev, + "failed[%d] to add action to the misc-dev\n", + ret); + goto exit; + } + } + + init_completion(&priv->done); + spin_lock_init(&priv->lock); + + dev_set_drvdata(dev, priv); + + if (info->reserved_dma_ranges) { + ret = of_reserved_mem_device_init(dev); + if (ret) { + dev_err(dev, + "failed to init reserved memory region %d\n", + ret); + priv->flags &= (~RESERVED_DMA_POOL); + goto exit; + } + priv->flags |= RESERVED_DMA_POOL; + } + + if (info->socdev) { + ret = imx_soc_device_register(dev, info); + if (ret) { + dev_err(dev, + "failed[%d] to register SoC device\n", ret); + goto exit; + } + } + + ret = ele_ping(dev); + if (ret) + dev_err(dev, "Failed[%d] to ping the fw.\n", ret); + + dev_info(dev, "i.MX secure-enclave: %s interface to firmware, configured.\n", + info->pdev_name[1]); + + return devm_of_platform_populate(dev); + +exit: + /* if execution control reaches here, ele-mu probe fail. + * hence doing the cleanup + */ + return se_probe_cleanup(pdev); +} + +static int se_fw_remove(struct platform_device *pdev) +{ + se_probe_cleanup(pdev); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int se_fw_suspend(struct device *dev) +{ + return 0; +} + +static int se_fw_resume(struct device *dev) +{ + struct ele_mu_priv *priv = dev_get_drvdata(dev); + int i; + + for (i = 0; i < priv->max_dev_ctx; i++) + wake_up_interruptible(&priv->ctxs[i]->wq); + + return 0; +} +#endif + +static const struct dev_pm_ops se_fw_pm = { + SET_SYSTEM_SLEEP_PM_OPS(se_fw_suspend, se_fw_resume) +}; + +static struct platform_driver se_fw_driver = { + .driver = { + .name = "fsl-se-fw", + .of_match_table = se_fw_match, + .pm = &se_fw_pm, + }, + .probe = se_fw_probe, + .remove = se_fw_remove, +}; +MODULE_DEVICE_TABLE(of, se_fw_match); + +module_platform_driver(se_fw_driver); + +MODULE_AUTHOR("Pankaj Gupta "); +MODULE_DESCRIPTION("iMX Secure Enclave FW Driver."); +MODULE_LICENSE("GPL"); diff --git a/drivers/firmware/imx/se_fw.h b/drivers/firmware/imx/se_fw.h new file mode 100644 index 000000000000..c7d7eaec199b --- /dev/null +++ b/drivers/firmware/imx/se_fw.h @@ -0,0 +1,154 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2021-2023 NXP + */ + +#ifndef SE_MU_H +#define SE_MU_H + +#include +#include +#include + +#define MAX_MESSAGE_SIZE 31 +#define MAX_RECV_SIZE MAX_MESSAGE_SIZE +#define MAX_RECV_SIZE_BYTES (MAX_RECV_SIZE << 2) +#define MAX_MESSAGE_SIZE_BYTES (MAX_MESSAGE_SIZE << 2) + +#define ELE_MSG_DATA_NUM 10 + +#define MSG_TAG(x) (((x) & 0xff000000) >> 24) +#define MSG_COMMAND(x) (((x) & 0x00ff0000) >> 16) +#define MSG_SIZE(x) (((x) & 0x0000ff00) >> 8) +#define MSG_VER(x) ((x) & 0x000000ff) +#define RES_STATUS(x) ((x) & 0x000000ff) +#define MAX_DATA_SIZE_PER_USER (65 * 1024) +#define S4_DEFAULT_MUAP_INDEX (2) +#define S4_MUAP_DEFAULT_MAX_USERS (4) +#define MESSAGING_VERSION_6 0x6 +#define MESSAGING_VERSION_7 0x7 + +#define DEFAULT_MESSAGING_TAG_COMMAND (0x17u) +#define DEFAULT_MESSAGING_TAG_RESPONSE (0xe1u) + +#define ELE_MU_IO_FLAGS_USE_SEC_MEM (0x02u) +#define ELE_MU_IO_FLAGS_USE_SHORT_ADDR (0x04u) + +struct ele_imem_buf { + u8 *buf; + phys_addr_t phyaddr; + u32 size; +}; + +struct ele_buf_desc { + u8 *shared_buf_ptr; + u8 *usr_buf_ptr; + u32 size; + struct list_head link; +}; + +/* Status of a char device */ +enum mu_device_status_t { + MU_FREE, + MU_OPENED +}; + +struct ele_shared_mem { + dma_addr_t dma_addr; + u32 size; + u32 pos; + u8 *ptr; +}; + +/* Private struct for each char device instance. */ +struct ele_mu_device_ctx { + struct device *dev; + struct ele_mu_priv *priv; + struct miscdevice miscdev; + + enum mu_device_status_t status; + wait_queue_head_t wq; + struct semaphore fops_lock; + + u32 pending_hdr; + struct list_head pending_in; + struct list_head pending_out; + + struct ele_shared_mem secure_mem; + struct ele_shared_mem non_secure_mem; + + u32 temp_cmd[MAX_MESSAGE_SIZE]; + u32 temp_resp[MAX_RECV_SIZE]; + u32 temp_resp_size; + struct notifier_block ele_notify; +}; + +/* Header of the messages exchange with the EdgeLock Enclave */ +struct mu_hdr { + u8 ver; + u8 size; + u8 command; + u8 tag; +} __packed; + +#define ELE_MU_HDR_SZ 4 +#define TAG_OFFSET (ELE_MU_HDR_SZ - 1) +#define CMD_OFFSET (ELE_MU_HDR_SZ - 2) +#define SZ_OFFSET (ELE_MU_HDR_SZ - 3) +#define VER_OFFSET (ELE_MU_HDR_SZ - 4) + +struct ele_api_msg { + u32 header; /* u8 Tag; u8 Command; u8 Size; u8 Ver; */ + u32 data[ELE_MSG_DATA_NUM]; +}; + +struct ele_mu_priv { + struct list_head priv_data; + struct ele_mu_device_ctx *cmd_receiver_dev; + struct ele_mu_device_ctx *waiting_rsp_dev; + /* + * prevent parallel access to the MU registers + * e.g. a user trying to send a command while the other one is + * sending a response. + */ + struct mutex mu_lock; + /* + * prevent a command to be sent on the MU while another one is still + * processing. (response to a command is allowed) + */ + struct mutex mu_cmd_lock; + struct device *dev; + u8 ele_mu_did; + u8 pdev_name[20]; + u32 ele_mu_id; + u8 cmd_tag; + u8 rsp_tag; + u8 success_tag; + u8 base_api_ver; + u8 fw_api_ver; + const void *info; + + struct mbox_client ele_mb_cl; + struct mbox_chan *tx_chan, *rx_chan; + struct ele_api_msg *tx_msg, *rx_msg; + struct completion done; + spinlock_t lock; + /* + * Flag to retain the state of initialization done at + * the time of ele-mu probe. + */ + uint32_t flags; + u8 max_dev_ctx; + struct ele_mu_device_ctx **ctxs; + struct ele_imem_buf imem; +}; + +phys_addr_t get_phy_buf_mem_pool(struct device *dev, + char *mem_pool_name, + u32 **buf, + uint32_t size); +void free_phybuf_mem_pool(struct device *dev, + char *mem_pool_name, + u32 *buf, + uint32_t size); +#endif diff --git a/include/linux/firmware/imx/ele_base_msg.h b/include/linux/firmware/imx/ele_base_msg.h new file mode 100644 index 000000000000..49e3619372be --- /dev/null +++ b/include/linux/firmware/imx/ele_base_msg.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2021-2023 NXP + * + * Header file for the ELE Base API(s). + */ + +#ifndef ELE_BASE_MSG_H +#define ELE_BASE_MSG_H + +#include + +#define WORD_SZ 4 +#define ELE_NONE_VAL 0x0 + +#define ELE_SUCCESS_IND 0xD6 + +#define ELE_GET_INFO_REQ 0xDA +#define ELE_GET_INFO_REQ_MSG_SZ 0x10 +#define ELE_GET_INFO_RSP_MSG_SZ 0x08 + +#define ELE_GET_INFO_BUFF_SZ 0x100 +#define ELE_GET_INFO_READ_SZ 0xA0 +#define DEVICE_GET_INFO_SZ 0x100 + +#define GET_INFO_SOC_INFO_WORD_OFFSET 1 +#define GET_INFO_UUID_WORD_OFFSET 3 +#define GET_INFO_SL_NUM_MSB_WORD_OFF \ + (GET_INFO_UUID_WORD_OFFSET + 3) +#define GET_INFO_SL_NUM_LSB_WORD_OFF \ + (GET_INFO_UUID_WORD_OFFSET + 0) + +#define ELE_PING_REQ 0x01 +#define ELE_PING_REQ_SZ 0x04 +#define ELE_PING_RSP_SZ 0x08 + +int ele_get_info(struct device *dev, phys_addr_t addr, u32 data_size); +int ele_ping(struct device *dev); + +#endif diff --git a/include/linux/firmware/imx/ele_mu_ioctl.h b/include/linux/firmware/imx/ele_mu_ioctl.h new file mode 100644 index 000000000000..e4017dd1337a --- /dev/null +++ b/include/linux/firmware/imx/ele_mu_ioctl.h @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause*/ +/* + * Copyright 2019-2023 NXP + */ + +#ifndef ELE_MU_IOCTL_H +#define ELE_MU_IOCTL_H + +/* IOCTL definitions. */ + +struct ele_mu_ioctl_setup_iobuf { + u8 *user_buf; + u32 length; + u32 flags; + u64 ele_addr; +}; + +struct ele_mu_ioctl_shared_mem_cfg { + u32 base_offset; + u32 size; +}; + +struct ele_mu_ioctl_get_mu_info { + u8 ele_mu_id; + u8 interrupt_idx; + u8 tz; + u8 did; +}; + +struct ele_mu_ioctl_signed_message { + u8 *message; + u32 msg_size; + u32 error_code; +}; + +/* IO Buffer Flags */ +#define ELE_MU_IO_FLAGS_IS_OUTPUT (0x00u) +#define ELE_MU_IO_FLAGS_IS_INPUT (0x01u) +#define ELE_MU_IO_FLAGS_USE_SEC_MEM (0x02u) +#define ELE_MU_IO_FLAGS_USE_SHORT_ADDR (0x04u) +#define ELE_MU_IO_DATA_BUF_SHE_V2X (0x08u) +#define ELE_MU_IO_FLAGS_IS_IN_OUT (0x10u) + +/* IOCTLS */ +#define ELE_MU_IOCTL 0x0A /* like MISC_MAJOR. */ + +/* + * ioctl to designated the current fd as logical-reciever. + * This is ioctl is send when the nvm-daemon, a slave to the + * firmware is started by the user. + */ +#define ELE_MU_IOCTL_ENABLE_CMD_RCV _IO(ELE_MU_IOCTL, 0x01) + +/* + * ioctl to get the buffer allocated from the memory, which is shared + * between kernel and FW. + * Post allocation, the kernel tagged the allocated memory with: + * Output + * Input + * Input-Output + * Short address + * Secure-memory + */ +#define ELE_MU_IOCTL_SETUP_IOBUF _IOWR(ELE_MU_IOCTL, 0x03, \ + struct ele_mu_ioctl_setup_iobuf) + +/* + * ioctl to get the mu information, that is used to exchange message + * with FW, from user-spaced. + */ +#define ELE_MU_IOCTL_GET_MU_INFO _IOR(ELE_MU_IOCTL, 0x04, \ + struct ele_mu_ioctl_get_mu_info) + +#endif From patchwork Mon Oct 30 09:58:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440504 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 C056BC4332F for ; Mon, 30 Oct 2023 11:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RD01cajpSFVpxu355eJEu9R0PKPbOxErUA6GYn6s27M=; b=PRzJ+RH7lCVrXH YvWRxI+c/oGZUZjfVd0RYUOnItdw/YtRUt0It3dsyAUimnG2CwmkpDbEA5VbXCgGimO7nf/Q5Tq/A ZYrijjGRsYvFNMDepEyUHJTMAYgNnHctwBqlcgkUigPvt5sN/lYrqHwpXwPAoCzA3i9gLH0aKvPix QjrOo7KloktPSC5HLf2g/rYm0SoKFkhc2wplji6cBeKDwgq6EM25pDq+Ore+5yZ0kZiRKYe6CgxV2 eLUrpUJFd25lBz7uqyoqiCyC2qUvoq4twpgHc4eyhJtIe35/jkKmOsIEj0RYz+PEZDOTPpeUjNIpX SGBk3UPOIf066yAQ8j+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxQEn-003FFa-1x; Mon, 30 Oct 2023 11:15:17 +0000 Received: from mail-db5eur01on0623.outbound.protection.outlook.com ([2a01:111:f400:fe02::623] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP4G-002xrY-1j for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 10:00:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R1NkYfdtxQ5xtWE+EBP2iW90bSp/yMc+d7R2Ys5xqWqGXVN6NfS5hCrVmCziuVL8Aw7S1ATbNHcYlh2bpWdr+lIOWhvCyxCEjwj5XbgLhRB4F1K3C5cI+wVeEOLHNWAWenp8cSOvZb6geRIX2WQSNENbjIfT18YMWWqNCJ8hHdQS+8ZsccT6nANBxSUe+lux3Z4Vh3+qrykRZDBTPiUvp4DDQoVIEXdIQjoKfhEsnH4K4825LvZ4regv4w4vHk0PFvvrnRtBM6VYFQfbO687Ud0bFbyWrkc/wHd0AjU11OUu/sO5unrzPWDxgn4nLme+1RKqu0iA2KilM+6t6coirA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Vgm8y7ATuZJ1awfg9Mv/pgp7xz4V7XqFF429jBVPLKc=; b=MKapxhdhfwHvNN2lxVOTVAYwnHt5e9yxbnOz5PVYreEgHzewMRZkOJxYa85CiLXUlKQK2TOVWx3QXCFhFeV0hhE45rFswUAMu42bQWRM5RfAYrQhwpLjKPIdUSS/RE4K4QTZjvf/s57nrVwaDoa5kg8rKju1usHF3ESuX4UMvbobJBQNIqQa//4KETBOnwuEU5k7Ac3e1E18ZxEqwTaUWB4n5deHy/GBLN9W6YzqTi6f8V+eM1zvLcGsWlozaMaAtiVzJ9xY9Sm5EROwI43Cp1M+xggPxP3qfAszRie4GKMjKQIfS3JDCY0daW5DjwwHwzED4+anTqwtuD0rz9bSUw== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vgm8y7ATuZJ1awfg9Mv/pgp7xz4V7XqFF429jBVPLKc=; b=XMbMfRNUjpw7CsDQP0P+DtnwsD1ye0vTvDwaOvAv548Vsm5xk/JwBdt/lxStJv1JiJRVTD9IpgZ1s+sVQHG3odmQ13rZtDzmCfO8czGk1Hwxtyiiudi4+UalFLjztckzLT8/qozVpE3a+TxVA5/D8B9VEZYZ+gVz5/maLDlwpfE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB8513.eurprd04.prod.outlook.com (2603:10a6:20b:340::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Mon, 30 Oct 2023 10:00:13 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 10:00:13 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta Subject: [PATCH v7 08/11] firmware: imx: init-fw api exchange on imx93 Date: Mon, 30 Oct 2023 15:28:46 +0530 Message-Id: <20231030095849.3456820-9-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8513:EE_ X-MS-Office365-Filtering-Correlation-Id: c50e1b32-1485-4ed8-5cb7-08dbd92f02ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9ocwOilMFy3XYs4vttVmpjqepa+LJq8/t7OiaqCsanqlTpjH7Rr3Fi0iaBK4nyatLuvJm4RmoC7KiAsDnSCMijMrnB6d7T7wwEltgfCw6UwNwOJFzwK1DLL2uyzXucM0tKx3P5q6Bh3GuvJ4FEtXSQZWtLBOkSDYngVTPFKPVYuVVejkOWaLNtx7gGFw8k6dWyTfBToyVb7wXMcT15GruRnE35/SVIxHrfaiqSGcQxx2aOeHkvyMzAY5sBSR2GBhl2jVWb32Hw8DiJGXlrotTKWSNGc1sMyUTKYVUYUkmasoyGmelJmk6+7dELvg+YSAL2yr4+8krUucrmPZK2BKHQ1CG7u07CNLNSdV3PaE2WHWNCATrTmVM5btGzBLpYhXR9+oRZsmaLxnVr/tvu+FuyKaRDKxb2qz1N8u0Z7PWGnvuH6hwsaSAvUIAnYxEo122NaHCO3L/rokhGZ5ksbQSFYK7B6Fq7yoI7NqdGyKkBcvsXwsZnUJRKUEc7vQUyjlF7fPvQHkN0xQuvjH9RX48hbTK4+wCESqLWyc3u9uzwfbZ4/SimdqyN0tU4ph1wZiQ+4oZ9Cs2siZbJfSxDFhWAZlnO3XDTU420kz7rp6rb+WMLqizLtFrtv/y4uPBRQi X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(396003)(39860400002)(376002)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(478600001)(6666004)(66946007)(6486002)(6506007)(83380400001)(36756003)(38100700002)(66556008)(1076003)(2616005)(66476007)(2906002)(41300700001)(26005)(52116002)(6512007)(44832011)(86362001)(38350700005)(921008)(6636002)(8676002)(4326008)(5660300002)(8936002)(316002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c4832OQrkqFvKOSkp+dfgCGRtF9uUc9DEDlHd1yTFjULWxwKeSBMPvksp235+Oq2iM3hKOhn3t4KbCmukaJJtC+a5xhgzyAHkqGx1ULmeCt5tCjnlSIA/sqQz4Y90gZVRCU2zxqnaEHO/JHNkI7ApCXE+2p3YhWtaNd/t7riH4I+9yicsMZhYBol/SUfMeIxG8UILSOOh1C7N2A6kr+VVBHIOGsHDeaA5D7lMRQbXXHR8EHazt+gpGnG03lbi0uSB9vd8ZDbeHrlFWSziMpN3GNGaQkdEHYinh6N2xOYSNJzYGJVux0iyI2oY4SJf6Zl2B4H62zrc1tc8PE9uZpGZHXBPMkYN4j0lwYtnywyq91lVmHEkdbqBFOAkdTR7LLw8gHBkHP/0H2eidX8NxmcbB3ZwwQ+HYjTtp6HP11PJKVbfqsS0FNC3OziLJ3O7yXgZkj8mdBDOW3JLxDbstSs/2vMtXXw/uVCl8PkFIK3YUyWEG5qoU0xcKeZuT16fP7/uoi2+u1gYpctblMYjRX5e2xPc6Qrta2Uea8eJEyPxzjGUxqsmg9Dmvt/IKiR17/U8JmpGlG5itLQYdzDwrgtMOgksB5LIJY5vHas0QSxcQvdZPl3nHdKcgQ4tEa5iAw+Q5OUXOYWDgMYHurvHWAtys1BcLjPpjuemh+G+Q/adxIpoDJVLrIRx9AQNlPgmXP2SgXXwvzLKGhLKhMSpKmXvo5+Amjj+bLFOFjr57exndSQ7q2cDGxeAqCypMba2s7by/PFECNOeeXhLNovs1nsvMtP7eXzHhvtG5xhGzCECyPzKEAJT5KTZ06yR2poZA3zN6yJYb5dscse0NQQlsOlCwWSVolaDZlQgrJ7j5kMybo89Lm9qSWQPASEOCBCA/47JfpWnRP3+7TxdjdpspneCXLYI1Scj8sPSyeDPU/meKiW2YfSpzJYyeQSaHKdU3TkekwQI4r5snjem2SpanZONGdK1GCsk7in2YPYvQYr19gGpzNvNPq9Xd85m5dRLe5wnDUBFK78ZksAyyErKdUV2quojacnXWQFJamx4/zyAweljrRDIthXJHv+wKDmA80OUXmIsMDp6fgPT8XcVL/JLq0yxS13qyFh0S4KI+CKN9kDJ+uwqjiIV0YLMMo7T7BExqR12ZjJ8dSX+faqg51nOjYZwkzsuQn6TnChNjqlDA4o9NAgbNPXfrqLKSrvuvfxnKkUp6QmrrnkWb8g+aUEHRUXs+Ptj0sDQ+dMhTsCPKuMKlI4w3XPAEZGctdTwUaxhUoTGm63NJfUup0xzyeyZ5ChBCg8dj/BO5JN6VxM/3RuYe+o0usDiNkNZfSU1y+sQD/L7ap5GK4eaalnfYYeAEJXylYMDcsEZ9GYl1cWr23a16SSzxCGOLKjfH0DpFCWntmm+QXn9rfVw+fYSPN5N/wG16UWzta5iWnG9Jouk0t3wld1wT7JZvLmR9Hd4ZfgBnvj/W+xUES3VJrL983xA/HFZrvNLO2nIyS9brcSJUsuyQvuR9nj0ziw2bggkl9PSPfHpqO8+2GWQgQtK3adEfPR0FFrQKB7fcoHx4Jnr9u6VCC7SgwlI/g3be/D+OQr X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c50e1b32-1485-4ed8-5cb7-08dbd92f02ca X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 10:00:13.8590 (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: LZzc2LcUb+fB0TJomenrO5N3mvfq3b+YnzwUxhBiKXpSgLuc5UZ8ECyZ4Zson+JdiAseMjkrRrS+vcssd7RM+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8513 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_030020_583661_0B89CA9C X-CRM114-Status: GOOD ( 22.43 ) 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 On imx93 platforms, exchange init-fw message with enclave's firmware is to be done. Signed-off-by: Pankaj Gupta --- drivers/firmware/imx/Makefile | 2 +- drivers/firmware/imx/ele_fw_api.c | 51 +++++++++++++++++++++++++++++++ drivers/firmware/imx/ele_fw_api.h | 20 ++++++++++++ drivers/firmware/imx/se_fw.c | 13 +++++++- 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 drivers/firmware/imx/ele_fw_api.c create mode 100644 drivers/firmware/imx/ele_fw_api.h diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 77ec0f922788..d61f06a8050a 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,5 +1,5 @@ # 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 -sec_enclave-objs = se_fw.o ele_common.o ele_base_msg.o +sec_enclave-objs = se_fw.o ele_common.o ele_base_msg.o ele_fw_api.o obj-${CONFIG_IMX_SEC_ENCLAVE} += sec_enclave.o diff --git a/drivers/firmware/imx/ele_fw_api.c b/drivers/firmware/imx/ele_fw_api.c new file mode 100644 index 000000000000..55dda9d6531a --- /dev/null +++ b/drivers/firmware/imx/ele_fw_api.c @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2023 NXP + */ + +#include + +#include "ele_common.h" +#include "ele_fw_api.h" + +int ele_init_fw(struct device *dev) +{ + struct ele_mu_priv *priv = dev_get_drvdata(dev); + unsigned int status; + int ret; + + ret = imx_se_alloc_tx_rx_buf(priv); + if (ret) + return ret; + + ret = plat_fill_cmd_msg_hdr(priv, + (struct mu_hdr *)&priv->tx_msg->header, + ELE_INIT_FW_REQ, ELE_INIT_FW_REQ_SZ, + false); + if (ret) + goto exit; + + ret = imx_ele_msg_send_rcv(priv); + if (ret < 0) + goto exit; + + ret = validate_rsp_hdr(priv, + priv->rx_msg->header, + ELE_INIT_FW_REQ, + ELE_INIT_FW_RSP_SZ, + false); + if (ret) + goto exit; + + status = RES_STATUS(priv->rx_msg->data[0]); + if (status != priv->success_tag) { + dev_err(dev, "Command Id[%d], Response Failure = 0x%x", + ELE_INIT_FW_REQ, status); + ret = -1; + } + +exit: + imx_se_free_tx_rx_buf(priv); + + return ret; +} diff --git a/drivers/firmware/imx/ele_fw_api.h b/drivers/firmware/imx/ele_fw_api.h new file mode 100644 index 000000000000..21bb35b4041f --- /dev/null +++ b/drivers/firmware/imx/ele_fw_api.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2023 NXP + */ + +#ifndef ELE_FW_API_H +#define ELE_FW_API_H + +#include + +#define MESSAGING_VERSION_7 0x7 + +#define ELE_INIT_FW_REQ 0x17 +#define ELE_INIT_FW_REQ_SZ 0x04 +#define ELE_INIT_FW_RSP_SZ 0x08 + + +int ele_init_fw(struct device *dev); + +#endif /* ELE_FW_API_H */ diff --git a/drivers/firmware/imx/se_fw.c b/drivers/firmware/imx/se_fw.c index fc06e9076d00..92dc8ea58960 100644 --- a/drivers/firmware/imx/se_fw.c +++ b/drivers/firmware/imx/se_fw.c @@ -24,6 +24,7 @@ #include #include "se_fw.h" +#include "ele_fw_api.h" #define SOC_ID_OF_IMX8ULP 0x084D #define SOC_ID_OF_IMX93 0x9300 @@ -46,6 +47,7 @@ struct imx_info { uint8_t *mbox_rx_name; uint8_t *pool_name; bool reserved_dma_ranges; + bool init_fw; }; struct imx_info_list { @@ -73,6 +75,7 @@ static const struct imx_info_list imx8ulp_info = { .mbox_rx_name = "rx", .pool_name = "sram", .reserved_dma_ranges = true, + .init_fw = false, }, }, }; @@ -95,8 +98,9 @@ static const struct imx_info_list imx93_info = { .mbox_rx_name = "rx", .pool_name = NULL, .reserved_dma_ranges = true, + .init_fw = true, }, - }, + }, }; static const struct of_device_id se_fw_match[] = { @@ -1236,6 +1240,13 @@ static int se_fw_probe(struct platform_device *pdev) priv->flags |= RESERVED_DMA_POOL; } + if (info->init_fw) { + /* start initializing ele fw */ + ret = ele_init_fw(dev); + if (ret) + dev_err(dev, "Failed to initialize ele fw.\n"); + } + if (info->socdev) { ret = imx_soc_device_register(dev, info); if (ret) { From patchwork Mon Oct 30 09:58:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440503 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 59AE2C4332F for ; Mon, 30 Oct 2023 11:15:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2zZgQTHdc7vWqQXXMDcCwumU+BZMQu6De/owcLxAzRA=; b=EFvP68ZCJv9uEk IpvjstzqucyM1AaUDm9azZcRc1Ju5OsQfWQw+h106hqqRZhk6xOtPB1VTjXhSHfz4W/7vm7obU0Ag /roX34ntVAgi9+9eQ5V4yltqLClJxrIaL5J75lPV4P1AJwUWcD/VlrgUmwogvlONevFn44ZYrIULQ Onx6dE9hQgdSFBU84gfT+EbhKNJiNJlxu0X2a5Nue+VXvUyY02WM7OHyJ4/Or3pO+XGzKBdxOw/L+ yOsJJHbkLjMJrNHWj1SPdrM2vsZfE0iMdN3dKPJCkUxU4Kdm84kU+AmizijMUsN8eHDUWmMOccy0H 65/2Fo6FiiWqpO1pVlmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxQEo-003FFt-0P; Mon, 30 Oct 2023 11:15:18 +0000 Received: from mail-db5eur01on0623.outbound.protection.outlook.com ([2a01:111:f400:fe02::623] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP4I-002xrY-29 for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 10:00:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dCjxFxfCej/ZCXwdxqeP8OXiPVqGT23LT1toKowrT5+n2adHBO662J+fepxYCMU8gyG+fiL1MNtqsuEasBVmJ73BLebqCl3xymG/OC5V6K2KbkbZ4u0qQpgpgrdNVm2JPQq25jm7I7ZweyVqwj4YpiVH+C9dE5uMCWVx7fP/6hoHK5VIkjR4vbc8XIP9ODzjBvw0v0l0IrulIWEXUci/ZfVK2hB1d7k44MNrpq9mTe6vbC2LvqQpsUHAwwlju2CVAICkQxeJIECbAmPOOrnJnbwHta4RvCOnOq52kqnBb4O78Dr/fROxJmvJD8p/uiJiIFW6Hq7FSr2R3LOPQ9g5xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=5ObzQh9GOHKEmnVwv7n7JF0opDF23pACxFYpMpHPC9s=; b=PmiidqRyVWdtFijlXG86YRHatxoI3PJ1/xYdWU9tYKegulXyvNuIuxoJgh6iaW+mcoErSKYlaJNNM0eY1WJ6DDTtfunDusHLAYAnhYCgpCKRVEfwOyCnoLWupB2nEIDoJuQxfgJKpGMU0Fn2tBWLa4z0dF9yHI7MDXdaoMyuLNjx+sSLPQfPyIg4iEVGDM5kGUvNHrwaBcZFQbF8J5MATfGOeQ7o0ENklMTRo1yhutbajNHyV0cL7gccacECwMR6rkN+ZPwAKjObPgjDr/cBVyE3bpUfac28KGkvT/jriPZHZL+fh4YGITEVu4jhWKoySlNULrbjAP05W0+6j/+WxQ== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5ObzQh9GOHKEmnVwv7n7JF0opDF23pACxFYpMpHPC9s=; b=rCSH2Vh9cNjLvtjdYR9CjOVw8DFSNCUrApk8WoyUGUGXNl3Gw+9oUS6GOdq/6fgIfN2HLYbVTJQ8EdDynbc8/CJA/z9XWjTVCFejQhVqaV7W4tYadM87iCDEOjhmSpLnEWr9Ju5/yAO8AF9YHYuDmKGm2jsHbOSJ9oNeMkI6Qd8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB8513.eurprd04.prod.outlook.com (2603:10a6:20b:340::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Mon, 30 Oct 2023 10:00:19 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 10:00:19 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta Subject: [PATCH v7 09/11] firmware: imx: enable trng Date: Mon, 30 Oct 2023 15:28:47 +0530 Message-Id: <20231030095849.3456820-10-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8513:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a510030-937e-493c-0c5f-08dbd92f0614 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uBSPgdPxH6OaRbOSZt16CwD/ZyYxNW/jvj/kbBiHrolJ8+/fFqkFZmooxgDz4brpp6TGRhodMqaE++d+3V+xD/n+/sj6OZEaDAPLLBZv7Tcn6pyESTll+hrn6hbVaWsAXm3jZV7ZdhSSVsi/GGl+3dgJtUwlSM2RqVnkIwleQWb6sW1JnBYr6wBsweZtzQjAvWtwoV1RKbmrzHzi4QDSoiqxqZHwSGaTx04CqGF4yhz4urK4StQMRC5tWV5DnNLXojCh7wvtrqIpqXqxvPY2WWsXeHcnd1CZvENrG+7yL9heCxmYW8QpIvjdrbBcZeVAGPfoXPbLMIbBtfYkOs6CGbRNJCtHKuVPWJb7BuMI4ZQs2eJtJX8swYPHW3KRKy+TBdqL39+jL30p3RStO3GykN0M+lGz9pk2l3/LzAXJ3qb9BUB/ZSQwQ94L1yzoJYsTJv/VYOaWB85PncOk4UIvu/RUuC301cPg9GBTifm7YyJ9Yw3FZiaf4pFOwVZX/sqQr+UzQTDkIhxt0Bi83PxFgbPOJeJbjwijNB42qeuOl2C8IcyKYaG5Q4XdaDQ88UbKlSafDA7DPqMKqer5Qs658l/KDAw4UbwIIABcHWlBfe/sBjFjCf8MFc/g/8b0EhmfJeN9qqGnleZg0B1sEm28AA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(396003)(39860400002)(376002)(366004)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(478600001)(6666004)(66946007)(6486002)(6506007)(83380400001)(36756003)(38100700002)(66556008)(1076003)(2616005)(66476007)(2906002)(41300700001)(26005)(52116002)(6512007)(44832011)(86362001)(38350700005)(921008)(6636002)(8676002)(30864003)(4326008)(5660300002)(8936002)(316002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RvdY2XbAaVGWpCObIquQDdJMgirRuquFhpkaM5LaqJzvRgRTguneW0xz+A4mCKKa1txZwNlR4z32+SM8TXVH6oAkOEfECTjIdHA4iXHHpx6hg4glAPR4VOMC0s142GpjPLK8kDtMR+KhLJVYFKbmETz0YHLvmoUYSjX4PgoQfAXHUsgvecIBCmKTiZGFMRQYbxLz6aRhK+97wOn1xc5KEo0wuWZDJeDNY7bQ5zOj243yV/dWs2kzBCLjiyX5uChc8x1KAAvF2xcl9ATx0i9lfXTh1TGXmJ1g/GN/osNBrUax/4GZ856itm3BXZK/U0S/hmzXWZe72OmwxX6q5Z8ODb+vrEU4KXHZYYGU3KnObfTmwpbDOVnlhz9Fi6+Hv6eGFVmpXFbxO365AoktjdBo5CpAYN3dzcjqngT/RxzRmHQA+3MA75OR6IlK8n1cw28lUrjsYZIq0g2C3rw5MG9ZtKCWZ9m2BRXoHLSUTVs14nhebcHreistlu80eyA5fQUWD7tIY7pj73Ao8lkq+EgOTKS0/HulPHC19GidCyXKrJxJ0WNTeyE3JvO+jL58YXRisSgcNyMiARKHz9NbWcsAVuvI6L6r2vvqWh/gQEd4+/Bc3AzpUOA6f0HtgEepbwaERlkI+X3Qi58bBifmn7rq0fRs4LH76pcQFNGN0o+7C2HikACh+cEqP+OmMcZ2trwiyC7BzZascIzGF5AeYmqizKwjHBnebAPA2XVVaoWG6aUrdzEEbvqwEEX7hY55uRA6QDtTIBlGWlv61MySh1mOL/jjgiKpBE1ddhNKg1fwRfz9nVNrjWu5Xv3LR8pIRNVUPB0zf62hTt8+KsilF1sjbsVYEGYK85S4pOjEcM7bpN1nqUALxIHHnevR4QFn4Qg0R6IvL+cIDX6OQrYQEgKcJC9gPGsLN3UNsRi3qZWnKsRx/FzvLlND9DuslbYFaWUDF90WhgFn+rsYw+mcRK55TIOaLPwvol2o2CnST0S7YjN9gMzqw4iJkYVe1NgqVkMwYGpki4QamSWDmXGf6vanTOYmVsyEJOX93+8Fky722v6Sa9tA3Rz3q5x0ZR7/bEKkb3KvYooSiHbj/rj4FbAv2EDxRHKjBc5AfrLNdIPODpLMdEgkiozWOF9DtI8fO7eyIArX+V2j1G+UGGq3vCMbOyJruJ7tMqVSOVVBGyhmLe0GX27TugbGg7XPsvaIoBqsNiTTtbki/0FAa9RRSikUofJf9zO0ctO1sJF64YSg0M1TOLy8nsKbHKflmtyYqntT1+/yFMFODerrkcInQ5aURtSK4Ss/Bz4JybaacUBb2pXz8X7nj67mTFuWxUUwkzCIwDzyryM0xUqOmFwrAJ+lqb67rUPUeZ6bwpkYnjt2SOzS+FBIKH8tfp8wEu9pg1kMBzlSNZvtBchc30iMH4a6LmXdyq1WF3SmRA7p7akmnajIsEwQTouLEKvLiwvR5r7EvS4egQwfydQBedzDr/Z/I9QeUXiOIp2rCuLSZiyRTclx4EM45YCxRyQYO9P0E5su3n0JQKA2Ps8IYiu9nr+iCFEUlIHHtUeul/Zc/ZvAsiS9gF37qLL7aBGWDrXfy8Se X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a510030-937e-493c-0c5f-08dbd92f0614 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 10:00:19.5363 (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: PFC7oe7chHaRDLbTSKM/Q6CB/76aUmCqVup3gXN+grHd29ZhEPntELyU5dNHvmleejkGMkyjCL3sj4STAN1xNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8513 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_030022_725027_C79C2107 X-CRM114-Status: GOOD ( 19.75 ) 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 Enabled trng on imx93 platform through enclave fw. Signed-off-by: Gaurav Jain Signed-off-by: Pankaj Gupta --- drivers/firmware/imx/Kconfig | 9 ++ drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/ele_base_msg.c | 117 ++++++++++++++++++++++ drivers/firmware/imx/ele_common.c | 40 ++++++++ drivers/firmware/imx/ele_common.h | 2 + drivers/firmware/imx/ele_fw_api.c | 67 +++++++++++++ drivers/firmware/imx/ele_fw_api.h | 6 ++ drivers/firmware/imx/ele_trng.c | 47 +++++++++ drivers/firmware/imx/se_fw.c | 21 ++++ include/linux/firmware/imx/ele_base_msg.h | 13 +++ 10 files changed, 323 insertions(+) create mode 100644 drivers/firmware/imx/ele_trng.c diff --git a/drivers/firmware/imx/Kconfig b/drivers/firmware/imx/Kconfig index 2822e5d4b24c..ffc02593293c 100644 --- a/drivers/firmware/imx/Kconfig +++ b/drivers/firmware/imx/Kconfig @@ -40,3 +40,12 @@ config IMX_SEC_ENCLAVE like base, HSM, V2X & SHE using the SAB protocol via the shared Messaging Unit. This driver exposes these interfaces via a set of file descriptors allowing to configure shared memory, send and receive messages. + +config IMX_ELE_TRNG + tristate "i.MX ELE True Random Number Generator" + default y + select CRYPTO_RNG + select HW_RANDOM + help + This driver provides kernel-side support for the Random Number generation, + through NXP hardware IP for secure-enclave called EdgeLock Enclave. diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index d61f06a8050a..9018f7824f36 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -3,3 +3,4 @@ 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 sec_enclave-objs = se_fw.o ele_common.o ele_base_msg.o ele_fw_api.o obj-${CONFIG_IMX_SEC_ENCLAVE} += sec_enclave.o +sec_enclave-${CONFIG_IMX_ELE_TRNG} += ele_trng.o diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele_base_msg.c index 813f769f7bc3..3a3af2321f67 100644 --- a/drivers/firmware/imx/ele_base_msg.c +++ b/drivers/firmware/imx/ele_base_msg.c @@ -99,3 +99,120 @@ int ele_ping(struct device *dev) return ret; } + +/* + * ele_get_trng_state() - prepare and send the command to read + * crypto lib and TRNG state + * TRNG state + * 0x1 TRNG is in program mode + * 0x2 TRNG is still generating entropy + * 0x3 TRNG entropy is valid and ready to be read + * 0x4 TRNG encounter an error while generating entropy + * + * CSAL state + * 0x0 Crypto Lib random context initialization is not done yet + * 0x1 Crypto Lib random context initialization is on-going + * 0x2 Crypto Lib random context initialization succeed + * 0x3 Crypto Lib random context initialization failed + * + * returns: csal and trng state. + * + */ +int ele_get_trng_state(struct device *dev) +{ + struct ele_mu_priv *priv = dev_get_drvdata(dev); + int ret; + unsigned int status; + + ret = imx_se_alloc_tx_rx_buf(priv); + if (ret) + return ret; + + ret = plat_fill_cmd_msg_hdr(priv, + (struct mu_hdr *)&priv->tx_msg->header, + ELE_GET_TRNG_STATE_REQ, + ELE_GET_TRNG_STATE_REQ_MSG_SZ, + true); + if (ret) { + pr_err("Error: plat_fill_cmd_msg_hdr failed.\n"); + goto exit; + } + + ret = imx_ele_msg_send_rcv(priv); + if (ret) + goto exit; + + ret = imx_ele_msg_send_rcv(priv); + if (ret < 0) + goto exit; + + ret = validate_rsp_hdr(priv, + priv->rx_msg->header, + ELE_GET_TRNG_STATE_REQ, + ELE_GET_TRNG_STATE_RSP_MSG_SZ, + true); + if (ret) + goto exit; + + status = RES_STATUS(priv->rx_msg->data[0]); + if (status != priv->success_tag) { + dev_err(dev, "Command Id[%d], Response Failure = 0x%x", + ELE_GET_TRNG_STATE_REQ, status); + ret = -1; + } else + ret = (priv->rx_msg->data[1] & CSAL_TRNG_STATE_MASK); + +exit: + imx_se_free_tx_rx_buf(priv); + + return ret; +} + +/* + * ele_start_rng() - prepare and send the command to start + * initialization of the ELE RNG context + * + * returns: 0 on success. + */ +int ele_start_rng(struct device *dev) +{ + struct ele_mu_priv *priv = dev_get_drvdata(dev); + int ret; + unsigned int status; + + ret = imx_se_alloc_tx_rx_buf(priv); + if (ret) + return ret; + + ret = plat_fill_cmd_msg_hdr(priv, + (struct mu_hdr *)&priv->tx_msg->header, + ELE_START_RNG_REQ, + ELE_START_RNG_REQ_MSG_SZ, + true); + if (ret) + goto exit; + + ret = imx_ele_msg_send_rcv(priv); + if (ret < 0) + goto exit; + + ret = validate_rsp_hdr(priv, + priv->rx_msg->header, + ELE_START_RNG_REQ, + ELE_START_RNG_RSP_MSG_SZ, + true); + if (ret) + goto exit; + + status = RES_STATUS(priv->rx_msg->data[0]); + if (status != priv->success_tag) { + dev_err(dev, "Command Id[%d], Response Failure = 0x%x", + ELE_START_RNG_REQ, status); + ret = -1; + } + +exit: + imx_se_free_tx_rx_buf(priv); + + return ret; +} diff --git a/drivers/firmware/imx/ele_common.c b/drivers/firmware/imx/ele_common.c index 4410245a19ec..d4b829c19133 100644 --- a/drivers/firmware/imx/ele_common.c +++ b/drivers/firmware/imx/ele_common.c @@ -3,6 +3,10 @@ * Copyright 2023 NXP */ +#include +#include +#include + #include "ele_common.h" #include "se_fw.h" @@ -137,3 +141,39 @@ int validate_rsp_hdr(struct ele_mu_priv *priv, unsigned int header, return ret; } + +int ele_do_start_rng(struct device *dev) +{ + int ret; + int count = ELE_GET_TRNG_STATE_RETRY_COUNT; + + ret = ele_get_trng_state(dev); + if (ret < 0) { + dev_err(dev, "Failed to get trng state\n"); + return ret; + } else if (ret != ELE_TRNG_STATE_OK) { + /* call start rng */ + ret = ele_start_rng(dev); + if (ret) { + dev_err(dev, "Failed to start rng\n"); + return ret; + } + + /* poll get trng state API, ELE_GET_TRNG_STATE_RETRY_COUNT times + * or while trng state != 0x203 + */ + do { + msleep(10); + ret = ele_get_trng_state(dev); + if (ret < 0) { + dev_err(dev, "Failed to get trng state\n"); + return ret; + } + count--; + } while ((ret != ELE_TRNG_STATE_OK) && count); + if (ret != ELE_TRNG_STATE_OK) + return -EIO; + } + + return 0; +} diff --git a/drivers/firmware/imx/ele_common.h b/drivers/firmware/imx/ele_common.h index 284b7f66d8e3..f9e1d949dc6a 100644 --- a/drivers/firmware/imx/ele_common.h +++ b/drivers/firmware/imx/ele_common.h @@ -27,4 +27,6 @@ static inline int ele_trng_init(struct device *dev) return 0; } #endif + +int ele_do_start_rng(struct device *dev); #endif diff --git a/drivers/firmware/imx/ele_fw_api.c b/drivers/firmware/imx/ele_fw_api.c index 55dda9d6531a..d195a920b3ee 100644 --- a/drivers/firmware/imx/ele_fw_api.c +++ b/drivers/firmware/imx/ele_fw_api.c @@ -49,3 +49,70 @@ int ele_init_fw(struct device *dev) return ret; } + +/* + * ele_get_random() - prepare and send the command to proceed + * with a random number generation operation + * + * returns: size of the rondom number generated + */ +int ele_get_random(struct device *dev, + void *data, size_t len) +{ + struct ele_mu_priv *priv = dev_get_drvdata(dev); + unsigned int status; + dma_addr_t dst_dma; + u8 *buf; + int ret; + + buf = dmam_alloc_coherent(priv->dev, len, &dst_dma, GFP_KERNEL); + if (!buf) { + dev_err(priv->dev, "Failed to map destination buffer memory\n"); + return -ENOMEM; + } + + ret = imx_se_alloc_tx_rx_buf(priv); + if (ret) { + ret = -ENOMEM; + goto exit1; + } + + ret = plat_fill_cmd_msg_hdr(priv, + (struct mu_hdr *)&priv->tx_msg->header, + ELE_GET_RANDOM_REQ, ELE_GET_RANDOM_REQ_SZ, + false); + if (ret) + goto exit; + + priv->tx_msg->data[0] = 0x0; + priv->tx_msg->data[1] = dst_dma; + priv->tx_msg->data[2] = len; + ret = imx_ele_msg_send_rcv(priv); + if (ret < 0) + goto exit; + + ret = validate_rsp_hdr(priv, + priv->rx_msg->header, + ELE_GET_RANDOM_REQ, + ELE_GET_RANDOM_RSP_SZ, + false); + if (ret) + return ret; + + status = RES_STATUS(priv->rx_msg->data[0]); + if (status != priv->success_tag) { + dev_err(dev, "Command Id[%d], Response Failure = 0x%x", + ELE_GET_RANDOM_REQ, status); + ret = -1; + } else { + memcpy(data, buf, len); + ret = len; + } + +exit: + imx_se_free_tx_rx_buf(priv); +exit1: + dmam_free_coherent(priv->dev, len, buf, dst_dma); + + return ret; +} diff --git a/drivers/firmware/imx/ele_fw_api.h b/drivers/firmware/imx/ele_fw_api.h index 21bb35b4041f..70cd8cf5074b 100644 --- a/drivers/firmware/imx/ele_fw_api.h +++ b/drivers/firmware/imx/ele_fw_api.h @@ -14,7 +14,13 @@ #define ELE_INIT_FW_REQ_SZ 0x04 #define ELE_INIT_FW_RSP_SZ 0x08 +#define ELE_GET_RANDOM_REQ 0xCD +#define ELE_GET_RANDOM_REQ_SZ 0x10 +#define ELE_GET_RANDOM_RSP_SZ 0x08 + int ele_init_fw(struct device *dev); +int ele_get_random(struct device *dev, void *data, size_t len); +int ele_get_hwrng(struct hwrng *rng, void *data, size_t len, bool wait); #endif /* ELE_FW_API_H */ diff --git a/drivers/firmware/imx/ele_trng.c b/drivers/firmware/imx/ele_trng.c new file mode 100644 index 000000000000..4a7a119ff435 --- /dev/null +++ b/drivers/firmware/imx/ele_trng.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * ELE Random Number Generator Driver NXP's Platforms + * + * Copyright 2023 NXP + */ + +#include "ele_common.h" +#include "ele_fw_api.h" + +struct ele_trng { + struct hwrng rng; + struct device *dev; +}; + +int ele_trng_init(struct device *dev) +{ + struct ele_trng *trng; + int ret; + + trng = devm_kzalloc(dev, sizeof(*trng), GFP_KERNEL); + if (!trng) + return -ENOMEM; + + trng->dev = dev; + trng->rng.name = "ele-trng"; + trng->rng.read = ele_get_hwrng; + trng->rng.priv = (unsigned long)trng; + trng->rng.quality = 1024; + + dev_dbg(dev, "registering ele-trng\n"); + + ret = devm_hwrng_register(dev, &trng->rng); + if (ret) + return ret; + + dev_info(dev, "Successfully registered ele-trng\n"); + return 0; +} + +int ele_get_hwrng(struct hwrng *rng, + void *data, size_t len, bool wait) +{ + struct ele_trng *trng = (struct ele_trng *)rng->priv; + + return ele_get_random(trng->dev, data, len); +} diff --git a/drivers/firmware/imx/se_fw.c b/drivers/firmware/imx/se_fw.c index 92dc8ea58960..3638a4fed5e7 100644 --- a/drivers/firmware/imx/se_fw.c +++ b/drivers/firmware/imx/se_fw.c @@ -24,6 +24,7 @@ #include #include "se_fw.h" +#include "ele_common.h" #include "ele_fw_api.h" #define SOC_ID_OF_IMX8ULP 0x084D @@ -48,6 +49,9 @@ struct imx_info { uint8_t *pool_name; bool reserved_dma_ranges; bool init_fw; + /* platform specific flag to enable/disable the ELE True RNG */ + bool start_rng; + bool enable_ele_trng; }; struct imx_info_list { @@ -76,6 +80,8 @@ static const struct imx_info_list imx8ulp_info = { .pool_name = "sram", .reserved_dma_ranges = true, .init_fw = false, + .start_rng = true, + .enable_ele_trng = false, }, }, }; @@ -99,6 +105,8 @@ static const struct imx_info_list imx93_info = { .pool_name = NULL, .reserved_dma_ranges = true, .init_fw = true, + .start_rng = true, + .enable_ele_trng = true, }, }, }; @@ -1260,6 +1268,19 @@ static int se_fw_probe(struct platform_device *pdev) if (ret) dev_err(dev, "Failed[%d] to ping the fw.\n", ret); + /* start ele rng */ + if (info->start_rng) { + ret = ele_do_start_rng(dev); + if (ret) + dev_err(dev, "Failed to start ele rng\n"); + } + + if (!ret && info->enable_ele_trng) { + ret = ele_trng_init(dev); + if (ret) + dev_err(dev, "Failed to init ele-trng\n"); + } + dev_info(dev, "i.MX secure-enclave: %s interface to firmware, configured.\n", info->pdev_name[1]); diff --git a/include/linux/firmware/imx/ele_base_msg.h b/include/linux/firmware/imx/ele_base_msg.h index 49e3619372be..3ca4b47e4c4e 100644 --- a/include/linux/firmware/imx/ele_base_msg.h +++ b/include/linux/firmware/imx/ele_base_msg.h @@ -34,7 +34,20 @@ #define ELE_PING_REQ_SZ 0x04 #define ELE_PING_RSP_SZ 0x08 +#define ELE_START_RNG_REQ 0xA3 +#define ELE_START_RNG_REQ_MSG_SZ 0x04 +#define ELE_START_RNG_RSP_MSG_SZ 0x08 + +#define ELE_GET_TRNG_STATE_REQ 0xA4 +#define ELE_GET_TRNG_STATE_REQ_MSG_SZ 0x04 +#define ELE_GET_TRNG_STATE_RSP_MSG_SZ 0x0C +#define ELE_TRNG_STATE_OK 0x203 +#define ELE_GET_TRNG_STATE_RETRY_COUNT 0x5 +#define CSAL_TRNG_STATE_MASK 0x0000ffff + int ele_get_info(struct device *dev, phys_addr_t addr, u32 data_size); int ele_ping(struct device *dev); +int ele_start_rng(struct device *dev); +int ele_get_trng_state(struct device *dev); #endif From patchwork Mon Oct 30 09:58:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440505 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 5A09FC4167D for ; Mon, 30 Oct 2023 11:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WWJpFucUuJky1nwHYp+5wuJVJXzedVKYe8qKsFLdIwg=; b=Ey+JOi6RdH4pXZ bAQjPAY+vLu3XDH9pm2HNgtJ9yNdfER9lNGlMaM+G9cfGKrmR6qS9RfDPf9dQt+MnTG+IQnKBPI3K U7c6148rhu+68hV5ZAdSS1RqxQQs2z6Mbm4AdFxRrfXzseRbuvsEc+Ux6Uscm3WwiHfzERLess501 ZxBRPu4BI2lIr+UrIEt5SJN7cxhjEg3P1pW8RNFWCXi6Mpf/W4HwpZA26rkZU1/nz7bu/Ko9dZ5+z rHllRt6BsniOapzQ+TSOmQ8e9ohPd1dARWwf1F6+sVpP3T9NAEtSp2flkN2Dy710fLbqmfC/C8N14 KX9dCyJA8/3OZ7YTUbMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxQEo-003FG8-1K; Mon, 30 Oct 2023 11:15:18 +0000 Received: from mail-am7eur03on20619.outbound.protection.outlook.com ([2a01:111:f400:7eaf::619] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP4R-002xzD-2W for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 10:00:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TGEHgQJgORQuflSP8kgtGTFYDwhug6SCRZWfPwIvilVhlubIWWmqpPPr2PKPikE/cdBVxQbwBredGrqCUwXGKv1vcZ8ICsKxw0CWjHLaR3b2uRxqPjBIkfCes9kvJJYlwq7jRzUn26k1hm7fLnqxygnb4EBKDfAqoXhYCeN9GCVj/kry7v22F3ehJgPg5BOzHeylIUKcIupuXts8k4zJ5QeuX9/UYuq3mRriC3/X7Xm032tagc7Nh0YAFvVOp7tCPhUXTts+BxwEEHfIFsSIjwmN2N06nKpjo3dFcFGW35ATbDMw9N7ujPvkzW7sIPtQ8q790VaxFWAkP6//jwW51A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=zCSVpQUTvwH8Yu42nuqPrmpsN8acGA6PQ7FPdBaJoxs=; b=CeUxuVnSHjcVQqJnqqaOoky4uzwUWeT6PJvYryakOjtlSQ8QxdMG28QKO4yLXhv6msL25Lu+LOg2GtTSuL31excxOYjxjxB9LSWriJ8DmEeO2Qi7E5Fl1cBS0nNlWhNNCVqwzRevsjCVjZ2MnmhDxJXFD4rV+JRs/GQRe3rAG5S6yMs34lRfk3UDVsnZT01UnGQwg5gR3IHsJNPeuu7ZvRmKF2UxwrEKfVrrcG2o4nFdOQ0HEuiLcCHfXzzJ3OvAKFU9K3UDUk/GNleRld2bR2KifBSQXGbo8YHuUWZ0nwCOOmydAGO7+If2l6MglVe5VEupW8p1pVzHK6609gdImg== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zCSVpQUTvwH8Yu42nuqPrmpsN8acGA6PQ7FPdBaJoxs=; b=BVMdpC+XB3yRXytQ4zZhPTU817NjOyzvHnMDyHHvBAYd4TCn3SQgOJ2aoC5a4Kyinh+xwaUndNSR2IqIWj6+OjKLd5GlddBtOuvukgyLGOSjQ7h8WE3x9oTwpA41ukDZMajcwg4G24kU1cdrEZp85QlJ2S39NCDCtMJz12uNWXU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by PAXPR04MB8141.eurprd04.prod.outlook.com (2603:10a6:102:1bf::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.14; Mon, 30 Oct 2023 10:00:25 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 10:00:25 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta Subject: [PATCH v7 10/11] firmware: imx: enclave-fw: add handling for save/restore IMEM region Date: Mon, 30 Oct 2023 15:28:48 +0530 Message-Id: <20231030095849.3456820-11-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|PAXPR04MB8141:EE_ X-MS-Office365-Filtering-Correlation-Id: 1984cfd1-084f-465d-1df9-08dbd92f097f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X5vLDXdQ8qr8iA+/NWSUfwoU5nXBzXIfwzMuMVHJPGcV7AUaGHV+8pDxJCP2EVT1wE9gI2l84AOSfFmFm3Qrjw7549MAO9encOgs2V12FVlEc+y2TKvBoLPs60Agfc2scWzUOQa5z7wNaV31t3zRGcawFEk1OtnOf5vcFXPa5hxlxSjUxHmMaAlUAiMogPcp5ePIL03+XMkWVJJE3PXcUtxXa+f9QCaWs61OZFQrBKxyWvNzefq3hr/Bs6fpTTmGFThaM8HD6lsDr94oB4qI1KrB6y44V+oKeT9aA1NhUw6lVxS+hXUXKdE1Pk88fZCEXn9oPDog/VdNlo6b+FOR8vyRqHcPuS1j7l1AA/iX5m1cTUOt6EYjtjbA8rXm3GnBX8Dv0bmCF42QZXvf9ICYhdbQeZ8XXX/Tv39gGCO67vGtPF9PW+9BufY8NlK/GtGruXy7PW2M688LEsdR21qaWU20rCGGE5tt+fOsqZtrJnpgEcwNoaENgEs25L10JlDt4HBS/fEjz90OYdu2rXrEIcjEEs+ThZwGsItA1DmNARg+9Zj8ZraVvG8jeBqUS6tnXJTRkN1+cxgW815JED2szFyHMNJvNo/+8+ze2HsuDSJq7MK8QkjHwhSvPmbrWoftEXBovVPVq+FGiuwLm0VpoA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(376002)(366004)(136003)(396003)(346002)(230922051799003)(64100799003)(1800799009)(186009)(451199024)(6512007)(6666004)(52116002)(6506007)(83380400001)(36756003)(26005)(316002)(66556008)(66476007)(478600001)(6636002)(6486002)(1076003)(38100700002)(86362001)(66946007)(2616005)(41300700001)(38350700005)(8676002)(921008)(4326008)(8936002)(44832011)(7416002)(2906002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bCc9YmPCt0E/oElRm8ozlGTJgZyh+kFM1BYDANIVFIm0IoFWAnNSd6Il/fGoG0FXAGLF/fNq4suCkhrcvMY/t7kZ+GF9+WmNtuN4knPhED8otp+cyJ4ZckRZcUpITdzuewuNcI3DIzNuC2htqX0ZEjispaOgEhgrDkW/tjnL5qMjeIYoCGSg8ah1LcpYlT5/IERpJOosXXOTh5BgnBjzOGrHawM+PSJ+8B3lBvdCYUKTSMW65zao08Lshcy5kS65NBVJP8pqIEjmkMmmE0wRXDQOPAG3xXLzdjrQ5QRhbkXxJd8xwxE4rJcR35SbqgSPyOCQEf3uGIK5c+5uSxJIgzsAfgQuaugs/MPImxVFWj7qnOFpsVJIJw3oK/nX0LwzlcpR2XFkhLglJSji338352ZFm/pPk8sqiRNaR17LMbPto2mdQeTNkAZSbi9CMEV7I5lvp3OhLbvLGmB5QwGTIuUJKTtm95OmFMCCkZZbz+VQ2e4UZXz1yLl8i3Lx7fBajFiS1JMZ22wkxd5JbhtQwwDD1PBI4z7LeTYVHf+jV8lhNb96Nfln+khDtxF7RiiVoQFalPpSIKTnewLnkYJRDNwWrY590DOxMJqkq8Zcz5oO2cxVxmGn+bm+uqXhgwnxkjDgmtAklpFA0l9C7ahVz4PFkKndSajsab3j2O1LGyF+Ptk4lVmhH1q/FbnIMWI010x2EhsqtgOhFMoG7ow+FrWSBTkv2k9IUTR/iC9gpzfykFd6BtEDucJE1g86pOQbRmUm+qa5jnxTBYbllsIpP8krxSs6C8skCXnkFI5Q3NE1tBOGX2WATYFEbizwBtDkgGvh3l8ICbjJv6QTATxAKxwUxdpELbQcfqNMzX9VHxV2qq1s5hFzSTqkQ1+D6mP2vwgImqi7DanZ57kjZLw/5t5GqQHCKUi/IfD+vkWEl1BP7BMkiBTlxlsXdJ4OYvKy37fKg1VlGtHi7RzERNYlN4NcI27hY00Cb+iPFah/Q9KFqn14GAL0ay4jzhgDtU6pvZZPQfmRQyfOJWxZNzL9uE3iWHQd5i8bmtHKXzn8B5fMDCdtjDNRIh+W4EmiNLg2kLNEvlIO8e7G1+Lm0Asx7XZh0BF3K4/pJ0/77KtDKQVSDnW0CNZRX1niz1qBpmKJeUxpSnO3xAUjt94QF1AV7slmUFDYNq9iBd8WIIEAUxqpE6UvQvdJl9KBRuOR3fpbpHngtx/paYJxl1ERXRs0qf4F84Ku6P8n5pO/TTzfpCKbeqVXsjmb2KZOLRIntBE03hCUCWnq4CZS4KshLnFE4conULkZRYIsl96rqu5tWFIbnxmP0oZxtpI798oLWPQqPCyth6RzJRdMJ3EoJa5/CTQ13pSzHsSxOm0CfBcMpY9g4cMgdlUKMHUCowuYIbGA8Dm8Rgec+7zgsV8cBD5jE4UFCiWQGm4BSlTlnbnHNSxBj5EFjKz+6Q66QCL3V7Ttidmni0OR3TI/JBxgrS+ccwt6pqriNDqSyOHuor8BazGR7czPYF8q68ORkilTaLMZMx6iYWVlI5A65BTTRsy5X4MNEFgp4bn3MxiC143no1o3WNuCS/prNahu86Purdqh X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1984cfd1-084f-465d-1df9-08dbd92f097f X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 10:00:25.2234 (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: 2fosGC3gJihoxd5mBwjPfxZmD+CfAmYY3fojSwFzb2HoukxYLAAgSx3OwHINXpp1McGIBfwDBgC6yi6H0kN2qA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8141 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_030031_978991_9901D2D1 X-CRM114-Status: GOOD ( 21.78 ) 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 Some IMEM region is lost during kernel power down. Due to this, firmware's functionaity cannot work correctly. Saving encrypted IMEM region in kernel memory during power down, and restore IMEM region on resume. Signed-off-by: Gaurav Jain Signed-off-by: Pankaj Gupta --- drivers/firmware/imx/ele_base_msg.c | 53 ++++++++++ drivers/firmware/imx/ele_common.c | 115 ++++++++++++++++++++++ drivers/firmware/imx/ele_common.h | 8 ++ drivers/firmware/imx/se_fw.c | 36 +++++++ include/linux/firmware/imx/ele_base_msg.h | 14 +++ 5 files changed, 226 insertions(+) diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele_base_msg.c index 3a3af2321f67..844bb0e54c02 100644 --- a/drivers/firmware/imx/ele_base_msg.c +++ b/drivers/firmware/imx/ele_base_msg.c @@ -216,3 +216,56 @@ int ele_start_rng(struct device *dev) return ret; } + +int ele_service_swap(struct device *dev, + phys_addr_t addr, + u32 addr_size, u16 flag) +{ + struct ele_mu_priv *priv = dev_get_drvdata(dev); + int ret; + unsigned int status; + + ret = imx_se_alloc_tx_rx_buf(priv); + if (ret) + return ret; + + ret = plat_fill_cmd_msg_hdr(priv, + (struct mu_hdr *)&priv->tx_msg->header, + ELE_SERVICE_SWAP_REQ, + ELE_SERVICE_SWAP_REQ_MSG_SZ, + true); + if (ret) + return ret; + + priv->tx_msg->data[0] = flag; + priv->tx_msg->data[1] = addr_size; + priv->tx_msg->data[2] = ELE_NONE_VAL; + priv->tx_msg->data[3] = lower_32_bits(addr); + priv->tx_msg->data[4] = plat_add_msg_crc((uint32_t *)&priv->tx_msg[0], + ELE_SERVICE_SWAP_REQ_MSG_SZ); + ret = imx_ele_msg_send_rcv(priv); + if (ret < 0) + return ret; + + ret = validate_rsp_hdr(priv, + priv->rx_msg->header, + ELE_SERVICE_SWAP_REQ, + ELE_SERVICE_SWAP_RSP_MSG_SZ, + true); + if (ret) + return ret; + + status = RES_STATUS(priv->rx_msg->data[0]); + if (status != priv->success_tag) { + dev_err(dev, "Command Id[%d], Response Failure = 0x%x", + ELE_SERVICE_SWAP_REQ, status); + ret = -1; + } else { + if (flag == ELE_IMEM_EXPORT) + ret = priv->rx_msg->data[1]; + else + ret = 0; + } + + return ret; +} diff --git a/drivers/firmware/imx/ele_common.c b/drivers/firmware/imx/ele_common.c index d4b829c19133..348f7194778f 100644 --- a/drivers/firmware/imx/ele_common.c +++ b/drivers/firmware/imx/ele_common.c @@ -45,6 +45,18 @@ void imx_se_free_tx_rx_buf(struct ele_mu_priv *priv) devm_kfree(priv->dev, priv->rx_msg); } +uint32_t plat_add_msg_crc(uint32_t *msg, uint32_t msg_len) +{ + uint32_t i; + uint32_t crc = 0; + uint32_t nb_words = msg_len / (uint32_t)sizeof(uint32_t); + + for (i = 0; i < nb_words - 1; i++) + crc ^= *(msg + i); + + return crc; +} + int imx_ele_msg_send_rcv(struct ele_mu_priv *priv) { unsigned int wait; @@ -177,3 +189,106 @@ int ele_do_start_rng(struct device *dev) return 0; } + +#ifdef CONFIG_PM_SLEEP +int save_imem(struct device *dev) +{ + int ret; + struct ele_mu_priv *priv = dev_get_drvdata(dev); + + /* EXPORT command will save encrypted IMEM to given address, + * so later in resume, IMEM can be restored from the given + * address. + * + * Size must be at least 64 kB. + */ + ret = ele_service_swap(dev, + priv->imem.phyaddr, + ELE_IMEM_SIZE, + ELE_IMEM_EXPORT); + if (ret < 0) + dev_err(dev, "Failed to export IMEM\n"); + else + dev_info(dev, + "Exported %d bytes of encrypted IMEM\n", + ret); + + return ret; +} + +int restore_imem(struct device *dev, + uint8_t *pool_name) +{ + int ret; + u32 imem_state; + u32 *get_info_buf = NULL; + phys_addr_t get_info_phyaddr = 0; + struct ele_mu_priv *priv = dev_get_drvdata(dev); + + get_info_phyaddr + = pool_name ? get_phy_buf_mem_pool(dev, + pool_name, + &get_info_buf, + DEVICE_GET_INFO_SZ) + : 0x0; + + if (!get_info_buf) { + dev_err(dev, "Unable to alloc sram from sram pool\n"); + return -ENOMEM; + } + + ret = ele_do_start_rng(dev); + if (ret) + goto exit; + + /* get info from ELE */ + ret = ele_get_info(dev, get_info_phyaddr, ELE_GET_INFO_READ_SZ); + if (ret) { + dev_err(dev, "Failed to get info from ELE.\n"); + goto exit; + } + + /* Get IMEM state, if 0xFE then import IMEM */ + imem_state = (get_info_buf[ELE_IMEM_STATE_WORD] + & ELE_IMEM_STATE_MASK) >> 16; + if (imem_state == ELE_IMEM_STATE_BAD) { + /* IMPORT command will restore IMEM from the given + * address, here size is the actual size returned by ELE + * during the export operation + */ + ret = ele_service_swap(dev, + priv->imem.phyaddr, + priv->imem.size, + ELE_IMEM_IMPORT); + if (ret) { + dev_err(dev, "Failed to import IMEM\n"); + goto exit; + } + } else + goto exit; + + /* After importing IMEM, check if IMEM state is equal to 0xCA + * to ensure IMEM is fully loaded and + * ELE functionality can be used. + */ + ret = ele_get_info(dev, get_info_phyaddr, ELE_GET_INFO_READ_SZ); + if (ret) { + dev_err(dev, "Failed to get info from ELE.\n"); + goto exit; + } + + imem_state = (get_info_buf[ELE_IMEM_STATE_WORD] + & ELE_IMEM_STATE_MASK) >> 16; + if (imem_state == ELE_IMEM_STATE_OK) + dev_info(dev, "Successfully restored IMEM\n"); + else + dev_err(dev, "Failed to restore IMEM\n"); + +exit: + if (pool_name && get_info_buf) + free_phybuf_mem_pool(dev, pool_name, + get_info_buf, DEVICE_GET_INFO_SZ); + + return ret; +} +#endif diff --git a/drivers/firmware/imx/ele_common.h b/drivers/firmware/imx/ele_common.h index f9e1d949dc6a..e1979b555b58 100644 --- a/drivers/firmware/imx/ele_common.h +++ b/drivers/firmware/imx/ele_common.h @@ -9,6 +9,7 @@ #include "se_fw.h" +uint32_t plat_add_msg_crc(uint32_t *msg, uint32_t msg_len); int imx_ele_msg_send_rcv(struct ele_mu_priv *priv); void imx_se_free_tx_rx_buf(struct ele_mu_priv *priv); int imx_se_alloc_tx_rx_buf(struct ele_mu_priv *priv); @@ -29,4 +30,11 @@ static inline int ele_trng_init(struct device *dev) #endif int ele_do_start_rng(struct device *dev); + +#ifdef CONFIG_PM_SLEEP +int save_imem(struct device *dev); +int restore_imem(struct device *dev, + uint8_t *pool_name); #endif + +#endif /*__ELE_COMMON_H__ */ diff --git a/drivers/firmware/imx/se_fw.c b/drivers/firmware/imx/se_fw.c index 3638a4fed5e7..db992b3cceb9 100644 --- a/drivers/firmware/imx/se_fw.c +++ b/drivers/firmware/imx/se_fw.c @@ -52,6 +52,7 @@ struct imx_info { /* platform specific flag to enable/disable the ELE True RNG */ bool start_rng; bool enable_ele_trng; + bool imem_mgmt; }; struct imx_info_list { @@ -82,6 +83,7 @@ static const struct imx_info_list imx8ulp_info = { .init_fw = false, .start_rng = true, .enable_ele_trng = false, + .imem_mgmt = true, }, }, }; @@ -107,6 +109,7 @@ static const struct imx_info_list imx93_info = { .init_fw = true, .start_rng = true, .enable_ele_trng = true, + .imem_mgmt = false, }, }, }; @@ -1062,6 +1065,17 @@ static int se_probe_cleanup(struct platform_device *pdev) if (priv->rx_chan) mbox_free_channel(priv->rx_chan); + /* free the buffer in ele-mu remove, previously allocated + * in ele-mu probe to store encrypted IMEM + */ + if (priv->imem.buf) { + dmam_free_coherent(&pdev->dev, + ELE_IMEM_SIZE, + priv->imem.buf, + priv->imem.phyaddr); + priv->imem.buf = NULL; + } + if (priv->flags & RESERVED_DMA_POOL) { of_reserved_mem_device_release(dev); priv->flags &= (~RESERVED_DMA_POOL); @@ -1281,6 +1295,18 @@ static int se_fw_probe(struct platform_device *pdev) dev_err(dev, "Failed to init ele-trng\n"); } + if (info->imem_mgmt) { + /* allocate buffer where ELE store encrypted IMEM */ + priv->imem.buf = dmam_alloc_coherent(dev, ELE_IMEM_SIZE, + &priv->imem.phyaddr, + GFP_KERNEL); + if (!priv->imem.buf) { + dev_err(dev, + "dmam-alloc-failed: To store encr-IMEM.\n"); + ret = -ENOMEM; + goto exit; + } + } dev_info(dev, "i.MX secure-enclave: %s interface to firmware, configured.\n", info->pdev_name[1]); @@ -1303,17 +1329,27 @@ static int se_fw_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int se_fw_suspend(struct device *dev) { + struct ele_mu_priv *priv = dev_get_drvdata(dev); + const struct imx_info *info = priv->info; + + if (info && info->imem_mgmt) + priv->imem.size = save_imem(dev); + return 0; } static int se_fw_resume(struct device *dev) { struct ele_mu_priv *priv = dev_get_drvdata(dev); + const struct imx_info *info = priv->info; int i; for (i = 0; i < priv->max_dev_ctx; i++) wake_up_interruptible(&priv->ctxs[i]->wq); + if (info && info->imem_mgmt) + restore_imem(dev, info->pool_name); + return 0; } #endif diff --git a/include/linux/firmware/imx/ele_base_msg.h b/include/linux/firmware/imx/ele_base_msg.h index 3ca4b47e4c4e..f027f687de2e 100644 --- a/include/linux/firmware/imx/ele_base_msg.h +++ b/include/linux/firmware/imx/ele_base_msg.h @@ -45,9 +45,23 @@ #define ELE_GET_TRNG_STATE_RETRY_COUNT 0x5 #define CSAL_TRNG_STATE_MASK 0x0000ffff +#define ELE_SERVICE_SWAP_REQ 0xDF +#define ELE_SERVICE_SWAP_REQ_MSG_SZ 0x18 +#define ELE_SERVICE_SWAP_RSP_MSG_SZ 0x0C +#define ELE_IMEM_SIZE 0x10000 +#define ELE_IMEM_STATE_OK 0xCA +#define ELE_IMEM_STATE_BAD 0xFE +#define ELE_IMEM_STATE_WORD 0x27 +#define ELE_IMEM_STATE_MASK 0x00ff0000 +#define ELE_IMEM_EXPORT 0x1 +#define ELE_IMEM_IMPORT 0x2 + int ele_get_info(struct device *dev, phys_addr_t addr, u32 data_size); int ele_ping(struct device *dev); int ele_start_rng(struct device *dev); int ele_get_trng_state(struct device *dev); +int ele_service_swap(struct device *dev, + phys_addr_t addr, + u32 addr_size, u16 flag); #endif From patchwork Mon Oct 30 09:58:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13440340 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 D8564C4332F for ; Mon, 30 Oct 2023 10:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gsuvFh90TBC2WA+CseHZ5yL2UfNFwe4sa+ZLMdUnFq0=; b=oDwIkxircb1f+5 P+MqEOxG/KsKhHQR714UP68xCCci/aprlq3c/2EKJJ9e05ygxXInI9gdpnJALcV2iP3zHQjLiFSdO M7agwFma69zbg7176ZcpBJlrK+bFykv6L08AaH/VCxY/gZRN8SnLxli5a+I7ftxqLDSQN3ODfTYwf /VDoA4sYmTKx8Q6hIJ8zlP06BUmOtwc7i2lPzNw1i53N0zjqs+JGWHeQF2L79psQOlwiRxYIHz7sT 8TIzLfQ2TM48s/m92mu+BOxlCD/GF1eR6Nl7BLtXdJFAqq+2R1+lj+M/rzZ1n5xae9T3iJZ+QDw2V WmSeJxrGmXctG7MX12Tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxP59-002ye4-2E; Mon, 30 Oct 2023 10:01:15 +0000 Received: from mail-am6eur05on2060b.outbound.protection.outlook.com ([2a01:111:f400:7e1b::60b] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxP4V-002y1v-2G for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 10:00:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cx2wzxhZmPEzzODh99pYFShPxHdwfOKlLYF0FX0vo7Asi3TCpRcSjFzw/P58ffyiGCPzHspU3MhRJpkwQev6Zgy/lCT6CTY44RRWMgse3RJv1v1qsLZvuvx3dBVg/yrDyE9Mm+Xqj4pE1h/Duu1S+GCoiDjFkoRiVMdNUuqha9kydeQrJINZluuzldNU5mQT9LYzLylL0ANwwogS0g1HGoDwouvLvlv2VAlEtMSLnT7SfZqRHYy6S/EzhQfS+D6OIJJyWbbfjuoHD3VCHZdX0otcWH2x+b0hsqRWCb5VcJ5tUGpX3qkawTOBWFCZ35DQSMeBuwFw8k5SCLNUgD0t3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=K0Gl73D3Z01os1JfF/f5yYMjVSKDswmv4vCyPTiid8M=; b=Zu/3PW690AQNzpHbAULNFuRsprznBRx2vhux81zlpZTyjbxcFOucVZmbGVVLHMB4l0vYyiWejVojyDr3jpFN08wR4HM/0kldo1sI1ka0yj5N37uBE+w4yAnlTCz/EIJt9uuwClztqBTyCv7evRG8CKsHEdBQxkr1YOPmCr9CPtndxrlxI/nbF6TIfBoAyeJkP5ID7SSJ+xGYGRo78TWh7BYwSWXEYw4PwaBo6OpHnava8/LxzkuSXFBJCVZAVtj46P713i7Bwy0VGtnIEeCaz83N/SGKvxuHfVybzHFgoYSzFbGxaI80dL14KxiB2FWa1y073nb/IGF0Be2FA5a/ug== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K0Gl73D3Z01os1JfF/f5yYMjVSKDswmv4vCyPTiid8M=; b=DIV1dlUx0x488jPwGTSnAvELqyM5mNhAqKVmt7bi85PUM61NzQtl+FWyKpwznsdJ+kLpg08t+7NRZdLXoDTs5FHS+hCWUtyCtsgqdKMjNEDLjxkOAPQXxqDZV3Y6Nhsfg+a0IBfCtKlXlMmfj/8rAQYt7tSiXPiloo/cJGzumDM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB8482.eurprd04.prod.outlook.com (2603:10a6:20b:34a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.16; Mon, 30 Oct 2023 10:00:31 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::9ba:8e4f:1465:9351%4]) with mapi id 15.20.6954.016; Mon, 30 Oct 2023 10:00:30 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta Subject: [PATCH v7 11/11] MAINTAINERS: Added maintainer details Date: Mon, 30 Oct 2023 15:28:49 +0530 Message-Id: <20231030095849.3456820-12-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030095849.3456820-1-pankaj.gupta@nxp.com> References: <20231030095849.3456820-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR03CA0100.apcprd03.prod.outlook.com (2603:1096:4:7c::28) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8482:EE_ X-MS-Office365-Filtering-Correlation-Id: f5e86bfe-8955-4314-4391-08dbd92f0cde X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qk8ewj55Ouqra4IPwyggdRv2hMpt/vVIETTBI7Gb8xc/fq6ycCKU77+OHd3xChU65m2XZzY3RU8MpVvLDguKhCQ0GkZSnwOQI+hYe6tpFRBSt7u5O8xS18GZDTY+PLa2AcITtZSfSI5twbu+mBti5rXl2y8xTV8NVmg0CMdRrOkg3mVfVPb6vuBOkaz8cfWW7yN37K2yPFIugN7ehfazPAG95hqSEr22NjDcVQrT5vfPfXfm52CPS98ILiHthPyc6UivXUfncPKN6k0NlBqqY1YTyFXBBELmchk7QZrrb62Tc15YsA0SAFnqMOudc4iGkwGpgBQRuWTzH6M8JnnWj2Zj7w30S0QRpOJ6V6rRO5+rfMu+Y1iswEyRtZ2xTrQzyoVobVuIM0M5zg6wRkQ7XYQjmcDy6F6/UlJOoDsh496NMozKAAE2UInDlamBF9oHi5kx2e6nzXYn8vr+VgIR2W7v36ekUMP4exR98uHczARXtLTDcGxwna4PSnHmSm7EKWrW5sN0muTaxqu2plLmJrh2UzDfbKqUkP5DD1SX+vcmsd/b4pjyNS3hnitJe8WuxS25XluUHYCln31EhUxkiJk7HcbM7F2YZE/DwXFNh2D1QtaWwYTR7zVjOCH4WohD4VYwYZu0cKem14t0sJMYxg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(366004)(136003)(346002)(396003)(39860400002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(921008)(4744005)(2906002)(5660300002)(44832011)(7416002)(41300700001)(4326008)(8676002)(38350700005)(8936002)(86362001)(36756003)(66946007)(38100700002)(316002)(6636002)(6666004)(66476007)(66556008)(83380400001)(1076003)(26005)(2616005)(52116002)(6506007)(478600001)(6512007)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zlAK5HvsfkrAT0jiwsjWD2Rdk1AC2ZFUaFYwol1vjwsLHAZTT81KA6+AMOdvaHcS9BmCtTWaH3WE+g0FsFxjtKaXfmuFEetTwT+BcQfksr+Mn7jY7ZvUrKo2PQmPd3yFdBjCtsgQNO32UVKYvo1kzdWF9N+XaV5Ou55Toy0MlAEOePIobejZHWOHO5JRzzT+zVvnOupfVW/H5nUjmwT4vx71HXJwPKx1uZQotgxRA20DEmLPNLo3a0xiKYuPbUukUSlmzqUzT68w31ZiEG/8ubU3VLaEmf3INHMtd3be9gGpEYW5H+Q2EzTY7Ht9KFO1Iz0JiGIsSdUPZ7PKkXTfD1Vvw8n+sDxBtoQ4EnEPxR15rE69vIaspC5VnWtEfBnnK0LKlY0r2tIqSRlP/ZCQzKUMLacrweIyypRGsV49C+MEAI0ROSmEpkyyef3tW5aUY4aMvgE2/xWafdyL3pKVFu+gjSAuRY/BmZU0QYXQXk/81QYMdnk2Pf5T+k+phErq3lywCxJSexeafGkRaYuc1BgI6TJYJ/43Tl4hqZzAH+hYKKcPSEYjwF5TZjulDzKwH94wMED4goeE5LELK8iToPBLX1EALiXHD00vOpypXu3tYHBbyn5mJ/FWp/m3NfZiKQm9Zo0yyxVNgZGVth0AZKDsbAqv/b2HGwNJR+ahEUVAxQF0stuIMzm/IIn8DXW/tBac93Jl2Xyxsipf3d7X0O8eMxKkA2Ziv0rbcoki5gZq8x7YQ9fcvCahPjhp521gSaMnxzro6Jmydh3rZsXMtF5Xd6ZhGQGHaR/PKRp+Yh35JbHNvcTOEajC812JsZRzlN5wwv+H1TwoHLX3keNMZ77s8mc1gCDMb/FMy69N6l+VpbxW4hC9ktth4MyXVZHlWNIrZuY32ppMSIP7UILKtPD64fENhi+utzKV89SXthskZ1f0dO47dXOu58HXG4ibD7ufsawKLd9yHUvrWI30owrBDT4T7uRQtS5TqXSBdDlDXScwa9iumJLbRg0OlYUcQb5mIhdVCjkE1gGNKQ7OEWF69ZNYp7mp5FIcWgSPQmI6DdUZuFe83Tu2LrBgKdD8z7Iv+smS+pBwWrOvvVDe34iNJWewh0KZ3BD8w0KOMjYKszZjs+7kO2UbGBuXYIQ091nuDLFJ4ZTxf9Wz8U+rGV6QzDjMfqUdmfg1wU3HjSKDPEwPR5ZwOpdU6LEgo6zrMG8C+D0N5bWUpqvFzhVjhnvDBDqQvBJuzz3k9qoenIcExPOVencctwRBYdemXATHb/djC6BOiRHAmiI5gRpSnkYexQAOuGq5aUsZ13dOktrS/Y2a6piN09tFAKhAnHIIYe6hYfZgkIqOVnyiIVsSOx4vP2+TdBYtU0p4t2cMyBgDAAuqvqgay1zE/I5EPyIuKD4Dnl0wPSiQSSOfWXK3FMHLVktuZ8FFPzKvlUFRi0omjmnrx4Az+FHRsJUhzAJ+I7c5wgwk42A50hby3s/KVser8v5i1Hv12yOxHaUv2ZEoRLSMQLyomHav1tgdDZFgGwvHGTtssxza3SBrVLjdT3QGFKKvOvzqBN38nhCvm2VpU97ZVaQGb71aLpujktuE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5e86bfe-8955-4314-4391-08dbd92f0cde X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 10:00:30.8807 (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: bJh6Yd3KyEc8lkvHWpOPVpFPOjoTU6qmcvYYzvEMyANAzfjFNVdB7v8KyZqBqYsm3dhRZK+422JdRViFrd3mDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8482 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_030035_770277_B544F959 X-CRM114-Status: UNSURE ( 9.16 ) X-CRM114-Notice: Please train this message. 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 MAINTAINERS: Added maintainer details for se-fw driver. Signed-off-by: Pankaj Gupta --- MAINTAINERS | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index dd5de540ec0b..984751d7514a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13758,6 +13758,16 @@ F: mm/ F: tools/mm/ F: tools/testing/selftests/mm/ +NXP EDGELOCK(SECURE) ENCLAVE FIRMWARE DRIVER +M: Pankaj Gupta +R: NXP Linux Team +L: linux-kernel@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/arm/freescale/fsl,se-fw.yaml +F: drivers/firmware/imx/ele*.* +F: drivers/firmware/imx/se*.* +F: include/linux/firmware/imx/ele*.* + MEMORY TECHNOLOGY DEVICES (MTD) M: Miquel Raynal M: Richard Weinberger