diff --git a/drivers/hwinfo/Kconfig b/drivers/hwinfo/Kconfig index f49d0393fb9..9e251e9a265 100644 --- a/drivers/hwinfo/Kconfig +++ b/drivers/hwinfo/Kconfig @@ -67,7 +67,7 @@ config HWINFO_NRF bool "NRF device ID" default y depends on SOC_FAMILY_NORDIC_NRF - depends on NRF_SOC_SECURE_SUPPORTED + depends on SOC_SERIES_NRF54HX || NRF_SOC_SECURE_SUPPORTED help Enable Nordic NRF hwinfo driver. diff --git a/drivers/hwinfo/hwinfo_nrf.c b/drivers/hwinfo/hwinfo_nrf.c index 8b644f2f60e..d1fca5350a6 100644 --- a/drivers/hwinfo/hwinfo_nrf.c +++ b/drivers/hwinfo/hwinfo_nrf.c @@ -8,7 +8,7 @@ #include #include #include -#ifndef CONFIG_BOARD_QEMU_CORTEX_M0 +#if !defined(CONFIG_SOC_SERIES_NRF54HX) && !defined(CONFIG_BOARD_QEMU_CORTEX_M0) #include #endif @@ -25,17 +25,34 @@ 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]; + uint32_t buf[2]; +#if NRF_FICR_HAS_DEVICE_ID || NRF_FICR_HAS_INFO_DEVICE_ID + /* DEVICEID is accessible, use this */ #if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && defined(NRF_FICR_S) - soc_secure_read_deviceid(deviceid); + soc_secure_read_deviceid(buf); #else - deviceid[0] = nrf_ficr_deviceid_get(NRF_FICR, 0); - deviceid[1] = nrf_ficr_deviceid_get(NRF_FICR, 1); + buf[0] = nrf_ficr_deviceid_get(NRF_FICR, 0); + buf[1] = nrf_ficr_deviceid_get(NRF_FICR, 1); +#endif +#elif NRF_FICR_HAS_DEVICE_ADDR || NRF_FICR_HAS_BLE_ADDR + /* DEVICEID is not accessible, use device/ble address instead. + * Assume that it is always accessible from the non-secure image. + */ + buf[0] = nrf_ficr_deviceaddr_get(NRF_FICR, 0); + buf[1] = nrf_ficr_deviceaddr_get(NRF_FICR, 1); + + /* Assume that ER and IR are available whenever deviceaddr is. + * Use the LSBytes from ER and IR to complete the device id. + */ + buf[1] |= (nrf_ficr_er_get(NRF_FICR, 0) & 0xFF) << 16; + buf[1] |= (nrf_ficr_ir_get(NRF_FICR, 0) & 0xFF) << 24; +#else +#error "No suitable source for hwinfo device_id generation" #endif - dev_id.id[0] = sys_cpu_to_be32(deviceid[1]); - dev_id.id[1] = sys_cpu_to_be32(deviceid[0]); + dev_id.id[0] = sys_cpu_to_be32(buf[1]); + dev_id.id[1] = sys_cpu_to_be32(buf[0]); if (length > sizeof(dev_id.id)) { length = sizeof(dev_id.id); @@ -46,7 +63,7 @@ ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length) return length; } -#ifndef CONFIG_BOARD_QEMU_CORTEX_M0 +#if !defined(CONFIG_SOC_SERIES_NRF54HX) && !defined(CONFIG_BOARD_QEMU_CORTEX_M0) int z_impl_hwinfo_get_reset_cause(uint32_t *cause) { uint32_t flags = 0;