public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] nvmem: patches(set 1) for 6.12
@ 2024-09-02 14:29 srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 1/9] dt-bindings: nvmem: imx-ocotp: support i.MX95 srinivas.kandagatla
                   ` (8 more replies)
  0 siblings, 9 replies; 17+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:29 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

Hi Greg,

Here are few patches in nvmem for 6.12 that includes
- updates to dt-bindings 
- adds i.MX95 provider support.
- u-boot env layout support.
- move to use devm_platform_ioremap_resource_byname

Can you please queue them up for 6.12.

Thanks,
Srini


MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Frank Li (1):
  dt-bindings: nvmem: sfp: add ref to nvmem-deprecated-cells.yaml

Krzysztof Kozlowski (1):
  dt-bindings: nvmem: st,stm32-romem: add missing
    "unevaluatedProperties" on child nodes

Matthew Wilcox (1):
  nvmem: Fix misspelling

Peng Fan (2):
  dt-bindings: nvmem: imx-ocotp: support i.MX95
  nvmem: imx-ocotp-ele: support i.MX95

Rafał Miłecki (3):
  dt-bindings: nvmem: convert U-Boot env to a layout
  nvmem: layouts: add U-Boot env layout
  MAINTAINERS: Update path for U-Boot environment variables YAML

Zhang Zekun (1):
  nvmem: sunplus-ocotp: Use devm_platform_ioremap_resource_byname()
    helper function

 Documentation/ABI/stable/sysfs-bus-nvmem      |   2 +-
 .../bindings/nvmem/fsl,layerscape-sfp.yaml    |   1 +
 .../devicetree/bindings/nvmem/imx-ocotp.yaml  |   3 +-
 .../bindings/nvmem/layouts/nvmem-layout.yaml  |   1 +
 .../nvmem/{ => layouts}/u-boot,env.yaml       |  39 +++-
 .../bindings/nvmem/st,stm32-romem.yaml        |   3 +
 MAINTAINERS                                   |   3 +-
 drivers/nvmem/Kconfig                         |   3 +-
 drivers/nvmem/imx-ocotp-ele.c                 |  32 ++-
 drivers/nvmem/layouts/Kconfig                 |  11 +
 drivers/nvmem/layouts/Makefile                |   1 +
 drivers/nvmem/layouts/u-boot-env.c            | 211 ++++++++++++++++++
 drivers/nvmem/layouts/u-boot-env.h            |  15 ++
 drivers/nvmem/sunplus-ocotp.c                 |   7 +-
 drivers/nvmem/u-boot-env.c                    | 165 +-------------
 15 files changed, 316 insertions(+), 181 deletions(-)
 rename Documentation/devicetree/bindings/nvmem/{ => layouts}/u-boot,env.yaml (75%)
 create mode 100644 drivers/nvmem/layouts/u-boot-env.c
 create mode 100644 drivers/nvmem/layouts/u-boot-env.h

-- 
2.25.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/9] dt-bindings: nvmem: imx-ocotp: support i.MX95
  2024-09-02 14:29 [PATCH 0/9] nvmem: patches(set 1) for 6.12 srinivas.kandagatla
@ 2024-09-02 14:29 ` srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 2/9] nvmem: imx-ocotp-ele: " srinivas.kandagatla
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:29 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Peng Fan, Krzysztof Kozlowski, Srinivas Kandagatla

From: Peng Fan <peng.fan@nxp.com>

Add i.MX95 ocotp compatible string

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml b/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml
index e21c06e9a741..b2cb76cf9053 100644
--- a/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml
@@ -14,7 +14,7 @@ maintainers:
 description: |
   This binding represents the on-chip eFuse OTP controller found on
   i.MX6Q/D, i.MX6DL/S, i.MX6SL, i.MX6SX, i.MX6UL, i.MX6ULL/ULZ, i.MX6SLL,
-  i.MX7D/S, i.MX7ULP, i.MX8MQ, i.MX8MM, i.MX8MN i.MX8MP and i.MX93 SoCs.
+  i.MX7D/S, i.MX7ULP, i.MX8MQ, i.MX8MM, i.MX8MN i.MX8MP and i.MX93/5 SoCs.
 
 allOf:
   - $ref: nvmem.yaml#
@@ -36,6 +36,7 @@ properties:
               - fsl,imx8mq-ocotp
               - fsl,imx8mm-ocotp
               - fsl,imx93-ocotp
+              - fsl,imx95-ocotp
           - const: syscon
       - items:
           - enum:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/9] nvmem: imx-ocotp-ele: support i.MX95
  2024-09-02 14:29 [PATCH 0/9] nvmem: patches(set 1) for 6.12 srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 1/9] dt-bindings: nvmem: imx-ocotp: support i.MX95 srinivas.kandagatla
@ 2024-09-02 14:29 ` srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 3/9] dt-bindings: nvmem: convert U-Boot env to a layout srinivas.kandagatla
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:29 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Peng Fan, Srinivas Kandagatla

From: Peng Fan <peng.fan@nxp.com>

i.MX95 OCOTP has same accessing method, so add an entry for i.MX95, but
some fuse has ECC feature, so only read out the lower 16bits for ECC fuses.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/imx-ocotp-ele.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/nvmem/imx-ocotp-ele.c b/drivers/nvmem/imx-ocotp-ele.c
index cf920542f939..1ba494497698 100644
--- a/drivers/nvmem/imx-ocotp-ele.c
+++ b/drivers/nvmem/imx-ocotp-ele.c
@@ -14,8 +14,9 @@
 #include <linux/slab.h>
 
 enum fuse_type {
-	FUSE_FSB = 1,
-	FUSE_ELE = 2,
+	FUSE_FSB = BIT(0),
+	FUSE_ELE = BIT(1),
+	FUSE_ECC = BIT(2),
 	FUSE_INVALID = -1
 };
 
@@ -93,7 +94,10 @@ static int imx_ocotp_reg_read(void *context, unsigned int offset, void *val, siz
 			continue;
 		}
 
-		*buf++ = readl_relaxed(reg + (i << 2));
+		if (type & FUSE_ECC)
+			*buf++ = readl_relaxed(reg + (i << 2)) & GENMASK(15, 0);
+		else
+			*buf++ = readl_relaxed(reg + (i << 2));
 	}
 
 	memcpy(val, (u8 *)p, bytes);
@@ -155,8 +159,30 @@ static const struct ocotp_devtype_data imx93_ocotp_data = {
 	},
 };
 
+static const struct ocotp_devtype_data imx95_ocotp_data = {
+	.reg_off = 0x8000,
+	.reg_read = imx_ocotp_reg_read,
+	.size = 2048,
+	.num_entry = 12,
+	.entry = {
+		{ 0, 1, FUSE_FSB | FUSE_ECC },
+		{ 7, 1, FUSE_FSB | FUSE_ECC },
+		{ 9, 3, FUSE_FSB | FUSE_ECC },
+		{ 12, 24, FUSE_FSB },
+		{ 36, 2, FUSE_FSB  | FUSE_ECC },
+		{ 38, 14, FUSE_FSB },
+		{ 63, 1, FUSE_ELE },
+		{ 128, 16, FUSE_ELE },
+		{ 188, 1, FUSE_ELE },
+		{ 317, 2, FUSE_FSB | FUSE_ECC },
+		{ 320, 7, FUSE_FSB },
+		{ 328, 184, FUSE_FSB }
+	},
+};
+
 static const struct of_device_id imx_ele_ocotp_dt_ids[] = {
 	{ .compatible = "fsl,imx93-ocotp", .data = &imx93_ocotp_data, },
+	{ .compatible = "fsl,imx95-ocotp", .data = &imx95_ocotp_data, },
 	{},
 };
 MODULE_DEVICE_TABLE(of, imx_ele_ocotp_dt_ids);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/9] dt-bindings: nvmem: convert U-Boot env to a layout
  2024-09-02 14:29 [PATCH 0/9] nvmem: patches(set 1) for 6.12 srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 1/9] dt-bindings: nvmem: imx-ocotp: support i.MX95 srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 2/9] nvmem: imx-ocotp-ele: " srinivas.kandagatla
@ 2024-09-02 14:29 ` srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 4/9] nvmem: layouts: add U-Boot env layout srinivas.kandagatla
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:29 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, Rafał Miłecki, Rob Herring,
	Srinivas Kandagatla

From: Rafał Miłecki <rafal@milecki.pl>

U-Boot environment variables can be stored in various data sources. MTD
is just one of available options. Refactor DT binding into a layout so
it can be used with UBI volumes and other NVMEM devices.

Link: https://lore.kernel.org/all/20231221173421.13737-1-zajec5@gmail.com/
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 .../bindings/nvmem/layouts/nvmem-layout.yaml  |  1 +
 .../nvmem/{ => layouts}/u-boot,env.yaml       | 39 ++++++++++++++++---
 2 files changed, 35 insertions(+), 5 deletions(-)
 rename Documentation/devicetree/bindings/nvmem/{ => layouts}/u-boot,env.yaml (75%)

diff --git a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
index 3b40f7880774..382507060651 100644
--- a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
+++ b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
@@ -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
diff --git a/Documentation/devicetree/bindings/nvmem/u-boot,env.yaml b/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
similarity index 75%
rename from Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
rename to Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
index 9c36afc7084b..56a8f55d4a09 100644
--- a/Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
+++ b/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
@@ -1,10 +1,10 @@
 # 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
+title: U-Boot environment variables layout
 
 description: |
   U-Boot uses environment variables to store device parameters and
@@ -21,9 +21,6 @@ description: |
   This binding allows marking storage device (as containing env data) and
   specifying used format.
 
-  Right now only flash partition case is covered but it may be extended to e.g.
-  UBI volumes in the future.
-
   Variables can be defined as NVMEM device subnodes.
 
 maintainers:
@@ -42,6 +39,7 @@ properties:
         const: brcm,env
 
   reg:
+    description: Partition offset and size for env on top of MTD
     maxItems: 1
 
   bootcmd:
@@ -58,6 +56,17 @@ properties:
         description: The first argument is a MAC address offset.
         const: 1
 
+allOf:
+  - if:
+      properties:
+        $nodename:
+          not:
+            contains:
+              pattern: "^partition@[0-9a-f]+$"
+    then:
+      properties:
+        reg: false
+
 additionalProperties: false
 
 examples:
@@ -101,3 +110,23 @@ examples:
             };
         };
     };
+  - |
+    partition@0 {
+        reg = <0x0 0x100000>;
+        label = "ubi";
+        compatible = "linux,ubi";
+
+        volumes {
+            ubi-volume-u-boot-env {
+                volname = "env";
+
+                nvmem-layout {
+                    compatible = "u-boot,env";
+
+                    ethaddr {
+                        #nvmem-cell-cells = <1>;
+                    };
+                };
+            };
+        };
+    };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/9] nvmem: layouts: add U-Boot env layout
  2024-09-02 14:29 [PATCH 0/9] nvmem: patches(set 1) for 6.12 srinivas.kandagatla
                   ` (2 preceding siblings ...)
  2024-09-02 14:29 ` [PATCH 3/9] dt-bindings: nvmem: convert U-Boot env to a layout srinivas.kandagatla
