Skip to contentSkip to conversation

Add control driver for ST M24LR RFID/NFC EEPROM chips

PATCH Superseded Abd-Alrhman Masalkhi 4 participants 14 messages Jun 1, 2025 – Jun 3, 2025

Subsystems (2)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add control driver for ST M24LR RFID/NFC EEPROM chips

This patch series adds support for the control interface of STMicroelectronics M24LR RFID/NFC EEPROM devices, such as the M24LR04E-R. The chip exposes two I2C addresses and two distinct address spaces: one for the system parameter sector and another for the EEPROM memory. These address spaces overlap (both start at address 0). Due to this overlap, the chip cannot be represented by a single Device Tree node and handled by the standard at24 driver.

While it might be possible to model the system parameter sector and EEPROM as two separate DT nodes, each handled by the standard at24 driver, this leads to synchronization problems. For example, if a multi-page EEPROM write is in progress and a control command (e.g., a i2c write lock) is issued concurrently, it can result in incomplete or inconsistent writeing.

To overcome these issues, while maintaining a clean architecture and ensuring synchronization, the chip is managed by two drivers:

1- The first driver exposes the system parameter sector and acts as an I2C mux
(gate) for EEPROM access. Using an I2C mux solves the synchronization issue. This patch series implements this driver.
2- The second is the standard at24 driver, which handles the EEPROM.

Tested on: M24LR04E-R using Yocto on Raspberry Pi 4

Abd-Alrhman Masalkhi (3):
dt-bindings: eeprom: Add ST M24LR control interface
misc: add sysfs control driver for ST M24LR series RFID/NFC chips
ABI: sysfs: document control attributes for ST M24LR

 .../testing/sysfs-bus-i2c-devices-m24lr_ctl   |  96 +++
 .../devicetree/bindings/eeprom/st,m24lr.yaml  |  72 ++
 drivers/misc/Kconfig                          |  15 +
 drivers/misc/Makefile                         |   1 +
 drivers/misc/m24lr_ctl.c                      | 677 ++++++++++++++++++
 5 files changed, 861 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr_ctl
 create mode 100644 Documentation/devicetree/bindings/eeprom/st,m24lr.yaml
 create mode 100644 drivers/misc/m24lr_ctl.c
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/3 dt-bindings: eeprom: Add ST M24LR control interface

Add support for the control interface of STMicroelectronics M24LR RFID/NFC EEPROM chips.

---
 .../devicetree/bindings/eeprom/st,m24lr.yaml  | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/eeprom/st,m24lr.yaml
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +72 -0
new file mode 100644
index 000000000000..6d72325865d6
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/eeprom/st,m24lr.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: STMicroelectronics M24LR Series NFC/RFID EEPROM Control Interface
+
+maintainers:
+  - Abd-Alrhman Masalkhi <[email protected]>
+
+description: |
+  STMicroelectronics M24LR series are dual-interface (RF + I2C)
+  EEPROM chips. These devices support I2C-based access to both
+  memory and a system area that controls authentication and configuration.
+  They expose two I2C addresses: one for EEPROM memory and one for the
+  system control area (e.g., UID, password management).
+
+allOf:
+  - $ref: ../i2c/i2c-mux.yaml#
+
+properties:
+  compatible:
+    enum:
+      - st,m24lr04e-r
+      - st,m24lr16e-r
+      - st,m24lr64e-r
+
+  reg:
+    maxItems: 1
+
+  pagesize:
+    enum: [1, 4, 8, 16, 32, 64, 128, 256]
+    default: 1
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: >
+      Maximum number of bytes that can be written in one I2C transaction.
+      the default is 1.
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      i2cmux@57 {
+        compatible = "st,m24lr04e-r";
+        reg = <0x57>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        i2c@0 {
+          reg = <0x0>;
+          #address-cells = <1>;
+          #size-cells = <0>;
+
+          eeprom@53 {
+            compatible = "atmel,24c04";
+            reg = <0x53>;
+            address-width = <16>;
+            pagesize = <4>;
+          };
+        };
+      };
+    };
+...
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: eeprom: Add ST M24LR control interface

