soc: at91: Add Atmel SFR SN (Serial Number) support
PATCH v4 1/1 soc: at91: Add Atmel SFR SN (Serial Number) support
Add support to read SFR's read-only registers providing the SoC Serial Numbers (SN0+SN1) to userspace.
~ # hexdump -n 8 -e'"%d\n"' /sys/bus/nvmem/devices/atmel-sfr0/nvmem 959527243
371539274
Signed-off-by Kamel Bouhara <[email protected]>
--- drivers/soc/atmel/Kconfig | 11 ++++ drivers/soc/atmel/Makefile | 1 + drivers/soc/atmel/sfr.c | 100 +++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 drivers/soc/atmel/sfr.c
drivers/soc/atmel/Kconfig +11 -0
@@ -5,3 +5,14 @@ config AT91_SOC_ID default ARCH_AT91 help Include support for the SoC bus on the Atmel ARM SoCs. + +config AT91_SOC_SFR + tristate "Special Function Registers support" + depends on ARCH_AT91 || COMPILE_TEST + help + This is a driver for the Special Function Registers available on + Atmel SAMA5Dx SoCs, providing access to specific aspects of the + integrated memory, bridge implementations, processor etc. + + This driver can also be built as a module. If so, the module + will be called sfr.
drivers/soc/atmel/Makefile +1 -0
@@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_AT91_SOC_ID) += soc.o +obj-$(CONFIG_AT91_SOC_SFR) += sfr.o
drivers/soc/atmel/sfr.c new file +100 -0
100 lines not on this page · raw message
Signature · 7 lines
2.23.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 2 lines
+++
b/drivers/soc/atmel/sfr.c
cut
drivers/soc/atmel/sfr.c line 34
Quoted 12 lines
drivers/soc/atmel/sfr.c new file +12
-0+ +static int atmel_sfr_read (void *context,unsigned int offset, +void *buf,size_t bytes) +{ +struct atmel_sfr_priv *priv = context; +size_t len = bytes /4 ; +int ret; + + ret =regmap_bulk_read (priv->regmap,SFR_SN0 + offset, + buf, len); +if (ret ==0 ) +add_device_randomness (buf, len);
this should be done at probe time, check drivers/nvmem/sunxi_sid.c for an example.
cut
drivers/soc/atmel/sfr.c line 100
Quoted 2 lines
drivers/soc/atmel/sfr.c new file +2
-0+MODULE_LICENSE ("GPL v2" ); +
please don't forget about this line
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel