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/ALG2Cu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1ZvZ0Jm+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) {