Quoted 6 lines · Abd-Alrhman Masalkhi

Add support for the control interface of STMicroelectronics M24LR RFID/NFC EEPROM chips.

---
 .../devicetree/bindings/eeprom/st,m24lr.yaml  | 72 +++++++++++++++++++

Do not send next version while the discussion is still happening.

Quoted 2 lines
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/eeprom/st,m24lr.yaml

I still do not understand what is this device exactly. You said this is not EEPROM, so my advice of putting this in eeprom seems not correct.

Quoted 9 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +2 -0
new file mode 100644
index 000000000000..6d72325865d6
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2

Documentation/devicetree/bindings/eeprom/st,m24lr.yaml line 12

Quoted 10 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +10 -0
+---
+$id: http://devicetree.org/schemas/eeprom/st,m24lr.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: STMicroelectronics M24LR Series NFC/RFID EEPROM Control Interface
+
+maintainers:
+  - Abd-Alrhman Masalkhi <[email protected]>
+
+description: |

Do not need '|' unless you need to preserve formatting.

Documentation/devicetree/bindings/eeprom/st,m24lr.yaml line 17

Quoted 5 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +5 -0
+  STMicroelectronics M24LR series are dual-interface (RF + I2C)
+  EEPROM chips. These devices support I2C-based access to both
+  memory and a system area that controls authentication and configuration.
+  They expose two I2C addresses: one for EEPROM memory and one for the
+  system control area (e.g., UID, password management).

e.g., -> e.g.

Documentation/devicetree/bindings/eeprom/st,m24lr.yaml line 20

Quoted 3 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +3 -0
+
+allOf:
+  - $ref: ../i2c/i2c-mux.yaml#

Full path, so /schemas/i2c/i2c-mux.... but this is not an i2c mux, at least not in your description, so something feels incomplete or incorrect.

Documentation/devicetree/bindings/eeprom/st,m24lr.yaml line 27

Quoted 7 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +7 -0
+
+properties:
+  compatible:
+    enum:
+      - st,m24lr04e-r
+      - st,m24lr16e-r
+      - st,m24lr64e-r

What does "r" stand for?

Documentation/devicetree/bindings/eeprom/st,m24lr.yaml line 36

Quoted 9 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +9 -0
+
+  reg:
+    maxItems: 1
+
+  pagesize:
+    enum: [1, 4, 8, 16, 32, 64, 128, 256]
+    default: 1
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: >

Do not need '>' unless you need to preserve formatting.

Documentation/devicetree/bindings/eeprom/st,m24lr.yaml line 38

Quoted 2 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +2 -0
+      Maximum number of bytes that can be written in one I2C transaction.
+      the default is 1.

Don't repeat constraints in free form text. I already asked for this.

Quoted 4 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +4 -0
+
+required:
+  - compatible
+  - reg

Documentation/devicetree/bindings/eeprom/st,m24lr.yaml line 52

Quoted 10 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +10 -0
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      i2cmux@57 {

Nothing in commit msg or binding description explained why this is i2c-mux. i2c-mux is not an eeprom. Exposing two I2C addresses also does not mean it is mux - we already have such devices and they were never called mux.

Documentation/devicetree/bindings/eeprom/st,m24lr.yaml line 54

Quoted 2 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +2 -0
+        compatible = "st,m24lr04e-r";
+        reg = <0x57>;

Where is the second address? It is supposed to be here.

Documentation/devicetree/bindings/eeprom/st,m24lr.yaml line 64

Quoted 10 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +10 -0
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        i2c@0 {
+          reg = <0x0>;
+          #address-cells = <1>;
+          #size-cells = <0>;
+
+          eeprom@53 {
+            compatible = "atmel,24c04";

And even if there was a mux here, then where is the second device?

Documentation/devicetree/bindings/eeprom/st,m24lr.yaml line 72

Quoted 8 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +8 -0
+            reg = <0x53>;
+            address-width = <16>;
+            pagesize = <4>;
+          };
+        };
+      };
+    };
+...

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v2 1/3] dt-bindings: Add Device Tree binding for ST M24LR control interface

