[PATCH V2 17/30] imx: imx8ulp: start the ELE RNG at boot
Peng Fan (OSS)
peng.fan at oss.nxp.com
Thu Jun 15 12:09:14 CEST 2023
From: Peng Fan <peng.fan at nxp.com>
On the imx8ulp A1 SoC, the ELE RNG needs to be manually started.
Signed-off-by: Clement Faure <clement.faure at nxp.com>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
arch/arm/include/asm/mach-imx/ele_api.h | 1 +
board/freescale/imx8ulp_evk/spl.c | 10 ++++++++++
drivers/misc/imx_ele/ele_api.c | 25 +++++++++++++++++++++++++
3 files changed, 36 insertions(+)
diff --git a/arch/arm/include/asm/mach-imx/ele_api.h b/arch/arm/include/asm/mach-imx/ele_api.h
index 053a23f030b..cfd4ecebb62 100644
--- a/arch/arm/include/asm/mach-imx/ele_api.h
+++ b/arch/arm/include/asm/mach-imx/ele_api.h
@@ -149,4 +149,5 @@ int ele_get_fw_status(u32 *status, u32 *response);
int ele_release_m33_trout(void);
int ele_write_secure_fuse(ulong signed_msg_blk, u32 *response);
int ele_return_lifecycle_update(ulong signed_msg_blk, u32 *response);
+int ele_start_rng(void);
#endif
diff --git a/board/freescale/imx8ulp_evk/spl.c b/board/freescale/imx8ulp_evk/spl.c
index b7c6ff092b1..66d0f68cc62 100644
--- a/board/freescale/imx8ulp_evk/spl.c
+++ b/board/freescale/imx8ulp_evk/spl.c
@@ -123,6 +123,16 @@ void spl_board_init(void)
ret = ele_release_caam(0x7, &res);
if (ret)
printf("ele release caam failed %d, 0x%x\n", ret, res);
+
+ /*
+ * RNG start only available on the A1 soc revision.
+ * Check some JTAG register for the SoC revision.
+ */
+ if (!is_soc_rev(CHIP_REV_1_0)) {
+ ret = ele_start_rng();
+ if (ret)
+ printf("Fail to start RNG: %d\n", ret);
+ }
}
void board_init_f(ulong dummy)
diff --git a/drivers/misc/imx_ele/ele_api.c b/drivers/misc/imx_ele/ele_api.c
index 8a14cf6aa92..0c017734a49 100644
--- a/drivers/misc/imx_ele/ele_api.c
+++ b/drivers/misc/imx_ele/ele_api.c
@@ -503,6 +503,31 @@ int ele_get_events(u32 *events, u32 *events_cnt, u32 *response)
return ret;
}
+int ele_start_rng(void)
+{
+ struct udevice *dev = gd->arch.ele_dev;
+ int size = sizeof(struct ele_msg);
+ struct ele_msg msg;
+ int ret;
+
+ if (!dev) {
+ printf("ele dev is not initialized\n");
+ return -ENODEV;
+ }
+
+ msg.version = ELE_VERSION;
+ msg.tag = ELE_CMD_TAG;
+ msg.size = 1;
+ msg.command = ELE_START_RNG;
+
+ ret = misc_call(dev, false, &msg, size, &msg, size);
+ if (ret)
+ printf("Error: %s: ret %d, response 0x%x\n",
+ __func__, ret, msg.data[0]);
+
+ return ret;
+}
+
int ele_write_secure_fuse(ulong signed_msg_blk, u32 *response)
{
struct udevice *dev = gd->arch.ele_dev;
--
2.40.0
More information about the U-Boot
mailing list