2022-11-18 06:53:58

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 00/13] nvmem: patches (set 1) for 6.2

Hi Greg,

Here are some nvmem patches for 6.2 which includes

- Adding bindings for new ONIE and sl28 vpd nvmem layouts
- few enhacements to stm32 provider.
- add Broadcom format support int u-boot-env provider.
- 2 typo fixes

Can you please queue them up for 6.2.

thanks for you help,
srini

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

Colin Ian King (1):
nvmem: Kconfig: Fix spelling mistake "controlls" -> "controls"

Jiangshan Yi (1):
nvmem: stm32: fix spelling typo in comment

Michael Walle (1):
dt-bindings: nvmem: add YAML schema for the sl28 vpd layout

Miquel Raynal (5):
dt-bindings: nvmem: Fix example
dt-bindings: nvmem: Introduce the nvmem-layout container
dt-bindings: eeprom: Inherit from nvmem.yaml
dt-bindings: vendor-prefixes: Add ONIE
dt-bindings: nvmem: add YAML schema for the ONIE tlv layout

Patrick Delaunay (4):
nvmem: stm32: move STM32MP15_BSEC_NUM_LOWER in config
nvmem: stm32: add warning when upper OTPs are updated
nvmem: stm32: add nvmem type attribute
dt-bindings: nvmem: add new stm32mp13 compatible for stm32-romem

Rafał Miłecki (1):
nvmem: u-boot-env: add Broadcom format support

.../devicetree/bindings/eeprom/at24.yaml | 5 +-
.../devicetree/bindings/eeprom/at25.yaml | 1 +
.../bindings/eeprom/microchip,93lc46b.yaml | 1 +
.../nvmem/layouts/kontron,sl28-vpd.yaml | 64 ++++++++
.../bindings/nvmem/layouts/nvmem-layout.yaml | 34 ++++
.../nvmem/layouts/onie,tlv-layout.yaml | 147 ++++++++++++++++++
.../devicetree/bindings/nvmem/nvmem.yaml | 8 +
.../bindings/nvmem/st,stm32-romem.yaml | 1 +
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
drivers/nvmem/Kconfig | 2 +-
drivers/nvmem/stm32-romem.c | 27 +++-
drivers/nvmem/u-boot-env.c | 14 ++
12 files changed, 298 insertions(+), 8 deletions(-)
create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/kontron,sl28-vpd.yaml
create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml

--
2.25.1



2022-11-18 06:54:09

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 02/13] nvmem: stm32: add warning when upper OTPs are updated

From: Patrick Delaunay <[email protected]>

As the upper OTPs are ECC protected, they support only one 32 bits word
programming.
For a second modification of this word, these ECC become invalid and
this OTP will be no more accessible, the shadowed value is invalid.

This patch adds a warning to indicate an upper OTP update, because this
operation is dangerous as OTP is not locked by the driver after the first
update to avoid a second update.

Signed-off-by: Patrick Delaunay <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
drivers/nvmem/stm32-romem.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/nvmem/stm32-romem.c b/drivers/nvmem/stm32-romem.c
index d93baee01d7b..bb8aa72ba2f9 100644
--- a/drivers/nvmem/stm32-romem.c
+++ b/drivers/nvmem/stm32-romem.c
@@ -132,6 +132,9 @@ static int stm32_bsec_write(void *context, unsigned int offset, void *buf,
}
}

+ if (offset + bytes >= priv->lower * 4)
+ dev_warn(dev, "Update of upper OTPs with ECC protection (word programming, only once)\n");
+
return 0;
}

--
2.25.1


2022-11-18 06:54:24

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 08/13] nvmem: u-boot-env: add Broadcom format support

From: Rafał Miłecki <[email protected]>

Broadcom uses U-Boot for a lot of their bcmbca familiy chipsets. They
decided to store U-Boot environment data inside U-Boot partition and to
use a custom header (with "uEnv" magic and env data length).

Add support for Broadcom's specific binding and their custom format.

Ref: 6b0584c19d87 ("dt-bindings: nvmem: u-boot,env: add Broadcom's variant binding")
Signed-off-by: Rafał Miłecki <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
drivers/nvmem/u-boot-env.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/drivers/nvmem/u-boot-env.c b/drivers/nvmem/u-boot-env.c
index 4fdbdccebda1..29b1d87a3c51 100644
--- a/drivers/nvmem/u-boot-env.c
+++ b/drivers/nvmem/u-boot-env.c
@@ -16,6 +16,7 @@
enum u_boot_env_format {
U_BOOT_FORMAT_SINGLE,
U_BOOT_FORMAT_REDUNDANT,
+ U_BOOT_FORMAT_BROADCOM,
};