Hi Krzysztof,

Thank you for the detailed feedback.

Quoted 1 line

Do not send next version while the discussion is still happening.

You're right, I sent the updated version too early while discussion was still ongoing. I'll hold off on sending further revisions until the current points are fully resolved.

Quoted 2 lines

Full path, so /schemas/i2c/i2c-mux.... but this is not an i2c mux, at least not in your description, so something feels incomplete or incorrect.

A Brief Overview of the Device:

The M24LR series is a dual-interface EEPROM with both I2C and ISO/IEC 15693 RF support. While it is technically an EEPROM, it also exposes a control interface over I2C via a second address, which is used to manage features such as password protection, energy harvesting configuration, and UID access. This secondary interface is not memory-mapped like traditional EEPROMs, which is why I initially considered separating the control aspect in the software.

How to Access the EEPROM and the System Parameter Sector?

According to the datasheet for the M24LR04E-R, the E2 bit must be set appropriately in the I2C device select code to distinguish between EEPROM access and control access.

What is E2?
E2 is a bit in the I2C device select code. It determines which internal function of the chip is being accessed.

Device Select Code Format:

Bit:                b7  b6  b5  b4  b3  b2  b1  b0
Value:              1   0   1   0   E2  1   1   R/W

To access the EEPROM memory, E2 (b3) should be 0:

Device Select Code Format:

Bit:                b7  b6  b5  b4  b3  b2  b1  b0
Value:              1   0   1   0   0  1   1   R/W

To access the system control interface, E2 (b3) should be 1:

Device Select Code Format:

Bit:                b7  b6  b5  b4  b3  b2  b1  b0
Value:              1   0   1   0   0  1   1   R/W

Is This a Gate?
Correct me if I'm wrong, but to me this behavior resembles a form of gate, instead of using a separate hardware pin to access the EEPROM, the chip encodes this selection in the I2C device address. However, the datasheet does not explicitly mention anything about a "gate" or "mux," which is why I've been careful to not label it as an I2C gate in the binding.

That said, I see it as a kind of implicit I2C mux (of type gate), where the chip use the 0x57 address as in the example and to select the internal EEPROM we just reset the b3 in the device select code.

Why This View Matters in my driver design:

Looking at the device from this perspective has helped me keep the driver design cleaner while keeping the synchronization issue in mind:

1- Avoiding code duplication (such as rewriting parts of the at24 driver). 2- Ensuring concurrent access to EEPROM and control areas is properly
handled and isolated.
3- Representing the dual-role nature of the chip more explicitly.

Quoted 1 line

What does "r" stand for?

The r in st,m24lr04e-r stands for RF, these are the RF-enabled variants of the M24LR series, as specified by STMicroelectronics.

Quoted 1 line

Do not need '>' unless you need to preserve formatting.

I'll remove the | and > where formatting preservation is not needed.

Quoted 1 line

Don't repeat constraints in free form text. I already asked for this.

I'll avoid repeating constraints in free-form text.

Quoted 7 lines

Where is the second address? It is supposed to be here.

