Add support for custom names for AT24 EEPROMs
Subsystems (5)
Jon Hunter
maintainerPATCH 2/5 dt-bindings: eeprom: at24: Add label property for AT24
In reply to Jon HunterAdd a label property for the AT24 EEPROM to allow a custom name to be used for identifying the EEPROM on a board. This is useful when there is more than one EEPROM present.
--- Documentation/devicetree/bindings/eeprom/at24.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/eeprom/at24.yaml +4 -0
@@ -114,6 +114,10 @@ properties: - const: renesas,r1ex24128 - const: atmel,24c128 + label: + description: Descriptive name of the EEPROM. + maxItems: 1 + reg: maxItems: 1
Signature · 1 line
2.25.1
Jon Hunter
maintainercover Add support for custom names for AT24 EEPROMs
For platforms that have multiple boards and hence have multiple EEPROMs for identifying the different boards, it is useful to label the EEPROMs in device-tree so that they can be easily identified. For example, MAC address information is stored in the EEPROM on the processor module for some Jetson platforms which is not only required by the kernel but the bootloader as well. So having a simple way to identify the EEPROM is needed.
Jon Hunter (5):
misc: eeprom: at24: Initialise AT24 NVMEM ID field
dt-bindings: eeprom: at24: Add label property for AT24
misc: eeprom: at24: Support custom device names for AT24 EEPROMs
arm64: tegra: Add label properties for EEPROMs
arm64: tegra: Populate EEPROMs for Jetson Xavier NX
.../devicetree/bindings/eeprom/at24.yaml | 4 ++++ .../boot/dts/nvidia/tegra186-p2771-0000.dts | 1 + arch/arm64/boot/dts/nvidia/tegra186-p3310.dtsi | 1 + arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi | 1 + .../boot/dts/nvidia/tegra194-p2972-0000.dts | 1 + .../nvidia/tegra194-p3509-0000+p3668-0000.dts | 14 ++++++++++++++ .../boot/dts/nvidia/tegra194-p3668-0000.dtsi | 16 ++++++++++++++++ arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi | 1 + .../boot/dts/nvidia/tegra210-p2371-2180.dts | 1 + .../boot/dts/nvidia/tegra210-p3450-0000.dts | 2 ++ drivers/misc/eeprom/at24.c | 11 ++++++++++- 11 files changed, 52 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
Jon Hunter
maintainerPATCH 5/5 arm64: tegra: Populate EEPROMs for Jetson Xavier NX
Populate the EEPROMs that are present on the Jetson Xavier NX developer platform.
--- .../nvidia/tegra194-p3509-0000+p3668-0000.dts | 14 ++++++++++++++ .../boot/dts/nvidia/tegra194-p3668-0000.dtsi | 16 ++++++++++++++++ 2 files changed, 30 insertions(+)
arch/arm64/boot/dts/nvidia/tegra194-p3509-0000+p3668-0000.dts +14 -0
@@ -27,6 +27,20 @@ ddc: i2c@3190000 { status = "okay"; }; + i2c@3160000 { + eeprom@57 { + compatible = "atmel,24c02"; + reg = <0x57>; + + label = "system"; + vcc-supply = <&vdd_1v8>; + address-width = <8>; + pagesize = <8>; + size = <256>; + read-only; + }; + }; + hda@3510000 { nvidia,model = "jetson-xavier-nx-hda"; status = "okay";
arch/arm64/boot/dts/nvidia/tegra194-p3668-0000.dtsi +16 -0
@@ -58,6 +58,22 @@ serial@c280000 { status = "okay"; }; + i2c@3160000 { + status = "okay"; + + eeprom@50 { + compatible = "atmel,24c02"; + reg = <0x50>; + + label = "module"; + vcc-supply = <&vdd_1v8ls>; + address-width = <8>; + pagesize = <8>; + size = <256>; + read-only; + }; + }; + /* SDMMC1 (SD/MMC) */ mmc@3400000 { status = "okay";
Signature · 1 line
2.25.1
Jon Hunter
maintainerPATCH 4/5 arm64: tegra: Add label properties for EEPROMs
In reply to Jon HunterPopulate the label property for the AT24 EEPROMs on the various Jetson platforms. Note that the name 'module' is used to identify the EEPROM on the processor module board and the name 'system' is used to identify the EEPROM on the main base board (which is sometimes referred to as the carrier board).
--- arch/arm64/boot/dts/nvidia/tegra186-p2771-0000.dts | 1 + arch/arm64/boot/dts/nvidia/tegra186-p3310.dtsi | 1 + arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi | 1 + arch/arm64/boot/dts/nvidia/tegra194-p2972-0000.dts | 1 + arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi | 1 + arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 1 + arch/arm64/boot/dts/nvidia/tegra210-p3450-0000.dts | 2 ++ 7 files changed, 8 insertions(+)
arch/arm64/boot/dts/nvidia/tegra186-p2771-0000.dts +1 -0
@@ -222,6 +222,7 @@ eeprom@57 { compatible = "atmel,24c02"; reg = <0x57>; + label = "system"; vcc-supply = <&vdd_1v8>; address-width = <8>; pagesize = <8>;
arch/arm64/boot/dts/nvidia/tegra186-p3310.dtsi +1 -0
@@ -173,6 +173,7 @@ eeprom@50 { compatible = "atmel,24c02"; reg = <0x50>; + label = "module"; vcc-supply = <&vdd_1v8>; address-width = <8>; pagesize = <8>;
arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi +1 -0
@@ -64,6 +64,7 @@ eeprom@50 { compatible = "atmel,24c02"; reg = <0x50>; + label = "module"; vcc-supply = <&vdd_1v8ls>; address-width = <8>; pagesize = <8>;
arch/arm64/boot/dts/nvidia/tegra194-p2972-0000.dts +1 -0
@@ -28,6 +28,7 @@ eeprom@56 { compatible = "atmel,24c02"; reg = <0x56>; + label = "system"; vcc-supply = <&vdd_1v8ls>; address-width = <8>; pagesize = <8>;
arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi +1 -0
@@ -273,6 +273,7 @@ eeprom@50 { compatible = "atmel,24c02"; reg = <0x50>; + label = "module"; vcc-supply = <&vdd_1v8>; address-width = <8>; pagesize = <8>;
arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts +1 -0
@@ -86,6 +86,7 @@ eeprom@57 { compatible = "atmel,24c02"; reg = <0x57>; + label = "system"; vcc-supply = <&vdd_1v8>; address-width = <8>; pagesize = <8>;
arch/arm64/boot/dts/nvidia/tegra210-p3450-0000.dts +2 -0
@@ -144,6 +144,7 @@ eeprom@50 { compatible = "atmel,24c02"; reg = <0x50>; + label = "module"; vcc-supply = <&vdd_1v8>; address-width = <8>; pagesize = <8>;
@@ -155,6 +156,7 @@ eeprom@57 { compatible = "atmel,24c02"; reg = <0x57>; + label = "system"; vcc-supply = <&vdd_1v8>; address-width = <8>; pagesize = <8>;
Signature · 1 line
2.25.1
Re: [PATCH 1/5] misc: eeprom: at24: Initialise AT24 NVMEM ID field
In reply to Jon HunterQuoted 30 lines · Jon Hunter
The AT24 EEPROM driver does not initialise the 'id' field of the
nvmem_configstructure and because the entire structure is not initialised, it ends up with a random value. This causes the NVMEM driver to append the device 'devid' value to name of the NVMEM device. Although this is not a problem per-se, for I2C devices such as the AT24, that already have a device unique name, there does not seem much value in appending an additional 0 to the I2C name. For example, appending a 0 to an I2C device name such as 1-0050 does not seem necessary and maybe even a bit confusing. Therefore, fix this by setting the NVMEM config.id toNVMEM_DEVID_NONEfor AT24 EEPROMs.Signed-off-by Jon Hunter <[email protected]>--- drivers/misc/eeprom/at24.c | 1 + 1 file changed, 1 insertion(+)drivers/misc/eeprom/at24.c +1
-1@@ -715,6 +715,7 @@ static int at24_probe(struct i2c_client *client) nvmem_config.name =dev_name (dev); nvmem_config.dev = dev; + nvmem_config.id =NVMEM_DEVID_NONE ; nvmem_config.read_only = !writable; nvmem_config.root_only = !(flags &AT24_FLAG_IRUGO ); nvmem_config.owner =THIS_MODULE ; --
Quoted 2 lines
2.25.1
This patch is correct and thanks for catching it. I vaguely recall wondering at some point why the appended 0 in the nvmem name for at24. Unfortunately this change would affect how the device is visible in user-space in /sys/bus/nvmem/devices/ and this could break existing users. Also: there are many in-kernel users that would need to be updated. I'm afraid we'll need some sort of backward compatibility.
Bartosz
Jon Hunter
maintainerRe: [PATCH 1/5] misc: eeprom: at24: Initialise AT24 NVMEM ID field
Quoted 24 lines · Bartosz Golaszewski
Quoted 23 lines · Jon Hunter
The AT24 EEPROM driver does not initialise the 'id' field of the
nvmem_configstructure and because the entire structure is not initialised, it ends up with a random value. This causes the NVMEM driver to append the device 'devid' value to name of the NVMEM device. Although this is not a problem per-se, for I2C devices such as the AT24, that already have a device unique name, there does not seem much value in appending an additional 0 to the I2C name. For example, appending a 0 to an I2C device name such as 1-0050 does not seem necessary and maybe even a bit confusing. Therefore, fix this by setting the NVMEM config.id toNVMEM_DEVID_NONEfor AT24 EEPROMs.Signed-off-by Jon Hunter <[email protected]>--- drivers/misc/eeprom/at24.c | 1 + 1 file changed, 1 insertion(+)drivers/misc/eeprom/at24.c +0
-0@@ -715,6 +715,7 @@ static int at24_probe(struct i2c_client *client)
Quoted 16 lines
Quoted 9 lines
drivers/misc/eeprom/at24.c +1
-1nvmem_config.name =dev_name (dev); nvmem_config.dev = dev; + nvmem_config.id =NVMEM_DEVID_NONE ; nvmem_config.read_only = !writable; nvmem_config.root_only = !(flags &AT24_FLAG_IRUGO ); nvmem_config.owner =THIS_MODULE ; --2.25.1
This patch is correct and thanks for catching it. I vaguely recall wondering at some point why the appended 0 in the nvmem name for at24. Unfortunately this change would affect how the device is visible in user-space in
/sys/bus/nvmem/devices/and this could break existing users. Also: there are many in-kernel users that would need to be updated. I'm afraid we'll need some sort of backward compatibility.
Thanks, yes that is a problem. I guess for now we could explicitly init to NVMEM_DEVID_AUTO or maybe just 0 so that it defaults to the same path in the NVMEM driver. However, I am not sure how we can make allow some devices to use NVMEM_DEVID_NONE and others use something else. This is not really something that we can describe in DT because it has nothing to do with h/w.
Cheers
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH 1/5] misc: eeprom: at24: Initialise AT24 NVMEM ID field
Quoted 44 lines · Jon Hunter
Quoted 24 lines · Bartosz Golaszewski
Quoted 23 lines · Jon Hunter
The AT24 EEPROM driver does not initialise the 'id' field of the
nvmem_configstructure and because the entire structure is not initialised, it ends up with a random value. This causes the NVMEM driver to append the device 'devid' value to name of the NVMEM device. Although this is not a problem per-se, for I2C devices such as the AT24, that already have a device unique name, there does not seem much value in appending an additional 0 to the I2C name. For example, appending a 0 to an I2C device name such as 1-0050 does not seem necessary and maybe even a bit confusing. Therefore, fix this by setting the NVMEM config.id toNVMEM_DEVID_NONEfor AT24 EEPROMs.Signed-off-by Jon Hunter <[email protected]>--- drivers/misc/eeprom/at24.c | 1 + 1 file changed, 1 insertion(+)drivers/misc/eeprom/at24.c +0
-0@@ -715,6 +715,7 @@ static int at24_probe(struct i2c_client *client)Quoted 16 lines
Quoted 9 lines
drivers/misc/eeprom/at24.c +1
-1nvmem_config.name =dev_name (dev); nvmem_config.dev = dev; + nvmem_config.id =NVMEM_DEVID_NONE ; nvmem_config.read_only = !writable; nvmem_config.root_only = !(flags &AT24_FLAG_IRUGO ); nvmem_config.owner =THIS_MODULE ; --2.25.1
This patch is correct and thanks for catching it. I vaguely recall wondering at some point why the appended 0 in the nvmem name for at24. Unfortunately this change would affect how the device is visible in user-space in
/sys/bus/nvmem/devices/and this could break existing users. Also: there are many in-kernel users that would need to be updated. I'm afraid we'll need some sort of backward compatibility.
Quoted 6 lines
Thanks, yes that is a problem. I guess for now we could explicitly init to
NVMEM_DEVID_AUTOor maybe just 0 so that it defaults to the same path in the NVMEM driver. However, I am not sure how we can make allow some devices to useNVMEM_DEVID_NONEand others use something else. This is not really something that we can describe in DT because it has nothing to do with h/w.
Unless we make the configuration of the 'id' dependent on the 'label' property so something like ...
if (device_property_present(dev, "label")) {
nvmem_config.id = NVMEM_DEVID_NONE;
err = device_property_read_string(dev, "label",
&nvmem_config.name);
if (err)
return err;
} else {
nvmem_config.id = NVMEM_DEVID_AUTO;
nvmem_config.name = dev_name(dev);
}Cheers
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerPATCH 3/5 misc: eeprom: at24: Support custom device names for AT24 EEPROMs
In reply to Jon HunterBy using the label property, a more descriptive name can be populated for AT24 EEPROMs NVMEM device. Update the AT24 driver to check to see if the label property is present and if so, use this as the name for NVMEM device.
--- drivers/misc/eeprom/at24.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/misc/eeprom/at24.c +9 -1
@@ -713,7 +713,15 @@ static int at24_probe(struct i2c_client *client)return err; } - nvmem_config.name =dev_name (dev); +if (device_property_present (dev,"label" )) { + err =device_property_read_string (dev,"label" , + &nvmem_config.name); +if (err) +return err; + }else { + nvmem_config.name =dev_name (dev); + } + nvmem_config.dev = dev; nvmem_config.id =NVMEM_DEVID_NONE ; nvmem_config.read_only = !writable;
Signature · 1 line
2.25.1
Jon Hunter
maintainerPATCH 1/5 misc: eeprom: at24: Initialise AT24 NVMEM ID field
In reply to Jon HunterThe AT24 EEPROM driver does not initialise the 'id' field of the nvmem_config structure and because the entire structure is not initialised, it ends up with a random value. This causes the NVMEM driver to append the device 'devid' value to name of the NVMEM device. Although this is not a problem per-se, for I2C devices such as the AT24, that already have a device unique name, there does not seem much value in appending an additional 0 to the I2C name. For example, appending a 0 to an I2C device name such as 1-0050 does not seem necessary and maybe even a bit confusing. Therefore, fix this by setting the NVMEM config.id to NVMEM_DEVID_NONE for AT24 EEPROMs.
--- drivers/misc/eeprom/at24.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/eeprom/at24.c +1 -0
@@ -715,6 +715,7 @@ static int at24_probe(struct i2c_client *client) nvmem_config.name =dev_name (dev); nvmem_config.dev = dev; + nvmem_config.id =NVMEM_DEVID_NONE ; nvmem_config.read_only = !writable; nvmem_config.root_only = !(flags &AT24_FLAG_IRUGO ); nvmem_config.owner =THIS_MODULE ;
Signature · 1 line
2.25.1
Re: [PATCH 1/5] misc: eeprom: at24: Initialise AT24 NVMEM ID field
In reply to Jon HunterQuoted 69 lines · Jon Hunter
Quoted 44 lines · Jon Hunter
Quoted 24 lines · Bartosz Golaszewski
Quoted 23 lines · Jon Hunter
The AT24 EEPROM driver does not initialise the 'id' field of the
nvmem_configstructure and because the entire structure is not initialised, it ends up with a random value. This causes the NVMEM driver to append the device 'devid' value to name of the NVMEM device. Although this is not a problem per-se, for I2C devices such as the AT24, that already have a device unique name, there does not seem much value in appending an additional 0 to the I2C name. For example, appending a 0 to an I2C device name such as 1-0050 does not seem necessary and maybe even a bit confusing. Therefore, fix this by setting the NVMEM config.id toNVMEM_DEVID_NONEfor AT24 EEPROMs.Signed-off-by Jon Hunter <[email protected]>--- drivers/misc/eeprom/at24.c | 1 + 1 file changed, 1 insertion(+)drivers/misc/eeprom/at24.c +0
-0@@ -715,6 +715,7 @@ static int at24_probe(struct i2c_client *client)Quoted 16 lines
Quoted 9 lines
drivers/misc/eeprom/at24.c +1
-1nvmem_config.name =dev_name (dev); nvmem_config.dev = dev; + nvmem_config.id =NVMEM_DEVID_NONE ; nvmem_config.read_only = !writable; nvmem_config.root_only = !(flags &AT24_FLAG_IRUGO ); nvmem_config.owner =THIS_MODULE ; --2.25.1
This patch is correct and thanks for catching it. I vaguely recall wondering at some point why the appended 0 in the nvmem name for at24. Unfortunately this change would affect how the device is visible in user-space in
/sys/bus/nvmem/devices/and this could break existing users. Also: there are many in-kernel users that would need to be updated. I'm afraid we'll need some sort of backward compatibility.Quoted 6 lines
Thanks, yes that is a problem. I guess for now we could explicitly init to
NVMEM_DEVID_AUTOor maybe just 0 so that it defaults to the same path in the NVMEM driver. However, I am not sure how we can make allow some devices to useNVMEM_DEVID_NONEand others use something else. This is not really something that we can describe in DT because it has nothing to do with h/w.Unless we make the configuration of the 'id' dependent on the 'label' property so something like ...
if (device_property_present(dev, "label")) { nvmem_config.id = NVMEM_DEVID_NONE; err = device_property_read_string(dev, "label", &nvmem_config.name); if (err) return err; } else { nvmem_config.id = NVMEM_DEVID_AUTO; nvmem_config.name = dev_name(dev); }
Quoted 5 lines
Cheers
Jon--
nvpublic
Yes, this looks like the best compromise we can get for now. Please make sure to document why we do this in the code.
Bartosz
Rob Herring
maintainerRe: [PATCH 2/5] dt-bindings: eeprom: at24: Add label property for AT24
In reply to Jon HunterQuoted 14 lines · Jon Hunter
Add a label property for the AT24 EEPROM to allow a custom name to be used for identifying the EEPROM on a board. This is useful when there is more than one EEPROM present.
Signed-off-by Jon Hunter <[email protected]>--- Documentation/devicetree/bindings/eeprom/at24.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/eeprom/at24.yaml +0
-0
Documentation/devicetree/bindings/eeprom/at24.yaml properties: · line 119
Quoted 6 lines
Documentation/devicetree/bindings/eeprom/at24.yaml +3
-0@@ -114,6 +114,10 @@ properties: - const: renesas,r1ex24128 - const: atmel,24c128 + label: + description: Descriptive name of the EEPROM. + maxItems: 1
label is always a single string, so drop 'maxItems'.
Quoted 7 lines
Documentation/devicetree/bindings/eeprom/at24.yaml +1
-0+ reg: maxItems: 1Signature · 1 line
2.25.1