@ 2024-09-02 14:29 ` srinivas.kandagatla
  2024-09-03 10:12   ` Greg KH
  2024-09-02 14:29 ` [PATCH 5/9] MAINTAINERS: Update path for U-Boot environment variables YAML srinivas.kandagatla
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:29 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, Rafał Miłecki, Miquel Raynal,
	Srinivas Kandagatla

From: Rafał Miłecki <rafal@milecki.pl>

U-Boot environment variables are stored in a specific format. Actual
data can be placed in various storage sources (MTD, UBI volume, EEPROM,
NVRAM, etc.).

Move all generic (NVMEM device independent) code from NVMEM device
driver to an NVMEM layout driver. Then add a simple NVMEM layout code on
top of it.

This allows using NVMEM layout for parsing U-Boot env data stored in any
kind of NVMEM device.

The old NVMEM glue driver stays in place for handling bindings in the
MTD context. To avoid code duplication it uses exported layout parsing
function. Please note that handling MTD & NVMEM layout bindings may be
refactored in the future.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 MAINTAINERS                        |   1 +
 drivers/nvmem/Kconfig              |   3 +-
 drivers/nvmem/layouts/Kconfig      |  11 ++
 drivers/nvmem/layouts/Makefile     |   1 +
 drivers/nvmem/layouts/u-boot-env.c | 211 +++++++++++++++++++++++++++++
 drivers/nvmem/layouts/u-boot-env.h |  15 ++
 drivers/nvmem/u-boot-env.c         | 165 +---------------------
 7 files changed, 242 insertions(+), 165 deletions(-)
 create mode 100644 drivers/nvmem/layouts/u-boot-env.c
 create mode 100644 drivers/nvmem/layouts/u-boot-env.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 42decde38320..25fe91a49314 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -23342,6 +23342,7 @@ U-BOOT ENVIRONMENT VARIABLES
 M:	Rafał Miłecki <rafal@milecki.pl>
 S:	Maintained
 F:	Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
+F:	drivers/nvmem/layouts/u-boot-env.c
 F:	drivers/nvmem/u-boot-env.c
 
 UACCE ACCELERATOR FRAMEWORK
diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index 283134498fbc..d2c384f58028 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -363,8 +363,7 @@ config NVMEM_SUNXI_SID
 config NVMEM_U_BOOT_ENV
 	tristate "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
diff --git a/drivers/nvmem/layouts/Kconfig b/drivers/nvmem/layouts/Kconfig
index 9c6e672fc350..5e586dfebe47 100644
--- a/drivers/nvmem/layouts/Kconfig
+++ b/drivers/nvmem/layouts/Kconfig
@@ -26,6 +26,17 @@ config NVMEM_LAYOUT_ONIE_TLV
 
 	  If unsure, say N.
 
+config NVMEM_LAYOUT_U_BOOT_ENV
+	tristate "U-Boot environment variables layout"
+	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.
+
+	  If unsure, say N.
+
 endmenu
 
 endif
diff --git a/drivers/nvmem/layouts/Makefile b/drivers/nvmem/layouts/Makefile
index 2974bd7d33ed..4940c9db0665 100644
--- a/drivers/nvmem/layouts/Makefile
+++ b/drivers/nvmem/layouts/Makefile
@@ -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
diff --git a/drivers/nvmem/layouts/u-boot-env.c b/drivers/nvmem/layouts/u-boot-env.c
new file mode 100644
index 000000000000..731e6f4f12b2
--- /dev/null
+++ b/drivers/nvmem/layouts/u-boot-env.c
@@ -0,0 +1,211 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2022 - 2023 Rafał Miłecki <rafal@milecki.pl>
+ */
+
+#include <linux/crc32.h>
+#include <linux/etherdevice.h>
+#include <linux/export.h>
+#include <linux/if_ether.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of.h>
+#include <linux/slab.h>
+
+#include "u-boot-env.h"
+
+struct u_boot_env_image_single {
+	__le32 crc32;
+	uint8_t data[];
+} __packed;
+
+struct u_boot_env_image_redundant {
+	__le32 crc32;
+	u8 mark;
+	uint8_t data[];
+} __packed;
+
+struct u_boot_env_image_broadcom {
+	__le32 magic;
+	__le32 len;
+	__le32 crc32;
+	DECLARE_FLEX_ARRAY(uint8_t, data);
+} __packed;
+
+static int u_boot_env_read_post_process_ethaddr(void *context, const char *id, int index,
+						unsigned int offset, void *buf, size_t bytes)
+{
+	u8 mac[ETH_ALEN];
+
+	if (bytes != 3 * ETH_ALEN - 1)
+		return -EINVAL;
+
+	if (!mac_pton(buf, mac))
+		return -EINVAL;
+
+	if (index)
+		eth_addr_add(mac, index);
+
+	ether_addr_copy(buf, mac);
+
+	return 0;
+}
+
+static int u_boot_env_parse_cells(struct device *dev, struct nvmem_device *nvmem, uint8_t *buf,
+				  size_t data_offset, size_t data_len)
+{
+	char *data = buf + data_offset;
+	char *var, *value, *eq;
+
+	for (var = data;
+	     var < data + data_len && *var;
+	     var = value + strlen(value) + 1) {
+		struct nvmem_cell_info info = {};
+
+		eq = strchr(var, '=');
+		if (!eq)
+			break;
+		*eq = '\0';
+		value = eq + 1;
+
+		info.name = devm_kstrdup(dev, var, GFP_KERNEL);
+		if (!info.name)
+			return -ENOMEM;
+		info.offset = data_offset + value - data;
+		info.bytes = strlen(value);
+		info.np = of_get_child_by_name(dev->of_node, info.name);
+		if (!strcmp(var, "ethaddr")) {
+			info.raw_len = strlen(value);
+			info.bytes = ETH_ALEN;
+			info.read_post_process = u_boot_env_read_post_process_ethaddr;
+		}
+
+		nvmem_add_one_cell(nvmem, &info);
+	}
+
+	return 0;
+}
+
+int u_boot_env_parse(struct device *dev, struct nvmem_device *nvmem,
+		     enum u_boot_env_format format)
+{
+	size_t crc32_data_offset;
+	size_t crc32_data_len;
+	size_t crc32_offset;
+	__le32 *crc32_addr;
+	size_t data_offset;
+	size_t data_len;
+	size_t dev_size;
+	uint32_t crc32;
+	uint32_t calc;
+	uint8_t *buf;
+	int bytes;
+	int err;
+
+	dev_size = nvmem_dev_size(nvmem);
+
+	buf = kzalloc(dev_size, GFP_KERNEL);
+	if (!buf) {
+		err = -ENOMEM;
+		goto err_out;
+	}
+
+	bytes = nvmem_device_read(nvmem, 0, dev_size, buf);
+	if (bytes < 0) {
+		err = bytes;
+		goto err_kfree;
+	} else if (bytes != dev_size) {
+		err = -EIO;
+		goto err_kfree;
+	}
+
+	switch (format) {
+	case U_BOOT_FORMAT_SINGLE:
+		crc32_offset = offsetof(struct u_boot_env_image_single, crc32);
+		crc32_data_offset = offsetof(struct u_boot_env_image_single, data);
+		data_offset = offsetof(struct u_boot_env_image_single, data);
+		break;
+	case U_BOOT_FORMAT_REDUNDANT:
+		crc32_offset = offsetof(struct u_boot_env_image_redundant, crc32);
+		crc32_data_offset = offsetof(struct u_boot_env_image_redundant, data);
+		data_offset = offsetof(struct u_boot_env_image_redundant, data);
+		break;
+	case U_BOOT_FORMAT_BROADCOM:
+		crc32_offset = offsetof(struct u_boot_env_image_broadcom, crc32);
+		crc32_data_offset = offsetof(struct u_boot_env_image_broadcom, data);
+		data_offset = offsetof(struct u_boot_env_image_broadcom, data);
+		break;
+	}
+
+	if (dev_size < data_offset) {
+		dev_err(dev, "Device too small for u-boot-env\n");
+		err = -EIO;
+		goto err_kfree;
+	}
+
+	crc32_addr = (__le32 *)(buf + crc32_offset);
+	crc32 = le32_to_cpu(*crc32_addr);
+	crc32_data_len = dev_size - crc32_data_offset;
+	data_len = dev_size - data_offset;
+
+	calc = crc32(~0, buf + crc32_data_offset, crc32_data_len) ^ ~0L;
+	if (calc != crc32) {
+		dev_err(dev, "Invalid calculated CRC32: 0x%08x (expected: 0x%08x)\n", calc, crc32);
+		err = -EINVAL;
+		goto err_kfree;
+	}
+
+	buf[dev_size - 1] = '\0';
+	err = u_boot_env_parse_cells(dev, nvmem, buf, data_offset, data_len);
+
+err_kfree:
+	kfree(buf);
+err_out:
+	return err;
+}
+EXPORT_SYMBOL_GPL(u_boot_env_parse);
+
+static int u_boot_env_add_cells(struct nvmem_layout *layout)
+{
+	struct device *dev = &layout->dev;
+	enum u_boot_env_format format;
+
+	format = (uintptr_t)device_get_match_data(dev);
+
+	return u_boot_env_parse(dev, layout->nvmem, format);
+}
+
+static int u_boot_env_probe(struct nvmem_layout *layout)
+{
+	layout->add_cells = u_boot_env_add_cells;
+
+	return nvmem_layout_register(layout);
+}
+
+static void u_boot_env_remove(struct nvmem_layout *layout)
+{
+	nvmem_layout_unregister(layout);
+}
+
+static const struct of_device_id u_boot_env_of_match_table[] = {
+	{ .compatible = "u-boot,env", .data = (void *)U_BOOT_FORMAT_SINGLE, },
+	{ .compatible = "u-boot,env-redundant-bool", .data = (void *)U_BOOT_FORMAT_REDUNDANT, },
+	{ .compatible = "u-boot,env-redundant-count", .data = (void *)U_BOOT_FORMAT_REDUNDANT, },
+	{ .compatible = "brcm,env", .data = (void *)U_BOOT_FORMAT_BROADCOM, },
+	{},
+};
+
+static struct nvmem_layout_driver u_boot_env_layout = {
+	.driver = {
+		.name = "u-boot-env-layout",
+		.of_match_table = u_boot_env_of_match_table,
+	},
+	.probe = u_boot_env_probe,
+	.remove = u_boot_env_remove,
+};
+module_nvmem_layout_driver(u_boot_env_layout);
+
+MODULE_AUTHOR("Rafał Miłecki");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(of, u_boot_env_of_match_table);
+MODULE_DESCRIPTION("NVMEM layout driver for U-Boot environment variables");
diff --git a/drivers/nvmem/layouts/u-boot-env.h b/drivers/nvmem/layouts/u-boot-env.h
new file mode 100644
index 000000000000..dd5f280ac047
--- /dev/null
+++ b/drivers/nvmem/layouts/u-boot-env.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _LINUX_NVMEM_LAYOUTS_U_BOOT_ENV_H
+#define _LINUX_NVMEM_LAYOUTS_U_BOOT_ENV_H
+
+enum u_boot_env_format {
+	U_BOOT_FORMAT_SINGLE,
+	U_BOOT_FORMAT_REDUNDANT,
+	U_BOOT_FORMAT_BROADCOM,
+};
+
+int u_boot_env_parse(struct device *dev, struct nvmem_device *nvmem,
+		     enum u_boot_env_format format);
+
+#endif  /* ifndef _LINUX_NVMEM_LAYOUTS_U_BOOT_ENV_H */
diff --git a/drivers/nvmem/u-boot-env.c b/drivers/nvmem/u-boot-env.c
index 593f0bf4a395..ced414fc9e60 100644
--- a/drivers/nvmem/u-boot-env.c
+++ b/drivers/nvmem/u-boot-env.c
@@ -3,23 +3,15 @@
  * Copyright (C) 2022 Rafał Miłecki <rafal@milecki.pl>
  */
 
-#include <linux/crc32.h>
-#include <linux/etherdevice.h>
-#include <linux/if_ether.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mtd/mtd.h>
-#include <linux/nvmem-consumer.h>
 #include <linux/nvmem-provider.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
-enum u_boot_env_format {
-	U_BOOT_FORMAT_SINGLE,
-	U_BOOT_FORMAT_REDUNDANT,
-	U_BOOT_FORMAT_BROADCOM,
-};
+#include "layouts/u-boot-env.h"
 
 struct u_boot_env {
 	struct device *dev;
@@ -29,24 +21,6 @@ struct u_boot_env {
 	struct mtd_info *mtd;
 };
 
-struct u_boot_env_image_single {
-	__le32 crc32;
-	uint8_t data[];
-} __packed;
-
-struct u_boot_env_image_redundant {
-	__le32 crc32;
-	u8 mark;
-	uint8_t data[];
-} __packed;
-
-struct u_boot_env_image_broadcom {
-	__le32 magic;
-	__le32 len;
-	__le32 crc32;
-	DECLARE_FLEX_ARRAY(uint8_t, data);
-} __packed;
-
 static int u_boot_env_read(void *context, unsigned int offset, void *val,
 			   size_t bytes)
 {
@@ -69,141 +43,6 @@ static int u_boot_env_read(void *context, unsigned int offset, void *val,
 	return 0;
 }
 
-static int u_boot_env_read_post_process_ethaddr(void *context, const char *id, int index,
-						unsigned int offset, void *buf, size_t bytes)
-{
-	u8 mac[ETH_ALEN];
-
-	if (bytes != 3 * ETH_ALEN - 1)
-		return -EINVAL;
-
-	if (!mac_pton(buf, mac))
-		return -EINVAL;
-
-	if (index)
-		eth_addr_add(mac, index);
-
-	ether_addr_copy(buf, mac);
-
-	return 0;
-}
-
-static int u_boot_env_add_cells(struct u_boot_env *priv, uint8_t *buf,
-				size_t data_offset, size_t data_len)
-{
-	struct nvmem_device *nvmem = priv->nvmem;
-	struct device *dev = priv->dev;
-	char *data = buf + data_offset;
-	char *var, *value, *eq;
-
-	for (var = data;
-	     var < data + data_len && *var;
-	     var = value + strlen(value) + 1) {
-		struct nvmem_cell_info info = {};
-
-		eq = strchr(var, '=');
-		if (!eq)
-			break;
-		*eq = '\0';
-		value = eq + 1;
-
-		info.name = devm_kstrdup(dev, var, GFP_KERNEL);
-		if (!info.name)
-			return -ENOMEM;
-		info.offset = data_offset + value - data;
-		info.bytes = strlen(value);
-		info.np = of_get_child_by_name(dev->of_node, info.name);
-		if (!strcmp(var, "ethaddr")) {
-			info.raw_len = strlen(value);
-			info.bytes = ETH_ALEN;
-			info.read_post_process = u_boot_env_read_post_process_ethaddr;
-		}
-
-		nvmem_add_one_cell(nvmem, &info);
-	}
-
-	return 0;
-}
-
-static int u_boot_env_parse(struct u_boot_env *priv)
-{
-	struct nvmem_device *nvmem = priv->nvmem;
-	struct device *dev = priv->dev;
-	size_t crc32_data_offset;
-	size_t crc32_data_len;
-	size_t crc32_offset;
-	__le32 *crc32_addr;
-	size_t data_offset;
-	size_t data_len;
-	size_t dev_size;
-	uint32_t crc32;
-	uint32_t calc;
-	uint8_t *buf;
-	int bytes;
-	int err;
-
-	dev_size = nvmem_dev_size(nvmem);
-
-	buf = kzalloc(dev_size, GFP_KERNEL);
-	if (!buf) {
-		err = -ENOMEM;
-		goto err_out;
-	}
-
-	bytes = nvmem_device_read(nvmem, 0, dev_size, buf);
-	if (bytes < 0) {
-		err = bytes;
-		goto err_kfree;
-	} else if (bytes != dev_size) {
-		err = -EIO;
-		goto err_kfree;
-	}
-
-	switch (priv->format) {
-	case U_BOOT_FORMAT_SINGLE:
-		crc32_offset = offsetof(struct u_boot_env_image_single, crc32);
-		crc32_data_offset = offsetof(struct u_boot_env_image_single, data);
-		data_offset = offsetof(struct u_boot_env_image_single, data);
-		break;
-	case U_BOOT_FORMAT_REDUNDANT:
-		crc32_offset = offsetof(struct u_boot_env_image_redundant, crc32);
-		crc32_data_offset = offsetof(struct u_boot_env_image_redundant, data);
-		data_offset = offsetof(struct u_boot_env_image_redundant, data);
-		break;
-	case U_BOOT_FORMAT_BROADCOM:
-		crc32_offset = offsetof(struct u_boot_env_image_broadcom, crc32);
-		crc32_data_offset = offsetof(struct u_boot_env_image_broadcom, data);
-		data_offset = offsetof(struct u_boot_env_image_broadcom, data);
-		break;
-	}
-
-	if (dev_size < data_offset) {
-		dev_err(dev, "Device too small for u-boot-env\n");
-		err = -EIO;
-		goto err_kfree;
-	}
-
-	crc32_addr = (__le32 *)(buf + crc32_offset);
-	crc32 = le32_to_cpu(*crc32_addr);
-	crc32_data_len = dev_size - crc32_data_offset;
-	data_len = dev_size - data_offset;
-
-	calc = crc32(~0, buf + crc32_data_offset, crc32_data_len) ^ ~0L;
-	if (calc != crc32) {
-		dev_err(dev, "Invalid calculated CRC32: 0x%08x (expected: 0x%08x)\n", calc, crc32);
-		err = -EINVAL;
-		goto err_kfree;
-	}
-
-	buf[dev_size - 1] = '\0';
-	err = u_boot_env_add_cells(priv, buf, data_offset, data_len);
-
-err_kfree:
-	kfree(buf);
-err_out:
-	return err;
-}
-
 static int u_boot_env_probe(struct platform_device *pdev)
 {
 	struct nvmem_config config = {
@@ -235,7 +74,7 @@ static int u_boot_env_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->nvmem))
 		return PTR_ERR(priv->nvmem);
 
-	return u_boot_env_parse(priv);
+	return u_boot_env_parse(dev, priv->nvmem, priv->format);
 }
 
 static const struct of_device_id u_boot_env_of_match_table[] = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/9] MAINTAINERS: Update path for U-Boot environment variables YAML
  2024-09-02 14:29 [PATCH 0/9] nvmem: patches(set 1) for 6.12 srinivas.kandagatla
                   ` (3 preceding siblings ...)
  2024-09-02 14:29 ` [PATCH 4/9] nvmem: layouts: add U-Boot env layout srinivas.kandagatla
@ 2024-09-02 14:29 ` srinivas.kandagatla
  2024-09-03 10:13   ` Greg KH
  2024-09-02 14:29 ` [PATCH 6/9] dt-bindings: nvmem: st,stm32-romem: add missing "unevaluatedProperties" on child nodes srinivas.kandagatla
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:29 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Rafał Miłecki, Srinivas Kandagatla

