This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 4fbab66754cc5166f0f7b9e4a965b93f4b906f3c
Author: Jukka Laitinen <[email protected]>
AuthorDate: Tue Sep 22 12:01:43 2026 +0300

    arch/arm/imxrt: Add revision read from ELE
    
    Add a new helper function for EdgeLock Enclave driver for reading the SoC 
revision
    
    - Refactor ELE_GET_INFO_REQ into an own function imxrt118x_ele_get_info
      and use that for imxrt118x_ele_get_lifecycle
    - Add imxrt118x_ele_get_soc_revision using the imxrt118x_ele_get_info
    
    Signed-off-by: Jukka Laitinen <[email protected]>
---
 arch/arm/src/imxrt/hardware/rt118x/imxrt118x_ele.h |  9 ++-
 arch/arm/src/imxrt/imxrt118x_ele.c                 | 77 ++++++++++++++++------
 arch/arm/src/imxrt/imxrt118x_ele.h                 | 17 +++++
 3 files changed, 81 insertions(+), 22 deletions(-)

diff --git a/arch/arm/src/imxrt/hardware/rt118x/imxrt118x_ele.h 
b/arch/arm/src/imxrt/hardware/rt118x/imxrt118x_ele.h
index ed050eac0d1..679fc641f47 100644
--- a/arch/arm/src/imxrt/hardware/rt118x/imxrt118x_ele.h
+++ b/arch/arm/src/imxrt/hardware/rt118x/imxrt118x_ele.h
@@ -76,9 +76,12 @@
 
 /* GET_INFO returned data. */
 
-#define ELE_GET_INFO_BYTES        160
-#define ELE_GET_INFO_LC_WORD      2
-#define ELE_GET_INFO_LC_MASK      0xffff
+#define ELE_GET_INFO_BYTES         160
+#define ELE_GET_INFO_SOC_WORD      1
+#define ELE_GET_INFO_SOC_REV_SHIFT 24
+#define ELE_GET_INFO_SOC_REV_MASK  0xff
+#define ELE_GET_INFO_LC_WORD       2
+#define ELE_GET_INFO_LC_MASK       0xffff
 
 /* System 3 Messaging Unit A (IMXRT1180RM Ch. 65).
  * The CM33 boots in Secure state and NXP's own SDK uses the Secure alias
diff --git a/arch/arm/src/imxrt/imxrt118x_ele.c 
b/arch/arm/src/imxrt/imxrt118x_ele.c
index 99a43414270..cbbc6708156 100644
--- a/arch/arm/src/imxrt/imxrt118x_ele.c
+++ b/arch/arm/src/imxrt/imxrt118x_ele.c
@@ -86,6 +86,8 @@ struct ele_trng_state
  ****************************************************************************/
 
 static struct ele_msg g_msg;