struct u_boot_env {
@@ -40,6 +41,13 @@ struct u_boot_env_image_redundant {
uint8_t data[];
} __packed;

+struct u_boot_env_image_broadcom {
+ __le32 magic;
+ __le32 len;
+ __le32 crc32;
+ uint8_t data[0];
+} __packed;
+
static int u_boot_env_read(void *context, unsigned int offset, void *val,
size_t bytes)
{
@@ -138,6 +146,11 @@ static int u_boot_env_parse(struct u_boot_env *priv)
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;
}
crc32 = le32_to_cpu(*(__le32 *)(buf + crc32_offset));
crc32_data_len = priv->mtd->size - crc32_data_offset;
@@ -202,6 +215,7 @@ 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, },
{},
};

--
2.25.1


2022-11-18 06:54:48

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 13/13] dt-bindings: nvmem: add YAML schema for the ONIE tlv layout

From: Miquel Raynal <[email protected]>

Add a schema for the ONIE tlv NVMEM layout that can be found on any ONIE
compatible networking device.

Describe all the possible NVMEM cells that can be produced by this
layout parser.

Signed-off-by: Miquel Raynal <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
.../bindings/nvmem/layouts/nvmem-layout.yaml | 1 +
.../nvmem/layouts/onie,tlv-layout.yaml | 147 ++++++++++++++++++
2 files changed, 148 insertions(+)
create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml

diff --git a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
index f64ea2fa362d..8512ee538c4c 100644
--- a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
+++ b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
@@ -19,6 +19,7 @@ description: |

oneOf:
- $ref: kontron,sl28-vpd.yaml
+ - $ref: onie,tlv-layout.yaml

properties:
compatible: true
diff --git a/Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml
new file mode 100644
index 000000000000..5a0e7671aa3f
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml
@@ -0,0 +1,147 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/nvmem/layouts/onie,tlv-layout.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVMEM layout of the ONIE tlv table
+
+maintainers:
+ - Miquel Raynal <[email protected]>
+
+description:
+ Modern networking hardware implementing the Open Compute Project ONIE
+ infrastructure shall provide a non-volatile memory with a table whose the
+ content is well specified and gives many information about the manufacturer
+ (name, country of manufacture, etc) as well as device caracteristics (serial
+ number, hardware version, mac addresses, etc). The underlaying device type
+ (flash, EEPROM,...) is not specified. The exact location of each value is also
+ dynamic and should be discovered at run time because it depends on the
+ parameters the manufacturer decided to embed.
+
+select: false
+
+properties:
+ compatible:
+ const: onie,tlv-layout
+
+ product-name:
+ type: object
+ additionalProperties: false
+
+ part-number:
+ type: object
+ additionalProperties: false
+
+ serial-number:
+ type: object
+ additionalProperties: false
+
+ mac-address:
+ type: object
+ description:
+ Base MAC address for all on-module network interfaces. The first
+ argument of the phandle will be treated as an offset.
+
+ properties:
+ "#nvmem-cell-cells":
+ const: 1
+
+ additionalProperties: false
+
+ manufacture-date:
+ type: object
+ additionalProperties: false
+
+ device-version:
+ type: object
+ additionalProperties: false
+
+ label-revision:
+ type: object
+ additionalProperties: false
+
+ platforn-name:
+ type: object
+ additionalProperties: false
+
+ onie-version:
+ type: object
+ additionalProperties: false
+
+ num-macs:
+ type: object
+ additionalProperties: false
+
+ manufacturer:
+ type: object
+ additionalProperties: false
+
+ country-code:
+ type: object
+ additionalProperties: false
+
+ vendor:
+ type: object
+ additionalProperties: false
+
+ diag-version:
+ type: object
+ additionalProperties: false
+
+ service-tag:
+ type: object
+ additionalProperties: false
+
+ vendor-extension:
+ type: object
+ additionalProperties: false
+
+required:
+ - compatible
+
+additionalProperties: false
+
+examples:
+ - |
+ spi {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ eeprom@56 {
+ compatible = "atmel,24c64";
+ read-only;
+ reg = <0x56>;
+
+ nvmem-layout {
+ compatible = "onie,tlv-layout";
+
+ serial-number {
+ };
+ };
+ };
+ };
+
+ - |
+ spi {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ flash@0 {
+ compatible = "m25p80", "jedec,spi-nor";
+ reg = <0>;
+
+ otp {
+ compatible = "user-otp";
+
+ nvmem-layout {
+ compatible = "onie,tlv-layout";
+
+ mac-address {
+ #nvmem-cell-cells = <1>;
+ };
+ };
+ };
+ };
+ };
+...
--
2.25.1


2022-11-18 06:55:01

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 05/13] nvmem: stm32: fix spelling typo in comment

From: Jiangshan Yi <[email protected]>

Fix spelling typo in comment.

Reported-by: k2ci <[email protected]>
Signed-off-by: Jiangshan Yi <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
drivers/nvmem/stm32-romem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/stm32-romem.c b/drivers/nvmem/stm32-romem.c
index 6de565639d5f..d1d03c2ad081 100644
--- a/drivers/nvmem/stm32-romem.c
+++ b/drivers/nvmem/stm32-romem.c
@@ -19,7 +19,7 @@
#define STM32_SMC_WRITE_SHADOW 0x03
#define STM32_SMC_READ_OTP 0x04

-/* shadow registers offest */
+/* shadow registers offset */
#define STM32MP15_BSEC_DATA0 0x200

struct stm32_romem_cfg {
--
2.25.1


2022-11-18 07:13:24

by Srinivas Kandagatla

[permalink] [raw]
Subject: [PATCH 09/13] dt-bindings: nvmem: Introduce the nvmem-layout container

From: Miquel Raynal <[email protected]>

The nvmem devices description works like this:

* Most cases (EEPROM & co):

eeprom@x {
compatible = "<eeprom-compatible>";
...
};

* MTD case:

flash@y {
compatible = "<flash-compatible>";
...
otp {
compatible = "user-otp"; /* or "factory-otp" */
...
};
};

In the former case, the nvmem device is "eeprom@x", while in the latter
case the nvmem device is "otp".

Nvmem devices can produce nvmem cells. The current way to describe nvmem
cells is to locate them by providing their static byte and bit offset
and length. These information are stored in subnodes of the nvmem
device.

It is now a fact that such description does not fit more advanced use
cases where the location or the size of the cells may vary. There are
currently three known situations which require being described
differently: Kontron's SL28 VPD, ONIE's TLV table and U-Boot's
environment variables.

Hence, we need a way to describe the parsers that must be used in order
to make the dynamic discovery of the nvmem cells. This new description
must fit both use cases (the generic situation and the MTD case).

Let's create in both cases a container node named nvmem-layout whose
content will depend on the parser. Right now nvmem-layout.yaml is
"empty", but references to additional layout parser bindings will be
inserted in the near future. The final goal being something that looks
like:

* Most cases (EEPROM & co):

eeprom@x {
compatible = "<eeprom-compatible>";
...
nvmem-layout {
compatible = "<parser-compatible>";
...
};
};

* MTD case:

flash@y {
compatible = "<flash-compatible>";
...
otp {
compatible = "user-otp"; /* or "factory-otp" */
...
nvmem-layout {
compatible = "<parser-compatible>";
...
};
};
};

Signed-off-by: Miquel Raynal <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
.../bindings/nvmem/layouts/nvmem-layout.yaml | 30 +++++++++++++++++++
.../devicetree/bindings/nvmem/nvmem.yaml | 7 +++++
2 files changed, 37 insertions(+)
create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml

diff --git a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
new file mode 100644
index 000000000000..ecc7c37cbc1f
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/nvmem/layouts/nvmem-layout.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVMEM (Non Volatile Memory) layouts
+
+maintainers:
+ - Srinivas Kandagatla <[email protected]>
+ - Michael Walle <[email protected]>
+ - Miquel Raynal <[email protected]>
+
+description: |
+ Most NVMEM layouts are static and thus do not require additional description
+ besides the bytes/bits offset and length. Other layouts can be less statically
+ define and might require dynamic reading of the NVMEM device in order to
+ perform their parsing. The nvmem-layout container is here to describe these.
+
+properties:
+ compatible: true
+
+ '#address-cells': false
+
+ '#size-cells': false
+
+required:
+ - compatible
+
+unevaluatedProperties: false
diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
index 0455506fc30f..75bb93dda9df 100644
--- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
+++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
@@ -39,6 +39,13 @@ properties:
when it's driven low (logical '0') to allow writing.
maxItems: 1

+ nvmem-layout:
+ $ref: /schemas/nvmem/layouts/nvmem-layout.yaml
+ description:
+ Alternative to the statically defined nvmem cells, this
+ container may reference more advanced (dynamic) layout
+ parsers.
+
patternProperties:
"@[0-9a-f]+(,[0-7])?$":
type: object
--
2.25.1