From: Rafał Miłecki <rafal@milecki.pl>

This file was moved to the layouts/ subdirectory.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 25fe91a49314..fb25e47adda4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -23341,7 +23341,7 @@ F:	drivers/media/pci/tw686x/
 U-BOOT ENVIRONMENT VARIABLES
 M:	Rafał Miłecki <rafal@milecki.pl>
 S:	Maintained
-F:	Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
+F:	Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
 F:	drivers/nvmem/layouts/u-boot-env.c
 F:	drivers/nvmem/u-boot-env.c
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 6/9] dt-bindings: nvmem: st,stm32-romem: add missing "unevaluatedProperties" on child nodes
  2024-09-02 14:29 [PATCH 0/9] nvmem: patches(set 1) for 6.12 srinivas.kandagatla
                   ` (4 preceding siblings ...)
  2024-09-02 14:29 ` [PATCH 5/9] MAINTAINERS: Update path for U-Boot environment variables YAML srinivas.kandagatla
@ 2024-09-02 14:29 ` srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 7/9] nvmem: sunplus-ocotp: Use devm_platform_ioremap_resource_byname() helper function srinivas.kandagatla
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:29 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Krzysztof Kozlowski, Conor Dooley,
	Srinivas Kandagatla

From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

All nodes need an explicit additionalProperties or unevaluatedProperties
unless a $ref has one that's false.  Fixing this for STM32
Factory-programmed data binding needs referencing fixed layout schema
for children.  Add reference to the NVMEM deprecated cells for the
schema to be complete.

This fixes dt_binding_check warning:

  st,stm32-romem.yaml: ^.*@[0-9a-f]+$: Missing additionalProperties/unevaluatedProperties constraint

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 Documentation/devicetree/bindings/nvmem/st,stm32-romem.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/nvmem/st,stm32-romem.yaml b/Documentation/devicetree/bindings/nvmem/st,stm32-romem.yaml
index 92bfe25f0571..3b2aa605a551 100644
--- a/Documentation/devicetree/bindings/nvmem/st,stm32-romem.yaml
+++ b/Documentation/devicetree/bindings/nvmem/st,stm32-romem.yaml
@@ -17,6 +17,7 @@ maintainers:
 
 allOf:
   - $ref: nvmem.yaml#
+  - $ref: nvmem-deprecated-cells.yaml#
 
 properties:
   compatible:
@@ -32,6 +33,8 @@ properties:
 patternProperties:
   "^.*@[0-9a-f]+$":
     type: object
+    $ref: layouts/fixed-cell.yaml
+    unevaluatedProperties: false
 
     properties:
       st,non-secure-otp:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 7/9] nvmem: sunplus-ocotp: Use devm_platform_ioremap_resource_byname() helper function
  2024-09-02 14:29 [PATCH 0/9] nvmem: patches(set 1) for 6.12 srinivas.kandagatla
                   ` (5 preceding siblings ...)
  2024-09-02 14:29 ` [PATCH 6/9] dt-bindings: nvmem: st,stm32-romem: add missing "unevaluatedProperties" on child nodes srinivas.kandagatla
@ 2024-09-02 14:29 ` srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 8/9] nvmem: Fix misspelling srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 9/9] dt-bindings: nvmem: sfp: add ref to nvmem-deprecated-cells.yaml srinivas.kandagatla
  8 siblings, 0 replies; 17+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:29 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Zhang Zekun, Srinivas Kandagatla