+static uint8_t g_info[ELE_GET_INFO_BYTES]
+  aligned_data(DCACHE_LINESIZE);
 
 #ifdef CONFIG_IMXRT_ELE_LOAD_FW
 /* Embeds the NXP EdgeLock Enclave firmware AHAB container (path from
@@ -177,6 +179,40 @@ static void imxrt118x_ele_receivemsg(struct ele_msg 
*msg_ptr)
     }
 }
 
+/****************************************************************************
+ * Name: imxrt118x_ele_get_info
+ *
+ * Description:
+ *   Query the device information from the EdgeLock Enclave.
+ *
+ ****************************************************************************/
+
+static int imxrt118x_ele_get_info(void)
+{
+  uint32_t addr = (uint32_t)(uintptr_t)g_info;
+
+  g_msg.header.version = ELE_VERSION;
+  g_msg.header.tag = ELE_CMD_TAG;
+  g_msg.header.size = 4;
+  g_msg.header.command = ELE_GET_INFO_REQ;
+  g_msg.data[0] = upper_32_bits(addr);
+  g_msg.data[1] = lower_32_bits(addr);
+  g_msg.data[2] = sizeof(g_info);
+
+  up_invalidate_dcache(addr, addr + sizeof(g_info));
+
+  imxrt118x_ele_sendmsg(&g_msg);
+  imxrt118x_ele_receivemsg(&g_msg);
+
+  if ((g_msg.data[0] & 0xff) != ELE_OK)
+    {
+      return -EIO;
+    }
+
+  up_invalidate_dcache(addr, addr + sizeof(g_info));
+  return 0;
+}
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -379,32 +415,35 @@ int imxrt118x_ele_close_device(void)
 
 uint32_t imxrt118x_ele_get_lifecycle(void)
 {
-  static uint8_t info[ELE_GET_INFO_BYTES]
-    aligned_data(DCACHE_LINESIZE);
-
-  uint32_t addr = (uint32_t)(uintptr_t)info;
-
-  g_msg.header.version = ELE_VERSION;
-  g_msg.header.tag = ELE_CMD_TAG;
-  g_msg.header.size = 4;
-  g_msg.header.command = ELE_GET_INFO_REQ;
-  g_msg.data[0] = upper_32_bits(addr);
-  g_msg.data[1] = lower_32_bits(addr);
-  g_msg.data[2] = sizeof(info);
+  if (imxrt118x_ele_get_info() < 0)
+    {
+      return 0;
+    }
 
-  up_invalidate_dcache(addr, addr + sizeof(info));
+  return ((uint32_t *)g_info)[ELE_GET_INFO_LC_WORD] &
+         ELE_GET_INFO_LC_MASK;
+}
 
-  imxrt118x_ele_sendmsg(&g_msg);
-  imxrt118x_ele_receivemsg(&g_msg);
+int imxrt118x_ele_get_soc_revision(uint8_t *revision)
+{
+  uint32_t soc;
+  int ret;
 
-  if ((g_msg.data[0] & 0xff) != ELE_OK)
+  if (revision == NULL)
     {
-      return 0;
+      return -EINVAL;
     }
 
-  up_invalidate_dcache(addr, addr + sizeof(info));
+  ret = imxrt118x_ele_get_info();
+  if (ret < 0)
+    {
+      return ret;
+    }
 
-  return ((uint32_t *)info)[ELE_GET_INFO_LC_WORD] & ELE_GET_INFO_LC_MASK;
+  soc = ((uint32_t *)g_info)[ELE_GET_INFO_SOC_WORD];
+  *revision = (soc >> ELE_GET_INFO_SOC_REV_SHIFT) &
+              ELE_GET_INFO_SOC_REV_MASK;
+  return 0;
 }
 
 int imxrt118x_ele_auth_oem_ctnr(unsigned long ctnr_addr, uint32_t *response)
diff --git a/arch/arm/src/imxrt/imxrt118x_ele.h 
b/arch/arm/src/imxrt/imxrt118x_ele.h
index ba7efaa4d01..ed1aa03fadb 100644
--- a/arch/arm/src/imxrt/imxrt118x_ele.h
+++ b/arch/arm/src/imxrt/imxrt118x_ele.h
@@ -179,6 +179,23 @@ int imxrt118x_ele_close_device(void);
 
 uint32_t imxrt118x_ele_get_lifecycle(void);
 
+/****************************************************************************
+ * Name: imxrt118x_ele_get_soc_revision
+ *
+ * Description:
+ *   Return the SoC silicon revision reported by ELE GET_INFO. The revision
+ *   uses NXP's hexadecimal major/minor encoding, for example 0xb0 or 0xc0.
+ *
+ * Output Parameters:
+ *   revision - SoC silicon revision.
+ *
+ * Returned Value:
+ *   OK on success, a negated errno value otherwise.
+ *
+ ****************************************************************************/
+
+int imxrt118x_ele_get_soc_revision(uint8_t *revision);
+
 /****************************************************************************
  * Name: imxrt118x_ele_auth_oem_ctnr
  *

Reply via email to