dt-bindings: nvmem: io: new binding for IO accessible NVMEM devices
PATCH 1/2 dt-bindings: nvmem: io: new binding for IO accessible NVMEM devices
From: Rafał Miłecki <[email protected]>
With the NVMEM layouts binding in place we should now use:
1. NVMEM device access bindings
2. NVMEM content description bindings
This binding allows describing NVMEM devices that can be accessed using IO mappings.
--- .../devicetree/bindings/nvmem/io.yaml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/io.yaml
Documentation/devicetree/bindings/nvmem/io.yaml new file +37 -0
@@ -0,0 +1,37 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/io.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: IO access based NVMEM + +description: | + This binding describes simple NVMEM devices that can be accessed by simply + mapping a predefined IO address. + + It's a generic solution for providing NVMEM content access. The way of + handling actual content may be device specific and can be described using a + proper layout. + +maintainers: + - Rafał Miłecki <[email protected]> + +allOf: + - $ref: nvmem.yaml# + +properties: + compatible: + const: io-nvmem + + reg: + maxItems: 1 + +unevaluatedProperties: false + +examples: + - | + nvmem@10000 { + compatible = "io-nvmem"; + reg = <0x10000000 0x10000>; + };
Signature · 1 line
2.34.1
PATCH 2/2 nvmem: add generic driver for devices with I/O based access
From: Rafał Miłecki <[email protected]>
With nvmem layouts in place we should now work on plain content access NVMEM drivers (e.g. IO one). Actual NVMEM content handling should go to layout drivers.
--- drivers/nvmem/Kconfig | 7 ++++ drivers/nvmem/Makefile | 2 ++ drivers/nvmem/io.c | 79 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 drivers/nvmem/io.c
drivers/nvmem/Kconfig +7 -0
@@ -90,6 +90,13 @@ config NVMEM_IMX_OCOTP_SCU This is a driver for the SCU On-Chip OTP Controller (OCOTP) available on i.MX8 SoCs. +config NVMEM_IO + tristate "IO access based NVMEM support" + depends on HAS_IOMEM + help + This driver provides support for NVMEM devices that can be accessed + using I/O mapping. + config NVMEM_JZ4780_EFUSE tristate "JZ4780 EFUSE Memory Support" depends on MACH_INGENIC || COMPILE_TEST
drivers/nvmem/Makefile +2 -0
@@ -20,6 +20,8 @@ obj-$(CONFIG_NVMEM_IMX_OCOTP) += nvmem-imx-ocotp.o nvmem-imx-ocotp-y := imx-ocotp.o obj-$(CONFIG_NVMEM_IMX_OCOTP_SCU) += nvmem-imx-ocotp-scu.o nvmem-imx-ocotp-scu-y := imx-ocotp-scu.o +obj-$(CONFIG_NVMEM_IO) += nvmem-io.o +nvmem-io-y := io.o obj-$(CONFIG_NVMEM_JZ4780_EFUSE) += nvmem_jz4780_efuse.o nvmem_jz4780_efuse-y := jz4780-efuse.o obj-$(CONFIG_NVMEM_LAN9662_OTPC) += nvmem-lan9662-otpc.o
drivers/nvmem/io.c new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.34.1
Rob Herring
maintainerRe: [PATCH 2/2] nvmem: add generic driver for devices with I/O based access
Quoted 5 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
With nvmem layouts in place we should now work on plain content access NVMEM drivers (e.g. IO one). Actual NVMEM content handling should go to layout drivers.
Surely we have some existing driver that could use this? Point its compatible here and delete the driver.
I'm normally against 'generic' bindings, but for generic drivers. In this case, I think nvmem is simple enough to be generic (hopefully).
Quoted 60 lines
Signed-off-by Rafał Miłecki <[email protected]>--- drivers/nvmem/Kconfig | 7 ++++ drivers/nvmem/Makefile | 2 ++ drivers/nvmem/io.c | 79 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 drivers/nvmem/io.cdrivers/nvmem/Kconfig +7
-0@@ -90,6 +90,13 @@ config NVMEM_IMX_OCOTP_SCU This is a driver for the SCU On-Chip OTP Controller (OCOTP) available on i.MX8 SoCs. +config NVMEM_IO + tristate "IO access based NVMEM support" + depends on HAS_IOMEM + help + This driver provides support for NVMEM devices that can be accessed + using I/O mapping. + config NVMEM_JZ4780_EFUSE tristate "JZ4780 EFUSE Memory Support" depends on MACH_INGENIC || COMPILE_TESTdrivers/nvmem/Makefile +2
-0@@ -20,6 +20,8 @@ obj-$(CONFIG_NVMEM_IMX_OCOTP) += nvmem-imx-ocotp.o nvmem-imx-ocotp-y := imx-ocotp.o obj-$(CONFIG_NVMEM_IMX_OCOTP_SCU) += nvmem-imx-ocotp-scu.o nvmem-imx-ocotp-scu-y := imx-ocotp-scu.o +obj-$(CONFIG_NVMEM_IO) += nvmem-io.o +nvmem-io-y := io.o obj-$(CONFIG_NVMEM_JZ4780_EFUSE) += nvmem_jz4780_efuse.o nvmem_jz4780_efuse-y := jz4780-efuse.o obj-$(CONFIG_NVMEM_LAN9662_OTPC) += nvmem-lan9662-otpc.odrivers/nvmem/io.c new file +14
-0@@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023 Rafał Miłecki <[email protected]> +*/ + +#include <linux/io.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/nvmem-provider.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/slab.h> + +struct io_nvmem {
drivers/nvmem/io.c line 24
Quoted 10 lines
drivers/nvmem/io.c new file +10
-0+void __iomem *base; +}; + +static int io_nvmem_read (void *context,unsigned int offset,void *val,size_t bytes) +{ +struct io_nvmem *priv = context; +u8 *dst = val; + +while (bytes--) + *dst++ =readb (priv->base + offset++);
memcpy_fromio
readb() has a barrier to ensure ordering. Not likely needed here.
Rob
Rob Herring
maintainerQuoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
With the NVMEM layouts binding in place we should now use:
1. NVMEM device access bindings
2. NVMEM content description bindings
Quoted 6 lines
This binding allows describing NVMEM devices that can be accessed using IO mappings.
Signed-off-by Rafał Miłecki <[email protected]>--- .../devicetree/bindings/nvmem/io.yaml | 37 +++++++++++++++++++
What do we call nvmem using ISA/PCI IO space? That was my first thought seeing "IO". Probably unlikely, but still. "MMIO" instead?
Quoted 14 lines
1 file changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/io.yamlDocumentation/devicetree/bindings/nvmem/io.yaml new file +5
-0@@ -0,0 +1,37 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/io.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#
Documentation/devicetree/bindings/nvmem/io.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/nvmem/io.yaml new file +10
-0+ +title: IO access based NVMEM + +description: | + This binding describes simple NVMEM devices that can be accessed by simply + mapping a predefined IO address. + + It's a generic solution for providing NVMEM content access. The way of + handling actual content may be device specific and can be described using a + proper layout.
As the accesses are memory-mapped, the child nodes should also have memory-mapped addresses. IOW, you need 'ranges', '#address-cells', '#size-cells'.
Documentation/devicetree/bindings/nvmem/io.yaml line 28
Quoted 13 lines
Documentation/devicetree/bindings/nvmem/io.yaml new file +13
-0+ +maintainers: + - Rafał Miłecki <[email protected]> + +allOf: + - $ref: nvmem.yaml# + +properties: + compatible: + const: io-nvmem + + reg: + maxItems: 1
The first addition here will be access size restrictions. Perhaps add that now (reg-io-width).
Quoted 12 lines
Documentation/devicetree/bindings/nvmem/io.yaml new file +9
-0+ +unevaluatedProperties: false + +examples: + - | + nvmem@10000 { + compatible = "io-nvmem"; + reg = <0x10000000 0x10000>; + };Signature · 1 line
2.34.1