From: Zhang Zekun <zhangzekun11@huawei.com>

platform_get_resource_byname() and devm_ioremap_resource() can be
replaced by devm_platform_ioremap_resource_byname(), which can
simplify the code logic a bit, No functional change here.

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/sunplus-ocotp.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/nvmem/sunplus-ocotp.c b/drivers/nvmem/sunplus-ocotp.c
index 38f5d9df39cd..30d55b111a64 100644
--- a/drivers/nvmem/sunplus-ocotp.c
+++ b/drivers/nvmem/sunplus-ocotp.c
@@ -159,7 +159,6 @@ static int sp_ocotp_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct nvmem_device *nvmem;
 	struct sp_ocotp_priv *otp;
-	struct resource *res;
 	int ret;
 
 	otp = devm_kzalloc(dev, sizeof(*otp), GFP_KERNEL);
@@ -168,13 +167,11 @@ static int sp_ocotp_probe(struct platform_device *pdev)
 
 	otp->dev = dev;
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hb_gpio");
-	otp->base[HB_GPIO] = devm_ioremap_resource(dev, res);
+	otp->base[HB_GPIO] = devm_platform_ioremap_resource_byname(pdev, "hb_gpio");
 	if (IS_ERR(otp->base[HB_GPIO]))
 		return PTR_ERR(otp->base[HB_GPIO]);
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "otprx");
-	otp->base[OTPRX] = devm_ioremap_resource(dev, res);
+	otp->base[OTPRX] = devm_platform_ioremap_resource_byname(pdev, "otprx");
 	if (IS_ERR(otp->base[OTPRX]))
 		return PTR_ERR(otp->base[OTPRX]);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 8/9] nvmem: Fix misspelling
  2024-09-02 14:29 [PATCH 0/9] nvmem: patches(set 1) for 6.12 srinivas.kandagatla
                   ` (6 preceding siblings ...)
  2024-09-02 14:29 ` [PATCH 7/9] nvmem: sunplus-ocotp: Use devm_platform_ioremap_resource_byname() helper function srinivas.kandagatla
@ 2024-09-02 14:29 ` srinivas.kandagatla
  2024-09-02 14:29 ` [PATCH 9/9] dt-bindings: nvmem: sfp: add ref to nvmem-deprecated-cells.yaml srinivas.kandagatla
  8 siblings, 0 replies; 17+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:29 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Matthew Wilcox, Marek Vasut, Srinivas Kandagatla

From: Matthew Wilcox <willy@infradead.org>

There is no function called kstrbool().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 Documentation/ABI/stable/sysfs-bus-nvmem | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/ABI/stable/sysfs-bus-nvmem b/Documentation/ABI/stable/sysfs-bus-nvmem
index aa89adf18bc5..0ae8cb074acf 100644
--- a/Documentation/ABI/stable/sysfs-bus-nvmem
+++ b/Documentation/ABI/stable/sysfs-bus-nvmem
@@ -11,7 +11,7 @@ Description:
 		Read returns '0' or '1' for read-write or read-only modes
 		respectively.
 		Write parses one of 'YyTt1NnFf0', or [oO][NnFf] for "on"
-		and "off", i.e. what kstrbool() supports.
+		and "off", i.e. what kstrtobool() supports.
 		Note: This file is only present if CONFIG_NVMEM_SYSFS
 		is enabled.
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 9/9] dt-bindings: nvmem: sfp: add ref to nvmem-deprecated-cells.yaml
  2024-09-02 14:29 [PATCH 0/9] nvmem: patches(set 1) for 6.12 srinivas.kandagatla
                   ` (7 preceding siblings ...)
  2024-09-02 14:29 ` [PATCH 8/9] nvmem: Fix misspelling srinivas.kandagatla
@ 2024-09-02 14:29 ` srinivas.kandagatla
  8 siblings, 0 replies; 17+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:29 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Frank Li, Krzysztof Kozlowski, Srinivas Kandagatla

From: Frank Li <Frank.Li@nxp.com>

Add ref nvmem-deprecated-cells.yaml to support old style binding.

Fix below CHECK_DTBS warning.
efuse@1e80000: Unevaluated properties are not allowed ('unique-id@1c' was unexpected)

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
index 70fb2ad25103..1b20b49eee79 100644
--- a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
@@ -15,6 +15,7 @@ description: |
 
 allOf:
   - $ref: nvmem.yaml#
+  - $ref: nvmem-deprecated-cells.yaml
 
 properties:
   compatible:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/9] nvmem: layouts: add U-Boot env layout
  2024-09-02 14:29 ` [PATCH 4/9] nvmem: layouts: add U-Boot env layout srinivas.kandagatla
@ 2024-09-03 10:12   ` Greg KH
  2024-09-03 10:55     ` Srinivas Kandagatla
  2024-09-03 11:04     ` Rafał Miłecki
  0 siblings, 2 replies; 17+ messages in thread
From: Greg KH @ 2024-09-03 10:12 UTC (permalink / raw)
  To: srinivas.kandagatla; +Cc: linux-kernel, Rafał Miłecki, Miquel Raynal

On Mon, Sep 02, 2024 at 03:29:47PM +0100, srinivas.kandagatla@linaro.org wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> U-Boot environment variables are stored in a specific format. Actual
> data can be placed in various storage sources (MTD, UBI volume, EEPROM,
> NVRAM, etc.).
> 
> Move all generic (NVMEM device independent) code from NVMEM device
> driver to an NVMEM layout driver. Then add a simple NVMEM layout code on
> top of it.
> 
> This allows using NVMEM layout for parsing U-Boot env data stored in any
> kind of NVMEM device.
> 
> The old NVMEM glue driver stays in place for handling bindings in the
> MTD context. To avoid code duplication it uses exported layout parsing
> function. Please note that handling MTD & NVMEM layout bindings may be
> refactored in the future.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  MAINTAINERS                        |   1 +
>  drivers/nvmem/Kconfig              |   3 +-
>  drivers/nvmem/layouts/Kconfig      |  11 ++
>  drivers/nvmem/layouts/Makefile     |   1 +
>  drivers/nvmem/layouts/u-boot-env.c | 211 +++++++++++++++++++++++++++++
>  drivers/nvmem/layouts/u-boot-env.h |  15 ++
>  drivers/nvmem/u-boot-env.c         | 165 +---------------------
>  7 files changed, 242 insertions(+), 165 deletions(-)
>  create mode 100644 drivers/nvmem/layouts/u-boot-env.c
>  create mode 100644 drivers/nvmem/layouts/u-boot-env.h

This patch doesn't apply to my tree :(

Also, if you generate patches with 'git format-patch -M' you can see
when files move easier (if that's what happened here, hard to tell..)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/9] MAINTAINERS: Update path for U-Boot environment variables YAML
  2024-09-02 14:29 ` [PATCH 5/9] MAINTAINERS: Update path for U-Boot environment variables YAML srinivas.kandagatla
@ 2024-09-03 10:13   ` Greg KH
  0 siblings, 0 replies; 17+ messages in thread
From: Greg KH @ 2024-09-03 10:13 UTC (permalink / raw)
  To: srinivas.kandagatla; +Cc: linux-kernel, Rafał Miłecki

On Mon, Sep 02, 2024 at 03:29:48PM +0100, srinivas.kandagatla@linaro.org wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> This file was moved to the layouts/ subdirectory.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 25fe91a49314..fb25e47adda4 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -23341,7 +23341,7 @@ F:	drivers/media/pci/tw686x/
>  U-BOOT ENVIRONMENT VARIABLES
>  M:	Rafał Miłecki <rafal@milecki.pl>
>  S:	Maintained
> -F:	Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
> +F:	Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml
>  F:	drivers/nvmem/layouts/u-boot-env.c
>  F:	drivers/nvmem/u-boot-env.c

Also does not apply because patch 4/9 did not :(

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/9] nvmem: layouts: add U-Boot env layout
  2024-09-03 10:12   ` Greg KH
@ 2024-09-03 10:55     ` Srinivas Kandagatla
  2024-09-03 11:04     ` Rafał Miłecki
  1 sibling, 0 replies; 17+ messages in thread
From: Srinivas Kandagatla @ 2024-09-03 10:55 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, Rafał Miłecki, Miquel Raynal



On 03/09/2024 11:12, Greg KH wrote:
> On Mon, Sep 02, 2024 at 03:29:47PM +0100, srinivas.kandagatla@linaro.org wrote:
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> U-Boot environment variables are stored in a specific format. Actual
>> data can be placed in various storage sources (MTD, UBI volume, EEPROM,
>> NVRAM, etc.).
>>
>> Move all generic (NVMEM device independent) code from NVMEM device
>> driver to an NVMEM layout driver. Then add a simple NVMEM layout code on
>> top of it.
>>
>> This allows using NVMEM layout for parsing U-Boot env data stored in any
>> kind of NVMEM device.
>>
>> The old NVMEM glue driver stays in place for handling bindings in the
>> MTD context. To avoid code duplication it uses exported layout parsing
>> function. Please note that handling MTD & NVMEM layout bindings may be
>> refactored in the future.
>>
>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>>   MAINTAINERS                        |   1 +
>>   drivers/nvmem/Kconfig              |   3 +-
>>   drivers/nvmem/layouts/Kconfig      |  11 ++
>>   drivers/nvmem/layouts/Makefile     |   1 +
>>   drivers/nvmem/layouts/u-boot-env.c | 211 +++++++++++++++++++++++++++++
>>   drivers/nvmem/layouts/u-boot-env.h |  15 ++
>>   drivers/nvmem/u-boot-env.c         | 165 +---------------------
>>   7 files changed, 242 insertions(+), 165 deletions(-)
>>   create mode 100644 drivers/nvmem/layouts/u-boot-env.c
>>   create mode 100644 drivers/nvmem/layouts/u-boot-env.h
> 
> This patch doesn't apply to my tree :(
> 
> Also, if you generate patches with 'git format-patch -M' you can see
> when files move easier (if that's what happened here, hard to tell..)
> 

Let me rebase this again on top of char-misc and resend it.

It might be the case that this was dependent on some of the fixes.

--srini
> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/9] nvmem: layouts: add U-Boot env layout
  2024-09-03 10:12   ` Greg KH
  2024-09-03 10:55     ` Srinivas Kandagatla
@ 2024-09-03 11:04     ` Rafał Miłecki
  2024-09-03 11:24       ` Greg KH
  1 sibling, 1 reply; 17+ messages in thread
From: Rafał Miłecki @ 2024-09-03 11:04 UTC (permalink / raw)
  To: Greg KH; +Cc: srinivas.kandagatla, linux-kernel, Miquel Raynal

Hi Greg,

On 2024-09-03 12:12, Greg KH wrote:
> On Mon, Sep 02, 2024 at 03:29:47PM +0100, 
> srinivas.kandagatla@linaro.org wrote:
>> From: Rafał Miłecki <rafal@milecki.pl>
>> 
>> U-Boot environment variables are stored in a specific format. Actual
>> data can be placed in various storage sources (MTD, UBI volume, 
>> EEPROM,
>> NVRAM, etc.).
>> 
>> Move all generic (NVMEM device independent) code from NVMEM device
>> driver to an NVMEM layout driver. Then add a simple NVMEM layout code 
>> on
>> top of it.
>> 
>> This allows using NVMEM layout for parsing U-Boot env data stored in 
>> any
>> kind of NVMEM device.
>> 
>> The old NVMEM glue driver stays in place for handling bindings in the
>> MTD context. To avoid code duplication it uses exported layout parsing
>> function. Please note that handling MTD & NVMEM layout bindings may be
>> refactored in the future.
>> 
>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>>  MAINTAINERS                        |   1 +
>>  drivers/nvmem/Kconfig              |   3 +-
>>  drivers/nvmem/layouts/Kconfig      |  11 ++
>>  drivers/nvmem/layouts/Makefile     |   1 +
>>  drivers/nvmem/layouts/u-boot-env.c | 211 
>> +++++++++++++++++++++++++++++
>>  drivers/nvmem/layouts/u-boot-env.h |  15 ++
>>  drivers/nvmem/u-boot-env.c         | 165 +---------------------
>>  7 files changed, 242 insertions(+), 165 deletions(-)
>>  create mode 100644 drivers/nvmem/layouts/u-boot-env.c
>>  create mode 100644 drivers/nvmem/layouts/u-boot-env.h
> 
> This patch doesn't apply to my tree :(
> 
> Also, if you generate patches with 'git format-patch -M' you can see
> when files move easier (if that's what happened here, hard to tell..)

It's because it was developed on top of "nvmem: u-boot-env: error if 
NVMEM device is too small" which you applied to the "char-misc-linus" 
branch. Perhaps you could push that fix ("error if...") to your both 
branches somehow?

-- 
Rafał Miłecki

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/9] nvmem: layouts: add U-Boot env layout
  2024-09-03 11:04     ` Rafał Miłecki
@ 2024-09-03 11:24       ` Greg KH
  2024-09-10 13:24         ` Rafał Miłecki
  0 siblings, 1 reply; 17+ messages in thread
From: Greg KH @ 2024-09-03 11:24 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: srinivas.kandagatla, linux-kernel, Miquel Raynal

On Tue, Sep 03, 2024 at 01:04:20PM +0200, Rafał Miłecki wrote:
> Hi Greg,
> 
> On 2024-09-03 12:12, Greg KH wrote:
> > On Mon, Sep 02, 2024 at 03:29:47PM +0100, srinivas.kandagatla@linaro.org
> > wrote:
> > > From: Rafał Miłecki <rafal@milecki.pl>
> > > 
> > > U-Boot environment variables are stored in a specific format. Actual
> > > data can be placed in various storage sources (MTD, UBI volume,
> > > EEPROM,
> > > NVRAM, etc.).
> > > 
> > > Move all generic (NVMEM device independent) code from NVMEM device
> > > driver to an NVMEM layout driver. Then add a simple NVMEM layout
> > > code on
> > > top of it.
> > > 
> > > This allows using NVMEM layout for parsing U-Boot env data stored in
> > > any
> > > kind of NVMEM device.
> > > 
> > > The old NVMEM glue driver stays in place for handling bindings in the
> > > MTD context. To avoid code duplication it uses exported layout parsing
> > > function. Please note that handling MTD & NVMEM layout bindings may be
> > > refactored in the future.
> > > 
> > > Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> > > Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > > Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > > ---
> > >  MAINTAINERS                        |   1 +
> > >  drivers/nvmem/Kconfig              |   3 +-
> > >  drivers/nvmem/layouts/Kconfig      |  11 ++
> > >  drivers/nvmem/layouts/Makefile     |   1 +
> > >  drivers/nvmem/layouts/u-boot-env.c | 211
> > > +++++++++++++++++++++++++++++
> > >  drivers/nvmem/layouts/u-boot-env.h |  15 ++
> > >  drivers/nvmem/u-boot-env.c         | 165 +---------------------
> > >  7 files changed, 242 insertions(+), 165 deletions(-)
> > >  create mode 100644 drivers/nvmem/layouts/u-boot-env.c
> > >  create mode 100644 drivers/nvmem/layouts/u-boot-env.h
> > 
> > This patch doesn't apply to my tree :(
> > 
> > Also, if you generate patches with 'git format-patch -M' you can see
> > when files move easier (if that's what happened here, hard to tell..)
> 
> It's because it was developed on top of "nvmem: u-boot-env: error if NVMEM
> device is too small" which you applied to the "char-misc-linus" branch.
> Perhaps you could push that fix ("error if...") to your both branches
> somehow?

I can pull the char-misc-linus branch into my -next branch if that would
help out here?  Give me a few days to let 0-day run on things to make
sure they are all sane first.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/9] nvmem: layouts: add U-Boot env layout
  2024-09-03 11:24       ` Greg KH
@ 2024-09-10 13:24         ` Rafał Miłecki
  2024-09-11 14:06           ` Greg KH
  0 siblings, 1 reply; 17+ messages in thread
From: Rafał Miłecki @ 2024-09-10 13:24 UTC (permalink / raw)
  To: Greg KH; +Cc: srinivas.kandagatla, linux-kernel, Miquel Raynal

