Add a Device Tree binding for the STMicroelectronics M24LR series
RFID/NFC EEPROM chips (e.g., M24LR04E-R), which support a separate
I2C interface for control and configuration.
This binding documents the control interface that is managed by
a dedicated driver exposing sysfs attributes. The EEPROM memory
interface is handled by the standard 'at24' driver and is
represented as a child node in the Device Tree.
Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
---
.../devicetree/bindings/misc/st,m24lr.yaml | 70 +++++++++++++++++++
1 file changed, 70 insertions(+)
create mode 100644 Documentation/devicetree/bindings/misc/st,m24lr.yaml
diff --git a/Documentation/devicetree/bindings/misc/st,m24lr.yaml b/Documentation/devicetree/bindings/misc/st,m24lr.yaml
new file mode 100644
index 000000000000..5a8f5aef13ec
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/st,m24lr.yaml
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/misc/st,m24lr.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: STMicroelectronics M24LR Series NFC/RFID EEPROM Control Interface
+
+maintainers:
+ - name: Abd-Alrhman Masalkhi
+ email: abd.masalkhi@gmail.com
+
+description: |
+ This binding describes the control interface for STMicroelectronics
+ M24LR series RFID/NFC EEPROM chips (e.g., M24LR04E-R, M24LR16E-R).
+ This driver provides sysfs access to device-specific control registers
+ (authentication, UID, etc.) over the I2C interface. It act as a
+ I2C gate for the EEPROM. Therefore, The EEPROM is represented as a
+ child node under a port and is accessed through a separate driver
+ (the standard 'at24' driver). This implementation is possible because
+ the M24LR chips uses two I2C addresses: one for accessing the
+ system parameter sector and another for the EEPROM.
+
+allOf:
+ - $ref: "i2c-mux.yaml#"
+
+properties:
+ compatible:
+ enum:
+ - st,m24lr04e-r
+ - st,m24lr16e-r
+ - st,m24lr64e-r
+
+ reg:
+ maxItems: 1
+ description: I2C address of the device.
+
+ pagesize:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: >
+ Maximum number of bytes that can be written in a single I2C
+ transaction. the default is 1.
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ i2c {
+ m24lr@57 {
+ compatible = "st,m24lr04e-r";
+ reg = <0x57>;
+
+ i2c-gate {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ m24lr_eeprom@53 {
+ compatible = "atmel,24c04";
+ reg = <0x53>;
+ address-width = <16>;
+ pagesize = <4>;
+ };
+ };
+ };
+ };
+...
\ No newline at end of file
--
2.43.0
On 31/05/2025 10:11, Abd-Alrhman Masalkhi wrote:
> Add a Device Tree binding for the STMicroelectronics M24LR series
> RFID/NFC EEPROM chips (e.g., M24LR04E-R), which support a separate
> I2C interface for control and configuration.
>
> This binding documents the control interface that is managed by
> a dedicated driver exposing sysfs attributes. The EEPROM memory
> interface is handled by the standard 'at24' driver and is
> represented as a child node in the Device Tree.
>
> Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
> ---
> .../devicetree/bindings/misc/st,m24lr.yaml | 70 +++++++++++++++++++
That's not a misc device, but eeprom. Place it in appropriate directory.
A nit, subject: drop second/last, redundant "binding for". The
"dt-bindings" prefix is already stating that these are bindings.
See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18
> 1 file changed, 70 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/misc/st,m24lr.yaml
>
> diff --git a/Documentation/devicetree/bindings/misc/st,m24lr.yaml b/Documentation/devicetree/bindings/misc/st,m24lr.yaml
> new file mode 100644
> index 000000000000..5a8f5aef13ec
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/misc/st,m24lr.yaml
> @@ -0,0 +1,70 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/misc/st,m24lr.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: STMicroelectronics M24LR Series NFC/RFID EEPROM Control Interface
> +
> +maintainers:
> + - name: Abd-Alrhman Masalkhi
> + email: abd.masalkhi@gmail.com
> +
> +description: |
> + This binding describes the control interface for STMicroelectronics
Describe the hardware, not the binding.
> + M24LR series RFID/NFC EEPROM chips (e.g., M24LR04E-R, M24LR16E-R).
> + This driver provides sysfs access to device-specific control registers
> + (authentication, UID, etc.) over the I2C interface. It act as a
Describe hardware, not drivers.
> + I2C gate for the EEPROM. Therefore, The EEPROM is represented as a
> + child node under a port and is accessed through a separate driver
> + (the standard 'at24' driver). This implementation is possible because
again, describe hardware not driver
> + the M24LR chips uses two I2C addresses: one for accessing the
> + system parameter sector and another for the EEPROM.
This suggests you have two I2C addresses for one device, not two devices
with parent child relationship.
> +
> +allOf:
> + - $ref: "i2c-mux.yaml#"
Drop quotes. So this is I2C mux or EEPROM?
> +
> +properties:
> + compatible:
> + enum:
> + - st,m24lr04e-r
> + - st,m24lr16e-r
> + - st,m24lr64e-r
> +
> + reg:
> + maxItems: 1
> + description: I2C address of the device.
Drop description, redundant.
This device is not compatible with AT24?
> +
> + pagesize:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: >
> + Maximum number of bytes that can be written in a single I2C
> + transaction. the default is 1.
enum:
default:
and drop redundant free form text.
> +
> +required:
> + - compatible
> + - reg
> +
> +additionalProperties: false
unevaluatedProperties instead
> +
> +examples:
> + - |
> + i2c {
> + m24lr@57 {
Node names should be generic. See also an explanation and list of
examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
> + compatible = "st,m24lr04e-r";
> + reg = <0x57>;
> +
> + i2c-gate {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + m24lr_eeprom@53 {
Node names should be generic. See also an explanation and list of
examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
> + compatible = "atmel,24c04";
> + reg = <0x53>;
> + address-width = <16>;
> + pagesize = <4>;
> + };
> + };
> + };
> + };
> +...
> \ No newline at end of file
Best regards,
Krzysztof
Hi Krzysztof, Thank you for your review. > Drop quotes. So this is I2C mux or EEPROM? The system parameter sector and the EEPROM do not share a continuous address space, each starts at address 0 and spans its own internal region. This overlapping addressing creates ambiguity if treated as a single memory space. Additionally, there's a synchronization issue: during multi-page writes to the EEPROM, if a control command (e.g., a lock) is issued mid-operation, it may result in partial or inconsistent writes. To address both challenges, the driver uses a mux-based design: 1- The m24lr_ctl driver acts as a gate for EEPROM access. 2- It provides exclusive, serialized access and handles the control interface. 3- The EEPROM itself is exposed as a child node using the standard at24 driver. This separation ensures reliable operation and a clean, maintainable architecture. > That's not a misc device, but eeprom. Place it in appropriate directory. Given the above, I'm unsure if placing it under eeprom/ is the best choice. Would you suggest still placing it eeprom or under somewhere else maybe i2c/ (e.g., i2c/i2c-mux-stm24lr.yaml)? Best regards, Abd-Alrhman Masalkhi
On Sat, 31 May 2025 08:11:57 +0000, Abd-Alrhman Masalkhi wrote:
> Add a Device Tree binding for the STMicroelectronics M24LR series
> RFID/NFC EEPROM chips (e.g., M24LR04E-R), which support a separate
> I2C interface for control and configuration.
>
> This binding documents the control interface that is managed by
> a dedicated driver exposing sysfs attributes. The EEPROM memory
> interface is handled by the standard 'at24' driver and is
> represented as a child node in the Device Tree.
>
> Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
> ---
> .../devicetree/bindings/misc/st,m24lr.yaml | 70 +++++++++++++++++++
> 1 file changed, 70 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/misc/st,m24lr.yaml
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
./Documentation/devicetree/bindings/misc/st,m24lr.yaml:25:11: [error] string value is redundantly quoted with any quotes (quoted-strings)
./Documentation/devicetree/bindings/misc/st,m24lr.yaml:30:5: [warning] wrong indentation: expected 6 but found 4 (indentation)
./Documentation/devicetree/bindings/misc/st,m24lr.yaml:70:4: [error] no new line character at the end of file (new-line-at-end-of-file)
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/st,m24lr.yaml: maintainers:0: {'name': 'Abd-Alrhman Masalkhi', 'email': 'abd.masalkhi@gmail.com'} is not of type 'string'
from schema $id: http://devicetree.org/meta-schemas/base.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/st,m24lr.yaml:
Error in referenced schema matching $id: http://devicetree.org/schemas/misc/i2c-mux.yaml
Tried these paths (check schema $id if path is wrong):
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/i2c-mux.yaml
/usr/local/lib/python3.11/dist-packages/dtschema/schemas/misc/i2c-mux.yaml
Documentation/devicetree/bindings/misc/st,m24lr.example.dts:21.13-26: Warning (reg_format): /example-0/i2c/m24lr@57:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: Warning (pci_device_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/misc/st,m24lr.example.dts:18.13-35.11: Warning (i2c_bus_bridge): /example-0/i2c: incorrect #address-cells for I2C bus
Documentation/devicetree/bindings/misc/st,m24lr.example.dts:18.13-35.11: Warning (i2c_bus_bridge): /example-0/i2c: incorrect #size-cells for I2C bus
Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: Warning (i2c_bus_reg): Failed prerequisite 'i2c_bus_bridge'
Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/misc/st,m24lr.example.dts:19.20-34.13: Warning (avoid_default_addr_size): /example-0/i2c/m24lr@57: Relying on default #address-cells value
Documentation/devicetree/bindings/misc/st,m24lr.example.dts:19.20-34.13: Warning (avoid_default_addr_size): /example-0/i2c/m24lr@57: Relying on default #size-cells value
Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: Warning (unique_unit_address_if_enabled): Failed prerequisite 'avoid_default_addr_size'
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: m24lr@57 (st,m24lr04e-r): 'i2c-gate' does not match any of the regexes: '^pinctrl-[0-9]+$'
from schema $id: http://devicetree.org/schemas/misc/st,m24lr.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: m24lr@57 (st,m24lr04e-r): {'compatible': ['st,m24lr04e-r'], 'reg': [[87]], 'i2c-gate': {'#address-cells': 1, '#size-cells': 0, 'm24lr_eeprom@53': {'compatible': ['atmel,24c04'], 'reg': [[83]], 'address-width': 16, 'pagesize': 4}}, '$nodename': ['m24lr@57']} should not be valid under {'description': "Can't find referenced schema: http://devicetree.org/schemas/misc/i2c-mux.yaml#"}
from schema $id: http://devicetree.org/schemas/misc/st,m24lr.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: m24lr_eeprom@53 (atmel,24c04): $nodename:0: 'm24lr_eeprom@53' does not match '^eeprom@[0-9a-f]{1,2}$'
from schema $id: http://devicetree.org/schemas/eeprom/at24.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/misc/st,m24lr.example.dtb: m24lr_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/misc/st,m24lr.example.dtb: m24lr_eeprom@53 (atmel,24c04): Unevaluated properties are not allowed ('$nodename', 'pagesize' were 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/20250531081159.2007319-2-abd.masalkhi@gmail.com
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.
© 2016 - 2025 Red Hat, Inc.