From: Pankaj Gupta <pankaj.gupta@nxp.com>
To: shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org,
pierre.gondois@arm.com, ping.bai@nxp.com, xiaoning.wang@nxp.com,
wei.fang@nxp.com, peng.fan@nxp.com, haibo.chen@nxp.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, sahil.malhotra@nxp.com,
aisheng.dong@nxp.com, V.Sethi@nxp.com
Cc: Pankaj Gupta <pankaj.gupta@nxp.com>
Subject: [PATCH v5 10/11] firmware: imx: enclave api to read-common-fuses
Date: Wed, 23 Aug 2023 13:03:29 +0530 [thread overview]
Message-ID: <20230823073330.1712721-11-pankaj.gupta@nxp.com> (raw)
In-Reply-To: <20230823073330.1712721-1-pankaj.gupta@nxp.com>
Added an API to read the common fuses only accessible to
enclave-firmware.
Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
---
drivers/firmware/imx/ele_base_msg.c | 80 +++++++++++++++++++++++
include/linux/firmware/imx/ele_base_msg.h | 7 ++
2 files changed, 87 insertions(+)
diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele_base_msg.c
index b19ab8abeeb8..9785fcdcc29d 100644
--- a/drivers/firmware/imx/ele_base_msg.c
+++ b/drivers/firmware/imx/ele_base_msg.c
@@ -190,3 +190,83 @@ int ele_service_swap(struct device *dev,
return -EINVAL;
}
+
+static int read_otp_uniq_id(struct ele_mu_priv *priv, u32 *value)
+{
+ unsigned int tag, command, size, ver, status;
+
+ tag = MSG_TAG(priv->rx_msg.header);
+ command = MSG_COMMAND(priv->rx_msg.header);
+ size = MSG_SIZE(priv->rx_msg.header);
+ ver = MSG_VER(priv->rx_msg.header);
+ status = RES_STATUS(priv->rx_msg.data[0]);
+
+ if (tag == priv->rsp_tag &&
+ command == ELE_READ_FUSE_REQ &&
+ size == ELE_READ_FUSE_RSP_MSG_SZ &&
+ ver == ELE_BASE_API_VERSION &&
+ status == priv->success_tag) {
+ value[0] = priv->rx_msg.data[1];
+ value[1] = priv->rx_msg.data[2];
+ value[2] = priv->rx_msg.data[3];
+ value[3] = priv->rx_msg.data[4];
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
+static int read_fuse_word(struct ele_mu_priv *priv, u32 *value)
+{
+ unsigned int tag, command, size, ver, status;
+
+ tag = MSG_TAG(priv->rx_msg.header);
+ command = MSG_COMMAND(priv->rx_msg.header);
+ size = MSG_SIZE(priv->rx_msg.header);
+ ver = MSG_VER(priv->rx_msg.header);
+ status = RES_STATUS(priv->rx_msg.data[0]);
+
+ if (tag == priv->rsp_tag &&
+ command == ELE_READ_FUSE_REQ &&
+ size == ELE_READ_FUSE_REQ_MSG_SZ &&
+ ver == ELE_BASE_API_VERSION &&
+ status == priv->success_tag) {
+ value[0] = priv->rx_msg.data[1];
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
+int read_common_fuse(struct device *dev,
+ uint16_t fuse_id, u32 *value)
+{
+ struct ele_mu_priv *priv = dev_get_drvdata(dev);
+ int err;
+
+ err = plat_fill_cmd_msg_hdr(priv,
+ (struct mu_hdr *)&priv->tx_msg.header,
+ ELE_READ_FUSE_REQ, 8);
+ if (err) {
+ pr_err("Error: plat_fill_cmd_msg_hdr failed.\n");
+ return err;
+ }
+
+ priv->tx_msg.data[0] = fuse_id;
+ err = imx_ele_msg_send_rcv(priv);
+ if (err < 0)
+ return err;
+
+ switch (fuse_id) {
+ case OTP_UNIQ_ID:
+ err = read_otp_uniq_id(priv, value);
+ break;
+ default:
+ err = read_fuse_word(priv, value);
+ break;
+ }
+
+ return err;
+}
+EXPORT_SYMBOL_GPL(read_common_fuse);
+
diff --git a/include/linux/firmware/imx/ele_base_msg.h b/include/linux/firmware/imx/ele_base_msg.h
index 6fbea7a8d7c9..99a135c21f56 100644
--- a/include/linux/firmware/imx/ele_base_msg.h
+++ b/include/linux/firmware/imx/ele_base_msg.h
@@ -47,6 +47,13 @@
#define ELE_IMEM_EXPORT 0x1
#define ELE_IMEM_IMPORT 0x2
+#define ELE_READ_FUSE_REQ 0x97
+#define ELE_READ_FUSE_RSP_MSG_SZ 0x07
+#define ELE_READ_FUSE_REQ_MSG_SZ 0x03
+
+#define OTP_UNIQ_ID 0x01
+#define OTFAD_CONFIG 0x2
+
#define ELE_BASE_API_VERSION 0x6
int ele_get_info(struct device *dev, phys_addr_t addr, u32 data_size);
--
2.34.1
next prev parent reply other threads:[~2023-08-23 7:37 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 7:33 [PATCH v5 00/11] firmware: imx: NXP Secure-Enclave FW Driver Pankaj Gupta
2023-08-23 7:33 ` [PATCH v5 01/11] dt-bindings: arm: fsl: add imx-se-fw binding doc Pankaj Gupta
2023-08-23 8:28 ` Rob Herring
2023-08-23 10:42 ` [EXT] " Pankaj Gupta
2023-08-23 12:43 ` Rob Herring
2023-08-24 18:45 ` Krzysztof Kozlowski
2023-08-24 19:23 ` Greg Kroah-Hartman
2023-08-28 6:00 ` [EXT] " Varun Sethi
2023-08-28 6:55 ` Krzysztof Kozlowski
2023-08-28 9:14 ` Varun Sethi
[not found] ` <DU2PR04MB86302A2639CA64D8DF08BF0495E3A@DU2PR04MB8630.eurprd04.prod.outlook.com>
2023-08-25 7:56 ` Varun Sethi
2023-08-23 7:33 ` [PATCH v5 02/11] arm64: dts: imx8ulp-evk: added nxp secure enclave firmware Pankaj Gupta
2023-08-23 7:33 ` [PATCH v5 03/11] arm64: dts: imx8ulp-evk: reserved mem-ranges to constrain ele_fw dma-range Pankaj Gupta
2023-08-23 7:33 ` [PATCH v5 04/11] arm64: dts: imx93-11x11-evk: added nxp secure enclave fw Pankaj Gupta
2023-08-23 7:33 ` [PATCH v5 05/11] arm64: dts: imx93-11x11-evk: reserved mem-ranges to constrain ele_fw dma-range Pankaj Gupta
2023-08-23 7:33 ` [PATCH v5 06/11] firmware: imx: add driver for NXP EdgeLock Enclave Pankaj Gupta
2023-08-24 18:31 ` Krzysztof Kozlowski
2023-08-25 10:22 ` Stefan Wahren
2023-08-25 15:16 ` Conor Dooley
2023-08-23 7:33 ` [PATCH v5 07/11] firmware: imx: init-fw api exchange on imx93 Pankaj Gupta
2023-08-24 18:35 ` Krzysztof Kozlowski
2023-08-23 7:33 ` [PATCH v5 08/11] firmware: imx: enable trng Pankaj Gupta
2023-08-24 18:23 ` Krzysztof Kozlowski
2023-08-23 7:33 ` [PATCH v5 09/11] firmware: imx: enclave-fw: add handling for save/restore IMEM region Pankaj Gupta
2023-08-24 18:37 ` Krzysztof Kozlowski
2023-08-23 7:33 ` Pankaj Gupta [this message]
2023-08-24 18:38 ` [PATCH v5 10/11] firmware: imx: enclave api to read-common-fuses Krzysztof Kozlowski
2023-08-23 7:33 ` [PATCH v5 11/11] MAINTAINERS: Added maintainer details Pankaj Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230823073330.1712721-11-pankaj.gupta@nxp.com \
--to=pankaj.gupta@nxp.com \
--cc=V.Sethi@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=alexander.stein@ew.tq-group.com \
--cc=clin@suse.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=gaurav.jain@nxp.com \
--cc=haibo.chen@nxp.com \
--cc=kernel@pengutronix.de \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=pierre.gondois@arm.com \
--cc=ping.bai@nxp.com \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sahil.malhotra@nxp.com \
--cc=shawnguo@kernel.org \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).