From patchwork Wed Sep 27 17:53:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400713 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 0687DE810DA for ; Wed, 27 Sep 2023 12:27:08 +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=pVAqmPQ85MyAsW 23T9XmlCQT2lbsCdJh7ATxya28v4XLXBzW+AgQ+aSlaDJXhAFF0/YiSatlv6DJVrbt4cPrvdVP3lX GdvKhBCItCMI7mbZu9cC00EVrtbuEw2WCjs4JlGrl3upPz75CNbxrahHrL0SwaBGUUeVYG5fMo6g0 URUyY4rvAnUn0eBdm3oI4UFrpiL0sTG1+pdToXTho4Ray79XlM33Ygiu5Ta9eD2B/bJ9gvSJ2JNXD t537ACXYhdDI1uGTjeQweDRshFqZEzAk5Ul0fYlzYAKbqzPe67zMRrYFncaVM6thYLfiJoarLjbEA HXgM1RFKa+GMndsDOsrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTct-000t8h-1I; Wed, 27 Sep 2023 12:26:47 +0000 Received: from mail-vi1eur04on061e.outbound.protection.outlook.com ([2a01:111:f400:fe0e::61e] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTcj-000t5K-2h for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:26:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ULo6z070lhQg1G6xx/NLn9QrGyFZu4P9BYao+pl4B1YvUfw/IMr59VSUAd4rSZdWUHn392TLXGtfjGH2+GxyaeQM0H0AZ7smd8TER/s6f9TncmAIH8Ncr0AlvAQbtvLpJn+JxLWptHPUcTFPwauwgRh2cExmAAXMzzcnLJ1bOC0OfcdInqUZr17YEh5ufRXP0msEZlEVJycT1qTdEysNcrONYKlgz2KZoT2gJj0hAjhVneb8RDUsYuy3Rg6DVyZdwtS9K1RkO9KAI9hm4IN4aWvidsiapBve/zdnmN0FEw8tTcUU9sma7tACC9BVGa+GlhR4dm4GPa3R4GkkiZ4VIQ== 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=VEF4io4uCzOYIMRk9VBozN1mXIbk3hMzBMhs2e/yixNkp538nRiIA2Kw5zdQM0EfHX3GfZROrkvhSdlnt1Tm6OdiPFMzhPvlBjCPscIS1lnWd9y/ugThL5lQ57qF6hAlUuCf7B7uQKLPQ1qw2SssEXareACYt7zDOlMtL9sBwAFiVB71s/+KrDT4MM96/nY93Klp7YtStvpMX45uypsUIgtMT5u8mPqlpzz7MN6C4/i1dMm0PH7t1D+lSFU7NBhu1PMqD2t91fZWlxqaUc1J7EsIhPin01VEUoUZMFqHF/LsQuHOMp5K45/ykCqiQTTXg7rpPLMQUDBQ2EJFLTd9Og== 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=LlS7T70ZzeE6nqh4Zl38xSQJeeTuIMxK5YNfbKyE0aYWUTX9YoPgPurybOJu7HWofIhS6FvZFyUWnGCcLHzmNhU00MhftQ4fwKxYf6vJoOB4aV/tkXh8X0q/rOtM7eQmMmiJWz5DozJpmyWLrdnP65y8nYWQcUiW9Kq7xUsObnw= 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 AS8PR04MB7704.eurprd04.prod.outlook.com (2603:10a6:20b:296::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.27; Wed, 27 Sep 2023 12:26:32 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:26:32 +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 v6 01/11] Documentation/firmware: added imx/se-fw to other_interfaces Date: Wed, 27 Sep 2023 23:23:51 +0530 Message-Id: <20230927175401.1962733-2-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB7704:EE_ X-MS-Office365-Filtering-Correlation-Id: c946d3d6-b7a1-4f07-9be2-08dbbf54fb87 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rQOKg38X1S7iVACD5Cn8S8lnS9oh380e2+DRTXbenj55bIzCgCm+39vuDdH0cOWGQy1RFKm03Op4SyeCNfQxxPrAdvwsfdbd/sw+V2x0aMvXs8cSUXoYiIMsJPz92+ec+TyyYZf6R4lRR/ek2mALzwE3TKHXmp4JPdhoikzv2TnmlqhsC4GHUkW2sB5Y6Td9276JxQ1khySdYKcK8c4FIQrwum5Tpwc7mgMfDgLXvHNwqooQ7U3bAljuTp98mrEpQKItDErhbk1spd1crabSMhnkVyd6n9dbXoyD7lFz6EIO+rIGvhbcn9oyvM9A5knJQhw6TDzcKTjSVw+5/aPCwu2/Tj2W7+uY3yrzAHN07o92qlHhY5Qu8h69/g+bhbn555IFPy/xnr6N1V7tHmGv/bMYg79lJZdBfvLEXn3IvUt+JANozqc889L0Fde9dd3HivQYNs90UOLhhx3EHZZTX7SAttFUgg6Qv3V6IhjmbsnkmN5xRv6Nhh65fZlzwYXmJ9apRV0Gz6W/uzvwDA06K9kZF8RY8PtI5R/cP3VoAvk9gBErP+STrhHhgKgqHPJCcEYsG6PQvRwr4SeXseAhPXiqEKAOcMJQCrulfhjmdZx1XJbjiFyh9YsitpwNtctOkLJnAcOJIX6psTnWleBpXw== 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)(346002)(366004)(136003)(39860400002)(396003)(376002)(230922051799003)(1800799009)(186009)(451199024)(1076003)(2616005)(6506007)(52116002)(6512007)(44832011)(26005)(8936002)(478600001)(921005)(5660300002)(6666004)(36756003)(4326008)(2906002)(316002)(6636002)(86362001)(66556008)(66946007)(8676002)(41300700001)(38100700002)(38350700002)(66476007)(6486002)(7416002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t6IYxPdF9AF7Ym/iTHWb+96TZFCNS0EOuz6FkIN7W2IDMzT1mqngw8Q8DTbQyIUyRX2pNJO9CDlukWAuz3QeHmkdJFLjYp3jobJULIbbEsqjxZxv+nhtQRrFn8968FXMAWq0bXHJ7jt1+QWOqynGJ6C9cY5JhZjNZXJ7HelQRMlJ1FPevs7j7yG3xKTBJde259IhrVr/WWWzZJPxZNN7ZJcIxtLjAf5tXtzBwxIeZi94bLaPKyxEPHeZ8ZjlyyvI9hooHEhpjAScjEJaj/0/N5TZi+Fg95mR5Rmf7ceIgeHJ9ReDJqI8XKaPtZ5Bi14pJQmdT6OyqRID+6M3OhKTguyDARBgqCHE+B23D7yKSFo6lIyHNasK+VrQ9pzUiJ8eI9Bwek1OXUGX+uJwd8GPdT/moYJtbL5D0A+FXzb5PA3I4GJxNiYVz+3gmqWEa61mVDPJw3oRVGpsIf7+OnxJfUZNt9mycoR2Bz1u6DZKWY0jCKV4lxiOKrRE/bntjaqej3cQOryl4mKrdMF3pF8gElBgKNzTsFW6nShz7H7CfJoHZK7LDz9+vQ5a/nQVcvZMre0EHks8exCMwS8f5iccsP2DSNDjpQhj0J+pQg5DNULaIni1vkR+MiI5HR6WeApnDMLPy2bxErN2luHW15rj2gAMgehyGqb9Ed30+2q0Ak+pzZi17iVCW+MZll2UI3lyRlz5+1ZhqY12Wh1VrgPVTcD2nvt9/Bd61LO6nG30NUbaPYPXeUa4dfSqYFngOSMCNhBn5NR9VGKOPa0Dy3PbTRAK25ufxOasIk4NzAOPjUKxpgXgWb0DFMbrjoBPldalNyc7FpGolHvSWJZZCRwr9Ppdx724rJndBOYNE/IlN/eRdtA7o2v7vtkoupcIUT3TPQcY8V+vob8aIuh9ldhV5muce2UAuIUcj4Ebfmdi2Hbxg+dDlUr/XtJFDsd2vJl8edX6zIJ3oha+qRrMtPRubuCFB+23FFY8uKTiFgW19ZqwRu71Ul/1EBFcdUf7JNVArzgpLdxpLMBWbVEQFqkdn9P7Tal8RM1PLXk+DNqWRUmr4lE2vafCWqTqEM3hqtyP6ppqhAIpFZpT4J/wzOAlEAc/zEOR/hHkx0P4qU3Hf1D/SvoyOTFGismvxkpirp2B1mhp6POtZ7N0P6QslhOh0LOCmPgrLGAkfQ5oId+gIXaIor6+CghWBTtkl8uETgILGYLCMDpF7xSxXToxh3Irtpb5vaSr0gH09YE8XI2liKe7CkB0mCd+n3ad3ig4kbCQD58wa3AIGaJlO2LHMlnxt4wuv6GTaxISipktYiP+jl8SHK9v0aCZaA/8lhfLQlU2AyuSd3P8yEWYPJOC0s8KoUNDjK/GR4TbSgtFZiNjPsbg8/I6PgEwvVSaC/88mGZoNUfSacF80d/4tksRIx4WvCy4CpiHMe9PiYA/g0xSHz0pBQEQZPLJhgFNZa7ak868k2DAtXx3pPu3Mgu9VA4ruFblId5V8/51wobBxT6eUIg3KZrSKDz9b/f12/VxYWP+7IyGxzGb4lEhSX26BANWEfBONoxMJDz2EtLNNS/mIKL9fVLz9iXBVMDyM5BayEiA X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c946d3d6-b7a1-4f07-9be2-08dbbf54fb87 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:26:32.3347 (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: yhlkK3LvVXCn/vu8rrKkc4CyOsq7dtlnBnJMUxop/aAFQoF9ZJx0QQjywDQFcHfBrJHDDkSdJyuYZpAti8H26Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7704 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_052637_875670_2F89D28C X-CRM114-Status: GOOD ( 12.44 ) 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 Wed Sep 27 17:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400714 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 92D8AE810D9 for ; Wed, 27 Sep 2023 12:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: 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=P2L/LODh22Lq5LZgBXa6Q+Y4i0ICCBP3TxW7TK7XM6Q=; b=HotWQLprGzRh7g hqpof9MJSufTI+0K2ihfFQUx2GLL8jqGTY0KgdfGFiwbMtYeZHBM4yltCv1EINpg2TAV5mR/I77in qe488Q8LgDU9hb9umO5bA5OWnvqpPjK22HfJSFoD7rn3kaaWIP7gX14x7v78ir8wDKfvDZ7gEOEDj DwYEbWhop0g6dezkfbb14UcpQA2nRS8ZyOBtsGv7MkgSIWWs6QX5jrB7sR30GAaJ3REBB6xmyN0ti +UOtEUtN7oCwelZkEmj0Zu1gAgdiaVtelVPJr7XYVkxy+SEHoVhTeYghZxdlm+9yahbnXCENArrvX GvweAZeJVuwEKWa0X9iw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTct-000t8z-2y; Wed, 27 Sep 2023 12:26:47 +0000 Received: from mail-vi1eur04on061e.outbound.protection.outlook.com ([2a01:111:f400:fe0e::61e] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTcl-000t5K-26 for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:26:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OtjOMAdggvR8MivNBUw0+xH/MJo8lzVjxpA9XRN1vnDJykqmUwfD/kNvHmaBngq4yJSanV/HlD3sNK4H1ZANN+am+jo7WlbE0dtvWcvKiVWSsfL55H6BEggK8SpwRrEPNAn+m4f9gj2C0Ohs9xi/qR85v1WzAR8Mf5z2mNNCavVWxcIyeztxf2PmNPCNT7fNhNQsqWNp9Ne5KZl2D2zQxuQjmmJUvLMTVgqEBK/GHd6cN/nEQ11PcrCab7Q5NYHrA5VEDreP3jkHqJWAVwaq5eUcureB12thRqF60j7tbkxl0afsrJDXIehU7lG8pKP98yesS9RB/yNJBmgjhohKFw== 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=y8+ymlawP3djoeglT5X6ixc1UnvqX9Wv925OgQ2Z9mk=; b=bMcXV06pwumfYrb38VIPrmizVehndFeYF0vlAPQOaSDiE2FPt65eEo8lNbvu0Wh5RkTpARt5Tyb1Y/kPzwxMTC0tE4LSuwHt0DB9VCWQNZB1qlEHEeumBadCwgPg8xFuPj/NAIMZ1vIKwKIQxnT4dkGWVNfefW6xB3sTpu2Wt3uhj0eyh6HoB+DYt5p1+qVjtgfCaefi2mrdM/yBdnE9K176VXdBR+0gAV3dIdXsZIStMWjPlIyEsCga0ngrw8lynxZ6Eh6jM5OOIS8qzdiskplfO7YZWHPoJt8L/gjQsMSprB77jbMhaxYCLWBKIhxApRKsxp58IWRfTC8EoSLP+Q== 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=y8+ymlawP3djoeglT5X6ixc1UnvqX9Wv925OgQ2Z9mk=; b=R0R6rgY2dyw8WWftaxFwEaBLDeguQRLyyoqM1rW9H/s9iMjsf7swHcYPyFTmsO5qPBMub73h4i4sBTzp53UL0N2oLys1TIcZStmn7BpgN+HTq76KcouwURwj/O+0lpy4FqhxTt/hPUid92h6LVDyeapdHNSjYJVNSRYT1kyMd7Q= 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 AS8PR04MB7704.eurprd04.prod.outlook.com (2603:10a6:20b:296::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.27; Wed, 27 Sep 2023 12:26:37 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:26:37 +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 v6 02/11] dt-bindings: arm: fsl: add imx-se-fw binding doc Date: Wed, 27 Sep 2023 23:23:52 +0530 Message-Id: <20230927175401.1962733-3-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB7704:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ba0d855-4cfa-4e31-da33-08dbbf54fe97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pmVQ6z7nSz3l6xOyUZS4t870kMSiVW8doEhNnLM8WNnvJxN1iXbSh9VRpybFCoU/pbTLKT0St9WWYAs1lootkFt9tjGBepe6PY2IMrW+Z9oZmaNLZFzRof8FIe7U1v9m4CHEnI/JRHGWhbcRjqE4zmeAMnB8xFdZYiSWcZfvi7A7N88z9n0bxT6NmWW1KyvcPh5gwwmIxwe6IROJP4SEbE6BKsH3DKnDD+56D0PiE+qLm1BxAeIwvaCCpqO3wI6DKYLQ4iiX4Xa4Vgo6IAzBrgZM/PM22zHBeogqoX0fLmsrJbEyH/tNWaQagl9sruIP2eeO2aX+8JzafO6wSVEi3Ir/kMNA2hYemifkmgYFJ65FD7++azGJw77H36m5Evl6p3rMAYd6qqiqC4H6Rjxn6KbR8JTRysrXBEnCVDsbJ8vpC9vsjEbqVanTgzyOOfZ2Ny3cd66209Gd1jgROuZ+eolstnrCH7NXuc5c+2NH1c4bjsxJur//JGaYjZ1k/x6fMTR1Shq3oTgPaGBIms3PLNFe4LHefFNJPzowJ2NoCTYwxKj6C/aBfEbAw8aGhRydkELco52d1X/zS40B/z6JzCrI6KUE/f662klhBFc36O9W3BPB5J1w9A703N+qCRkw 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)(346002)(366004)(136003)(39860400002)(396003)(376002)(230922051799003)(1800799009)(186009)(451199024)(1076003)(2616005)(6506007)(52116002)(6512007)(44832011)(26005)(8936002)(478600001)(921005)(5660300002)(6666004)(36756003)(4326008)(2906002)(316002)(6636002)(86362001)(66556008)(66946007)(8676002)(966005)(41300700001)(38100700002)(38350700002)(66476007)(6486002)(7416002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: P3Mgjvc7XlQhLSaN+PauMX/qFd07t/YS1xA6GHNgag7WXtyM5lR4H9qaV0Vo8WvI1h2WvNOscAvToz8vUs1NyQzSa5qWTUQhQ/vS+micn9oUaE8mfIFfPIfLu/LRR/WqaFSdPV4GzyCkf7tPAcAMt3/+YGQxwDOnRWJ7F8wWkVNIzRq4SUznTsZ5slxArcKC99fwk2kYiLnR3fJWW2QjilFig2rqjM3Cn03egw0qO4uSVn0d5SW6DgmOdxgz27TQZeaUgLcEVZpdI/rEjjcmPi9eGmhix5iOiaOR5Vtwh761BrvSWfGPnEu7F0RzKKcxwt/XfMBZVZeUdOu2l50uUl+LMXbnp25QWtxxVE9qmYqbFh83Tdo7tqUUhQVpDaf0arjv/fYT10TnUZA2QbY9WB5EDx6GbV2ENl/3VisbDrfkfO3jPMEf8hsRUeMv9awTJIzpjQbEJmEhTa88zNhZzBJy588S3v66Zj+bhYblD2D+EbIU6kaFCmSV0mb68HxA5tK4Ay1wbBSOji3D4EGOlMTp9phoDtkv1lturg7Q10Ro+TnFFtwN+EGoMyQUEx8jXwXTEH28g9X9XFzPy5B9a9ZD2niBiyxtRkoWbmSQjrUtMsfCbqnFjhDWdXoRh/PbWsk7044d4YhvxYxq8Facowrdpmyvn/oZunYHCnE1PXYsy99YkuJYQEDQe5WvGNXHM5c+HdF431YSKPMKiJktvdljJI8ey5BTT/mwWLeEaKm0mI/AbOSzF8UylOfZQ4IhiLOsVdR3CnmGypAx0qEUd9CAciZxGROuPVoEioZ3SDhib7juxeVFQ6isaTmk8ITyE23YUPz8L+GJnJzC4YVM2xRa487tLucnAhJ9Mn80Lcoi4rD+Kp9DUTHl/tCNgPHFeQJg+/b9B51jhtAjq6Vy5fcGroc27dy/L3Pe9/RzvzuE7Ixzk1dsxBq87WLtUXwbOyoKu3qlPV3JpvvImB7pK5IoDwU99QL4dWqcX+2e8F5Q9YpMBmRFA6xtk1p0o4LrOWiPw2Xm1+90JE7xBJN1BibaTl72CWRKu2V4YHXjz3kG/X1eDlrgAz/3gsZZXmVLc12E4SVxvlPY4LJWELxxjSC0Ldx1IzGZznBveFb5CFc4zbtsSBmrxxfPZQQNtJ/YOBkI7pw8Uwc6J9mTpJ6UYobgYmgo+hzOymxBReSyf3q0Q8JN6H3mYj1OuW7MZ+5yvDMH/BnToPHCowvkSOWgoRfrb0onFwGvvSMt8jocrjqnzxl49i8QqdUipCzoxvcH+djLFXkrBPKdONshobNr4zRa3+6kK3Mm6uxNkOOUJKCNjcdzw9lDBpULRVU1lDq9mNbzDQGDane5ICl6ZojrVLuK4qJ74OGLL/Norwl+cPHo1dt7H4oaau2tFFbeZ3z6bvefmikW2qtFCIzqYq418HN4SF8VJ7y8e9dEoHqa8pW7dBBuC9nkbl7JO+36pNBFswlcSkjGSkXic8xKik9aFPQWkNxxDfWKbby5xadpV/X1cniyeC/xobJvRzZyakiPw4vSMrq5Px77XDRqmSRH4yLO48CPU9NjHQ6C1/xcQuwQqW23TUgJmLnFK1kjubpt X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ba0d855-4cfa-4e31-da33-08dbbf54fe97 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:26:37.5420 (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: 3UG50l9EN275sqtbZJUqMAAOJHGrFMC/xqReDZsBLqUjFgDoeVUp1SSSoRfdyVhrI3WrAUYMYfL8Afl76y1Sqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7704 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_052639_693242_EB21506F X-CRM114-Status: GOOD ( 15.12 ) 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 | 73 +++++++++++++++++++ 1 file changed, 73 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..d250794432b3 --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml @@ -0,0 +1,73 @@ +# 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 + + fsl,mu-id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Identifier to the message-unit among the multiple message-unit that exists on SoC. + Per message-unit, multiple misc-devices are created, that are used by userspace + application as logical-waiter and logical-receiver. + + memory-region: + items: + - description: Reserved memory region that can be accessed by firmware. Used for + exchanging the buffers between driver and firmware. + + fsl,sram: + description: Phandle to the device SRAM + $ref: /schemas/types.yaml#/definitions/phandle-array + +required: + - compatible + - mboxes + - mbox-names + - fsl,mu-id + +additionalProperties: false + +examples: + - | + ele_fw: se-fw { + compatible = "fsl,imx8ulp-se-fw"; + mbox-names = "tx", "rx"; + mboxes = <&s4muap 0 0>, <&s4muap 1 0>; + fsl,mu-id = <2>; + }; From patchwork Wed Sep 27 17:53:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400715 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 B2999E810DA for ; Wed, 27 Sep 2023 12:27: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=fkTXvjoHIbynzLPgJ1Ffu+w2LSQkLOKDrEfKdMEnel8=; b=M8pRcTJ5PFpLzU pT5ck0xL+XvAjxaGC/Swvd9LzL3JETRQ3YoVPlH9G/9aUZ5NPAl8jSEkFoKKuJdBJuc03rErYhw+a JiTggA/az1E+Ji7ot3kY1NiaSmH+ITxN5hGrJ5mQeQpB36xLVIPkCh5riK26my1XoIBgLsflcVCbL E3tfArg9Ovn+oXjFr/3Pc+Eghpcnl/WWV2tKQ81+ZU4bfa29eAmcESw7VvxOgRPk21hvs5Nmbw9TP V5QGgOG039QhPHxV7HxkZ+7Wzh10u8/6pMAYhiFDotDTOWxDxjvhRAuojzySxsSt90auUZi6UCpNy AczWbG+7tgEYjS+fOEhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTd8-000tEK-1l; Wed, 27 Sep 2023 12:27:02 +0000 Received: from mail-am7eur03on20614.outbound.protection.outlook.com ([2a01:111:f400:7eaf::614] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTcu-000t8e-14 for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:26:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a+S0HQQdfkBMAv2kth/w/KNYjEuJTUjSDhzrXZIUlPtEQjT35cpf2pEyc9J28gxCHdoVWWXT3K329v0ivux2cmnCNOvEY9bkEjyps9wtghZtMKlS1Sy8hL1qaUAMCOGLhUkqebCSholrBPZGevlnL1tAk9LlyS82BlXbT3q15gYCJTmmnDrBUhv1NZ8L2GjhgjLQ+Bl9PmylbfZUoyGYWjEO10rCIuMyraeDz5H19cCJVIB5rN9lboMbuBmKYr74nDR0mA/WXMOgAUPULCVTv2dKHiGAo+fnMO5f7AXZFxyBIFIgd4AOpbcBE+lBZ7B/biONbZjKF8xAwwF5mVdP4A== 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=7IGdDA4++YHirN8WansbBnd/kYOSwl31f4gDzXfa7As=; b=Xv0cJ4/euwVwgqcTA1bFdZPo4uz+ixIY3fzTxzMGvXx15EBzjN690DqKeVNcsgFueO9O+wYnnAcMaMQp+DbRtDMEzoeQ3ZhEedf4SBni3/f7fI14d+k74pcVx7qpLTqozKcmeE/hnsl0dAx+1jYVhR0n+JeSkgGIsy05nFn7yk4R+ZigymzYWUJoE9rU1eqbiCDKLvJlJSAkFzPt2Ltqp9XEoam7FNWG9piRG9/xHaLsIrCgEK+Q2WMdAQozK4x7hWv4xQJLWJrrkEKlrpyKxaHSEcDAShGD/WZz7ImkZ/wsB8oOjGKEcSh2E9NOkdeGDTY3ZlsJ+7TYEZlnbUK2EQ== 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=7IGdDA4++YHirN8WansbBnd/kYOSwl31f4gDzXfa7As=; b=Y9m0r896KmPiG2ko2X1ZDuUnLRWPQcJ3dPAT1ZIrfYK0I7RLvmIUjn1mfB52YeKopr5LsTsAGeZQ4dK2HMsKR7N9NhiLUVbUnKJxlDcbk3twRSsup9vwdeU3M/OhGEHcTKm+PmryrmRuy+QPr+5J7WE8mLHi//msNCiFv67jTQE= 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 AS8PR04MB8181.eurprd04.prod.outlook.com (2603:10a6:20b:3f5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 12:26:43 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:26:43 +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 v6 03/11] arm64: dts: imx8ulp-evk: added nxp secure enclave firmware Date: Wed, 27 Sep 2023 23:23:53 +0530 Message-Id: <20230927175401.1962733-4-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8181:EE_ X-MS-Office365-Filtering-Correlation-Id: aa266497-e8aa-44dd-65f3-08dbbf5501d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ovC1U13UJNsaBv3OvZbmI6uHk52vEfNudzQVITx6c5pO1r1C+kKLD0rY2ayw3YUzIo2S3iGbIlyNUS5lYM5Pin93jWZ3tbB+bzYqBrI0C6IHxdUw4PgS2aSpWVRIZTd9XI/hm/Wh3D5yRojIPs5LMD+Y2R0KBlEFsf8MfHUGaCRGOTkg//agHop4hwz6+j0Ai4BnP8pqCZssbQU7gVRlF4477SsGSEafP8MWHeH8SJv3qYt+FhgMOoTFYxGyULKT3mSELmxOuWGh62RLs8r7zqEZBN2sP/qfXcdogXSboZQLRQG2mAXT3IebTdtIwVUpMBDhqiz5DBi+sZtS+tLA+/PNKWgw3vaVoMngUAKt8ANZq+xElIEe0ocVbPOBnRq/lVm8kMkjrH0xmAeMrCBGZSE3iPTPmryW6BJiHXkxVVv9gcBhZKwWpFNTlRQF0bJgwsxUVPRXAyyUqtA/SVKz6YIrxwV3xKLVQOhr4G+NY6RNaAYS4YWf1i4fgfB/c5gDpZJSApeE2rpssGt6vdUHyaITZFsS5vjj59jqgguOiaCoxMjMqkZCa4wIWPtmmUoEOX5kgV1SzTQZnAiIUW+0MBlmZG34KGhzlpg3PYAIl1akOjoSK6CdLR5/Ccfok6qkw0TflIZg2EPLGgQtRvyW+bKWvtBio7Udmip34kdTeao= 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)(396003)(366004)(346002)(136003)(376002)(230922051799003)(451199024)(186009)(1800799009)(4744005)(7416002)(5660300002)(316002)(921005)(83380400001)(44832011)(41300700001)(6636002)(8676002)(8936002)(36756003)(2616005)(66946007)(4326008)(86362001)(1076003)(6666004)(6486002)(6512007)(52116002)(6506007)(66476007)(66556008)(26005)(2906002)(38350700002)(38100700002)(478600001)(32563001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L6Md0ODiqjoQAPUzJ7PAajX5Hsm8Zz+Q0psWftvV6JFAlZ4EoPbgy9OizX7PkTcFJXushyq15HLbmBsz9/BzJ+Ez9VEZeH/FyHWaHyBjdDWvut4BDq4Ztp2jvY+NyNTlkSwc0X8lY95ozf0KQH0KGmezNKDGVJ+/3IwGnr8V/2qJkCn3pKQZEuT1wizDsHNKSvXr41qsnB1Fet1anSwB4r/2MbfgTrxJh5HWQfnlQ3t5/+tToyUWLFbN9Mf6znkUOvnCuoEsvdR3fCIqrKH4rjZmk6lDBWniPXbHbW5KJS81qKBrCUTvLjN/8ye6vjXbbaJlVJKAM01Yt1uAjYeSu93wcOZVHGaT/AEn7jpBsHo0tD1ZzvBmy4aR1A0huC6BbkgP3wcswFUcGKoKxjJ6FD0Wc4TBomy0fsI8yFhqcTcqS/BSQV/uWQYs8F4rKjUt0J4blinjssl3PxZL6o8opaAs6ugz5SCCvFB2AqRBl9oBWyNH2KjJAk1SVupaJkmkoONeNjPDsZkbo4auwczLt6cbwa+cATyS5u47ldDaIcZOP9y8/wfmqy94KLYbRgR4eJw72Hzua7d8INwvC5Km6uRbXvNY+GZlcfCkE06dCjZ7OZdBlyAtSuvydDkiHqqrasEBFxBe5zbrND4Gg/WACo2WNw6FIM8mAZ/4fT25+3v3NDo/VvKCmBVbp/kko22DKhnB27NTF1H33ImEj06K4wCFa/b/XRk/BlJtVIcC0JlZivlDalKG9IzIcg2nfLBHqA5Raav2RIyUJ82PnHYbQ63s0x5nNC1q5hLDyPcY68xudvKD4EJJ1PdA3oVzaS/wAZlyZHq0kAZ6CbJDfke++ttYsuwT47FxkDYjOGE6UhYBfqi/o+NQblFTAGghEdGqlXIGkcT8VX971urkKJFfmEdBVtdf0OMVh7NYfBUwbT/WavMXFA26cNsMGzhh2goppC7yBXDkSUwsWU1sT8uCoqcyl3Gy1OK3hhNJ/RZKG8gj/rZnFI9rhh0qUnc7plMGDMI27v75dSYi0gOeC204rrDfardXb+5vlOaFMKgHv6u6v2Es5Jr/cjXl1WglwQc/8ySHxm+ri7LM0xnFRSX46VTa+NNbU3tMsCSij5gxoUjLuOQpXq9xPIabwuQoLMRjK1COaoJAlkLuEhBi+fguIPveS7qACXGXeudvcxvH+AmgO6fTT3W8ZTMhQlZFh6CZZMPRzDaz1mo0qP1GUczjoVQ14ji/CMevudC2h0XuFTJQIyZWhv+o5my8dzSTcMCEQ7PmXyatPglUzPlDC7WxiMvK73uPfojD9q0LsgZuOAUw+BcpC3DYHmNaLLu28aWrSH/scyJE/17GS3KPc2Upcag72s75EWjIq4XVv2s59FLen1klDsoyZevp4DT9cIU6yehUzVicIL4xeoI/Fyr/6xGDRAst+Gxv4pb/kkAGj1gvLen1hxdau1KTtytmKdcB0l/pPbMuYu60f+rhEREDxviDOk96boRt8apsApHnRt7ZC5hAWluMMnk3Uj6qTabTro2KeBN4FSSfXcK+x88oORkLV5J+dPE/henVZLByaGXfRdNkQ33gb5ndam/ts/7M X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa266497-e8aa-44dd-65f3-08dbbf5501d5 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:26:43.0162 (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: muCNXIXydpCHfBlkZmJ6iUv76Iazt1fqGyXu3qgpl9TuczvbS3qtz73xjGo2qJHhDPEuyU1tITxLnYpjzCTejg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_052648_376276_899C5714 X-CRM114-Status: GOOD ( 10.88 ) 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi b/arch/arm64/boot/dts/freescale/imx8ulp.dtsi index 946f2b68d16f..0724a2524ac2 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,14 @@ 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>; + fsl,mu-id = <2>; + fsl,sram = <&sram0>; + }; + }; From patchwork Wed Sep 27 17:53:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400716 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 46B14E810DA for ; Wed, 27 Sep 2023 12:27:29 +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=kN1TNbdkYF+BEu 9FXrLtFgInX4htPYkoXBKs+eHcZK4T3j5WDsEiYg3poRjeB6JTLSBVzM0uygtq/2MKNc96wR1tpF+ /T33aUw7humbqRMcbGD361vbJmBiCWoZYMwCadDKSEKLwGeaQkoFHOzjeV+acuOfbMKiGZk+aG/QQ X48j+8+1UIHbhzuJhWDEJqykp960ljn2S7F7vWHq3SzLtAX9UdVLJfFR0EAFEV9yya/6VdWS+3Iwv lzNBLHCtVnV36ZXO1ehL1pJCkOqPONZFY3rDtUidDbFJgm7vhItnS8eYbB2K3MKpcogo5q9xk7sBo pDgVeFA6CVsXcp/3WHhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTd9-000tEu-0K; Wed, 27 Sep 2023 12:27:03 +0000 Received: from mail-am7eur03on20614.outbound.protection.outlook.com ([2a01:111:f400:7eaf::614] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTcv-000t8e-2r for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:26:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BSyXr1XKzym75LWsnT7cdLrQBbd/5vx3Fzp8Zea6LLdgL4Wu3NhbSdsximIp7PHNxk1IGSrrzjdHmJJo/nE5uMLS0kvPXjPb8P3p/pj+RbxknntjjWQ6a3J9xfmwLyoErHCVTzwgNjZ5SBa1H1Cacl1TPIBS5VysuBMNxAA6FmP1WRv182GuCZ3p+4etf0L/Qu1h3XMbmmNIH82k+n/ZUGDVE6Ad0eQ1j9G0t2SWYHaAf/9qhG+Jy55d694tQpEJyJoIS1hQ/aCsYuzCICIdpTr54kKFknRfVDdxEjDlSNBH8XHp12rYaSPvDbxb60S8rbYWggPzgcy6Hdxkvzqttg== 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=Egc2POKNN/i8g+LFVlcuP9IgPiQCWJ/oanbMMHW2Ub+aE5Ka4M/B62H6tRmzwMoM7GIwFe2fy2MYed7kZjMEqCB3cG3FQDd4t5utTR5TKQVgbAzpST9NQzAWhWtLLbhpNNOq2qUC+jJ11P54WMaTT2hIT994E1zBIEj18iwiUB6TgtABXXOHzvstG6BFTLeFvRZvEgLA5fdWouOhZ+c4XA0teNbvxVXtWrtJ/uXGRRVg330+LcbSZM/rWg0bphci/DJGFLlal4rqH4j/LW3O+scDcKjvOj5LtxBHDQA0Q1OYDJKRWVgG8aEbCNKf9EJgb3CsB737nCkPlKysC9WuMw== 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=ZS1yOfu1J9tqk1knbmvPG6+RmgqIv7x4SV7kle/d5QrP6IZS2W7kQHa0dhdoZjR6TzqjEUFEx9dRhOJpWCgtVtOAtNIZCjt4gm+QVAJ6+PezTLiVQvU+GU3L5CEBPC8nRsB5O4K3tc8RPOrTcNcQkMR4beeWS3jWsaBqn1MMbo0= 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 AS8PR04MB8181.eurprd04.prod.outlook.com (2603:10a6:20b:3f5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 12:26:48 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:26:48 +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 v6 04/11] arm64: dts: imx8ulp-evk: reserved mem-ranges to constrain ele_fw dma-range Date: Wed, 27 Sep 2023 23:23:54 +0530 Message-Id: <20230927175401.1962733-5-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8181:EE_ X-MS-Office365-Filtering-Correlation-Id: 42c9a8d2-08f7-4bf9-1861-08dbbf55051a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Uo8I2eNRTQQYlKM2tUz8/yqXyrf5/sD+rq52OmJ/OagcEisV2H9pDpTaBqTxEKAH7MsRkCLUqi0Kk3tIjtTt5y2eMfSbu/UCBjHoh0DikHxHMRYsizBSxcvAN3my26BfPve1lUDkRhhpam3e5z/Le9QeL+DQyWAslP7mKPBjRRQCCQRE6DIvHZJv4EvqBI19PwlKuYGoYIqNSkmFoJhvjOQVBRMGjfClcDUYb1kVNRFU1KJBndIIsY1cuJvCLaehSNfqIDZ9ANG9UxtIK2ltLcPlzbq4n7lQ8Lf16fmJBIPDdK+hShCA8jUJUyp1qPpCN/A2cx5heeeJJnIWRBqMrQfPq3g0leNX6bV6Ie0aDu9kKgVf+Bv1RwHapH9Q/dc6GfBIcXTf3uRsIpfBIEE9AXxs5gvESk7Y1UgsIxXDlwe1fBrl1oJS8IAwQw5ns8DatQVxYiSsQsxbDpkQECsYOzYqyjhD8Xw5YMcWzl7uBEMz+wXBUxzBLRi+MEqwOrGADEGmR/wR0SsLqJo+hEeqDWv8s6PTNh30HwSrY617/Rtc0F7Got+/5FhLNtCBSFfEbhBAwpzQUpId+Gc4jaIMOwIRX308Q9vRdYdUdl+Mz4hlZ33y+tJrn4Ffxy3U95I4J5PgHJ1lJCWVa2OaaHtqygAwLn9WXHPSaec/1hxTdVE= 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)(396003)(366004)(346002)(136003)(376002)(230922051799003)(451199024)(186009)(1800799009)(7416002)(5660300002)(316002)(54906003)(921005)(83380400001)(44832011)(41300700001)(6636002)(8676002)(8936002)(36756003)(2616005)(66946007)(4326008)(86362001)(1076003)(6666004)(6486002)(6512007)(52116002)(6506007)(66476007)(66556008)(26005)(2906002)(38350700002)(38100700002)(478600001)(32563001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ViCEZ03EOp6D12GKBj6VNjWmtPV8QlGQbOjFMFKcxMJsmOHAe77PNvCj2op97oXgkIgeRj0lno0OLMXHeEsVD3W86LguGZo/0njyMR8Q9OF7IFvHhIEBiZbipYN6GHPgkxX/rqjYlKMYVNVOCRUPn1Hi9yHQuxXcBrLCs8aOW8shLuNVpdSKiGH1HKgOHiSLSckKpU22EaFIGgIBtwhtHQI1063C9suFys3Yb6nC3t8PGGFtnnnirLKLMiiaNLgYVa51qyVapx7/9U5KBJeX/38NcO8DT5T8qFcnscU5C6Hi5l1Kj0Hb1Hv99nYDUwfkufZYVvjrMwdU9fmvC1rTfsXrpkSLtykI+7RGoFi4A4loNZ41BDUqXXOEXZmAOvx4ToaQMApeE2i6cRe++4YtzLzLqx4kzTWwpWBVb1CtY4Ox7DjRAOINVG3jfsLYTJAg4jzGoWDXc867cVKMub/GRL0K6HhbUZTVm4MeFCyDZB0xAnbZCufV97gUBW/tlpsbFaqrHIx+rjmv3Ii4hERBUfYCKeah6AEcgpjHHCe2mBaMLo8gaNFLnk5+hvnQLM5I79EOOISmTimzxngpjG881cTAb0sxjcGVXYZJ+i7F7yQG9z5/qvnFtYhFMZmZFfnKd5AO57Hq8AEhkz3JqkJhJGZI989GfdaCBx1fFIuCJuk/aG+PRpduJ2/g/emn7Hd9vCcW4RNpNZksfP0zbgytHaY8suCpkqiVJUI/5huuOudZ+IsQGz67eAbvzUZ7G+l9r8U+Xz56hlvE09wmE23KAQKKzV+HWYdQAaxxirkJEoIZCnhZQhknYkbhRu02vWeRKe0lP/TkIRVDykwZZEOle0cqu7bqysnt7wEoEjcPwzPMSi5eoyC4U/uzoC+LZBaMIba/QqryddftU4pOyT5mksmXkofThhrwBgKh8vAwDm/PK8hHiT8AaTkulCadHFICqKrgeSJptSdzGK19WBuKTkoRL4AaLaUjG4P4Xe2vxzhtf9A+ZpfyyawjAiH6iFxPqI2iDsoO2/Q8qL2SGphJayZzABIhYCAchgfZYTwJ+9q1Xo/wpKVCFKeUbJY+YSPEgIxQjupMQ4VDYajeOFoFQuFCV6BJU0L5mHLIScmb/FGVFIa8MtzlLrBZ7jZLjOc5RvshleZYRAbgRFgex0IGe71bRyQVkbz7nwN+oTUMoOvoiF1+niEPg1b5AtbOm221ZVQtlPSJbnriXNp9UI1XJJh1O5i19cWJvhTG09r/Lt4EXs5yxFxVCN46gOiNof/aUfSnOorqc0B7a4eCxMPfhSkUSEVvb2JCmKMo/cyBQK1xoDUMkDXCt/FFSa5dDYPx8fXIomS3aQI1Fp5XYoUKZBnQyAJulhiR0s3UscZ8N5Yd0XPjziAWRa1ZdR/nXL3F3jFRXZ+4DdSJFF4NL9fwEvjkHRnK2M3dVrG3dGwOi0w4wtLf4iBKcNQFs3DSqUSyMKBIGVTTelCCeTa3fdmp8U0nxJRrJd6F8/stmqouWEqMwUxTAapBJrxTgWB+97W7q4Uj2cB14QI51vv4FfG5kLAOmHudPSDXB/HaXIUuIzqUGpBU6GTSkduu5CzRUiVX X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42c9a8d2-08f7-4bf9-1861-08dbbf55051a X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:26:48.6075 (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: z3s/wriCgoPEyLL19ujICgaK/5N8H/Rf0mLP0/JUnuApXkGkdobitHB89oIMUepilWUnrQUzepPivxzWWG6uHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_052649_923788_FB58B3F2 X-CRM114-Status: GOOD ( 10.18 ) 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 Wed Sep 27 17:53:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400759 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 61A7BE810DB for ; Wed, 27 Sep 2023 12:43:29 +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=PXOJmX86iBG2CN/qwdiBaJtssl+M7K54kwCmzeM2KkA=; b=LyStSdGFHk/ru3 yuTTfyjIxdeoFBZmWuuKV6muA9HT7HCksql/M+4Qb/0PklLw51aOwpjlEF3Pa/EFau+P/iIvCdQjO Um6TBvUAFZeksbrzWHmyLoeNALp0207DcgTyuPQgN8jnAM28VGO9Tn75BUuPNieECG8HdBE1H3Yct X4QlSrhYQCh/zpQlgq+/sfEBS6F05ZIbPJ/aIBJL1iTi+BY0+Mzfs9mtBDurxfFjdIoNwORf8qXZa L15je7lTpXd0UEfiexm8ub7dF6psgEDDqEO11jdxG48zBaaR68v307MC5pO//j+d1M+qnjCtUMZ6H QsjITSmlLFk/ONDNdNQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTsd-000vnJ-2D; Wed, 27 Sep 2023 12:43:03 +0000 Received: from mail-he1eur04on0614.outbound.protection.outlook.com ([2a01:111:f400:fe0d::614] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTsb-000vls-0N for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:43:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DOiNbMFXgdAHOoKAMvep1tIYmP7OGFv266mDC6pME/GcJ/KiN0HERv2E9GJYeQaG2GXzSJEpI3N8xPI95lfdPSTNH7x/FMBinCLPVwdpfuEPlnX+ULguqCwW7fFptKMtB1AK5UP0/XtLihomrLLisFRFZ3SDe2+w4kCRqdPwv3TuwXll1yG7Z+J8JZWl9pJj8eliF4daAOUsCbH0lBs/JXY5P25iLO0NatC80CiNze9tj/T9r0hi0qY7GySfas4lf7Af60sScENaqBF9m8Mh6O2rbKy1/3hlrZDLcKT4ioY3iKGlYw40heHLdUl3ynAjxx9e18IQgNJxCJN6ORR6TA== 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=fXuDmsJ4NYqcfo6ZtOu3Lk7rp0SukW1T5R5zV/3/gPg=; b=Vn7Z2PCKGfpXRW+Mt+8Vn9otS1DeqZ6stfOl/kZfiC0T4nol/dEhkOdFAthcqohW+LTFRYNfWxdbwPC3LMRUA6j+2pAd563uGXsFIAmvtJ67Ci80yCw9NxJZuDH0/JQGCSBToYrcAn4g770dvbIO8vjOUG1vqeDTSM3eId4vydNWNQC8q1qZFKfTVw+3Vtqe5uJB5JNBCCWHbJ+Ve9pygp7rEc51L8vfx+AafkvKjkNVnoifFNNQovr1WMsg8Lj7bt1uOyDMaSOjZSe2IT6iVxosWB261B4JtubpP54h5m7MU9fafmXpDLUKJsQi1IU2W2mkRj9R/tMvO1mHC89cBA== 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=fXuDmsJ4NYqcfo6ZtOu3Lk7rp0SukW1T5R5zV/3/gPg=; b=WLZFE92vY+sbhAxLFPAmMiNoEZzoICyKsHd6C2tN5l0m+qqzSzOjC1NFavBTshc3Bc0tkW/koeiteNnd3BdjkHfYGz0b+nYbE8KzzX0MyKCfslGaAmIPbDPDhjMzp2oHfRcptPmCTk8U2Utt1s0lJF/2EHZvV0jOUYqOW1zL34U= 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 AS8PR04MB8181.eurprd04.prod.outlook.com (2603:10a6:20b:3f5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 12:26:54 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:26:54 +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 v6 05/11] arm64: dts: imx93-11x11-evk: added nxp secure enclave fw Date: Wed, 27 Sep 2023 23:23:55 +0530 Message-Id: <20230927175401.1962733-6-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8181:EE_ X-MS-Office365-Filtering-Correlation-Id: 85bd2cb1-0e06-439e-3c0f-08dbbf550893 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cYZz2B8+yIU3Ar+B4YHS08tfJzpc39Zl4cxcXWyBdCbDwh250zdLagSfofJtJB/PRgvfqx6QLj8xs2/pJTuQZmoo7MyVa5L3F3n0pqwj2D4lKigDEW5JGwULa6+NZq0e/Ee8JZwvc4SgfA5LN801PH/8QRR5zcNAcBzb6lf0PTspyerWmb8k6E2fnNMMLcae86WnFyruSf8kaVj6rUpnmTLygkaNxzX2M3AC4lZI958/6uHiMzSqV5Qx/kjDDE8PoCQu9QTRKps4A6h6YXt+Gl0N80filtg1Kf2kljWpyx3AUj9aBkqZXn7UlvIXU8l/aKLR23+1IpBripFeNtX9zei6mK2j1U9EqpqGEG85G0mA8cLwg03EnoZ0kZooRFz19z6Dqk2DvyF2GEho8z16HayxtCX8KVSugjCweKQ3KVX6ZOWnNI5ccrq/bGf48UsPAWAhw+K87xCmsSpf3AgVuAc9g5C9DKfJTtsIrIGD+3pEprXA65fgng5CfCR5BbGl+WsEJVu9wv8sWIUn/ZbxKes9E0JxnSB2JMhi97HLq+SreLyJnjVji5zeIk9qP8r4LOLodxXXA/ggm1apv1vqKnSy+Nra8y3dtB0loI+YR1e0vJeOlYSzV5gWCekKrBZYiwRvcXV74SsctiGweSFO8A== 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)(396003)(366004)(346002)(136003)(376002)(230922051799003)(451199024)(186009)(1800799009)(4744005)(7416002)(5660300002)(316002)(921005)(83380400001)(44832011)(41300700001)(6636002)(8676002)(8936002)(36756003)(2616005)(66946007)(4326008)(86362001)(1076003)(6486002)(6512007)(52116002)(6506007)(66476007)(66556008)(26005)(2906002)(38350700002)(38100700002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0GoqfCv4qFwaPJ12DAxV4hBVMLJDEg1Gey5fTAdVi4PjlNnBjhR1u2fuCAt2CBCiS1NbzM1lSh7glGt1rWnMiAu7hJQ7UAwj0XaF/dktB8jEKbmbLZtKAy15bXqavu2kb5B9oofTvyJiMC7su0QFhC4qSwi2U43VZf9dQnAwqwpuNJ48Aswbzm8pXdYHj5CfeBcr80yjkDOB5bB7CTIElJysYe74HI1cy1Yq8HaR2pSv2anexuSjiO8pCSO2zpqE7ltDrqQCI+933onIUm236yLlUhB38UFdpnNp75x4/4Y9+EqW9C4j6nPvq5dboaobf5jgd2gQ8Zb7mluaEapQW5zgthz9XJxr2RqKoPjyDRqBo1Dw/QGgri3OY3kHF2AEffH2g8DEYCf0g7yNPHqkGCMGWlucPOxTjrR+tzqeTBAEw0yY5P/qlFRdoyV/W3ocgjTXrgzYmEHXQVObzz0mjHf7HRpJlZAHv3EMHZCUuxDHSqhMhzb3mTxmONWPSOeRxRYP2GDEU/fR82HNzRBVdbe/qzvKD9fEzrCa5pn5qH1H6lYsFKn8nsjhupcEd7PfXpG/uIoLh51L8yoL8zHCYapsE02aTHDTF+XppmYrpjgelPQDQOHqLJl/c6E4BvWvzgJqc/nzGJgycKF8+l/6jYJXpgsOC7wArYUHmfxehxPHp97s1jSVO0WtQgpXpfhjc4EN+TcdHDP845lOokoyfkQI2q262ZxHnD/pH7wXfZoOKDoZEF+TITzjspIAeOL8sjqUZMGJGl2TiHzhbP7kilMDeMu0zzTxX0PTbhrbH/dOSh7VefMKhFYjk/uM6RuSs9Hjqk04s5L0l0OBXUT3uqdIBONno/qhTW5VTeOHD9QsXVWHgcY6biq0kNlFwDggdjSWjp9wCsA0ZuO+l834H+NeqRYyqHXmZqCv0nWj72hR8yrk3MTWIDKGCzbwGM86ApyY1YqNcf6RDY6C1CtYf6Ek87i+L6szXdCqIa55nGIxB1OlaLqBpy5Tr3N7hUA2/tDzuuRwmouL/lRnhNkCRRVXv5AOS/Bd/QFKCtdwuQJZcp/X9B99Ikkl+VRT8jHA54dm1+UOAJZZppvhaL1clhSD+9FtdUetUVLEW3jdubiAMfHuSYyzRNhhWNkzq9KLcF5ZNdevlHen/Foz9fGfYss3GVQqLVoMdqAulU0n3EKODWIC8gNFrLmf6a4a4bAJV6P7jniQ2M/ed7ZuH/r5I3mLMAv6PR/0WMHq3OFdNPhdhWvd8dzIunVHxC9R6MeFM4+F03+PaIggBy0+gZbOWI088JkJvquaFlvOmawPsb+JuyaWAk/6ke/Hgc5eeYBVEKp2QAXwnYSTiDh0Pbh/t2lLLrNgy+b82EOi21LIjfEb6l3KTlAug6YdzPsJlUJglNZrUQ3anv0n3qr2UoRl1+CmJciM2+f7tuMUWUgaPfNy493Iw2fb4wPOQnNhJOMgulxIFYDCgbL9neVDnk9JJrCWj1LvgYnhWRFGVW7b2xTgUjdVjTNYdwwkMQ7fFLN8EFJry1lK2jHOSWnWOpJZ6xuzsv6Q1bJMc02EbZYks/Pn0X8HM3llb7mS9uIMt95j X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85bd2cb1-0e06-439e-3c0f-08dbbf550893 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:26:54.3236 (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: BESfDwR45f0VucOB5fPqDvU3J/Dv+yEWyucdO0ZCvQxfS/FyfOZ5Icny/fya1LJ670Oy1fc41tpymn9s6GS5xA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_054301_157366_8220579B X-CRM114-Status: GOOD ( 10.41 ) 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/freescale/imx93.dtsi b/arch/arm64/boot/dts/freescale/imx93.dtsi index 6f85a05ee7e1..04c9af059461 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 @@ -923,4 +923,12 @@ ddr-pmu@4e300dc0 { interrupts = ; }; }; + + ele_fw2: se-fw2 { + compatible = "fsl,imx93-se-fw"; + mbox-names = "tx", "rx"; + mboxes = <&s4muap 0 0>, + <&s4muap 1 0>; + fsl,mu-id = <2>; + }; }; From patchwork Wed Sep 27 17:53:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400753 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 E5626E810DB for ; Wed, 27 Sep 2023 12:41:45 +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=T97DYFw+LW4QtG 5/t8BZmIsONotaIEGse2qhDeZscl3GXcX0mduGtWJ1bb6HUAEAApFi4w34rIFkD2phWWtD3N1SavG ow2jrijvGSNakH/x9/Eh14r9WVMg6x1MO9FDp1ptWaI0HBEI92Yqyrwn6A92X1yIvG6wx+dElU3Xc SG/M+fOCsE3lJVNt9o/LEnZlvW5f+SWSROs+VzTlk9Vh0duDv646vzmhhmwrBo6QvYaCXagdfsw+1 mPn1y5FmqEBk5fPfrhJv6QDBkjhi2x3JxMZre716uY/D3dygVofG0gnh0XxMmGFF87t/m4n2xS2rP IEkqpH+YwA1ayi3mjEyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTqz-000vAV-0N; Wed, 27 Sep 2023 12:41:21 +0000 Received: from mail-he1eur04on0626.outbound.protection.outlook.com ([2a01:111:f400:fe0d::626] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTqx-000v8I-0V for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:41:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ev5NVq03NFDhRoMb1B/Kgvn4RXlDPmA0DJ9YyoD0dgBRw6csUiorFFYsbaX/8KOoHQYKQ9TcxiUo2GlNqU3Myg7fFKsZK7kvx5e4Kr1fuRag9C1aNL9VuCKz7nwWpxbEiEok9TC9DC9IFWdq0cWyKGFjZuwt+bXr+OrS6oR9nGLbgsukOI01Xprh7HmknDbZo9XEh416hi/D3B3Y7frEeJxcYlQLG814XH8WHCpTrsOT3QR0MDxDhYVJ7S5tkp0ltOu0A8siiVHZRY98adAJkucVIMbUneKM3nZ1GbRdWtqMUHVvHdoL0oXLpfXJnbgM0JnI/uRBZcKbygrF8ZFnbQ== 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=imxQ0nH9ryKEmWO6/uZZQ/dA7bGdEacblU1APmQMrIycFe5vPVZtt96rkNeZrbjUInFAu18MsxjI+mo/SMjvp8a6cF2NH7YXt7KHHhI1ctfIwG0pBaCMoKIdScXLxsrW+pUIV3hNGbc8gh/Gl4j1xn7qQ6V90uXNQabA95n+4dha6fVeLNjOPye2Fjk3zO106nbhELfrzF6aE/zPRCrGaUeMhKU0k2a4HAxyCB/+UuwjcpK+ZWa0OoX/N3TRbZv4EKXCXxBH2/lgoqe6bGnpbPb4kBPzLBb3Hqg1MG58ylb6nDPNN5XEFX7QrLJ0am1CCF2z03QtVG4zfkd1oiWdlw== 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=VoepL0SI2hjYtjz5E0y4u9U7gFcYCmJ9+GvS8VHvNq981ok0FtSe3pqk97YG3f6qwOyzrYs8HSYOImrwcClMmZK4sZFqkPIE5QZJiXwg0LYCHmfN4qDWSNdazJ+yUSZEqKx0k+el4SJwrjTkM2v4e7tdI8/Ak6+s/m5UaT/giFk= 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 AS8PR04MB8181.eurprd04.prod.outlook.com (2603:10a6:20b:3f5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 12:27:00 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:27:00 +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 v6 06/11] arm64: dts: imx93-11x11-evk: reserved mem-ranges Date: Wed, 27 Sep 2023 23:23:56 +0530 Message-Id: <20230927175401.1962733-7-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8181:EE_ X-MS-Office365-Filtering-Correlation-Id: d1f9ea1b-2a15-4d66-ee6b-08dbbf550bd7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yis4HJnmv7UMirAYJzBNlkH7QUteBZX3rEeVXvsDF6/ytMv6+DjJMTUf1fJTHyWVZmlTekKw/RMgd6aK18nwnu96+fGREe4+/ZrDw6Y4LG5crdTA80zwP0iUa3p0fQ9Rzp5r2CBUiSV+rRZHkzkm6JkTlOZFef7aG/kHESsprYav7Dj1Eb16qkJN3uy4797vdqSrplcu8SNBMUlQYAnCL9QA5MBnNkoG49YBzG9rHScDlO8J3u8uzrB1k3okNdDeWM13wj4IFNIGnQl6kzMXumZvSETcjI8+K/YgptZzBNaaf6jtVUTtmMbIPruIZPBklWTGn8Xl+EeWVo9Ji3uryl4Xy0zY1JAA5H9AyBjpgp+NrTevwL0MmltasN5Z3vC/xuu+hiImmxZPSZgyDBffYYL3TjC0H4kOitIh2pxUDWsg4SxDHiTp9gX7s9nRbQuOSSdjnOdKWveDem76k6iNMp5WFJnxRFRDfkjv5tLFF3weuIps34DK9dqkVkoQ+VePd4GVEKNb0fJr2UWqFNgY8cjmMDoI57tZwof10Z6YfS1q1KheAI66lMoS0rxa383CCOvOrotZPfd2dewBx31y+KaCCr5A04d2/xZAL3FCAHpJZpgMbv1D/5t49fG75KxC2XYptXxHVgLbabAHCWkv0g== 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)(396003)(366004)(346002)(136003)(376002)(230922051799003)(451199024)(186009)(1800799009)(7416002)(5660300002)(316002)(54906003)(921005)(83380400001)(44832011)(41300700001)(6636002)(8676002)(8936002)(36756003)(2616005)(66946007)(4326008)(86362001)(1076003)(6666004)(6486002)(6512007)(52116002)(6506007)(66476007)(66556008)(26005)(2906002)(38350700002)(38100700002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zXD2BJU07DU+XmIp/i38v5JBNq/OzWFQuNnp5/xFppFpl8eziSACnRaVMqLPwqcAuPJqxNNUNxkn3oRIe/yJ8wHsG5HxlAFRM8PQdrGf8fKyjpDinI+BZPX2CWHgH997ttbJrMvVsBkL1c6VFVaO75oJFZzald/OcZk9I3If8MUrB+r9ssHuk+55nfyy0wIdm7L8YQolA59lPWU46W/9D3fE4rEQGDyqCzea3NWSl015o/FJbZRmZ6a+L5/GUDoT2arrekmVJQSMiqB5eUwT/lxh7K9FL8CKZT+pCI4fLY2ItcN1/2/pBNNgCegjMeci/B/UHTyDX+qcxd4mv3QTEei/iyVhDcdOb5G0LUcfLc+8eA17GVxQujO75Y1aBiHn1BGmFBdkHoT/7O9thYyJ4P988NjAXFwngdhu23C9tf2ltm2xobpNOR4AsfyRh3qg7LwHCsR1AM0tRsjZX23JkzTMHYPMfFSNIWX6ZJnRRamOAEOLvoxsJK74lwgit6a/uJ7Ua/+7x3iNKQSLTZJkm8z8mTgTeMHeAIg+qjEVqAIrkyar3J/C1gkXqdyiQLsLNjj9z+pstgr7SvggIoNNQQwCaEnr4gw6yD7uo/zLtcB5wxI/IduhGt3HtqM7M4vtTc4yLeqbWwRbzR41o8DJKugMaIh/MiMtmEc2SwLmIirEmwo77S/hu+2IdkzhMEqcb6xHalO3s2NzsBZqiI3dC3rLf1OQAlLSBcvddFOTxslVGXxLjqjsx+5U0RyOs5u92DIUIw5Xoz3t8KVBFpSVd5BKPBD1hTsOL0YTG9iIvk302xOjLPjjh+u0SW9oGEZBOxeWuOIf0Ctlq5d6jGkOQLiWM4wx34j2ZQcRsvDgHrP7WvV5pFoaMg2tTQUeWjTRqbQvVholfJQm0uXH7vYGFVkAJ4H8zvlDhQjnJa97NYjlWc8oIJmn1UMxKGHFSRsYSZ1HWHZl5NB3xLq9O2jI7wWaioUM53rGj/tp1V0GeJIWnhxV5rHA1AfwMKE8LnhL8w05nsbiVICC5rIcUmJcUxT/Hgbsv61P9MVfbVbRwiZfC8Kl9TID4fjfoTdFkzJyPc568NS+3nVJtECm2UiuRdLYl41+JhQOxH19uJrBXHr0Omv/x8SiS10QUxg062Dnl0BUbI2b4oCqM2pvVxLW5mGgcFAzF9hzN7cFOiHacHgW6Ihan2BBTRFjN1fWjPGt7Wm+m8RnvphSvMlgzjmj3QMMyXyscyI5wsGhwOJ97KkWadu1KTSzuANgKaBpf+cUE3HqNbqfKtU8s4aHK95MGZKh1abGffWponRDfUGN5XEinn1bYk0JbgDKwYapzrwSYkG3Urrnn6Ac3yvaUlm2n8qPT8dzUkM5eIEk1AubaBuDO1/uScwp8+FJA5+rU17FJxQmIeHcaGnHoAZnlPYpKq9s83fxUdM9dta1vjX5mC+6+Tqt/PHeSisF9j1x2Qvs6HgdkvGS7D39zCdXzN573iGiS71jmq3KgIY4ZLCqUaB5aPNiVdFDmi9ANmE3zkdXf9e1aBZRSiKqntfNUlhWnxE5tk/+nDi+vfCj+89CBD+/QAOxu1sUW414+ZJHPyNu X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1f9ea1b-2a15-4d66-ee6b-08dbbf550bd7 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:26:59.9747 (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: keYilByZmuEbtODY/9+wWVIF3eGehk1CA4B+v4JIZTv1d9Q7I1V+oCMIxBWiwR2Ds55nbuSZ96OIBCAoLGFmUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_054119_193599_5D1E441F X-CRM114-Status: UNSURE ( 9.98 ) 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 Wed Sep 27 17:53:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400755 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 67DA4E810DC for ; Wed, 27 Sep 2023 12:42:36 +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=ygVRFTDrWjaKPaLK4J/BU3cj0zKNz55NeeBzC+6bStY=; b=FaDC+Zj8YZDAnk YY+2t0d5YM/06nDbWQgvXE3MQtVR+owwklIxg0oOZZsgMM5OWAdPsYmDS8nzNqz3bY+xXaiHBOe7c qjP9bPujswckS9secBvnb6BDi+cW7lrScnq+JyyzLdQyK2jL84ZjHEPvSjITduB9b8SNE1WURvHuJ Fn1arSMP5NKL4A1SU8/PB2dUTw8FziJ59f3SBHq5fHEfZbflBA3ttn/JCCKW6pKMISuyX7rOerZPI aAxdx2ysnzdUlNCyyFFo+H+EPTylGsEiHJ3r3cFEZaDrUfOr69qc91LPVfB05QErfe37rm83BOkOS UndzSn5N31n0vJojSp7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTrd-000vOF-1H; Wed, 27 Sep 2023 12:42:01 +0000 Received: from mail-he1eur04on0602.outbound.protection.outlook.com ([2a01:111:f400:fe0d::602] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTrW-000vKo-2p for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:42:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IoFXArNdEqQRaxSUMOPuQ36xbUx+CyVRlQPnfhjB26iiGQM8zAamITU7LN5fCOO/wcFCDfIQEb7Y2dIl7GmYnPxrc0mrzFC/7za06e+Ohj7FkBQfT0T+qhsdfhLWCtjPRJkXMqi+gJX6ONo8T5O4gHiQRmu6kv4lwbMGPM/SE4GoAQSCJ4qhMBFiUQ+FbR5l6+34DALDg4W5Aol3DeaS/ANxE30zTvk7H8WAoZU4SAXjgNWT3pQSzZWyCgVcPEr50vC1YS7B8c3Zk9FuQkex8KluyKHoXEHlUaShy7OKvaCOG7ItxyNSS8cFsHrQmmm/efpQmmmBzCmw3sto6OjHSg== 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=fzREwVvYaak8+gjWo2ETEM0vTm+xQwAvK8277hoN5sg=; b=PEgylbimHtwYpaiS7ZZp2u9b/n2pBBjKteT+ItoIhGMd+dM8RRMwdREw2tVlUjlUpJpjWiu3dDc6fYVK95CxW/nF50LKmqLNcVIflsx1wVCJmLdK2bmwyLISnWcXnd4rwT5qIOL4W0i+v2RPZdoG1otxoeVZHhG3ATP3HXwAWWRwrDW8OZI1pkLPci+czSwhbr15Y0IJlbguSvDERrRGFtgtYvB+2NKy//SI0sUo+Tfn7vBL5lB1ewunr55sNIzN7CQoV4AmY34gLu0TTnaRSqIM9o+B0f0eX6Yj/3527fIvPVRukY3hrfINNumWuS6JbE0Ijh2J49lFSfqXjvQlJQ== 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=fzREwVvYaak8+gjWo2ETEM0vTm+xQwAvK8277hoN5sg=; b=ref+Lca12VZzupyXk9im5NB7NSnd67SAR7c7hCmtkHnZ2V/0HYh7ptMKRhczLrUbypVOyPs/ZQ1ADuoje9Uj/qJZQSpuyptlMs+/8ot6ryw+++M6XQbv+p0FeY+mq1Gf1ivaGeHabMXGmu7kbt3yP8/duQA0IwJHeu3Z3zt0khI= 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 AS8PR04MB8181.eurprd04.prod.outlook.com (2603:10a6:20b:3f5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 12:27:05 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:27:05 +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 v6 07/11] firmware: imx: add driver for NXP EdgeLock Enclave Date: Wed, 27 Sep 2023 23:23:57 +0530 Message-Id: <20230927175401.1962733-8-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8181:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f90550d-9cd0-40ec-5355-08dbbf550f0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uJtyoKBZPGxBYNv+ut/tpDPEPyWC3+2UT7P5f4/wQ476mkrT3OtOrh0eczq6vmNNfdaJ5Rx783aIoISsBHX3hRH6KUj26uJqa+NUSiHZ5w+0FfL13Oh1GvYXUCJcVoUmn/Gr3+ajhBY6x+sntip4+HCJQSju6KSB2eruokG0O1Ux5SvXGu5izxY2ai7gwnFwqt/flQBkgVGDjGhTJ0/uhFQVg6fhUnfMNrgcKGMYcIqLYd1q0TDmoLTAjacvZOtgOULJQC+LX1Ie8ssYNfK1CtETN19x0x7adnYYVUlyYsTe44uzWJNiURQg35ny3r2H6VOhN5ySentLDp1VH8Z5Ro//8gRMt9jIMQi7tWGwJAon9k9NIzHm5x8tnO4biSx3Y9IX9+6kON/ARwTO6faa1F03032aeDf/1IW1RhE33b1O/Fu7csBjw0rG3PoYZ5NkaFeqxJBB43RkZlfwdKHMtJiESvWuHuKETM5ZzyH5+gD6zCebtR3oTJw0IzeGhh43dsPDeZ5vx62CuLq5Qhe06JKwKHNFvZHtVCT0L16+r4wjxm1HWzkOqSV7GMa7VVWU3wqXj3mWUAOA2ak45/enFUucDOfOdsrLW5b3/pj5cffBruM0K4dyWJLTpco7GT6x 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)(396003)(366004)(346002)(136003)(376002)(230922051799003)(451199024)(186009)(1800799009)(66899024)(7416002)(5660300002)(316002)(921005)(83380400001)(44832011)(41300700001)(6636002)(30864003)(8676002)(8936002)(36756003)(2616005)(66946007)(4326008)(86362001)(1076003)(966005)(6666004)(6486002)(6512007)(52116002)(6506007)(66476007)(66556008)(26005)(2906002)(38350700002)(38100700002)(478600001)(579004)(559001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3/G/rRXbWKen62Uksp2FboLSgtzM2tSTcbxt2PtqH/pr/lLMIDDCzofAVMO1JSOEphieGionUGjY1DlFOGkng3CPn0321ryAFoSzXc56X6eXKkcMMtILdYhKn8bXM6i2IuRB3zSJZtro/S5DwTRUXeleyfMgB9SLaIaCWSUG74RRY6Rm8EoST5h3j9qe1+ecwlx9d68CWaYdz4Q5f4GbOc59foLidGJQi6cb2zg6xeDC0rbWkXfSUa+LQq05hgXWSaxjqX2P89dbNr36Gw4XHKexBtAgM6HUQNT4p0M64DicA4XJE/fEuO68kmX1OOWc4vD/PjXCMyJSyxQqMldP4MMhZlf6SF/N01F89nlNzu3fyQo2uaIn8v7nTVDbY54S3dk40N6qVNaBcwgRlcZhLr31Im8qgzDzIxwtRD4+SFIEzmKKa/pl2lVwauutUkXa0nvSZwkxRFQUzq5yMLMo6iQ3EIC8KXAomOgKqeqR+whzhDXnB0S7Kv8fcH1VacR+3Fd5JE3F8kR0C0MFyrWGp5TUctXhZ7FOe3DM+bWpEUHi5XN9wrezQ0ofbf9EXnWT80NFZZGIec3Lo+BvE5FVtAyQvJXmFqVr0MWEggU+d6mHU0zvLSSyFlh/Lmblg19Kqj8UK+PEPmVsoExvOtcfw65FVkA86/SINRahw5mvLx1fmM4DItFMyqvPx0Uj0bM92B9RDZTF9PIL7hAATN3Hq72EPeJaueeLfrIPHWLYvCUPMwxaPPgcSGa/vxp7xh+nL3zneYa4ZA+WhyX/WSrtFEjtbaVcJODpkbYF25nZKf60jQGuZGBmDCrTdy9yHqp5L1FP9HMc3FS8M48kFWoTIzRN3457noSz4r/V6SYI09yFufsOZAgPaD303lvq1Kb7q02PRsHSbJYXXidWtnRj1Frmo1z9B4jaTPM0EEGsOpX66Tbx4aYvYICKpUmchOK8YulIR4CvoX51xbf+oxuqFAewfl8wzj9MceKQ0+8Ks7rO7Hjx8FLSbEgqSNdGcVGGRlWjQ+WjL3sJ2i5AmG0NryfscD7h8cYimSjz1jNdwhVsddI3CjaBX5QwjfqQtWMf3l8BI+zY68rj6gkKmFkyL2WyLyVbuNJIRLBtTdFFNOW/swZp5CLOTa0nag4QK96fO3VbGL80FIfI1pIHEOKTLzRQtaGq1Lj3OA/Y4ybOqDNfhRidf0dnOvcVgCpMLbmuwrxRvnFkmCbraqqTvjBVlyZ7wzX1jaNXbzbdEmhI0MY+gEzzcqoBwZfB7gw26q087sl3Njyz6iW28hm+Op1CveFxMmeLUN62ZsJVHJaAiGTYkSsWxs3ehD3hfrCTTtwU2OFEBl9aNckVZn5BNzrdfhVVDT3sC8ofciW7Gn1EFM723QVuzNEuojNwxUUya7Of3OiiHZl2v6NQRh3jVmu2Vp5tjnzA9sl2WBxifhhKlKU8ZHAUmiBnpPnmUH/hn/lWt5TECXOrBFj8zrlw7Y98POw1CZxNZsZCIRsVKsSMMZrdWcI76vjBFoUXldK5BozpwNLmCTtq2xTidTfFZ6bazTGOJboUZ4zwtCFehjCL7Uv7rgE4tvq5AwPwWGYcKpng X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f90550d-9cd0-40ec-5355-08dbbf550f0e X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:27:05.1947 (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: ryxaAgV2+QrlxBbTcCD9Uhv9YHrnZUVKSM45R2mbCWg3H2hawR/mVVWHwUmAEmve986iVI1HPzuZGs/gyYCZiw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_054155_257742_373E4AAE X-CRM114-Status: GOOD ( 25.32 ) 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. 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 | 1300 +++++++++++++++++++++ drivers/firmware/imx/se_fw.h | 144 +++ include/linux/firmware/imx/ele_base_msg.h | 40 + include/linux/firmware/imx/ele_mu_ioctl.h | 73 ++ 10 files changed, 1882 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..e47ad4b6ba54 --- /dev/null +++ b/drivers/firmware/imx/se_fw.c @@ -0,0 +1,1300 @@ +// 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 { + uint8_t mu_id; + 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 = { + { + .mu_id = 2, + .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 = "fsl,sram", + .reserved_dma_ranges = true, + }, + }, +}; + +static const struct imx_info_list imx93_info = { + .num_mu = 1, + .info = { + { + .mu_id = 2, + .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, + uint32_t mu_id) +{ + int i = 0; + + for (i = 0; i < info_list->num_mu; i++) + if (info_list->info[i].mu_id == mu_id) + 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; + +} + +static 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); +} + +static 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. */ + if (wait_event_interruptible(dev_ctx->wq, dev_ctx->pending_hdr != 0)) { + dev_err(ele_mu_priv->dev, + "%s: Err[0x%x]:Interrupted by signal.\n", + dev_ctx->miscdev.name, err); + err = -EINTR; + 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 = priv->ele_mu_id; + 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 = 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(&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_err(dev, "Fail allocate mem for private data\n"); + return ret; + } + memset(priv, 0x0, sizeof(*priv)); + priv->dev = dev; + dev_set_drvdata(dev, priv); + + /* + * Get the address of MU. + */ + np = pdev->dev.of_node; + if (!np) { + dev_err(dev, "Cannot find MU User 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; + + ret = of_property_read_u32(np, "fsl,mu-id", &priv->ele_mu_id); + if (ret) { + ret = -EINVAL; + dev_err(dev, "Not able to read mu-id.\n"); + goto exit; + } + + info = get_imx_info((struct imx_info_list *)of_id->data, + priv->ele_mu_id); + + priv->ele_mu_did = info->mu_did; + 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_err(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_err(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_err(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_err(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_mu%d_ch%d", + info->se_name, + priv->ele_mu_id, i); + if (!devname) { + ret = -ENOMEM; + dev_err(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); + + list_add_tail(&priv->priv_data, &priv_data_list); + 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's mu#%d interface to firmware, configured.\n", + info->se_name, + priv->ele_mu_id); + 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..25906f40daef --- /dev/null +++ b/drivers/firmware/imx/se_fw.h @@ -0,0 +1,144 @@ +/* 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; + u32 ele_mu_id; + u8 cmd_tag; + u8 rsp_tag; + u8 success_tag; + u8 base_api_ver; + u8 fw_api_ver; + + 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; +}; + +#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..3eb1f1177393 --- /dev/null +++ b/include/linux/firmware/imx/ele_mu_ioctl.h @@ -0,0 +1,73 @@ +/* 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_FLAGS_IS_IN_OUT (0x08u) + +/* 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 Wed Sep 27 17:53:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400757 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 0AB28E810DD for ; Wed, 27 Sep 2023 12:42:55 +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=kXHFZA2XnQ3UJ6w/biL5VjY7JoIUGXAA4jCjh4wtP7k=; b=dCR5Tw0Po5K0eK FsOMhJuubHDixn9H96XITyr+7sUOKWc8/Miwy+wAkSwQjK/5ZTcZwWUhsS1XrIo1+CPDTGqJc2J35 RJWPHd2Sf5y5uPsTrNf/f/S+0F+us0uf+BZutB0Sbr1UtimaBIyxRnNPjSJoqPAzEeO2vdDFzpaEI oNPvp6y1wYIE2Mn16HLXsIz1PaomXIwxOlpPN1dvqY1Apz+z5Dp7/x1kAp6DXsbgQVLugL2p/2u8H xoYkiI+xflz4auV9RiihVe6xdxDgjIqZiON6JjtK03aUvmx/R1PksfdDIz+rBac6hX6F/21KaJcFU G/pkBP/QxEz9xHK1GnYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTs3-000vZg-2k; Wed, 27 Sep 2023 12:42:27 +0000 Received: from mail-he1eur04on062f.outbound.protection.outlook.com ([2a01:111:f400:fe0d::62f] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTrv-000vWH-31 for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:42:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TJKr1uyyyPRqtYCeCGWIsxCPDMqNBXHK6AfouzPCh2eNFwR+sBt5BJ9N8I3HJbADXkTSNvWhSj/r1jxZATqrpTizAZrCdFcOtRuA8LFMq4PfajlRVmCX5E+sb/2h7aZxUP2OTCjaxX/bcemUxvW7S6pE45KlbsUon+hyxFJdV0rcOx57OGXIL5oJOSLa4TjEe1sgjjOkPonEVavDu50Ri+orRAgR2nkqoMUqalAWzrtRJPRXXz4kMFuAHoVloyHtG+IbeWl1mDjBq8kOrxqTY9UWuhlIJ2rGpMGOqRc6dUr+o7eaION5Ap6ecY1BMZ0BuB4tU6Pz6ktppU5n/qbp1g== 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=SEGD3lZF5GRjR1fzm9UFSGZLaxgzTzd4wV4SYSR5qAI=; b=hnsavzvKmh3CR33T3QzPUQ7wzJe/YMx1PU/ydUyTnozfbo+6Lqb4NILDrkt7dPNrxoDG0i7Sidxcl1AMNm5IWZIEAbKeIPoSnFqt04S4kJlsJKh3cOy7RuG3dd0OsdwRjjmmYEhVR0DJI8eFiBn+efiil7e/TYf8dY1OfjP81XGGeuJJpPyacjcupp6FNTbBUyh8K/Osv0izXqkgqZAFqhjKbC9lIdTLbAk+wvTEjAena1Wpfc3/8KUgwi53J0xuUR4hm3KnlQQzY8ChYcMRiVPqUIQkgbPywaAYQYcup6DVfU+oTrQDeY2ETEbT9Hx5JGplSFOFPsIdd1dEwTjD0A== 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=SEGD3lZF5GRjR1fzm9UFSGZLaxgzTzd4wV4SYSR5qAI=; b=Gm/1A6NvGvDieNb+iecK1lS59nZnFztwFA145esgSNcTACzq1sNuUh6e2s5Dx1A6FSBcqANKYi7CQ9N95g9d4/QHXlzS54tpg+dwF23ax62wPMUCvaOIXhhPQ0azLp9YVN0ZACH5SWWH0R87icVB7v/yeH56VAWVxl4V5xcTuiI= 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 AS8PR04MB8181.eurprd04.prod.outlook.com (2603:10a6:20b:3f5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 12:27:10 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:27:10 +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 v6 08/11] firmware: imx: init-fw api exchange on imx93 Date: Wed, 27 Sep 2023 23:23:58 +0530 Message-Id: <20230927175401.1962733-9-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8181:EE_ X-MS-Office365-Filtering-Correlation-Id: cc9a3fa7-d716-4534-4401-08dbbf55122f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xP0cMzLP9hYA9unte3bBgIVt6CFEBblsClsHBJ0FHMgx9yMo3WfMNbvxXTjHGFAsylekAvCGl4WpvPPraxR55Ijn7228lw8cTeyKxDa4LQKl9biXGCk3oVLGbabQzmGGV+Lzzd/SaSwzQV/bUASLxULGI9Om2NdPpmt6vK4iLRyRc5VgWcL3ZM6YLzcb3fAnmJocl16bM/x5ZGoSHSPOWbU5rcUTgEJ/4ufR8/ZA82JnDSEaBMk0ZHRtuuDY/Y99LH3vEc/CNEu0EwrMSt1hG8Opxi6uSeRxcnzRbtvqyjfe7CHYAM7fSA0JJfbR+dp2b1faruwzQdFEQdpZMDFR1HNhdIY38Z5DHLg5KRexg7bZd1APDALN1I341Ig7sWjFpCqNodQAyfvJQGwAYXaCtce1nG6EKvX7nCc0chT7R0p6NEfZK5TnCnJVHCBUJ3OCUWeJnIJ1crmkEtx9DBBmUzfaZSgp8/6GC+jvvQJPNPaZkJch4K9qMDDRO2WTulIdGrq2e3WXrejtT6AhIUpAY3ziIpsg4T8appPAld9p14qKTm5TP/OFsYqXeZi0ckpnS0c/U9dQ5YegeVNSzdI2jAIMKWK4nogH5gCjUvWI1SG5nwbPsIwSxfFOyJaBb5vfTVsndp7l0p76W2p0MlFYVw== 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)(396003)(366004)(346002)(136003)(376002)(230922051799003)(451199024)(186009)(1800799009)(7416002)(5660300002)(316002)(921005)(83380400001)(44832011)(41300700001)(6636002)(8676002)(8936002)(36756003)(2616005)(66946007)(4326008)(86362001)(1076003)(6666004)(6486002)(6512007)(52116002)(6506007)(66476007)(66556008)(26005)(2906002)(38350700002)(38100700002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MO3eQzogVYcndQ5ZWdIP9HIRzY/ZlEYPpLXEnewe+9A68CCUShkajP9yQ/HCITJa+JzHlmjc/9X5dzIBwXrltAjyyXFmUkDu3zZSYD/TqS+l/iBYvTTiBlWVSj0+MZo0/mQ/nYrtxQsQ/QgYgpYRlfI7KaoL63rTbg+PlOTZ78QDBHkM0K20qEeGfb48rpZPzgSGtADqYsfsmARLqCz2ml3+8aAmqCcbw+cNw/si3lICC0QP+NNssgkZ0fn8AlokSX9FgxfeYMstdnodPZlxwHU3cOkT461XDlHpMjurXt3s36pHH6S5+eYkcsQo7+M5VH4TNLprs5xs0saKE3w1UQiLjqw4wdndLXFM33uycxnVLYFOwwLERRTWXxU6hmCcmt/Q3OyqbJNMbSg6gz1h/1B1IooERFXm+MRNQ+oF0camDx9sMC0GFVMNDc5uei9mkMFjUFNtS/vhXerriAX/BDszzAT/ALG2CuWF8Z8hfuia8VmaarJvmvpjLx92JhN9A+h4pCpyOCYhyO8MpB1+oCKQFWt4d7h3GBxpThFPUzLNtF4X+ElHBcYdr19VHbgRR3n9G74Xpg3JRNfwTXGMCbh1SdiF0NNBZJbcJlD0FP87dMlGoRJqc3oOL+Ppgn/u6mvgYlx3KD4/KfzpNKP7NreMnOA3ymLSxiQ0/9pNC924ngqDXQWO57dzoe62lJ6NtgT21nzFbEueCxnI7fWZJIqj4rlRSdc6TpZH3WFIf+H4Qku8QtypLUMTYUefsDUxS1j8hsbGfBzh1IAmSdDzzwARCiS7VtD75zkTjF5W5u4pKHxYCKw0GLeghbDviiFFCvllFsn3bg3e0mcdp1pzsK/feF/k/mAQZlLkk1QbI9ZVlsAFhsYvtFFa/sb4+0RqRqmYa6Ih8NhIN0MJLVkCgcRFEARUsc75MwpinC86KNKbtqpNm9yLM2cRX0P/v3AH97FvKgy6OwrpCqOHkA26AfqR0HJKSCJlKhffyi0fYPiExZ6rQifuGQ1d0RL+BNOV0Ll54A+FcJCsNnOvEVPdJE+w/4sM3K+gGXouJzQN4dBsrdfuAYvLtctR5tXEHwcEwjK4oBUhbfbCq2XjQB2S8Z9k7U37uQjkuKRbaQKaS0db/2c6jrzEkXMzkvaw4a6f+QnIQcLmZRahbTJqm7Kq0H1I07rTDPwglD6HGKiVHLhEwSDXmN1KjYF1MRDzI9qNRQrGV8tBoViUk7Lkcd1B8B35VHVlAzbRFS60vnsD/HaeAVJkAYv+OvJx4uN2zDmTV3uqwUGTm3nsHxLXec1G0IikCJLKgYJe8M5gvzZUI5QLsLFVg6m0dPHTdhkoT4Z+tV+GkVzs62e0rVhH6s43wgzrzaL+fqfHQmWZbaGmGI/cff7pxoPDy1lQUOzzWFoEM09z7dvD1XXA4HYvESejxk1ttUh9CgXJZlNycZ8BBmCEJmYDWhySb78TyMkLo3H5PMbKuiCy+xO4aapcomHCrlgLbZXfGKi7ibim4L8wWcnuRIV9IeKeRnJetaJJZZnHLC7h0jdjqR2O1ZvZ0Jm+opq8eunU3Ja6rH4qmcaojKR+JjxIGNEooQMGSASK0zgj X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc9a3fa7-d716-4534-4401-08dbbf55122f X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:27:10.2999 (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: /YmnUd6/LppK9ZiWrFZAaMSWaYzEwAa60Jigh8oVQar1RXbnNfEM76pkU1OzWxg73Rj/Nx/6AygpAWNuqS4ckA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_054219_996900_39329CDD X-CRM114-Status: GOOD ( 22.32 ) 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 e47ad4b6ba54..c225cdc016be 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 = "fsl,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[] = { @@ -1228,6 +1232,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 Wed Sep 27 17:53:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400717 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 9CE29E810DA for ; Wed, 27 Sep 2023 12:27: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=ZeQAx/EKTEvgP6wYBQWwS0cJW6www8RJv1YO8Yy90l0=; b=xjIQlyenFjO2P/ hfEmVFjGNrcI87mlO0JXM6dpwVxHxV0G365WWRfqrGqgfefsDo5JbXu66C7scZkxciCnlYeAIx8qo 037JGiLH/f+4JgnaQbuX6Bzhth8DmxY9rR7jUjrCWHUK2ITIfWYqHQcu5aG7QQrA0qxI2I6CnC1kn YXWcOa+3ypCaXsZXlMqyDujpYM6/hKAjIpZQl/ZXeIZ6YHBrrfcJrzHYWFAcEs6igsA0VWEaI/CZG yGbnL4mWIWStofY45Ygixzw/jHLTjiEhAqYr86/6Nu57nAxghQyOq/1Yx67hQmRjCPDx04LpWzAKQ W/Z7a4z1PbivTcidjn0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTdX-000tQS-2M; Wed, 27 Sep 2023 12:27:27 +0000 Received: from mail-am7eur03on20615.outbound.protection.outlook.com ([2a01:111:f400:7eaf::615] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTdT-000tNx-36 for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:27:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SW9M9tONnwQSCFhh9MCpwVrjV8sm5Nkh/fKDcux6JlpshkOFnCKmvTIbTi0O8P19UB/C+fjLpcprdh3LYGSROwXWK9igaPH18wVVCvCvEY6SXwmS3+OnVyV5Ye+nwkVHZPp6wQPJDVLtaZ5QiDBgTSD+wKOMX2i6DNoe8uOjlyOJxe646K1B461Vf/UTGQ8s0v8Wc1oHP6CNAb0KQa60BRr9WWsJbZ+zMqliScYtc3u15u5+jcbFZs2+fyPvVchzxuF+QXQBYuDkVnSojoEfyzovYh0m5Sa2jGZHTnSNMdPPTMJdluMi9YSaRGw/LA30HPMvXu4Xu0NVQq3q0gEl/w== 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=YK8Ce2sPN4PvhEO31Wk1kFV2ywQ6aCtnoachpsl9dQA=; b=LyeojhQRcFeCBAIOdmF+yGsmaKpxnx/7EF8rORxSGhS31Z3lU1RzEC/zi48BQUKK8QAIJ9XUtDYu8Jov8PGFb71VyUmK/Zm4DcSbN3iFAkidPAbfErscD2zomz0l3be4OIR0+cZUQBsRn7NOi7gMN+HFVbM/JMih7MHFsHBYeKxybHCm3dn59fR7iT8BRzqtQu0Wt4OExZlR1QxcA16VnDUOMiel4MmWfEEGKpXZ0+A8b0Nkb4eoNaQO0uH95DxFM+m2vbzLeQwizhZpQrKv/JbTZ84BUcdDxH9n4ezsq64L1UjWgI/Vcbnd+SUZjBoJi8JKzVBZOM8Jui5jIwEG7Q== 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=YK8Ce2sPN4PvhEO31Wk1kFV2ywQ6aCtnoachpsl9dQA=; b=pW2ea/l7AJsyWs4m6jgC/7L5BcxMvtM4YXkMU7282ydOsj9u9ZFZL3Q0mz1LoCZP2EkqoFKn5f6tktyKw1hRODy7HI4/jcgfYB0p5hCecXCMvJ3izWsYBEafY3wip8v602FKlVAS79K0/ZyWLETgLxq/0I9UNxdMXRK1stkCnNY= 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 AS8PR04MB8181.eurprd04.prod.outlook.com (2603:10a6:20b:3f5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 12:27:15 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:27:15 +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 v6 09/11] firmware: imx: enable trng Date: Wed, 27 Sep 2023 23:23:59 +0530 Message-Id: <20230927175401.1962733-10-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8181:EE_ X-MS-Office365-Filtering-Correlation-Id: 36486cd2-55ec-423f-5e41-08dbbf551538 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Yosj9pHvmeZIknWVTH86Dz/FZe/qp0k5KxoJ5RwpnlJediibCdkIUM8pNLrpIDqcio+Xs1Wkp1BHPSklAJuzLPYyejJoCwFFObQj1fGdTAZDEm7YyfGkufQV+gdswRkGkYGYhB6ooj3yWiXq9TIl618yGi/NV7fGVR/qXPjmsq21wYqzZXvQtN/CtzzpJHVPPvCTHU/MGjDZUb0E/X1tCaFkHBmi/irwhkTn3ZVipY0FmuJlcy30es5+xau1WNKDom4/vvMSIDBAHc/FMmvS1NQQ2FGtkEKBbsgBaXIOcia+wyAjs9D9DRmBjETGfX74mygGrn12Ky2bPG8gKdftMhlhmkv/QQztZy7JYSa3H2pd9A0g46wF01Q1ZzxLozlA9eEIgTAv+b6MsbS1+36iEdFJiifxaplTMJQoxeLvGl9XhxseXnDBYBFFnD7ZeM/NBY+cd1bZTwDZY+ZywntoACsH+dk0faWLvdvuLF6L4lD6PWU1u7u2pF+uCqqZMdIlybCNSLKnmTgdFu+ejwrh7dt1HaMpcfgiMm4cwuV23V8jE9rUYY7RxMvyFNlsrKqdduoOqqPE7NbcNECXsActSG3JL2BiFXuqLEzV/hXATrB0tKAWB5b2KOohdsAG8M2S1FanVpE5M5LGzZaSXRltQ== 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)(396003)(366004)(346002)(136003)(376002)(230922051799003)(451199024)(186009)(1800799009)(7416002)(5660300002)(316002)(921005)(83380400001)(44832011)(41300700001)(6636002)(30864003)(8676002)(8936002)(36756003)(2616005)(66946007)(4326008)(86362001)(1076003)(6666004)(6486002)(6512007)(52116002)(6506007)(66476007)(66556008)(26005)(2906002)(38350700002)(38100700002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d0lIcGdWWanKwXq2MCj9UdSrGqxnXXBDiDGliwUh1ppRmz35GBbYfQOlKc+/M1yoFNRNI2Pc8fFMFSEN3qb6iN3Y4iVfVpe4ENX/QNDRbMmctHKkAY+Gbnsk+mdMoE6o88SH2UE9plN5LBUX63R5M+Ih3DLMOpn9QON9I35k473HyR8JQATyOX0eVJUvrtYF81tBGwmeWqpZnRI/I/JCRU446t5QzKkXM1tkkWS7ijIAtv8srhl+/b2Ygs7GBI5EoXum9RSEaocCRrUTuBc4sgFwcEGl5qq9itkjLL1lyGxFRCF58CeS8qY4nO7h6WjT/I5+7TzGkjslDlryLrW3IpLS5rK2i/BZ1Wu0Sbz/sUS7/1qmd9LXwxmjAfRakCEDccimXNHExHt0yE+DV4AIpNu7VkVkngWEc3cjaeh2I+WA7nzoW3l86mK86sr4Pstzw8DY2gpxV7SwYzc0gfwftLXu3kcqU9fOv2FIEJrX/GyoGy8BGzkZF2xtvONd62mLMHgl0nY0SkK77mgzdV0pNdNzqvH6drwAs4K7HXojj4EfqPbB8XAxL5HWOJf2UGByfcQKvevd8he4Z6NNKsQaDV+wOYMWGZ0iwpSnny/RmKEfi9jix+ZKf7ON2n/UrQ4Gsl68AEFwEsRd2P5FqnVg0TVV+gExBgSuWLDbdZ1M5ytIJ+VcFv1XL53ZedsVtNhWZISA+VZchp4G987BifXgOeA8nXkVKpAb1a5SOhKfbT4k+t1mAAaiJIe3tqavG7LyBLCACj1/icyd3Gn0bfQ3hFy6gYOhbkqmGJT3SFU+0qsK7femBv1VrhDvS06Xw3jz0ixTeV9/XrMfDmFAHhtAjBUmPaCa6hUDGpx3jAchuaomFpYH+Sx5I+8yqknrH8k2VFLPDfq5oya9XuQIcQagodV1lT/3pSkoWsBgf3JRaBXmG3hk8rqxzi3hJKek/NIycFIunqGVH5uW7MjOHNwc4QWVx2kC61DqBEhJYwk3RJaG1t2BeaSzCdbmXAf+j2nT/N8T0LAOGIkIAUkj+bx/7+NNT923MbuNksr1aICuqchil+JNnTkOfRbm+ij92p/bXra0enmOwvHDa+gE9cIDtNWTBXawCVWy5GBlyeaTywNjRRQd/MJZyTD/q7E01Q+yxU2UmE1DLoIFEnrYDfe0FtxizXePzMThQEKlLaXvVaJZnBugF7U2XN88xgCPkeKjvWATHCF4msy9o5+IR8cG4DO16NaNHIeThII9NMbXeeNf+8HFN+ssugahwQjuEG54LJHpPlu/uQxpYL8I038JtSsq4i/H3HUhoA9i1rzedwCp4jl1nXDuNhCXthYLF9M0Tg5/JDuCEeEgijwDCz+bsZSXieXV6S8hBSx0LFWnJ83I7a+CuUeQF8rONlRcHeZoo6wldQo29gxHLWgfhNPg6xEooXW1bJkSxa6paOiYgqsyGaL2dwhoFaR+JjlWX6gX6b1WJBN8aIskb/XTc+2jNVlTsA1It6M7qQu8i2xOLYC/OgMaDN1phrQBkhVY/16YZD84dqBXcYYOzE21fqUhYH0ANNjEfSQxOuJjIB+IS6kVkM/Xs86y/HsfzbK6gWZD X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36486cd2-55ec-423f-5e41-08dbbf551538 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:27:15.3998 (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: 0KO7ZyQpEbEYqNdJD5zgCsGufE4UdpjIUoS8LQ3qK7eRNxr7EKnQKgsnyWhAxi0c/JKD+SCBfXyPQShIbNccsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_052724_149556_554C09EB X-CRM114-Status: GOOD ( 19.70 ) 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 | 23 ++++- include/linux/firmware/imx/ele_base_msg.h | 13 +++ 10 files changed, 324 insertions(+), 1 deletion(-) 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 c225cdc016be..b2ac00b3ac7d 100644 --- a/drivers/firmware/imx/se_fw.c +++ b/drivers/firmware/imx/se_fw.c @@ -20,10 +20,10 @@ #include #include #include -#include #include #include "se_fw.h" +#include "ele_common.h" #include "ele_fw_api.h" #define SOC_ID_OF_IMX8ULP 0x084D @@ -48,6 +48,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 +79,8 @@ static const struct imx_info_list imx8ulp_info = { .pool_name = "fsl,sram", .reserved_dma_ranges = true, .init_fw = false, + .start_rng = true, + .enable_ele_trng = false, }, }, }; @@ -99,6 +104,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, }, }, }; @@ -1252,9 +1259,23 @@ 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's mu#%d interface to firmware, configured.\n", info->se_name, priv->ele_mu_id); + return devm_of_platform_populate(dev); exit: 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 Wed Sep 27 17:54:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400718 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 DC078E810DA for ; Wed, 27 Sep 2023 12:28:01 +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=sk/aPEaBFszXrmoWvwthFWookd028DdeLhjBPpRzrTE=; b=tiYOeANkwCD7i3 2iBo3ID8l7eih+Gzx93LCEQQXbbchDNCPqrUY/Tbd1Y5hd3eR00yd/fpJN1WDvkmP2W1Ro8PBvGRV qpxxFJYcYlDJBgl5sw/2Q2iMa579l3d6SFn9IGq4lR4v1RdpLb7HJrpu/7q00jDNSxfjlUG0yh1D+ 6rIfAg+OpqYt5eQCDGIsosIJH1gyTBqXoBozRBq+dM8/GCrNNeVDPQ6dU1EVbMDldgg1I1G+uBwKC KN0o7SnUpcjYu+gapHu3BRLUEIkpCoD0yV4muyIAv3BD1vpnrrbTkP/yH1T7cpQvTgTP0k60pgW4H oEp98gyNKOMeae4H9wdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTdf-000tUD-2x; Wed, 27 Sep 2023 12:27:35 +0000 Received: from mail-am7eur03on20615.outbound.protection.outlook.com ([2a01:111:f400:7eaf::615] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTdW-000tNx-1s for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:27:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CYiqvjiRu5eOCNtKm3f7SRCs9Yk71/RD5yjgdUAHZqbWFsdsh89uVgYGQSugUvzyJUugXvp6n9Sr6e68rIa76jQE9wO313KW9QBZJ9kN1lugwU/p4T5UiLHZXb2RuN4tojs1qKKjshhVoRaJXYMehnm7lfCbqTKUFMWBW8cKPRRlU9G2TDaOGj/NuNhJjR2w2iSN1R/pbim/ZTl2CBn+wC0F62VpWhpNCrLPuUJ6+478VyJLb4p5Agb/ipox0Qgnhhm9DGmFmU9f+qk5ic0MG6/UCD7Y6vn/gHsdKdFIM9qeiwD7qp02YQ9kiN0lzStCuRhX2bVCENysh/4Eobv2OA== 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=xPdk9tpDk8gF9CSpSdzRlpIkHY9v/04YuY0kfVQW9WE=; b=aUNBj+rbKj6frLpr3LF4+4e/R3TyeNKXO1bKk3IhOLYNdWoNJtpc2/tdflbWkkh8vhDeonr6yNvuoXUlSEIsBDN4XhAAquIrCfRIikG4yBFjk21P6tgRVSOlpzQ5uh6GJ4zRiOvGtQdISk6Z1WcwZpPl6grjxs3FO2uDlyHQdneVJW0e7tTr0lQl2dEzNMrL6pPI3QlzGC2+0CR1fHQ6/mXg0D8us/prmTI2BgQ3MXI/S/9WwWgumZTtBrwRaJ/BKHNID3Td2YPcKutTEOipqRl+BC+l0EbojWoRs3L82IaZFgzEbmolOkQVV+D4nKPpr6sRCW0pjo/2BhVgelS2CQ== 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=xPdk9tpDk8gF9CSpSdzRlpIkHY9v/04YuY0kfVQW9WE=; b=HUIM4zi4mGKgyqCf7eWtneO9IAv2WiOx5PlBTJFx4D6F/iNbMwxmEmimU9FELv57pxbY5XlYCckboRpzkIOFLyR0QhxZYeJhbrnh/PYWjFM9iyiu7nnNP2B2xssUCWhJZdySNhzxIqGixmMekQZvWa6XjvbiJuVssOLvD60pZdg= 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 AS8PR04MB8181.eurprd04.prod.outlook.com (2603:10a6:20b:3f5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 12:27:20 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:27:20 +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 v6 10/11] firmware: imx: enclave-fw: add handling for save/restore IMEM region Date: Wed, 27 Sep 2023 23:24:00 +0530 Message-Id: <20230927175401.1962733-11-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8181:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d48cedb-f829-4642-3cfd-08dbbf551846 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8zPWG3A4NtGoJa8vcdtKKNUHvZYek2KalstZhFwZwRD+GLHzu1wNmTwuo5xlA2PmNLJIl/N7OpA7URXo2Z+nAN/kaSO9+8F35TfUNHG1oHkQI+KkpS05E1ju8RSWXKbmrE0DaEJcTNkJh+qeZr+hcd9mZ/5nILrlY7+B8aIWu6mAUyZAZy9Bex4Oo8tHjTDjTbsILEO/EVb9NEaqKQ+Ay57C5lC3W1+H6uWaXKmT6umfTL7pSSHdyexh7oJwyHrNAJWnKST3IuTluwJN+DDkhFKYk6DtH6DoFcUSild6KfV3HBA6cFCgv7LiHkQg20TNTLl5Bak2c7TK74giu7B54QCVxMTw03ZzSLi8sPl2AEjOQd7pKScTkaGjqyHLcWR7VojK/1XjBREY2wpKus3BJ1Nf3LU0/BYCHbptgvqG4SNpARzz8M7NblcTDHuBfok2ca+nzMtCF+7UymT5mfMimoDC2xYX5X3iPzopllINq2FWItJ64ha+bzuykqalg7oYbvD8vtX4sOTuCW8UnLjFfX98zU8h+CD3/z4Tvg7Hm3WPu6yL3acMHBYzFehC0snvNJiQrYuZq+qrFWhNoaAeolQCjRSjOupEX45m4nA+mm1ZG+zEnjoesNEgMiWJN7EDyk/nPiBiqO2o4gZtnSC3vQ== 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)(396003)(366004)(346002)(136003)(376002)(230922051799003)(451199024)(186009)(1800799009)(7416002)(5660300002)(316002)(921005)(83380400001)(44832011)(41300700001)(6636002)(30864003)(8676002)(8936002)(36756003)(2616005)(66946007)(4326008)(86362001)(1076003)(6666004)(6486002)(6512007)(52116002)(6506007)(66476007)(66556008)(26005)(2906002)(38350700002)(38100700002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ORHX//qu97Tm0aPXR32GQ75hJWt1AAVaKAqFrOWhqbi1FjRjz8uXkuaYA9fae0I/t3+4e4ymnk85I8kBrxNPxOPVr4AnNSNC/nebWIenUMeRgOBteGK0bRybEwtKhVkZq4DaCHUAguEYpwIzpR8jB51nHpnVIy4TGYwLT8DPBszGBCsQqQomQTbkAHRUgsU05BmmnGSxU2diYnQWKxzw5q4azcfwYNrwgGTDZap0QyGoaTKdPrJFhy9YcvyiWWzxyoXs+LQ+xdnzwmfj2lTIKM3oVFDu9vn9U41qGah8qa/iyGGNv4p2zp6aF6UhjztvCaIrVxN+Y5gWgxvGclhs0715cnacR8v8UuD06qGklZ+ptHUuKDrUi5QTClnVTgB29Tih0IJ5STYypRU/Ua91NVmliGrLslUNosdPq6UtZkbS45UmtVaGu30NGVwBSe3RIjPtPKBZ2SkWJNgV2EyrkrjELI87Ity8AjBqsrjBcfat/YI4SXbKcMLzosBn7cdvFjR3qeKbOVCEV6/KLe1i2+W8Aohn2JWNdwznszYn4Gmyd+t2NmNRidmescPcoF9HisvFUcSdItBhcinZVXYM07l7fB6idqDRNKxpiufBpWlI2SwtRVA3FdnW6IKmkwnVHjK7K1ggxQbosKTywIUWSPRTLGdYZ4CFvftyxRzaOXonWf48i9WikkgPdIbtG7cgrPu2mkuRP0dNMhnvVowHcXEtAbBy0Wqm7Zax2ANNMs7ChFZUUAixY4PtS7q1nx6eRPjUGRToudURStvTXv323fctg3tsxD8m6oYI4BthNAGapWTUhyBlKkILm5nj0rbVtuFu9ROPzbnuR0Sa4jwiHpTS8gT5G7i6WP3vw6tL9aaBiAkmPw+CduMK3NrhKU7pCGObDNBR26GNaE17Kt3rGX1u0hkmgDEfJXjXKAjizXh7WAUl4tQtdgRgANAEZqdbh42FOqDLqEmIhNIWD2lZIdYdd9wZ+ujmL8MJYvY2e0jSyKmQht2ljg8E6IiMOlJNKBZQIfOAcVk+5vrLMG2Ul7zvhS8//B2K0NGEpqdMUgniLssVwGw6GwSHsONM6pUTbuVEACZlswOFOu5wxd8buP2lCKJsQnRED45YspE6B+39iO3FO9WaJv3F5w+Qc3SlgtbuH1d8GbEJ5GT+vlzbSgugtE2rH4G2eFCRKeZa/JKFCF36P0UDLOnKrVHJc2EA3jvK7Qw8yWLW2lYttyG1sEhnjXZStbutrI+KW1RE70TAf7FAKCcKBOrj2nBdKtf9m1OOQUBNlOB8Pph50qjQLVvvJVCoiOhuGFnZPgruvhX7Jo8pxYaPHMUXX9ReJnf2M1DAEEhaDI4/+7HpHcqdOXEn5BjSMCzNUINGVm23ipJHiEbwGAT3rkXg3gsjxCU+wRL27I+QW17BWjemyz7AtTEysLzmWIudV7gzCfKP5wB2k8YHT/L7DRslWhp49ThmnoqMyRnt0e3kcwU2OBNstT8z4+i3mQfa8e8DCO+Irc8JgGXII8k0Zn862gnng8ShSGRbwhH6TPk1kEeQe3Lj/kYMplOAz+n2ZvU3IBg66Zg5pz6bAr01uKyLKCIs73EZ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d48cedb-f829-4642-3cfd-08dbbf551846 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:27:20.5047 (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: LybHu+KvyHmLb40CR6NRfJvEvjBo9VHOG+q9Gh7uXVLvBqzH7j6EW/5A8hpw7siq/zXB98oskWqEdijZyT9asg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_052726_654281_53957A0C X-CRM114-Status: GOOD ( 22.64 ) 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 | 44 ++++++++- drivers/firmware/imx/se_fw.h | 8 ++ include/linux/firmware/imx/ele_base_msg.h | 14 +++ 6 files changed, 240 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele_base_msg.c index 3a3af2321f67..473388357dea 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, + 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 b2ac00b3ac7d..bae8c265bc9f 100644 --- a/drivers/firmware/imx/se_fw.c +++ b/drivers/firmware/imx/se_fw.c @@ -51,6 +51,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 { @@ -81,6 +82,7 @@ static const struct imx_info_list imx8ulp_info = { .init_fw = false, .start_rng = true, .enable_ele_trng = false, + .imem_mgmt = true, }, }, }; @@ -106,6 +108,7 @@ static const struct imx_info_list imx93_info = { .init_fw = true, .start_rng = true, .enable_ele_trng = true, + .imem_mgmt = false, }, }, }; @@ -209,7 +212,7 @@ static void ele_mu_rx_callback(struct mbox_client *c, void *msg) } -static phys_addr_t get_phy_buf_mem_pool(struct device *dev, +phys_addr_t get_phy_buf_mem_pool(struct device *dev, char *mem_pool_name, u32 **buf, uint32_t size) @@ -231,7 +234,7 @@ static phys_addr_t get_phy_buf_mem_pool(struct device *dev, return gen_pool_virt_to_phys(mem_pool, (ulong)*buf); } -static void free_phybuf_mem_pool(struct device *dev, +void free_phybuf_mem_pool(struct device *dev, char *mem_pool_name, u32 *buf, uint32_t size) @@ -1063,6 +1066,17 @@ static int se_probe_cleanup(struct platform_device *pdev) priv->flags &= (~RESERVED_DMA_POOL); } + /* 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->ctxs) { for (i = 0; i < priv->max_dev_ctx; i++) { if (priv->ctxs[i]) @@ -1272,6 +1286,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's mu#%d interface to firmware, configured.\n", info->se_name, priv->ele_mu_id); @@ -1295,17 +1321,31 @@ 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 of_device_id *of_id = of_match_device(se_fw_match, dev); + struct imx_info *info = (of_id != NULL) ? (struct imx_info *)of_id->data + : NULL; + + 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 of_device_id *of_id = of_match_device(se_fw_match, dev); + struct imx_info *info = (of_id != NULL) ? (struct imx_info *)of_id->data + : NULL; 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/drivers/firmware/imx/se_fw.h b/drivers/firmware/imx/se_fw.h index 25906f40daef..c7123c9233ca 100644 --- a/drivers/firmware/imx/se_fw.h +++ b/drivers/firmware/imx/se_fw.h @@ -141,4 +141,12 @@ struct ele_mu_priv { 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 index 3ca4b47e4c4e..a7de50fdf8f4 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 0x24 +#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 Wed Sep 27 17:54:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400719 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 7C028E810DB for ; Wed, 27 Sep 2023 12:28:03 +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=bE5n5+R0TXwNkjN63N386/VnSuhRbiikU5Iw/0BtjAw=; b=QAWyNUbgvilpfs +Q17LhFIEFM3tJzaW14MrvzlRqT0Q8F9TKEL6h612SZXWh5vg14sSeXdOOkSAmnaB32nYdjmwAPsH gpn8OU8hp9HsaTww/KS8fabIZKchY++P+AJQctPpszSwSd051JmCV4A26waBuIgxgvBZ8ZDOeAFvx CA/nteyCLGtt2Ab0GUljhfhRs2XzRyzo7yQGZNmsWUj0ibrKwEuebJwOxe4ecXQw/sDUbOEOTCgQQ H1RZnM6Ezy0GMc6VdYkHkcI3hEV0dV0C4OBQ6lbBIcW5vaaqRGDYWLikkFTP6dhRlc1ZZc9MAXqZa hLtnNYwdt7MD5rKyRd9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTdg-000tUe-25; Wed, 27 Sep 2023 12:27:36 +0000 Received: from mail-am7eur03on20615.outbound.protection.outlook.com ([2a01:111:f400:7eaf::615] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTdZ-000tNx-0y for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:27:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=irrH46qA+b6cQmp00nQ3AUvpNDKAefuUWuIBRJhRwjGqETtdm06u4zighGc/dKNXkEitnJvGVfaHhMdqM6hciceRO4yNGlz2db8+JJai7h0YHlUuC/nQTlWrwaJ8yFLHPHeutLkYxcY2vf8HByhnT6GB4VwJ20IbY9aEKyqNil5/57X95KVvJUKgBklyuHdFg+bTspJ1kkI77Sm6geEjyy+IiJ973ZBp3i5Qvsxh+dO8rVI6j69L3N+d0nUDQzFt/17fQvNOLAeNBihSQnH/QVWbgGNRJ5zmqHGSJomJ2AlfdrZBlhrAGFESOqe1iCjpqcqvNx6w30uQ8v7U0G6gww== 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=ypreJhlI5ztDAx9ETL4uwlW64cL8JvY3OuMHb3MXoXA=; b=Ba5c0vfjVGOP/cMTtaUvhnvEBmOQO4cQgocF9aYt+PosB00asbUM4sxVkHJwUgP1as21yA+2HcSvFEIXM02OK2mkViqqIrFB2L6C4Ra/YRYLvaxCCRPZzd+5YBSyo+xpIjYL9E1jlO7sbFSaqHwbOm5XfnzbEwj4bJYE3Rnl2JQAw+o6qygyIQB7EhhxaSpCKxqBMjPjyVeAV7y4MoUvLkxDzAq1U95xGQpJYZdkvHw9DKZ6E77VaMFPdkHcrDeb8KsiwdNPjupK+26Q0tA+hKQzsRivPOCPB7WsruJKKqex1mZ5BQuBm/ca6h+lGcc9+lh0wVgXsQSRciqj5IPqqQ== 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=ypreJhlI5ztDAx9ETL4uwlW64cL8JvY3OuMHb3MXoXA=; b=fQn9EaTzdp5bMpw9OW3QFBmYpJlXb7Iv8osLpD0OBJuc9Vt67PjaYfDVg8CNjOuuVjRSqd38KU1dQykStXeGpd+/ZBWa1v/MxPtyRJmd0VzVjK9+r+tvP7n6G65MOu3DYygt3C/X/NvNX+XySfb0hQVaS9fdxp9W2JrdAoOwwCA= 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 AS8PR04MB8181.eurprd04.prod.outlook.com (2603:10a6:20b:3f5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 12:27:25 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:27: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 v6 11/11] MAINTAINERS: Added maintainer details Date: Wed, 27 Sep 2023 23:24:01 +0530 Message-Id: <20230927175401.1962733-12-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175401.1962733-1-pankaj.gupta@nxp.com> References: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB8181:EE_ X-MS-Office365-Filtering-Correlation-Id: 719b34e7-043f-46c5-f4fa-08dbbf551b4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mvwPhToexW+r7wml/qVy99edPzFXL49bZSDzitCTF8eb4x2TLhMmoEebd5S4O8cW01vpzCtUI7DYQP2EyRZQ47dPNZpJOnyl4C3RpyLV1ZwdIIxTMVCH6zTXn7ae0qsx1PkcJCty+wK54Er/KN55Y4OeWHQl2g3qUMrxims8urCO1yH09r/9PiDC9ZqQO4WXdgkd9k6F4NFpXKqkeAt5bkIlkpQ4beIvPh7n5rB23AFDD0jAouWfFuxGWjkw7mUYpNMB8/eJv5MvduQJO2YnbFpEKJ37NGm08txHM221fX5uUwh6SEH/Hn7mbxq+80hBCxTua90v3ewj83Nhsgx6FX7T2Zu3fydOowc8VAn/Bg1uuinYP8yDhi8WwMeJVDz0+eJBHqWuYP16WDfjCnIfcdGp45pfH2cI3wUlXxlaYsaQOG3MKx34Tlo5AMQbrSbthOKqLQvDYfcqD63TuLuRLGaRGLHDpVXp+7sjAFg7CuIp+DdB0TlIyxY9zJ1GBOSJeuITf8mDTL4LXETj/l3VjYkT522oWnwRP83hElGJop5aDdQUGEHzV2JLdolDPtE7+ZiRXpo2Yna5qT+vraQn0yo3oz+bKhDsAFRnsP+S3WQf82PX/UKLb/GbKB0Ta8V2z77LriJhXb6Ru4+SW9Y9LA== 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)(396003)(366004)(346002)(136003)(376002)(230922051799003)(451199024)(186009)(1800799009)(4744005)(7416002)(5660300002)(316002)(921005)(83380400001)(44832011)(41300700001)(6636002)(8676002)(8936002)(36756003)(2616005)(66946007)(4326008)(86362001)(1076003)(6666004)(6486002)(6512007)(52116002)(6506007)(66476007)(66556008)(26005)(2906002)(38350700002)(38100700002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: O9/OzcedipAPYkob7ROJcYgTTBZjzlBDNxVAMJIkZK0hRiW64r2rZLJPrS8Vvo4AeerxNZXSV3nRyCNy1+rDNbWK8Rz7HNI/ceJG+X9mv2IfTooL3uFdIkl3SQ4DPhCmjqMDSyRy+L2gUSHAw+ft9Qal8uK7okuJJ0hgAbuPLF/VKYG6ihyHFs35Ra32q7PmXpwioyY1fZFYicPmvyR8ox8CjVGFaGCJbuh7Maj+KLaPxbVWLkkt90WL9/6sAMb7+4a5kzbp86Phampr81tXk3JIKjtxKqNt4YNav5MLQqk57gX8UdIIcOuLf+2ca3BIGzYOcW8mOSIWrI/rgEYMAeNGyCQ7QdQVC5DBX4M/1CVrEDZfZ912UiaiAIMiEUi+h6/7DXzB2VbclYT6ewHp3SAkSSQKliPtS76jCUd2k106pdTRX27Tq0cHpmqPr2dbzHWpNkTT4ZNJB23F6nlKgR7RpyRsPqD2eU30vHx39JzTXgRQkCzGu/Fguytbu4/sr18x30sDoa5VTMzNn5yHw92bw5sPUgLbbIsWPuswO0bYTEvOFv56L6SErSN1bLarx6+KMkie7irdmDzOzoI6vZNDMvk64bKjEmo2tZ4Pz3xA5OVvarewGqR3tTY1B7Svy1TWe9fNldOevvC3JXecX7SpZYtz2pEuc42qbWQDHjTWTfWPVi1w2X3IY7fxaIeApGKmL4LZo4yZgnPjXhgVKhMXz/hmeh+yRWLjkIZRZxndb7Qa1dmSDSAgKTFRAvO6rMbkYdc6Bv5X/cV6NFV7zYOSUrr+do0fP8nLgczYUotU3eQL//TBtqgjS3RS19zZBOSRmC8NNZIbS7dwG5Ctsy4RbcSEYpz3ST9vm+etAjMQ7T8vQ35w7gfToVN2twPLQJRauJ+uHBaLZF+o4yrUuwV2cWfvQqjjHZ4wo+XNccwkOYpA2HHW2KweGDOeTzo/N3zl3vHuhCzppz414TWdUW9UPZdHCaMEbR62gdFcKx4Y2MBN39cF4JI3rnTbnVoBSWhRc0b/SVqr3L2vlJXmGwVnuor1Sxt1puYkVkgrSrcaIecv0/ySu3btO/1hCJ92eFl2fsXmc/YgrzuQteWiy74GZ5OaUWgJawDR9a0qpAsXMCmS9mpoGHiP7Cuk5qjMvsEM/oJQvJ+V5q/3VLV4V1tTphc9qWM+nxaq0NRF0AmAP7brXWnU6EsMRCoBv47PIn4FkArVCeeyg8pD2P40EYPq+slZtcGjRRmNu6ITDK8J7z2P1FVr+Y+GZNf9ns7J/CdRiptjQFHLHA85aP2oxerLi7O6U/c6cpa1X0sHYdcDK3mE7uYEzho18z+ldEG4pRVND0GcpFB2GPRfxrMEg4HG0ysY2zuryoeQrRrEjd+27f3jeXJ9wQB9RPuLjnDjFK3lHD4bqDeNG09QcLAMlIQHACYytRaaKLQybMj/poVxUnfgCzE902Xjl44q43U/ZSTKlHYlCtAaNozDyqc4z6D0spNqMDql+FbR/Pj7040PxTceLy8KygOevnnfVwWVdKXp5WTDd2suKINVZqxw643OrfzBozWvX6GQxC6W20JeLmMVgZMkbkDxO/weldUI X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 719b34e7-043f-46c5-f4fa-08dbbf551b4c X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:27:25.7322 (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: AGZou3ZpJW/AsV1HdwayV2Lu6V1IpjDCAwX8mFl7Sjqsl2JzfYDJDucIzhj6b6oui9GTAM/LEtqfkGU2XB7yEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_052729_392425_CECE6613 X-CRM114-Status: UNSURE ( 9.09 ) 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 b19995690904..61e69dc247ad 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