Quoted 5 lines
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +5 -0
+          #size-cells = <0>;
+
+          eeprom@53 {
+            compatible = "atmel,24c04";
+            reg = <0x53>;

Here is the second address is 0x53, to select the EEPROM

I appreciate your feedback.

Best regards,
Abd-Alrhman Masalkhi

#4 lore raw

Re: [PATCH v2 1/3] dt-bindings: Add Device Tree binding for ST M24LR control interface

Quoted 36 lines · Abd-Alrhman Masalkhi

Hi Krzysztof,

Thank you for the detailed feedback.

Quoted 1 line

Do not send next version while the discussion is still happening.

You're right, I sent the updated version too early while discussion was still ongoing. I'll hold off on sending further revisions until the current points are fully resolved.

Quoted 2 lines

Full path, so /schemas/i2c/i2c-mux.... but this is not an i2c mux, at least not in your description, so something feels incomplete or incorrect.

A Brief Overview of the Device:

The M24LR series is a dual-interface EEPROM with both I2C and ISO/IEC 15693 RF support. While it is technically an EEPROM, it also exposes a control interface over I2C via a second address, which is used to manage features such as password protection, energy harvesting configuration, and UID access. This secondary interface is not memory-mapped like traditional EEPROMs, which is why I initially considered separating the control aspect in the software.

How to Access the EEPROM and the System Parameter Sector?

According to the datasheet for the M24LR04E-R, the E2 bit must be set appropriately in the I2C device select code to distinguish between EEPROM access and control access.

What is E2?
E2 is a bit in the I2C device select code. It determines which internal function of the chip is being accessed.

Device Select Code Format:

Bit:                b7  b6  b5  b4  b3  b2  b1  b0
Value:              1   0   1   0   E2  1   1   R/W
Quoted 7 lines

To access the EEPROM memory, E2 (b3) should be 0:

Device Select Code Format:

Bit:                b7  b6  b5  b4  b3  b2  b1  b0
Value:              1   0   1   0   0  1   1   R/W

To access the system control interface, E2 (b3) should be 1:

So these are just two different addresses. I already commented on this. This is not I2C mux but a device with two addresses.

Quoted 12 lines

Device Select Code Format:

Bit:                b7  b6  b5  b4  b3  b2  b1  b0
Value:              1   0   1   0   0  1   1   R/W

Is This a Gate?
Correct me if I'm wrong, but to me this behavior resembles a form of gate, instead of using a separate hardware pin to access the EEPROM, the chip encodes this selection in the I2C device address. However, the datasheet does not explicitly mention anything about a "gate" or "mux," which is why I've been careful to not label it as an I2C gate in the binding.

Quoted 5 lines

That said, I see it as a kind of implicit I2C mux (of type gate), where the chip use the 0x57 address as in the example and to select the internal EEPROM we just reset the b3 in the device select code.

Why This View Matters in my driver design:

We do not talk here about driver design but bindings.

Quoted 9 lines

Looking at the device from this perspective has helped me keep the driver design cleaner while keeping the synchronization issue in mind:

1- Avoiding code duplication (such as rewriting parts of the at24 driver). 2- Ensuring concurrent access to EEPROM and control areas is properly
handled and isolated.
3- Representing the dual-role nature of the chip more explicitly.

Quoted 4 lines
Quoted 1 line

What does "r" stand for?

The r in st,m24lr04e-r stands for RF, these are the RF-enabled variants of the M24LR series, as specified by STMicroelectronics.

It's fine.

Quoted 4 lines
Quoted 2 lines

Do not need '>' unless you need to preserve formatting.

I'll remove the | and > where formatting preservation is not needed.

Respond inline, not by removing entire context.

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH v2 1/3] dt-bindings: Add Device Tree binding for ST M24LR control interface

Hi Krzysztof,

Thank you again for yourfeedback, it's been very helpful in understanding how best to write the binding file represent this device.

Quoted 25 lines
Quoted 25 lines

A Brief Overview of the Device:

The M24LR series is a dual-interface EEPROM with both I2C and ISO/IEC 15693 RF support. While it is technically an EEPROM, it also exposes a control interface over I2C via a second address, which is used to manage features such as password protection, energy harvesting configuration, and UID access. This secondary interface is not memory-mapped like traditional EEPROMs, which is why I initially considered separating the control aspect in the software.

How to Access the EEPROM and the System Parameter Sector?

According to the datasheet for the M24LR04E-R, the E2 bit must be set appropriately in the I2C device select code to distinguish between EEPROM access and control access.

What is E2?
E2 is a bit in the I2C device select code. It determines which internal function of the chip is being accessed.

Device Select Code Format:

Bit:                b7  b6  b5  b4  b3  b2  b1  b0
Value:              1   0   1   0   E2  1   1   R/W

To access the EEPROM memory, E2 (b3) should be 0:

Quoted 8 lines
Quoted 5 lines

Device Select Code Format:

Bit:                b7  b6  b5  b4  b3  b2  b1  b0
Value:              1   0   1   0   0  1   1   R/W

To access the system control interface, E2 (b3) should be 1:

So these are just two different addresses. I already commented on this. This is not I2C mux but a device with two addresses.

I'd like to clarify one point before proceeding further, If I remove the i2c-mux usage from the binding file, as your recommendation, does this also imply that I should stop using the i2c-mux API in my driver implementation itself? and treat this as a multi-function device, or Is it acceptable to keep the current driver logic as-is, while limiting the change to just fixing the binding and device tree representation?

and if only the binding file, should i represent it as the following:

  eeprom-ctl@57 {
  #address-cells = <1>;
  #size-cells = <0>;
  compatible = "st,m24lr04e-r";
  reg = <0x57>;

  }

Best regards,
Abd-Alrhman Masalkhi

#6 lore raw

Re: [PATCH v2 1/3] dt-bindings: Add Device Tree binding for ST M24LR control interface

Quoted 13 lines · Abd-Alrhman Masalkhi
Quoted 13 lines
Quoted 12 lines

Device Select Code Format:

Bit:                b7  b6  b5  b4  b3  b2  b1  b0
Value:              1   0   1   0   E2  1   1   R/W

To access the EEPROM memory, E2 (b3) should be 0:

Device Select Code Format:

Bit:                b7  b6  b5  b4  b3  b2  b1  b0
Value:              1   0   1   0   0  1   1   R/W

To access the system control interface, E2 (b3) should be 1:

Quoted 7 lines
Quoted 2 lines

So these are just two different addresses. I already commented on this. This is not I2C mux but a device with two addresses.

I'd like to clarify one point before proceeding further, If I remove the i2c-mux usage from the binding file, as your recommendation, does this also imply that I should stop using the i2c-mux API in my driver implementation itself? and treat this as a multi-function device, or

Not using i2c-mux schema means only that you cannot use i2c-mux properties. Maybe this implies that you cannot use i2c-mux API, feels likely, but not really sure and I don't want to take responsibility for that decision.

I am commenting here about bindings, not the drivers. Drivers can implement binding in many different ways, thus discussion about bindings is independent, except narrowing/restricting the ABI.

Quoted 2 lines

Is it acceptable to keep the current driver logic as-is, while limiting the change to just fixing the binding and device tree representation?

Dunno, did not look at your driver. Again, I am here talking about bindings. How you implement it in the driver is up to you. You have however one device with two addresses, so you should most likely have only one device node in DTS with two addresses. In certain cases, like separate resources and re-usability, children are common, but that was not really the case here.

Look at ti,pcm6240.yaml, ti,tas2781.yaml and few others (you can git grep for them for reg with coma).

Quoted 6 lines

and if only the binding file, should i represent it as the following:

  eeprom-ctl@57 {
  #address-cells = <1>;
  #size-cells = <0>;

These two are obviously not used.

Quoted 2 lines
  compatible = "st,m24lr04e-r";
  reg = <0x57>;

That's only one address, you need two.

Quoted 5 lines
  }

Best regards,
Abd-Alrhman Masalkhi

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH v2 1/3] dt-bindings: Add Device Tree binding for ST M24LR control interface

Hi Krzysztof,

Quoted 10 lines
Quoted 2 lines

Is it acceptable to keep the current driver logic as-is, while limiting the change to just fixing the binding and device tree representation?

Dunno, did not look at your driver. Again, I am here talking about bindings. How you implement it in the driver is up to you. You have however one device with two addresses, so you should most likely have only one device node in DTS with two addresses. In certain cases, like separate resources and re-usability, children are common, but that was not really the case here.

Quoted 2 lines

Look at ti,pcm6240.yaml, ti,tas2781.yaml and few others (you can git grep for them for reg with coma).

Okay, I'll rework the pathcs to use a single device node with two addresses instead of modeling it as an I2C mux. Thanks also for the hint about ti,pcm6240.yaml and ti,tas2781.yaml, I'll review those to make sure the structure aligns properly.

