drivers: hwinfo: sam: Add sam4l hwinfo support
Add initial version. Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
parent
4e1d6af8f8
commit
bca8e83cab
3 changed files with 40 additions and 1 deletions
|
@ -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_ESP32 hwinfo_esp32.c)
|
||||||
zephyr_sources_ifdef(CONFIG_HWINFO_IMXRT hwinfo_imxrt.c)
|
zephyr_sources_ifdef(CONFIG_HWINFO_IMXRT hwinfo_imxrt.c)
|
||||||
zephyr_sources_ifdef(CONFIG_HWINFO_SAM hwinfo_sam.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_SAM0 hwinfo_sam0.c)
|
||||||
zephyr_sources_ifdef(CONFIG_HWINFO_LITEX hwinfo_litex.c)
|
zephyr_sources_ifdef(CONFIG_HWINFO_LITEX hwinfo_litex.c)
|
||||||
zephyr_sources_ifdef(CONFIG_HWINFO_SHELL hwinfo_shell.c)
|
zephyr_sources_ifdef(CONFIG_HWINFO_SHELL hwinfo_shell.c)
|
||||||
|
|
|
@ -55,11 +55,19 @@ config HWINFO_IMXRT
|
||||||
config HWINFO_SAM
|
config HWINFO_SAM
|
||||||
bool "Atmel SAM device ID"
|
bool "Atmel SAM device ID"
|
||||||
default y
|
default y
|
||||||
depends on SOC_FAMILY_SAM
|
depends on SOC_FAMILY_SAM && !SOC_SERIES_SAM4L
|
||||||
select HWINFO_HAS_DRIVER
|
select HWINFO_HAS_DRIVER
|
||||||
help
|
help
|
||||||
Enable Atmel SAM hwinfo driver.
|
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
|
config HWINFO_SAM0
|
||||||
bool "Atmel SAM0 device ID"
|
bool "Atmel SAM0 device ID"
|
||||||
default y
|
default y
|
||||||
|
|
30
drivers/hwinfo/hwinfo_sam4l.c
Normal file
30
drivers/hwinfo/hwinfo_sam4l.c
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Gerson Fernando Budke <nandojve@gmail.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DT_DRV_COMPAT atmel_sam4l_uid
|
||||||
|
|
||||||
|
#include <device.h>
|
||||||
|
#include <drivers/hwinfo.h>
|
||||||
|
#include <init.h>
|
||||||
|
#include <soc.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue