From bca8e83cab7e4cc86db42eb8a646cb5374c9474c Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Fri, 19 Jun 2020 00:30:59 -0300 Subject: [PATCH] drivers: hwinfo: sam: Add sam4l hwinfo support Add initial version. Signed-off-by: Gerson Fernando Budke --- drivers/hwinfo/CMakeLists.txt | 1 + drivers/hwinfo/Kconfig | 10 +++++++++- drivers/hwinfo/hwinfo_sam4l.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 drivers/hwinfo/hwinfo_sam4l.c diff --git a/drivers/hwinfo/CMakeLists.txt b/drivers/hwinfo/CMakeLists.txt index 3fa1b484c9f..0ebc99ca178 100644 --- a/drivers/hwinfo/CMakeLists.txt +++ b/drivers/hwinfo/CMakeLists.txt @@ -9,6 +9,7 @@ zephyr_sources_ifdef(CONFIG_HWINFO_MCUX_SIM hwinfo_mcux_sim.c) zephyr_sources_ifdef(CONFIG_HWINFO_ESP32 hwinfo_esp32.c) zephyr_sources_ifdef(CONFIG_HWINFO_IMXRT hwinfo_imxrt.c) 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_SHELL hwinfo_shell.c) diff --git a/drivers/hwinfo/Kconfig b/drivers/hwinfo/Kconfig index 51ccf90bf9c..bb8a603af50 100644 --- a/drivers/hwinfo/Kconfig +++ b/drivers/hwinfo/Kconfig @@ -55,11 +55,19 @@ config HWINFO_IMXRT config HWINFO_SAM bool "Atmel SAM device ID" default y - depends on SOC_FAMILY_SAM + depends on SOC_FAMILY_SAM && !SOC_SERIES_SAM4L select HWINFO_HAS_DRIVER help Enable Atmel SAM hwinfo driver. +config HWINFO_SAM4L + bool "Atmel SAM4L device ID" + default y + depends on SOC_SERIES_SAM4L + select HWINFO_HAS_DRIVER + help + Enable Atmel SAM4L hwinfo driver. + config HWINFO_SAM0 bool "Atmel SAM0 device ID" default y diff --git a/drivers/hwinfo/hwinfo_sam4l.c b/drivers/hwinfo/hwinfo_sam4l.c new file mode 100644 index 00000000000..25719be054d --- /dev/null +++ b/drivers/hwinfo/hwinfo_sam4l.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2020 Gerson Fernando Budke + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT atmel_sam4l_uid + +#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 < 0) { + length = DT_INST_REG_SIZE(0); + } + + memcpy(buffer, uid_addr, length); + + return length; +}