I appreciate your guidance.

Best regards,
Abd-Alrhman Masalkhi

#8 lore raw

Re: [PATCH v2 1/3] dt-bindings: eeprom: Add ST M24LR control interface

In reply to Abd-Alrhman Masalkhi
Quoted 9 lines · Abd-Alrhman Masalkhi

Add support for the control interface of STMicroelectronics M24LR RFID/NFC EEPROM chips.

---
 .../devicetree/bindings/eeprom/st,m24lr.yaml  | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/eeprom/st,m24lr.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/eeprom/st,m24lr.example.dtb: eeprom@53 (atmel,24c04): pagesize: 4 is not one of [1, 8, 16, 32, 64, 128, 256]
from schema $id: http://devicetree.org/schemas/eeprom/at24.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/eeprom/st,m24lr.example.dtb: eeprom@53 (atmel,24c04): Unevaluated properties are not allowed ('pagesize' was unexpected)
from schema $id: http://devicetree.org/schemas/eeprom/at24.yaml#

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#9 lore raw

Re: [PATCH v2 1/3] dt-bindings: eeprom: Add ST M24LR control interface

Hi Rob,

Thanks for the feedback.

Quoted 12 lines

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/eeprom/st,m24lr.example.dtb: eeprom@53 > (atmel,24c04): pagesize: 4 is not one of [1, 8, 16, 32, 64, 128, 256]
from schema $id: http://devicetree.org/schemas/eeprom/at24.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/eeprom/st,m24lr.example.dtb: eeprom@53 > (atmel,24c04): Unevaluated properties are not allowed ('pagesize' was unexpected)
from schema $id: http://devicetree.org/schemas/eeprom/at24.yaml#

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

Quoted 8 lines

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

I had already updated dtschema to the latest version and ensured that yamllint was installed, as advised in the previous version. i have executed 'make dt_binding_check' as you guided me, but still it did not emit any errors.

Best regards,
Abd-Alrhman Masalkhi

#10 lore raw

Re: [PATCH v2 1/3] dt-bindings: eeprom: Add ST M24LR control interface

Quoted 23 lines · Abd-Alrhman Masalkhi

Hi Rob,

Thanks for the feedback.

Quoted 19 lines

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/eeprom/st,m24lr.example.dtb: eeprom@53 > (atmel,24c04): pagesize: 4 is not one of [1, 8, 16, 32, 64, 128, 256]
from schema $id: http://devicetree.org/schemas/eeprom/at24.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/eeprom/st,m24lr.example.dtb: eeprom@53 > (atmel,24c04): Unevaluated properties are not allowed ('pagesize' was unexpected)
from schema $id: http://devicetree.org/schemas/eeprom/at24.yaml#

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

Quoted 6 lines
Quoted 1 line

pip3 install dtschema --upgrade

I had already updated dtschema to the latest version and ensured that yamllint was installed, as advised in the previous version. i have executed 'make dt_binding_check' as you guided me, but still it did not emit any errors.

I doubt that you run it exactly the way as describe here, because you have obvious error in binding which is nicely reported here - you put pagesize to wrong node.

Best regards,
Krzysztof

#11 lore raw

PATCH v2 2/3 misc: add sysfs control driver for ST M24LR series RFID/NFC chips

In reply to Abd-Alrhman Masalkhi

Add a sysfs-based control driver for the STMicroelectronics M24LR series RFID/NFC EEPROM chips, such as the M24LR04E-R. It enables access to control registers for features such as password authentication, memory access, and device configuration. It also synchronize access to the device. (The EEPROM uses a separate driver; see the note below for details.)

This driver provides only the control interface for M24LR chips. It also acts as an I2C mux (gate) for the EEPROM. Therefore, the EEPROM is represented as a child node in the Device Tree and is accessed through a separate driver (the standard 'at24' driver). This setup is possible because M24LR chips use two I2C addresses: one for accessing the system parameter sector, and another for accessing the EEPROM.

---
 drivers/misc/Kconfig     |  15 +
 drivers/misc/Makefile    |   1 +
 drivers/misc/m24lr_ctl.c | 677 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 693 insertions(+)
 create mode 100644 drivers/misc/m24lr_ctl.c
drivers/misc/Kconfig +15 -0
index c161546d728f..c4152f03695f 100644
@@ -644,6 +644,21 @@ config MCHP_LAN966X_PCI
 	    - lan966x-miim (MDIO_MSCC_MIIM)
 	    - lan966x-switch (LAN966X_SWITCH)
 
+config M24LR_CTL
+	tristate "M24LR I2C RFID/NFC Control Interface driver"
+	depends on I2C_MUX && SYSFS
+	select REGMAP_I2C
+	help
+	  This driver provides support for the control interface of M24LR I2C
+	  RFID/NFC chips.
+
+	  Note This driver does not handle the EEPROM on the device. For EEPROM
+	  access, use the standard 'at24' driver (drivers/misc/eeprom/at24.c),
+	  which supports I2C-based EEPROMs.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called m24lr_ctl.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
index 054cee9b08a4..5ae54112ad7e 100644
@@ -75,3 +75,4 @@ lan966x-pci-objs		:= lan966x_pci.o
 lan966x-pci-objs		+= lan966x_pci.dtbo.o
 obj-$(CONFIG_MCHP_LAN966X_PCI)	+= lan966x-pci.o
 obj-y				+= keba/
+obj-$(CONFIG_M24LR_CTL)		+= m24lr_ctl.o
drivers/misc/m24lr_ctl.c new file +677 -0

677 lines not on this page · raw message

Signature · 1 line
2.43.0
#12 lore raw

PATCH v2 3/3 ABI: sysfs: document control attributes for ST M24LR

In reply to Abd-Alrhman Masalkhi

Add documentation for sysfs attributes used by the M24LR control interface, including unlock, password update, UID, memory size, and sector security status.

---
 .../testing/sysfs-bus-i2c-devices-m24lr_ctl   | 96 +++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr_ctl
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr_ctl new file +96 -0
new file mode 100644
index 000000000000..50228f9f43f6
@@ -0,0 +1,96 @@
+What:           /sys/bus/i2c/devices/<busnum>-<addr>/unlock
+Date:           2025-05-31
+KernelVersion:  6.16
+Contact:        Abd-Alrhman Masalkhi <[email protected]>
+Description:
+                Write-only attribute used to present a password and unlock
+                access to protected areas of the M24LR chip, including
+                configuration registers such as the Sector Security Status
+                (SSS) bytes. A valid password must be written to enable write
+                access to these regions via the I2C interface.
+
+                Format:
+                  - Hexadecimal string representing a 32-bit (4-byte) password
+                  - Accepts 1 to 8 hex digits (e.g., "c", "1F", "a1b2c3d4")
+                  - No "0x" prefix, whitespace, or trailing newline
+                  - Case-insensitive
+
+                Behavior:
+                  - If the password matches the internal stored value,
+                    access to protected memory/configuration is granted
+                  - If the password does not match the internally stored value,
+                    it will fail silently
+
+What:           /sys/bus/i2c/devices/<busnum>-<addr>/new_pass
+Date:           2025-05-31
+KernelVersion:  6.16
+Contact:        Abd-Alrhman Masalkhi <[email protected]>
+Description:
+                Write-only attribute used to update the password required to
+                unlock the M24LR chip.
+
+                Format:
+                  - Hexadecimal string representing a new 32-bit password
+                  - Accepts 1 to 8 hex digits (e.g., "1A", "ffff", "c0ffee00")
+                  - No "0x" prefix, whitespace, or trailing newline
+                  - Case-insensitive
+
+                Behavior:
+                  - Overwrites the current password stored in the I2C password
+                    register
+                  - Requires the device to be unlocked before changing the
+                    password
+                  - If the device is locked, the write silently fails
+
+What:           /sys/bus/i2c/devices/<busnum>-<addr>/uid
+Date:           2025-05-31
+KernelVersion:  6.16
+Contact:        Abd-Alrhman Masalkhi <[email protected]>
+Description:
+                Read-only attribute that exposes the 8-byte unique identifier
+                programmed into the M24LR chip at the factory.
+
+                Format:
+                  - Lowercase hexadecimal string representing a 64-bit value
+                  - 1 to 16 hex digits (e.g., "e00204f12345678")
+                  - No "0x" prefix
+                  - Includes a trailing newline
+
+What:           /sys/bus/i2c/devices/<busnum>-<addr>/mem_size
+Date:           2025-05-31
+KernelVersion:  6.16
+Contact:        Abd-Alrhman Masalkhi <[email protected]>
+Description:
+                Read-only attribute that exposes the internal memory size code
+                of the M24LR device, as stored in the system register area.
+
+                Format:
+                  - Unsigned 8-bit integer
+                  - Includes a trailing newline
+
+                Notes:
+                  - Value is encoded by the chip and corresponds to the EEPROM
+                    size (e.g., 3 = 4 kbit for M24LR04E-R)
+
+What:           /sys/bus/i2c/devices/<busnum>-<addr>/sss<N>
+Date:           2025-05-31
+KernelVersion:  6.16
+Contact:        Abd-Alrhman Masalkhi <[email protected]>
+Description:
+                Read/write attribute representing the Sector Security Status
+                (SSS) byte for EEPROM sector <N> in the M24LR chips. Each sector
+                has one SSS byte, which defines I2c and RF access control via a
+                combination of protection and password settings.
+
+                Format:
+                  - Read: returns a 8-bit hexadecimal value followed by a
+                          newline
+                  - Write: requires exactly one or two hexadecimal digits
+                      - No "0x" prefix, whitespace, or trailing newline
+                      - Case-insensitive
+
+                Notes:
+                  - Refer to the M24LR chip datasheet for full bit definitions
+                    and usage
+                  - Write access requires prior password authentication in I2C
+                    mode
Signature · 1 line
2.43.0
maintainer
#13 lore raw
In reply to Abd-Alrhman Masalkhi
Quoted 30 lines · Abd-Alrhman Masalkhi

This patch series adds support for the control interface of STMicroelectronics M24LR RFID/NFC EEPROM devices, such as the M24LR04E-R. The chip exposes two I2C addresses and two distinct address spaces: one for the system parameter sector and another for the EEPROM memory. These address spaces overlap (both start at address 0). Due to this overlap, the chip cannot be represented by a single Device Tree node and handled by the standard at24 driver.

While it might be possible to model the system parameter sector and EEPROM as two separate DT nodes, each handled by the standard at24 driver, this leads to synchronization problems. For example, if a multi-page EEPROM write is in progress and a control command (e.g., a i2c write lock) is issued concurrently, it can result in incomplete or inconsistent writeing.

To overcome these issues, while maintaining a clean architecture and ensuring synchronization, the chip is managed by two drivers:

1- The first driver exposes the system parameter sector and acts as an I2C mux
(gate) for EEPROM access. Using an I2C mux solves the synchronization issue. This patch series implements this driver.
2- The second is the standard at24 driver, which handles the EEPROM.

Tested on: M24LR04E-R using Yocto on Raspberry Pi 4

Abd-Alrhman Masalkhi (3):
dt-bindings: eeprom: Add ST M24LR control interface
misc: add sysfs control driver for ST M24LR series RFID/NFC chips
ABI: sysfs: document control attributes for ST M24LR

Quoted 13 lines
 .../testing/sysfs-bus-i2c-devices-m24lr_ctl   |  96 +++
 .../devicetree/bindings/eeprom/st,m24lr.yaml  |  72 ++
 drivers/misc/Kconfig                          |  15 +
 drivers/misc/Makefile                         |   1 +
 drivers/misc/m24lr_ctl.c                      | 677 ++++++++++++++++++
 5 files changed, 861 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr_ctl
 create mode 100644 Documentation/devicetree/bindings/eeprom/st,m24lr.yaml
 create mode 100644 drivers/misc/m24lr_ctl.c
Signature · 1 line
2.43.0

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot