drivers: hwinfo: stm32: Add support for reading EUI64 on STM32W*

The STM32WB, STM32WB and STM32WBA families devices include a EUI64 ID
(called "IEEE 64-bit unique device ID register" in the reference manual
that is distinct from the standard device ID. Add support for reading
it, noting that it is stored in little endian format in the registers.

On other families the weak implementation takes over and returns
-ENOSYS.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
Aurelien Jarno 2024-04-28 21:05:06 +02:00 committed by David Leach
parent ada2c78235
commit 185edca797

View file

@ -44,6 +44,26 @@ ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
return length;
}
#if defined(CONFIG_SOC_SERIES_STM32WBAX) || \
defined(CONFIG_SOC_SERIES_STM32WBX) || \
defined(CONFIG_SOC_SERIES_STM32WLX)
struct stm32_eui64 {
uint32_t id[2];
};
int z_impl_hwinfo_get_device_eui64(uint8_t *buffer)
{
struct stm32_eui64 dev_eui64;
dev_eui64.id[0] = sys_cpu_to_be32(READ_REG(*((uint32_t *)UID64_BASE + 1U)));
dev_eui64.id[1] = sys_cpu_to_be32(READ_REG(*((uint32_t *)UID64_BASE)));
memcpy(buffer, dev_eui64.id, sizeof(dev_eui64));
return 0;
}
#endif
int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
{
uint32_t flags = 0;