On 2024-09-03 13:24, Greg KH wrote:
> On Tue, Sep 03, 2024 at 01:04:20PM +0200, Rafał Miłecki wrote:
>> Hi Greg,
>> 
>> On 2024-09-03 12:12, Greg KH wrote:
>> > On Mon, Sep 02, 2024 at 03:29:47PM +0100, srinivas.kandagatla@linaro.org
>> > wrote:
>> > > From: Rafał Miłecki <rafal@milecki.pl>
>> > >
>> > > U-Boot environment variables are stored in a specific format. Actual
>> > > data can be placed in various storage sources (MTD, UBI volume,
>> > > EEPROM,
>> > > NVRAM, etc.).
>> > >
>> > > Move all generic (NVMEM device independent) code from NVMEM device
>> > > driver to an NVMEM layout driver. Then add a simple NVMEM layout
>> > > code on
>> > > top of it.
>> > >
>> > > This allows using NVMEM layout for parsing U-Boot env data stored in
>> > > any
>> > > kind of NVMEM device.
>> > >
>> > > The old NVMEM glue driver stays in place for handling bindings in the
>> > > MTD context. To avoid code duplication it uses exported layout parsing
>> > > function. Please note that handling MTD & NVMEM layout bindings may be
>> > > refactored in the future.
>> > >
>> > > Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>> > > Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
>> > > Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> > > ---
>> > >  MAINTAINERS                        |   1 +
>> > >  drivers/nvmem/Kconfig              |   3 +-
>> > >  drivers/nvmem/layouts/Kconfig      |  11 ++
>> > >  drivers/nvmem/layouts/Makefile     |   1 +
>> > >  drivers/nvmem/layouts/u-boot-env.c | 211
>> > > +++++++++++++++++++++++++++++
>> > >  drivers/nvmem/layouts/u-boot-env.h |  15 ++
>> > >  drivers/nvmem/u-boot-env.c         | 165 +---------------------
>> > >  7 files changed, 242 insertions(+), 165 deletions(-)
>> > >  create mode 100644 drivers/nvmem/layouts/u-boot-env.c
>> > >  create mode 100644 drivers/nvmem/layouts/u-boot-env.h
>> >
>> > This patch doesn't apply to my tree :(
>> >
>> > Also, if you generate patches with 'git format-patch -M' you can see
>> > when files move easier (if that's what happened here, hard to tell..)
>> 
>> It's because it was developed on top of "nvmem: u-boot-env: error if 
>> NVMEM
>> device is too small" which you applied to the "char-misc-linus" 
>> branch.
>> Perhaps you could push that fix ("error if...") to your both branches
>> somehow?
> 
> I can pull the char-misc-linus branch into my -next branch if that 
> would
> help out here?  Give me a few days to let 0-day run on things to make
> sure they are all sane first.

FWIW I can confirm that
[PATCH 4/9] nvmem: layouts: add U-Boot env layout
[PATCH 5/9] MAINTAINERS: Update path for U-Boot environment variables 
YAML
apply cleanly on top of the "char-misc-next".

-- 
Rafał Miłecki

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/9] nvmem: layouts: add U-Boot env layout
  2024-09-10 13:24         ` Rafał Miłecki
@ 2024-09-11 14:06           ` Greg KH
  0 siblings, 0 replies; 17+ messages in thread
From: Greg KH @ 2024-09-11 14:06 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: srinivas.kandagatla, linux-kernel, Miquel Raynal

On Tue, Sep 10, 2024 at 03:24:33PM +0200, Rafał Miłecki wrote:
> On 2024-09-03 13:24, Greg KH wrote:
> > On Tue, Sep 03, 2024 at 01:04:20PM +0200, Rafał Miłecki wrote:
> > > Hi Greg,
> > > 
> > > On 2024-09-03 12:12, Greg KH wrote:
> > > > On Mon, Sep 02, 2024 at 03:29:47PM +0100, srinivas.kandagatla@linaro.org
> > > > wrote:
> > > > > From: Rafał Miłecki <rafal@milecki.pl>
> > > > >
> > > > > U-Boot environment variables are stored in a specific format. Actual
> > > > > data can be placed in various storage sources (MTD, UBI volume,
> > > > > EEPROM,
> > > > > NVRAM, etc.).
> > > > >
> > > > > Move all generic (NVMEM device independent) code from NVMEM device
> > > > > driver to an NVMEM layout driver. Then add a simple NVMEM layout
> > > > > code on
> > > > > top of it.
> > > > >
> > > > > This allows using NVMEM layout for parsing U-Boot env data stored in
> > > > > any
> > > > > kind of NVMEM device.
> > > > >
> > > > > The old NVMEM glue driver stays in place for handling bindings in the
> > > > > MTD context. To avoid code duplication it uses exported layout parsing
> > > > > function. Please note that handling MTD & NVMEM layout bindings may be
> > > > > refactored in the future.
> > > > >
> > > > > Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> > > > > Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > > > > Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > > > > ---
> > > > >  MAINTAINERS                        |   1 +
> > > > >  drivers/nvmem/Kconfig              |   3 +-
> > > > >  drivers/nvmem/layouts/Kconfig      |  11 ++
> > > > >  drivers/nvmem/layouts/Makefile     |   1 +
> > > > >  drivers/nvmem/layouts/u-boot-env.c | 211
> > > > > +++++++++++++++++++++++++++++
> > > > >  drivers/nvmem/layouts/u-boot-env.h |  15 ++
> > > > >  drivers/nvmem/u-boot-env.c         | 165 +---------------------
> > > > >  7 files changed, 242 insertions(+), 165 deletions(-)
> > > > >  create mode 100644 drivers/nvmem/layouts/u-boot-env.c
> > > > >  create mode 100644 drivers/nvmem/layouts/u-boot-env.h
> > > >
> > > > This patch doesn't apply to my tree :(
> > > >
> > > > Also, if you generate patches with 'git format-patch -M' you can see
> > > > when files move easier (if that's what happened here, hard to tell..)
> > > 
> > > It's because it was developed on top of "nvmem: u-boot-env: error if
> > > NVMEM
> > > device is too small" which you applied to the "char-misc-linus"
> > > branch.
> > > Perhaps you could push that fix ("error if...") to your both branches
> > > somehow?
> > 
> > I can pull the char-misc-linus branch into my -next branch if that would
> > help out here?  Give me a few days to let 0-day run on things to make
> > sure they are all sane first.
> 
> FWIW I can confirm that
> [PATCH 4/9] nvmem: layouts: add U-Boot env layout
> [PATCH 5/9] MAINTAINERS: Update path for U-Boot environment variables YAML
> apply cleanly on top of the "char-misc-next".

Ok, that worked, both now applied, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2024-09-11 14:06 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-02 14:29 [PATCH 0/9] nvmem: patches(set 1) for 6.12 srinivas.kandagatla
2024-09-02 14:29 ` [PATCH 1/9] dt-bindings: nvmem: imx-ocotp: support i.MX95 srinivas.kandagatla
2024-09-02 14:29 ` [PATCH 2/9] nvmem: imx-ocotp-ele: " srinivas.kandagatla
2024-09-02 14:29 ` [PATCH 3/9] dt-bindings: nvmem: convert U-Boot env to a layout srinivas.kandagatla
2024-09-02 14:29 ` [PATCH 4/9] nvmem: layouts: add U-Boot env layout srinivas.kandagatla
2024-09-03 10:12   ` Greg KH
2024-09-03 10:55     ` Srinivas Kandagatla
2024-09-03 11:04     ` Rafał Miłecki
2024-09-03 11:24       ` Greg KH
2024-09-10 13:24         ` Rafał Miłecki
2024-09-11 14:06           ` Greg KH
2024-09-02 14:29 ` [PATCH 5/9] MAINTAINERS: Update path for U-Boot environment variables YAML srinivas.kandagatla
2024-09-03 10:13   ` Greg KH
2024-09-02 14:29 ` [PATCH 6/9] dt-bindings: nvmem: st,stm32-romem: add missing "unevaluatedProperties" on child nodes srinivas.kandagatla
2024-09-02 14:29 ` [PATCH 7/9] nvmem: sunplus-ocotp: Use devm_platform_ioremap_resource_byname() helper function srinivas.kandagatla
2024-09-02 14:29 ` [PATCH 8/9] nvmem: Fix misspelling srinivas.kandagatla
2024-09-02 14:29 ` [PATCH 9/9] dt-bindings: nvmem: sfp: add ref to nvmem-deprecated-cells.yaml srinivas.kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox