Read MAC address from SST vendor specific SFDP region
Subsystems (8)
v4 cover Read MAC address from SST vendor specific SFDP region
Some Microchip/SST QSPI flashes (e.g. the SST26VF064BEUI) are factory programmed with globally unique, write-protected EUI-48 and EUI-64 identifiers stored in a vendor-specific SFDP parameter table. On boards that have no on-board EEPROM (sama5d27_wlsom1, sama5d29 curiosity, sam9x75 curiosity) this is a reliable source for an Ethernet MAC address, instead of relying on a U-Boot-provided or random address.
This v4 reworks the approach into a generic NVMEM framework with no vendor code in the SPI NOR core:
- The SPI NOR core now exposes the entire SFDP as a generic read-only NVMEM device, rooted at a new "sfdp" child node of the flash.
- A new NVMEM layout driver (drivers/nvmem/layouts/) locates the Microchip vendor parameter table at runtime and presents the EUI-48 as a "mac-address" cell.
- Arbitrary parameters can be read with a standard fixed-layout (known offset) or with an nvmem-layout parser (location discovered at runtime).
Changes in v4:
- Rework per v3 review: remove the vendor-specific SFDP handling from the SPI NOR core; expose the whole SFDP as a generic read-only NVMEM device and move the EUI extraction into an nvmem-layout driver.
- Introduce a new nvmem-layout driver to discover the vendor-table location at runtime; no offset hardcoded in the device tree.
- Describe the SFDP via a dedicated "sfdp" subnode (compatible "jedec,sfdp"), which also resolves the v3 dtbs_check "Unevaluated properties ('nvmem-layout')" warning.
- Reverse the stored EUI bytes into canonical MAC order.
- Enable the layout in sama5_defconfig.
Changes in v3:
- 2/3 - add support to update the QSPI partition into 'fixed-partition' binding in sama5d27_wlsom1
- 3/3 - add nvmem-layout in qspi node for EUI48 MAC Address and nvmem cell properties for macb node in sama5d27_wlsom1
Changes in v2:
- 1/3 - parse the SST vendor table, read and store the addresses into a resource - managed space. Register the addresses into NVMEM framework
- 2/3 - add support to update the QSPI partition into 'fixed-partition' binding
v3: https://lore.kernel.org/linux-arm-kernel/[email protected]/
Manikandan Muralidharan (7):
dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via
NVMEM
dt-bindings: nvmem: layouts: add Microchip/SST SFDP EUI layout
mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device
nvmem: layouts: add Microchip/SST SFDP EUI layout driver
ARM: dts: microchip: sama5d27_wlsom1: use fixed-partitions for QSPI
flash
ARM: dts: microchip: sama5d27_wlsom1: read MAC address from QSPI SFDP
ARM: configs: sama5: enable Microchip/SST SFDP EUI NVMEM layout
.../bindings/mtd/jedec,spi-nor.yaml | 18 ++ .../layouts/microchip,sst26vf-sfdp-eui.yaml | 60 ++++++ .../bindings/nvmem/layouts/nvmem-layout.yaml | 1 + MAINTAINERS | 6 + .../dts/microchip/at91-sama5d27_wlsom1.dtsi | 61 +++--- .../dts/microchip/at91-sama5d27_wlsom1_ek.dts | 2 + arch/arm/configs/sama5_defconfig | 1 + drivers/mtd/spi-nor/core.c | 5 + drivers/mtd/spi-nor/core.h | 1 + drivers/mtd/spi-nor/sfdp.c | 83 ++++++++ drivers/nvmem/layouts/Kconfig | 10 + drivers/nvmem/layouts/Makefile | 1 + drivers/nvmem/layouts/sst26vf-sfdp-eui.c | 182 ++++++++++++++++++ 13 files changed, 409 insertions(+), 22 deletions(-) create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/microchip,sst26vf-sfdp-eui.yaml create mode 100644 drivers/nvmem/layouts/sst26vf-sfdp-eui.c
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
Signature · 1 line
2.43.0
PATCH v4 1/7 dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM
Add an optional "sfdp" child node (compatible "jedec,sfdp") that describes the SFDP as a read-only NVMEM provider via nvmem.yaml, so its contents (e.g. a vendor EUI-48/EUI-64) can be read through NVMEM cells.
--- .../devicetree/bindings/mtd/jedec,spi-nor.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +18 -0
@@ -103,6 +103,20 @@ properties: spi-cpol: true spi-cpha: true + sfdp: + $ref: /schemas/nvmem/nvmem.yaml# + unevaluatedProperties: false + description: + The Serial Flash Discoverable Parameters (SFDP) tables exposed as a + read-only NVMEM device. This allows standard or vendor-specific SFDP + data (for example a factory-programmed EUI-48/EUI-64 identifier) to be + consumed through NVMEM cells. + properties: + compatible: + const: jedec,sfdp + required: + - compatible + dependencies: spi-cpol: [ spi-cpha ] spi-cpha: [ spi-cpol ]
@@ -122,6 +136,10 @@ examples: spi-max-frequency = <40000000>; m25p,fast-read; reset-gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + + sfdp { + compatible = "jedec,sfdp"; + }; }; }; ...
Signature · 1 line
2.43.0
Re: [PATCH v4 1/7] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM
Hi Manikandan,
thanks for your patch!
Quoted 5 lines · Manikandan Muralidharan
Add an optional "sfdp" child node (compatible "jedec,sfdp") that describes the SFDP as a read-only NVMEM provider via
nvmem.yaml, so its contents (e.g. a vendor EUI-48/EUI-64) can be read through NVMEM cells.Signed-off-by Manikandan Muralidharan <[email protected]>
I would expect it to follow nvmem conventions like this, notice compatibles specific-to-general with sfdp first:
sfdp {
/* NVMEM provided by SFDP */
compatible = "jedec,sfdp", "nvmem-cells";
label = "SFDP";
read-only;
#address-cells = <1>;
#size-cells = <1>;
mac0: macaddr@0x00 {
reg = <0x00 0x06>;
};
mac1: macaddr@0x06 {
reg = <0x06 0x06>;
};
};Your example should definitely be more elaborate like this, just an opaque sfdp node will not suffice. Maybe a separate example?
Yours,
Linus Walleij
Re: [PATCH v4 1/7] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM
Hi,
Quoted 6 lines
Quoted 5 lines
Add an optional "sfdp" child node (compatible "jedec,sfdp") that describes the SFDP as a read-only NVMEM provider via
nvmem.yaml, so its contents (e.g. a vendor EUI-48/EUI-64) can be read through NVMEM cells.Signed-off-by Manikandan Muralidharan <[email protected]>
Quoted 8 lines
I would expect it to follow nvmem conventions like this, notice compatibles specific-to-general with sfdp first:
sfdp { /* NVMEM provided by SFDP */ compatible = "jedec,sfdp", "nvmem-cells"; label = "SFDP";
Isn't using label frowned upon? I wouldn't add that to the example.
Quoted 11 lines
read-only;
#address-cells = <1>;
#size-cells = <1>;
mac0: macaddr@0x00 {
reg = <0x00 0x06>;
};
mac1: macaddr@0x06 {
reg = <0x06 0x06>;
};
};If I'm correct, this is the old style, see commit bd912c991d2e ("dt-bindings: nvmem: layouts: add fixed-layout"). So it should eventually look like:
sfdp {
compatible = "jedec,sfdp";
nvmem-layout {
compatible = "microchip,sst26vf-sfdp-eui";
};
};Which is what patch series will lead to.
Also I'm not sure if we really need to add the "nvmem-cells" here. IIRC in MTD it was there to tell a driver to add an nvmem device to an already existing compatible/node.
Apart from the MTD case, I've just found qcom,smem-part,yaml which has compatible = "nvmem-cells".
-michael
Quoted 6 lines
Your example should definitely be more elaborate like this, just an opaque sfdp node will not suffice. Maybe a separate example?
Yours,
Linus Walleij
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Linus Walleij
Reviewed-byRe: [PATCH v4 1/7] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM
Quoted 6 lines · Michael Walle
If I'm correct, this is the old style, see commit
bd912c991d2e("dt-bindings: nvmem: layouts: add fixed-layout"). So it should eventually look like:sfdp { compatible = "jedec,sfdp";
(...)
Quoted 6 lines
Also I'm not sure if we really need to add the "nvmem-cells" here. IIRC in MTD it was there to tell a driver to add an nvmem device to an already existing compatible/node.
Apart from the MTD case, I've just found qcom,smem-part,yaml which has compatible = "nvmem-cells".
You're right, I was using old information, discard my comments...
I think my comment in the driver to check for the compatible instead of the node name is still valid though.
Yours,
Linus Walleij
Re: [PATCH v4 1/7] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM
Quoted 15 lines · Linus Walleij
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 6 lines · Michael Walle
If I'm correct, this is the old style, see commit
bd912c991d2e("dt-bindings: nvmem: layouts: add fixed-layout"). So it should eventually look like:sfdp { compatible = "jedec,sfdp";(...)
Quoted 4 lines
Also I'm not sure if we really need to add the "nvmem-cells" here. IIRC in MTD it was there to tell a driver to add an nvmem device to an already existing compatible/node.
Quoted 8 lines
Quoted 2 lines
Apart from the MTD case, I've just found qcom,smem-part,yaml which has compatible = "nvmem-cells".
You're right, I was using old information, discard my comments...
Reviewed-by Linus Walleij <[email protected]>I think my comment in the driver to check for the compatible instead of the node name is still valid though.
Thank you Linus Wallejj and Michael.
I will address the driver changes in the next version.
Quoted 3 lines
Yours,
Linus Walleij
Signature · 2 lines
Thanks and Regards, Manikandan M.
Re: [PATCH v4 1/7] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM
In reply to Manikandan MuralidharanQuoted 2 lines · Manikandan Muralidharan
Add an optional "sfdp" child node (compatible "jedec,sfdp") that describes the SFDP as a read-only NVMEM provider via
nvmem.yaml, so its
What is SFDP?
Quoted 18 lines
contents (e.g. a vendor EUI-48/EUI-64) can be read through NVMEM cells.
Signed-off-by Manikandan Muralidharan <[email protected]>--- .../devicetree/bindings/mtd/jedec,spi-nor.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +3
-0@@ -103,6 +103,20 @@ properties: spi-cpol: true spi-cpha: true + sfdp: + $ref: /schemas/nvmem/nvmem.yaml# + unevaluatedProperties: false
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml properties: · line 118
Quoted 10 lines
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +10
-0+ description: + The Serial Flash Discoverable Parameters (SFDP) tables exposed as a + read-only NVMEM device. This allows standard or vendor-specific SFDP + data (for example a factory-programmed EUI-48/EUI-64 identifier) to be + consumed through NVMEM cells. + properties: + compatible: + const: jedec,sfdp + required: + - compatible
Where are any resources? What sort of sub-device is represented here by an empty device node?
Best regards,
Krzysztof
Re: [PATCH v4 1/7] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM
Hi Krzysztof,
Quoted 8 lines · Krzysztof Kozlowski
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 2 lines · Manikandan Muralidharan
Add an optional "sfdp" child node (compatible "jedec,sfdp") that describes the SFDP as a read-only NVMEM provider via
nvmem.yaml, so itsWhat is SFDP?
SFDP is the Serial Flash Discoverable Parameters -- a JEDEC-standardised (JESD216) read-only parameter table present in most SPI NOR flashes, the table contents provide basic information about the flash. There are standard tables which are specified by the JEDEC standard and there are vendor tables.
Quoted 15 lines
Quoted 15 lines
contents (e.g. a vendor EUI-48/EUI-64) can be read through NVMEM cells.
Signed-off-by Manikandan Muralidharan <[email protected]>--- .../devicetree/bindings/mtd/jedec,spi-nor.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +0
-0@@ -103,6 +103,20 @@ properties: spi-cpol: true spi-cpha: true
Quoted 16 lines
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml properties: · line 118
Quoted 13 lines
Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +13
-0+ sfdp: + $ref: /schemas/nvmem/nvmem.yaml# + unevaluatedProperties: false + description: + The Serial Flash Discoverable Parameters (SFDP) tables exposed as a + read-only NVMEM device. This allows standard or vendor-specific SFDP + data (for example a factory-programmed EUI-48/EUI-64 identifier) to be + consumed through NVMEM cells. + properties: + compatible: + const: jedec,sfdp + required: + - compatibleWhere are any resources? What sort of sub-device is represented here by an empty device node?
The sub-device describes the flash's SFDP region exposed as a read-only NVMEM provider:the SPI NOR core reads the SFDP and registers it as an NVMEM device rooted at this node.Its contents are then consumed through NVMEM cells -- a "fixed-layout" for data at a known offset, or an "nvmem-layout" parser for data whose location must be discovered at runtime (the Microchip EUI layout driver in patch 4/7 does the latter). It is not a bus-addressed hardware sub-device, so it has no reg.
This models the SFDP-as-NVMEM approach suggested during the v3 review, instead of special-casing the vendor table in the SPI NOR core:
https://lore.kernel.org/linux-arm-kernel/[email protected]/
Quoted 4 lines
Best regards,
Krzysztof
Signature · 2 lines
Thanks and Regards, Manikandan M.
Rob Herring
maintainerRe: [PATCH v4 1/7] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM
Quoted 9 lines · On Thu, Jul 02, 2026 at 06:55:15AM +0000, [email protected] wrote:
Hi Krzysztof,
Quoted 6 lines · Krzysztof Kozlowski
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 2 lines · Manikandan Muralidharan
Add an optional "sfdp" child node (compatible "jedec,sfdp") that describes the SFDP as a read-only NVMEM provider via
nvmem.yaml, so its
Quoted 7 lines
Quoted 2 lines
What is SFDP?
SFDP is the Serial Flash Discoverable Parameters -- a JEDEC-standardised (JESD216) read-only parameter table present in most SPI NOR flashes, the table contents provide basic information about the flash. There are standard tables which are specified by the JEDEC standard and there are vendor tables.
Is SFDP present or not discoverable? Or we have a table of discoverable parameters that itself is not discoverable.
If it is discoverable, why does this need to be in DT?
Rob
Miquel Raynal
maintainerRe: [PATCH v4 1/7] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM
Quoted 12 lines · Rob Herring
Quoted 11 lines · On Thu, Jul 02, 2026 at 06:55:15AM +0000, [email protected] wrote:
Hi Krzysztof,
Quoted 8 lines · Krzysztof Kozlowski
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 2 lines · Manikandan Muralidharan
Add an optional "sfdp" child node (compatible "jedec,sfdp") that describes the SFDP as a read-only NVMEM provider via
nvmem.yaml, so itsWhat is SFDP?
Quoted 8 lines
Quoted 5 lines
SFDP is the Serial Flash Discoverable Parameters -- a JEDEC-standardised (JESD216) read-only parameter table present in most SPI NOR flashes, the table contents provide basic information about the flash. There are standard tables which are specified by the JEDEC standard and there are vendor tables.
Is SFDP present or not discoverable? Or we have a table of discoverable parameters that itself is not discoverable.
SFDP is almost always there. I don't think there are any non SFDP chips manufactured today (?). The thing is, even if we don't need to define it in DT, we might need to point to it in order to extract eg. a unique ID or a MAC address through the NVMEM interface.
SFDP is split into several sub-tables, the first one is mandatory, but then there are optional tables which can be discovered dynamically.
Thanks,
Miquèl
Re: [PATCH v4 1/7] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM
Quoted 20 lines · Miquel Raynal
Quoted 18 lines · Rob Herring
Quoted 16 lines · On Thu, Jul 02, 2026 at 06:55:15AM +0000, [email protected] wrote:
Hi Krzysztof,
Quoted 8 lines · Krzysztof Kozlowski
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 2 lines · Manikandan Muralidharan
Add an optional "sfdp" child node (compatible "jedec,sfdp") that describes the SFDP as a read-only NVMEM provider via
nvmem.yaml, so itsWhat is SFDP?
SFDP is the Serial Flash Discoverable Parameters -- a JEDEC-standardised (JESD216) read-only parameter table present in most SPI NOR flashes, the table contents provide basic information about the flash. There are standard tables which are specified by the JEDEC standard and there are vendor tables.
Quoted 5 lines
Quoted 2 lines
Is SFDP present or not discoverable? Or we have a table of discoverable parameters that itself is not discoverable.
SFDP is almost always there. I don't think there are any non SFDP chips manufactured today (?).
Oh i bet there are, and IIRC there were some additions lately. Not sure if the chip was new though.
Quoted 3 lines
The thing is, even if we don't need to define it
in DT, we might need to point to it in order to extract eg. a unique ID or a MAC address through the NVMEM interface.
Exactly. We can detect whether is a SFDP table or not, by trying to read its signature using the RDSFDP opcode. But as Miquel pointed out, that's not what this is about. For the nvmem part being useful, we have to have some node to point to. At the moment, there are three different kind of NVMEM devices an spi nor flash can create:
- partitions
- factory OTP (i.e. OTP by the flash manufacturer)
- user OTP (i.e. what an OEM could write to)
Now there's a fourth one: SFDP. It can contain vendor specific tables, which in the mchp case is used to store a mac address, which is then used for a NIC.
So we somehow has to organize all of them, thus the sfdp node. A more complete example would be:
flash@0 {
compatible = "jedec,spi-nor";
partitions {
compatible = "fixed-partitions";
partition@0 {
compatible = "nvmem-cells";
};
};
otp-1 {
compatible = "factory-otp";
};
otp-2 {
compatible = "user-otp";
};
sfdp {
compatile = "jedec,sfdp";
};
};All being NVMEM devices and expose some kind of data used for drivers.
HTH
-michael
Quoted 5 lines
SFDP is split into several sub-tables, the first one is mandatory, but then there are optional tables which can be discovered dynamically.
Thanks,
Miquèl
PATCH v4 2/7 dt-bindings: nvmem: layouts: add Microchip/SST SFDP EUI layout
In reply to Manikandan MuralidharanAdd a binding for the NVMEM layout that exposes the factory-programmed EUI-48 identifier from the Microchip/SST vendor-specific SFDP parameter table (e.g. SST26VF064BEUI) as a "mac-address" NVMEM cell, and reference it from nvmem-layout.yaml.
--- .../layouts/microchip,sst26vf-sfdp-eui.yaml | 60 +++++++++++++++++++ .../bindings/nvmem/layouts/nvmem-layout.yaml | 1 + 2 files changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/microchip,sst26vf-sfdp-eui.yaml
Documentation/devicetree/bindings/nvmem/layouts/microchip,sst26vf-sfdp-eui.yaml new file +60 -0
@@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/layouts/microchip,sst26vf-sfdp-eui.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVMEM layout of the Microchip/SST SFDP EUI-48 identifier + +maintainers: + - Manikandan Muralidharan <[email protected]> + +description: + Some Microchip/SST serial flashes (for example the SST26VF064BEUI) are + factory programmed with a globally unique EUI-48 identifier stored in a + vendor-specific SFDP parameter table and permanently write-protected. This + layout locates that table and exposes the EUI-48 as an NVMEM cell so that, + for example, a network driver can use it as a MAC address. The location of + the data is discovered at runtime from the SFDP; no offset is encoded in the + device tree. + +select: false + +properties: + compatible: + const: microchip,sst26vf-sfdp-eui + + mac-address: + type: object + description: + The factory-programmed EUI-48 identifier, usable as a MAC address. + additionalProperties: false + +required: + - compatible + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + + sfdp { + compatible = "jedec,sfdp"; + + nvmem-layout { + compatible = "microchip,sst26vf-sfdp-eui"; + + mac-address { + }; + }; + }; + }; + }; +...
Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml +1 -0
@@ -20,6 +20,7 @@ description: | oneOf: - $ref: fixed-layout.yaml - $ref: kontron,sl28-vpd.yaml + - $ref: microchip,sst26vf-sfdp-eui.yaml - $ref: onie,tlv-layout.yaml - $ref: u-boot,env.yaml
Signature · 1 line
2.43.0
PATCH v4 3/7 mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device
In reply to Manikandan MuralidharanRegister the cached SFDP as a read-only NVMEM device rooted at the flash's "sfdp" child node, exposing it in on-flash byte order. This lets NVMEM cells reference any SFDP data: a fixed-layout for parameters at a known offset, or an nvmem-layout parser for vendor data whose location must be discovered at runtime. The device is only registered when an "sfdp" node is present in the device tree.
--- drivers/mtd/spi-nor/core.c | 5 +++ drivers/mtd/spi-nor/core.h | 1 + drivers/mtd/spi-nor/sfdp.c | 83 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+)
drivers/mtd/spi-nor/core.c +5 -0
@@ -3204,6 +3204,11 @@ static int spi_nor_init_params(struct spi_nor *nor)spi_nor_init_params_deprecated (nor); } +/* Expose the SFDP as an NVMEM device. */ + ret =spi_nor_register_sfdp_nvmem (nor); +if (ret) +return ret; + ret =spi_nor_late_init_params (nor);if (ret)return ret;
drivers/mtd/spi-nor/core.h +1 -0
@@ -698,6 +698,7 @@ int spi_nor_controller_ops_write_reg(struct spi_nor *nor, u8 opcode,int spi_nor_check_sfdp_signature (struct spi_nor *nor);int spi_nor_parse_sfdp (struct spi_nor *nor); +int spi_nor_register_sfdp_nvmem (struct spi_nor *nor);static inline struct spi_nor *mtd_to_spi_nor (struct mtd_info *mtd) {
drivers/mtd/spi-nor/sfdp.c +83 -0
92 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v4 3/7] mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device
Hi Manikandan,
thanks for your patch!
Quoted 6 lines · Manikandan Muralidharan
Register the cached SFDP as a read-only NVMEM device rooted at the flash's "sfdp" child node, exposing it in on-flash byte order. This lets NVMEM cells reference any SFDP data: a fixed-layout for parameters at a known offset, or an nvmem-layout parser for vendor data whose location must be discovered at runtime. The device is only registered when an "sfdp" node is present in the device tree.
It seems the existing serial NOR driver core already reads out the SFDP and stores it in nor->sfdp->dwords, right?
This should be mentioned in the commit so we know when the stuff is actually read in from the flash memory.
Quoted 2 lines
Signed-off-by Manikandan Muralidharan <[email protected]>
(...)
drivers/mtd/spi-nor/core.c static int spi_nor_init_params(struct spi_nor *nor) · line 3207
Quoted 5 lines
drivers/mtd/spi-nor/core.c +1
-0@@ -3204,6 +3204,11 @@ static int spi_nor_init_params(struct spi_nor *nor)spi_nor_init_params_deprecated (nor); } +/* Expose the SFDP as an NVMEM device. */
Add "if and only if the flash has an SFDP"
drivers/mtd/spi-nor/sfdp.c int spi_nor_parse_sfdp(struct spi_nor *nor) · line 1619
Quoted 2 lines
drivers/mtd/spi-nor/sfdp.c +2
-0+static int spi_nor_sfdp_nvmem_read (void *priv,unsigned int offset, +void *val,size_t bytes)
Name it _reg_read() to mirror the nvmem prototype.
Quoted 15 lines
drivers/mtd/spi-nor/sfdp.c +15
-0+/** +* spi_nor_register_sfdp_nvmem() - expose the SFDP as a read-only NVMEM device +* @nor: pointer to a 'struct spi_nor' +* +* Expose the whole SFDP, in on-flash byte order, as a read-only NVMEM device +* rooted at the flash's "sfdp" child node. This lets generic (fixed-layout) or +* vendor (nvmem-layout) cells reference any SFDP data. The device is only +* registered when an "sfdp" node is described in the device tree. +* +* Return: 0 on success or if there is nothing to do, -errno otherwise. +*/ +int spi_nor_register_sfdp_nvmem (struct spi_nor *nor) +{ +struct device *dev = nor->dev; +struct nvmem_config config = { };
drivers/mtd/spi-nor/sfdp.c int spi_nor_parse_sfdp(struct spi_nor *nor) · line 1663
Quoted 10 lines
drivers/mtd/spi-nor/sfdp.c +10
-0+struct nvmem_device *nvmem; +struct device_node *np; +int ret; + +if (!nor->sfdp) +return 0 ; + + np =of_get_child_by_name (dev_of_node (dev),"sfdp" ); +if (!np) +return 0 ;
If this node name is required to be named like that it has to be enforced in the schema.
I would instead check all the nodes (for_each_available_child) for the right compatible "jedec,sfdp".
Yours,
Linus Walleij
[email protected]
reviewerRE: [PATCH v4 3/7] mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device
In reply to Manikandan MuralidharanHi,
Quoted 8 lines
Register the cached SFDP as a read-only NVMEM device rooted at the flash's "sfdp" child node, exposing it in on-flash byte order. This lets NVMEM cells reference any SFDP data: a fixed-layout for parameters at a known offset, or an nvmem-layout parser for vendor data whose location must be discovered at runtime. The device is only registered when an "sfdp" node is present in the device tree.
Signed-off-by Manikandan Muralidharan <[email protected]>
SFDP is exposed in sysfs (e.g., /sys/bus/spi/devices/spi0.0/spi-nor/sfdp). Why don't you just use this existing entry?
Thanks,
Takahiro
[email protected]
reviewerRE: [PATCH v4 3/7] mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device
Quoted 9 lines
Hi,
Quoted 7 lines
Register the cached SFDP as a read-only NVMEM device rooted at the flash's "sfdp" child node, exposing it in on-flash byte order. This lets NVMEM cells reference any SFDP data: a fixed-layout for parameters at a known offset, or an nvmem-layout parser for vendor data whose location must be discovered at runtime. The device is only registered when an "sfdp" node is present in the device tree.
Quoted 4 lines
Quoted 1 line
Signed-off-by Manikandan Muralidharan <[email protected]>SFDP is exposed in sysfs (e.g.,
/sys/bus/spi/devices/spi0.0/spi-nor/sfdp). Why don't you just use this existing entry?
Sorry, sysfs is for userspace.
Please just disregard my previous comment.
Thanks,
Takahiro
PATCH v4 4/7 nvmem: layouts: add Microchip/SST SFDP EUI layout driver
In reply to Manikandan MuralidharanAdd an NVMEM layout that exposes the factory-programmed EUI-48 identifier from the Microchip/SST vendor SFDP parameter table (e.g. SST26VF064BEUI) as a "mac-address" cell, for use as a network MAC address. The vendor table is located at runtime via the SFDP NVMEM device (no offset in DT), and a read_post_process callback reverses the LSB-first bytes into canonical MAC order. Binds to an "nvmem-layout" node with compatible "microchip,sst26vf-sfdp-eui".
--- MAINTAINERS | 6 + drivers/nvmem/layouts/Kconfig | 10 ++ drivers/nvmem/layouts/Makefile | 1 + drivers/nvmem/layouts/sst26vf-sfdp-eui.c | 182 +++++++++++++++++++++++ 4 files changed, 199 insertions(+) create mode 100644 drivers/nvmem/layouts/sst26vf-sfdp-eui.c
MAINTAINERS +6 -0
@@ -17812,6 +17812,12 @@ F: Documentation/devicetree/bindings/sound/atmel,at91-ssc.yaml F: drivers/misc/atmel-ssc.c F: include/linux/atmel-ssc.h +MICROCHIP SST SFDP EUI NVMEM LAYOUT DRIVER +M: Manikandan Muralidharan <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/nvmem/layouts/microchip,sst26vf-sfdp-eui.yaml +F: drivers/nvmem/layouts/sst26vf-sfdp-eui.c + Microchip Timer Counter Block (TCB) Capture Driver M: Kamel Bouhara <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/nvmem/layouts/Kconfig +10 -0
@@ -26,6 +26,16 @@ config NVMEM_LAYOUT_ONIE_TLV If unsure, say N. +config NVMEM_LAYOUT_SST26VF_SFDP_EUI + tristate "Microchip/SST SFDP EUI-48 layout support" + help + Say Y here if you want to expose the factory-programmed EUI-48 + identifier stored in the Microchip/SST vendor-specific SFDP parameter + table (e.g. SST26VF064BEUI) as NVMEM cells, so that network drivers + can use them as a MAC address. + + If unsure, say N. + config NVMEM_LAYOUT_U_BOOT_ENV tristate "U-Boot environment variables layout" select CRC32
drivers/nvmem/layouts/Makefile +1 -0
@@ -5,4 +5,5 @@ obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) += sl28vpd.o obj-$(CONFIG_NVMEM_LAYOUT_ONIE_TLV) += onie-tlv.o +obj-$(CONFIG_NVMEM_LAYOUT_SST26VF_SFDP_EUI) += sst26vf-sfdp-eui.o obj-$(CONFIG_NVMEM_LAYOUT_U_BOOT_ENV) += u-boot-env.o
drivers/nvmem/layouts/sst26vf-sfdp-eui.c new file +182 -0
182 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v4 5/7 ARM: dts: microchip: sama5d27_wlsom1: use fixed-partitions for QSPI flash
In reply to Manikandan MuralidharanMove the QSPI flash partitions under a "partitions" node with the "fixed-partitions" compatible, as required by the current MTD partition binding, instead of declaring them as direct children of the flash node. No functional change.
--- .../dts/microchip/at91-sama5d27_wlsom1.dtsi | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-)
arch/arm/boot/dts/microchip/at91-sama5d27_wlsom1.dtsi +29 -23
@@ -240,34 +240,40 @@ qspi1_flash: flash@0 { m25p,fast-read; status = "disabled"; - at91bootstrap@0 { - label = "at91bootstrap"; - reg = <0x0 0x40000>; - }; + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + at91bootstrap@0 { + label = "at91bootstrap"; + reg = <0x0 0x40000>; + }; - bootloader@40000 { - label = "bootloader"; - reg = <0x40000 0xc0000>; - }; + bootloader@40000 { + label = "bootloader"; + reg = <0x40000 0xc0000>; + }; - bootloaderenvred@100000 { - label = "bootloader env redundant"; - reg = <0x100000 0x40000>; - }; + bootloaderenvred@100000 { + label = "bootloader env redundant"; + reg = <0x100000 0x40000>; + }; - bootloaderenv@140000 { - label = "bootloader env"; - reg = <0x140000 0x40000>; - }; + bootloaderenv@140000 { + label = "bootloader env"; + reg = <0x140000 0x40000>; + }; - dtb@180000 { - label = "device tree"; - reg = <0x180000 0x80000>; - }; + dtb@180000 { + label = "device tree"; + reg = <0x180000 0x80000>; + }; - kernel@200000 { - label = "kernel"; - reg = <0x200000 0x600000>; + kernel@200000 { + label = "kernel"; + reg = <0x200000 0x600000>; + }; }; }; };
Signature · 1 line
2.43.0
Re: [PATCH v4 5/7] ARM: dts: microchip: sama5d27_wlsom1: use fixed-partitions for QSPI flash
Quoted 6 lines · Manikandan Muralidharan
Move the QSPI flash partitions under a "partitions" node with the "fixed-partitions" compatible, as required by the current MTD partition binding, instead of declaring them as direct children of the flash node. No functional change.
Signed-off-by Manikandan Muralidharan <[email protected]>
Yours,
Linus Walleij
PATCH v4 6/7 ARM: dts: microchip: sama5d27_wlsom1: read MAC address from QSPI SFDP
In reply to Manikandan MuralidharanDescribe the QSPI flash SFDP as an NVMEM provider with the microchip,sst26vf-sfdp-eui layout, which exposes the factory-programmed EUI-48 as a "mac-address" cell, and point macb0 at it through nvmem-cells. This yields a stable MAC address on boards where U-Boot does not program one, instead of falling back to a random address.
--- arch/arm/boot/dts/microchip/at91-sama5d27_wlsom1.dtsi | 11 +++++++++++ .../boot/dts/microchip/at91-sama5d27_wlsom1_ek.dts | 2 ++ 2 files changed, 13 insertions(+)
arch/arm/boot/dts/microchip/at91-sama5d27_wlsom1.dtsi +11 -0
@@ -240,6 +240,17 @@ qspi1_flash: flash@0 { m25p,fast-read; status = "disabled"; + sfdp { + compatible = "jedec,sfdp"; + + nvmem-layout { + compatible = "microchip,sst26vf-sfdp-eui"; + + mac_address_eui48: mac-address { + }; + }; + }; + partitions { compatible = "fixed-partitions"; #address-cells = <1>;
arch/arm/boot/dts/microchip/at91-sama5d27_wlsom1_ek.dts +2 -0
@@ -97,6 +97,8 @@ uart6: serial@200 { &macb0 { status = "okay"; + nvmem-cells = <&mac_address_eui48>; + nvmem-cell-names = "mac-address"; }; &pioA {
Signature · 1 line
2.43.0
PATCH v4 7/7 ARM: configs: sama5: enable Microchip/SST SFDP EUI NVMEM layout
In reply to Manikandan MuralidharanEnable CONFIG_NVMEM_LAYOUT_SST26VF_SFDP_EUI so the factory EUI-48 stored in the SST26VF QSPI flash SFDP can be used as a MAC address on boards such as the sama5d27_wlsom1.
--- arch/arm/configs/sama5_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/sama5_defconfig +1 -0
@@ -220,6 +220,7 @@ CONFIG_PWM=y CONFIG_PWM_ATMEL=y CONFIG_PWM_ATMEL_HLCDC_PWM=y CONFIG_PWM_ATMEL_TCB=y +CONFIG_NVMEM_LAYOUT_SST26VF_SFDP_EUI=y CONFIG_EXT4_FS=y CONFIG_FANOTIFY=y CONFIG_AUTOFS_FS=m
Signature · 1 line
2.43.0