Add support for STMicroelectronics M24LR EEPROM/NFC chips
Subsystems (2)
v4 cover Add support for STMicroelectronics M24LR EEPROM/NFC chips
This patch series adds support for the STMicroelectronics M24LR series RFID/NFC EEPROM devices. These chips expose two I2C addresses: the primary one provides access to system control and configuration registers, while the secondary address is used for EEPROM access.
The driver implements both functionalities:
- A sysfs-based interface for the control and system parameter registers.
- EEPROM access via the nvmem subsystem using a secondary I2C dummy client.
Tested on: M24LR04E-R using Yocto on Raspberry Pi 4
Abd-Alrhman Masalkhi (3):
dt-bindings: eeprom: Add ST M24LR support
eeprom: add driver for ST M24LR series RFID/NFC EEPROM chips
ABI: sysfs: add documentation for ST M24LR EEPROM and control
interface
.../ABI/testing/sysfs-bus-i2c-devices-m24lr | 100 +++ .../devicetree/bindings/eeprom/st,m24lr.yaml | 52 ++ drivers/misc/eeprom/Kconfig | 18 + drivers/misc/eeprom/Makefile | 1 + drivers/misc/eeprom/m24lr.c | 653 ++++++++++++++++++ 5 files changed, 824 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr create mode 100644 Documentation/devicetree/bindings/eeprom/st,m24lr.yaml create mode 100644 drivers/misc/eeprom/m24lr.c
Signature · 1 line
2.43.0
PATCH v4 1/3 dt-bindings: eeprom: Add ST M24LR support
Add support for STMicroelectronics M24LR RFID/NFC EEPROM chips. These devices use two I2C addresses: the primary address provides access to control and system parameter registers, while the secondary address is used for EEPROM access.
---
Changes in v4:
- Moved the binding file to the eeprom/ directory
- Updated reg property to use items: with per-address descriptions instead of minItems/maxItems
--- .../devicetree/bindings/eeprom/st,m24lr.yaml | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/eeprom/st,m24lr.yaml
Documentation/devicetree/bindings/eeprom/st,m24lr.yaml new file +52 -0
@@ -0,0 +1,52 @@ +# 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 NFC/RFID EEPROM + +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 the system parameter sector and + one for the EEPROM. + +allOf: + - $ref: /schemas/nvmem/nvmem.yaml# + +properties: + compatible: + enum: + - st,m24lr04e-r + - st,m24lr16e-r + - st,m24lr64e-r + + reg: + items: + - description: I2C address used for control/system registers + - description: I2C address used for EEPROM memory access + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + eeprom@57 { + compatible = "st,m24lr04e-r"; + reg = <0x57>, /* primary-device */ + <0x53>; /* secondary-device */ + }; + }; +...
Signature · 1 line
2.43.0
Re: [PATCH v4 1/3] dt-bindings: eeprom: Add ST M24LR support
Quoted 11 lines · Abd-Alrhman Masalkhi
Add support for STMicroelectronics M24LR RFID/NFC EEPROM chips. These devices use two I2C addresses: the primary address provides access to control and system parameter registers, while the secondary address is used for EEPROM access.
Signed-off-by Abd-Alrhman Masalkhi <[email protected]>---
Changes in v4:
- Moved the binding file to the eeprom/ directory
- Updated reg property to use items: with per-address descriptions instead of minItems/maxItems
And the rest of the changelog? Where is v2, v3?
Quoted 4 lines
--- .../devicetree/bindings/eeprom/st,m24lr.yaml | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/eeprom/st,m24lr.yaml
Best regards,
Krzysztof
Re: [PATCH v4 1/3] dt-bindings: eeprom: Add ST M24LR support
Hi Krzysztof,
Thank you for the review.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Abd-Alrhman Masalkhi <[email protected]>---
Changes in v4:
- Moved the binding file to the eeprom/ directory
- Updated reg property to use items: with per-address descriptions instead of minItems/maxItemsAnd the rest of the changelog? Where is v2, v3?
Apologies for the omission, I'll make sure to include all previous changes in any future patches.
Best regards,
Abd-Alrhman Masalkhi
PATCH v4 2/3 eeprom: add driver for ST M24LR series RFID/NFC EEPROM chips
In reply to Abd-Alrhman Masalkhiadds support for STMicroelectronics M24LRxx devices, which expose two separate I2C addresses: one for system control and one for EEPROM access. The driver implements both a sysfs-based interface for control registers (e.g. UID, password authentication) and an nvmem provider for EEPROM access.
---
Changes in v4:
- Moved the source file to the eeprom/ directory
- Removed use of unlikely() macro
- Removed use of EIO as a fallback error
- Stopped dynamically creating sysfs attributes
- Replaced per-sector SSS attributes with a single bin_attribute for all SSS
- Introduced total_sectors sysfs attribute to report the number of valid sectors
- Avoided sharing a single show/store callback across multiple attribute types
--- drivers/misc/eeprom/Kconfig | 18 + drivers/misc/eeprom/Makefile | 1 + drivers/misc/eeprom/m24lr.c | 653 +++++++++++++++++++++++++++++++++++ 3 files changed, 672 insertions(+) create mode 100644 drivers/misc/eeprom/m24lr.c
drivers/misc/eeprom/Kconfig +18 -0
@@ -119,4 +119,22 @@ config EEPROM_EE1004 This driver can also be built as a module. If so, the module will be called ee1004. +config EEPROM_M24LR + tristate "STMicroelectronics M24LR RFID/NFC EEPROM support" + depends on I2C && SYSFS + select REGMAP_I2C + select NVMEM + select NVMEM_SYSFS + help + This enables support for STMicroelectronics M24LR RFID/NFC EEPROM + chips. These dual-interface devices expose two I2C addresses: + one for EEPROM memory access and another for control and system + configuration (e.g. UID, password handling). + + This driver provides a sysfs interface for control functions and + integrates with the nvmem subsystem for EEPROM access. + + To compile this driver as a module, choose M here: the + module will be called m24lr. + endmenu
drivers/misc/eeprom/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_EEPROM_93XX46) += eeprom_93xx46.o obj-$(CONFIG_EEPROM_DIGSY_MTC_CFG) += digsy_mtc_eeprom.o obj-$(CONFIG_EEPROM_IDT_89HPESX) += idt_89hpesx.o obj-$(CONFIG_EEPROM_EE1004) += ee1004.o +obj-$(CONFIG_EEPROM_M24LR) += m24lr.o
drivers/misc/eeprom/m24lr.c new file +653 -0
653 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v4 3/3 ABI: sysfs: add documentation for ST M24LR EEPROM and control interface
In reply to Abd-Alrhman MasalkhiAdd sysfs ABI documentation for the STMicroelectronics M24LR device, covering both the control interface (e.g., unlock, password update, UID, memory size, and SSS entries) and EEPROM access via the nvmem subsystem.
---
Changes in v4:
- Replaced 'sss<N>' entries with a single binary 'sss' attribute
- Added 'total_sectors' attribute to report the number of valid SSS bytes
- removed 'mem_size' attribute
--- .../ABI/testing/sysfs-bus-i2c-devices-m24lr | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +100 -0
@@ -0,0 +1,100 @@ +What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/unlock +Date: 2025-06-8 +KernelVersion: 6.15 +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>-<primary-addr>/new_pass +Date: 2025-06-8 +KernelVersion: 6.15 +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>-<primary-addr>/uid +Date: 2025-06-8 +KernelVersion: 6.15 +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>-<primary-addr>/total_sectors +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Read-only attribute that exposes the total number of EEPROM + sectors available in the M24LR chip. + + Format: + - 1 to 2 hex digits (e.g. "F") + - No "0x" prefix + - 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>-<primary-addr>/sss +Date: 2025-06-8 +KernelVersion: 6.15 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Read/write binary attribute representing the Sector Security + Status (SSS) bytes for all EEPROM sectors in STMicroelectronics + M24LR chips. + + Each EEPROM sector has one SSS byte, which controls I2C and + RF access through protection bits and optional password + authentication. + + Format: + - The file contains one byte per EEPROM sector + - Byte at offset N corresponds to sector N + - Binary access only; use tools like dd, Python, or C that + support byte-level I/O and offset control. + + Notes: + - The number of valid bytes in this file is equal to the + value exposed by 'total_sectors' file + - Write access requires prior password authentication in + I2C mode + - Refer to the M24LR datasheet for full SSS bit layout
Signature · 1 line
2.43.0
PATCH v4 3/3 ABI: sysfs: add documentation for ST M24LR EEPROM and control interface
Hello Greg,
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 3
Quoted 3 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +3
-0+What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/unlock +Date: 2025-06-8 +KernelVersion: 6.15
Apologies for the typo, the correct kernel version should be 6.17, targeting the next available merge window.
Should I resubmit the entire series as v5 with this fix applied, or is it acceptable to submit a single follow-up patch that corrects it?
Thank you for your guidance.
Best regards,
Abd-Alrhman Masalkhi