diff --git a/drivers/hwinfo/CMakeLists.txt b/drivers/hwinfo/CMakeLists.txt index 0ebc99ca17..30a1507248 100644 --- a/drivers/hwinfo/CMakeLists.txt +++ b/drivers/hwinfo/CMakeLists.txt @@ -12,4 +12,5 @@ zephyr_sources_ifdef(CONFIG_HWINFO_SAM hwinfo_sam.c) zephyr_sources_ifdef(CONFIG_HWINFO_SAM4L hwinfo_sam4l.c) zephyr_sources_ifdef(CONFIG_HWINFO_SAM0 hwinfo_sam0.c) zephyr_sources_ifdef(CONFIG_HWINFO_LITEX hwinfo_litex.c) +zephyr_sources_ifdef(CONFIG_HWINFO_PSOC6 hwinfo_psoc6.c) zephyr_sources_ifdef(CONFIG_HWINFO_SHELL hwinfo_shell.c) diff --git a/drivers/hwinfo/Kconfig b/drivers/hwinfo/Kconfig index bb8a603af5..9089eb986d 100644 --- a/drivers/hwinfo/Kconfig +++ b/drivers/hwinfo/Kconfig @@ -91,4 +91,13 @@ config HWINFO_LITEX select HWINFO_HAS_DRIVER help Enable LiteX hwinfo driver + +config HWINFO_PSOC6 + bool "Cypress PSoC-6 unique device ID" + default y + depends on SOC_FAMILY_PSOC6 + select HWINFO_HAS_DRIVER + help + Enable Cypress PSoC-6 hwinfo driver. + endif diff --git a/drivers/hwinfo/hwinfo_psoc6.c b/drivers/hwinfo/hwinfo_psoc6.c new file mode 100644 index 0000000000..ede3be28ac --- /dev/null +++ b/drivers/hwinfo/hwinfo_psoc6.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 ATL Electronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT cypress_psoc6_uid + +#include +#include +#include +#include +#include + +#include + +ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length) +{ + uint8_t *uid_addr = (uint8_t *) DT_INST_REG_ADDR(0); + + if (buffer == NULL) { + return 0; + } + + if (length > DT_INST_REG_SIZE(0)) { + length = DT_INST_REG_SIZE(0); + } + + memcpy(buffer, uid_addr, length); + + return length; +}