dt-bindings: nvmem: convert U-Boot env to NVMEM layout
Subsystems (4)
PATCH 1/3 dt-bindings: nvmem: convert U-Boot env to NVMEM layout
From: Rafał Miłecki <[email protected]>
Use "nvmem-layout" and drop unused "mac" label while at it.
---
.../bindings/nvmem/layouts/nvmem-layout.yaml | 1 +
.../nvmem/{ => layouts}/u-boot,env.yaml | 17 +++++++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
rename Documentation/devicetree/bindings/nvmem/{ => layouts}/u-boot,env.yaml (87%)Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml +1 -0
@@ -21,6 +21,7 @@ oneOf: - $ref: fixed-layout.yaml - $ref: kontron,sl28-vpd.yaml - $ref: onie,tlv-layout.yaml + - $ref: u-boot,env.yaml properties: compatible: true
Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml renamed from Documentation/devicetree/bindings/nvmem/u-boot,env.yaml +11 -6
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause %YAML 1.2 --- -$id: http://devicetree.org/schemas/nvmem/u-boot,env.yaml# +$id: http://devicetree.org/schemas/nvmem/layouts/u-boot,env.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: U-Boot environment variables
@@ -72,11 +72,14 @@ examples: }; env: partition@40000 { - compatible = "u-boot,env"; reg = <0x40000 0x10000>; - mac: ethaddr { - #nvmem-cell-cells = <1>; + nvmem-layout { + compatible = "u-boot,env"; + + ethaddr { + #nvmem-cell-cells = <1>; + }; }; }; };
@@ -92,9 +95,11 @@ examples: label = "u-boot"; partition-u-boot-env { - compatible = "brcm,env"; + nvmem-layout { + compatible = "brcm,env"; - ethaddr { + ethaddr { + }; }; }; };
Signature · 1 line
2.35.3
PATCH 2/3 nvmem: core: export nvmem device size
From: Michael Walle <[email protected]>
Export the size of the nvmem device. NVMEM layout drivers might need it and might not have access to the device which is registering the NVMEM device.
--- drivers/nvmem/core.c | 13 +++++++++++++ include/linux/nvmem-consumer.h | 6 ++++++ 2 files changed, 19 insertions(+)
drivers/nvmem/core.c +13 -0
@@ -2224,6 +2224,19 @@ const char *nvmem_dev_name(struct nvmem_device *nvmem) }EXPORT_SYMBOL_GPL (nvmem_dev_name); +/** +* nvmem_device_size() - Get the size of a given nvmem device. +* +* @nvmem: nvmem device. +* +* Return: size of the nvmem device. +*/ +size_t nvmem_device_size (struct nvmem_device *nvmem) +{ +return nvmem->size; +} +EXPORT_SYMBOL_GPL (nvmem_device_size); +static int __init nvmem_init (void ) {return bus_register (&nvmem_bus_type);
include/linux/nvmem-consumer.h +6 -0
@@ -77,6 +77,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf);int nvmem_device_cell_write (struct nvmem_device *nvmem,struct nvmem_cell_info *info,void *buf); +size_t nvmem_device_size (struct nvmem_device *nvmem);const char *nvmem_dev_name (struct nvmem_device *nvmem);
@@ -206,6 +207,11 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem,return -EOPNOTSUPP ; } +static inline size_t nvmem_device_size (struct nvmem_device *nvmem) +{ +return 0 ; +} +static inline const char *nvmem_dev_name (struct nvmem_device *nvmem) {return NULL ;
Signature · 1 line
2.35.3
PATCH 3/3 nvmem: u-boot-env: convert to NVMEM layout
In reply to Rafał MiłeckiFrom: Rafał Miłecki <[email protected]>
This avoids code duplication (NVMEM device access) and allows reusing this on top of other NVMEM devices.
---
drivers/mtd/mtdcore.c | 7 ++
drivers/nvmem/Kconfig | 15 ++-
drivers/nvmem/Makefile | 2 -
drivers/nvmem/layouts/Kconfig | 10 ++
drivers/nvmem/layouts/Makefile | 1 +
drivers/nvmem/{ => layouts}/u-boot-env.c | 112 +++++++++--------------
6 files changed, 68 insertions(+), 79 deletions(-)
rename drivers/nvmem/{ => layouts}/u-boot-env.c (67%)drivers/mtd/mtdcore.c +7 -0
@@ -556,6 +556,13 @@ static int mtd_nvmem_add(struct mtd_info *mtd) config.ignore_wp = true; config.priv = mtd; +if (IS_ENABLED (NVMEM_U_BOOT_ENV ) && + (of_device_is_compatible (node,"u-boot,env" ) || +of_device_is_compatible (node,"brcm,env" ))) { +/* FIXME */ +pr_warn ("Missing support for deprecated U-Boot env binding\n" ); + } + mtd->nvmem =nvmem_register (&config);if (IS_ERR (mtd->nvmem)) {/* Just ignore if there is no NVMEM support in the kernel */
drivers/nvmem/Kconfig +6 -9
@@ -347,18 +347,15 @@ config NVMEM_SUNXI_SID will be called nvmem_sunxi_sid. config NVMEM_U_BOOT_ENV - tristate "U-Boot environment variables support" + bool "U-Boot environment variables support" depends on OF && MTD - select CRC32 - select GENERIC_NET_UTILS + select NVMEM_LAYOUT_U_BOOT_ENV help - U-Boot stores its setup as environment variables. This driver adds - support for verifying & exporting such data. It also exposes variables - as NVMEM cells so they can be referenced by other drivers. - - Currently this drivers works only with env variables on top of MTD. + This option enables support for the old device tree binding describing + U-Boot environment variables block on top of MTD partition. - If compiled as module it will be called nvmem_u-boot-env. + Those bindings have been deprecated in favor of using a proper NVMEM + layout. config NVMEM_UNIPHIER_EFUSE tristate "UniPhier SoCs eFuse support"
drivers/nvmem/Makefile +0 -2
@@ -69,8 +69,6 @@ obj-$(CONFIG_NVMEM_SUNPLUS_OCOTP) += nvmem_sunplus_ocotp.o nvmem_sunplus_ocotp-y := sunplus-ocotp.o obj-$(CONFIG_NVMEM_SUNXI_SID) += nvmem_sunxi_sid.o nvmem_sunxi_sid-y := sunxi_sid.o -obj-$(CONFIG_NVMEM_U_BOOT_ENV) += nvmem_u-boot-env.o -nvmem_u-boot-env-y := u-boot-env.o obj-$(CONFIG_NVMEM_UNIPHIER_EFUSE) += nvmem-uniphier-efuse.o nvmem-uniphier-efuse-y := uniphier-efuse.o obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o
drivers/nvmem/layouts/Kconfig +10 -0
@@ -20,4 +20,14 @@ config NVMEM_LAYOUT_ONIE_TLV If unsure, say N. +config NVMEM_LAYOUT_U_BOOT_ENV + tristate "U-Boot environment variables layout support" + depends on OF + select CRC32 + select GENERIC_NET_UTILS + help + U-Boot stores its setup as environment variables. This driver adds + support for verifying & exporting such data. It also exposes variables + as NVMEM cells so they can be referenced by other drivers. + endmenu
drivers/nvmem/layouts/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) += sl28vpd.o obj-$(CONFIG_NVMEM_LAYOUT_ONIE_TLV) += onie-tlv.o +obj-$(CONFIG_NVMEM_LAYOUT_U_BOOT_ENV) += u-boot-env.o
drivers/nvmem/layouts/u-boot-env.c renamed from drivers/nvmem/u-boot-env.c +44 -68
218 lines not on this page · raw message
Signature · 1 line
2.35.3
Quoted 3 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Use "nvmem-layout" and drop unused "mac" label while at it.
Stupid question perhaps, does the "old" way of doing this still work after this series?
Thanks
Conor.
Quoted 71 lines
Signed-off-by Rafał Miłecki <[email protected]>--- .../bindings/nvmem/layouts/nvmem-layout.yaml | 1 + .../nvmem/{ => layouts}/u-boot,env.yaml | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) rename Documentation/devicetree/bindings/nvmem/{ => layouts}/u-boot,env.yaml (87%)Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml +1
-0@@ -21,6 +21,7 @@ oneOf: - $ref: fixed-layout.yaml - $ref: kontron,sl28-vpd.yaml - $ref: onie,tlv-layout.yaml + - $ref: u-boot,env.yaml properties: compatible: trueDocumentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml renamed from Documentation/devicetree/bindings/nvmem/u-boot,env.yaml +11
-6@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause %YAML 1.2 --- -$id: http://devicetree.org/schemas/nvmem/u-boot,env.yaml# +$id: http://devicetree.org/schemas/nvmem/layouts/u-boot,env.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: U-Boot environment variables@@ -72,11 +72,14 @@ examples: }; env: partition@40000 { - compatible = "u-boot,env"; reg = <0x40000 0x10000>; - mac: ethaddr { - #nvmem-cell-cells = <1>; + nvmem-layout { + compatible = "u-boot,env"; + + ethaddr { + #nvmem-cell-cells = <1>; + }; }; }; };@@ -92,9 +95,11 @@ examples: label = "u-boot"; partition-u-boot-env { - compatible = "brcm,env"; + nvmem-layout { + compatible = "brcm,env"; - ethaddr { + ethaddr { + }; }; }; };Signature · 1 line
2.35.3