From 52be3030aac9ad6523baeb3d83a473ffe05d62a1 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Fri, 18 Mar 2022 15:06:00 +0100 Subject: [PATCH] drivers: hwinfo: Remove HWINFO_NRF limitation for non-secure config Remove the limitiation in HWINFO_NRF not working in non-secure configuration. Use the exposed soc_secure_read_deviceid function that accesses the device ID through the secure services. Signed-off-by: Joakim Andersson --- drivers/hwinfo/Kconfig | 2 +- drivers/hwinfo/hwinfo_nrf.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/hwinfo/Kconfig b/drivers/hwinfo/Kconfig index 2b9492315cc..597636f0b8d 100644 --- a/drivers/hwinfo/Kconfig +++ b/drivers/hwinfo/Kconfig @@ -31,7 +31,7 @@ config HWINFO_STM32 config HWINFO_NRF bool "NRF device ID" default y - depends on SOC_FAMILY_NRF && !TRUSTED_EXECUTION_NONSECURE + depends on SOC_FAMILY_NRF help Enable Nordic NRF hwinfo driver. diff --git a/drivers/hwinfo/hwinfo_nrf.c b/drivers/hwinfo/hwinfo_nrf.c index 5be49bd88a6..9f181e4a8ef 100644 --- a/drivers/hwinfo/hwinfo_nrf.c +++ b/drivers/hwinfo/hwinfo_nrf.c @@ -12,7 +12,7 @@ #ifndef CONFIG_BOARD_QEMU_CORTEX_M0 #include #endif - +#include struct nrf_uid { uint32_t id[2]; }; @@ -20,9 +20,12 @@ struct nrf_uid { ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length) { struct nrf_uid dev_id; + uint32_t deviceid[2]; - dev_id.id[0] = sys_cpu_to_be32(nrf_ficr_deviceid_get(NRF_FICR, 1)); - dev_id.id[1] = sys_cpu_to_be32(nrf_ficr_deviceid_get(NRF_FICR, 0)); + soc_secure_read_deviceid(deviceid); + + dev_id.id[0] = sys_cpu_to_be32(deviceid[1]); + dev_id.id[1] = sys_cpu_to_be32(deviceid[0]); if (length > sizeof(dev_id.id)) { length = sizeof(dev_id.id);