* [PATCH v2 0/2] i2c: slave-eeprom: DT binding and OF match table for module autoload
@ 2026-11-20 4:32 ` Arun Iyengar
0 siblings, 0 replies; 7+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-20 4:32 UTC (permalink / raw)
To: Andi Shyti, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Wolfram Sang, Uwe Kleine-König, Björn Ardö,
linux-i2c, devicetree, linux-kernel, Arun Iyengar
A slave EEPROM backend described in the device tree binds only when the
driver is built in: the client announces an of: modalias and the module
has only i2c: aliases. Patch 2 adds the OF table.
Patch 1 documents the compatibles. Wolfram Sang asked for a YAML file
when Björn Ardö sent a patch for the same problem in 2021 [1], and on v1
he asked why compatibles without a binding should be added.
The binding keeps the driver's names, without a vendor prefix. Björn's
patch and the old DesignWare binding example (removed in 2020) used
"linux,slave-24c02"; that form binds too, because the I2C core strips
the prefix, but would not autoload with this table. I can switch to it
or list both if preferred.
This series was developed with Claude (Anthropic) as a coding assistant:
it investigated the problem, wrote the code, the binding and the commit
messages. I reviewed it, and it was tested on an Orange Pi Zero2 (H616)
as described in patch 2.
[1] https://lore.kernel.org/r/20210504135209.4757-1-bjorn.ardo@axis.com
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Changes in v2:
- New patch 1: DT binding for the compatibles (Wolfram Sang).
- Drop the <linux/mod_devicetable.h> include: <linux/i2c.h> already
provides of_device_id (Uwe Kleine-König).
- Fix a NULL dereference in v1: a node that matches through a fallback
compatible has no i2c id. Take the size and flags from
i2c_get_match_data() and give the OF entries that data.
- Rebase onto i2c/i2c-next, new test results.
- Link to v1: https://patch.msgid.link/20261110-i2c-slave-eeprom-of-match-v1-1-8f762bf06205@gmail.com
---
Arun Iyengar (2):
dt-bindings: i2c: Add the slave EEPROM backend
i2c: slave-eeprom: Add an OF match table for module autoload
.../devicetree/bindings/i2c/slave-eeprom.yaml | 59 ++++++++++++++++++++++
drivers/i2c/i2c-slave-eeprom.c | 34 +++++++++++--
2 files changed, 89 insertions(+), 4 deletions(-)
---
base-commit: 9c19b1c078541841f6b68f815bb4ba5201ab2b65
change-id: 20261110-i2c-slave-eeprom-of-match-ba9fdb67a830
Best regards,
--
Arun Iyengar <aiyengar1990@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2 0/2] i2c: slave-eeprom: DT binding and OF match table for module autoload @ 2026-11-20 4:32 ` Arun Iyengar 0 siblings, 0 replies; 7+ messages in thread From: Arun Iyengar @ 2026-11-20 4:32 UTC (permalink / raw) To: Andi Shyti, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: Wolfram Sang, Uwe Kleine-König, Björn Ardö, linux-i2c, devicetree, linux-kernel, Arun Iyengar A slave EEPROM backend described in the device tree binds only when the driver is built in: the client announces an of: modalias and the module has only i2c: aliases. Patch 2 adds the OF table. Patch 1 documents the compatibles. Wolfram Sang asked for a YAML file when Björn Ardö sent a patch for the same problem in 2021 [1], and on v1 he asked why compatibles without a binding should be added. The binding keeps the driver's names, without a vendor prefix. Björn's patch and the old DesignWare binding example (removed in 2020) used "linux,slave-24c02"; that form binds too, because the I2C core strips the prefix, but would not autoload with this table. I can switch to it or list both if preferred. This series was developed with Claude (Anthropic) as a coding assistant: it investigated the problem, wrote the code, the binding and the commit messages. I reviewed it, and it was tested on an Orange Pi Zero2 (H616) as described in patch 2. [1] https://lore.kernel.org/r/20210504135209.4757-1-bjorn.ardo@axis.com Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com> --- Changes in v2: - New patch 1: DT binding for the compatibles (Wolfram Sang). - Drop the <linux/mod_devicetable.h> include: <linux/i2c.h> already provides of_device_id (Uwe Kleine-König). - Fix a NULL dereference in v1: a node that matches through a fallback compatible has no i2c id. Take the size and flags from i2c_get_match_data() and give the OF entries that data. - Rebase onto i2c/i2c-next, new test results. - Link to v1: https://patch.msgid.link/20261110-i2c-slave-eeprom-of-match-v1-1-8f762bf06205@gmail.com --- Arun Iyengar (2): dt-bindings: i2c: Add the slave EEPROM backend i2c: slave-eeprom: Add an OF match table for module autoload .../devicetree/bindings/i2c/slave-eeprom.yaml | 59 ++++++++++++++++++++++ drivers/i2c/i2c-slave-eeprom.c | 34 +++++++++++-- 2 files changed, 89 insertions(+), 4 deletions(-) --- base-commit: 9c19b1c078541841f6b68f815bb4ba5201ab2b65 change-id: 20261110-i2c-slave-eeprom-of-match-ba9fdb67a830 Best regards, -- Arun Iyengar <aiyengar1990@gmail.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] dt-bindings: i2c: Add the slave EEPROM backend 2026-11-20 4:32 ` Arun Iyengar @ 2026-11-20 4:32 ` Arun Iyengar -1 siblings, 0 replies; 7+ messages in thread From: Arun Iyengar via B4 Relay @ 2026-11-20 4:32 UTC (permalink / raw) To: Andi Shyti, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: Wolfram Sang, Uwe Kleine-König, Björn Ardö, linux-i2c, devicetree, linux-kernel, Arun Iyengar From: Arun Iyengar <aiyengar1990@gmail.com> A node with one of the i2c-slave-eeprom names as compatible and I2C_OWN_SLAVE_ADDRESS in reg already binds to the backend, because the I2C core names the client after the compatible and matches the I2C id. The driver also reads firmware-name. None of this is documented. Document the names without a vendor prefix, as the driver and Documentation/i2c spell them (ipmb-dev and mctp-i2c-controller are unprefixed too). Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com> --- .../devicetree/bindings/i2c/slave-eeprom.yaml | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/slave-eeprom.yaml b/Documentation/devicetree/bindings/i2c/slave-eeprom.yaml new file mode 100644 index 000000000000..b7a6e6653a64 --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/slave-eeprom.yaml @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/i2c/slave-eeprom.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: I2C target EEPROM backend + +maintainers: + - Arun Iyengar <aiyengar1990@gmail.com> + +description: + The I2C controller answers on its own address as a target and behaves + like a 24Cxx EEPROM towards the other controllers on the bus. The + compatible selects the EEPROM type that is simulated. The "ro" variants + ignore writes from the bus. + +properties: + compatible: + enum: + - slave-24c02 + - slave-24c02ro + - slave-24c32 + - slave-24c32ro + - slave-24c64 + - slave-24c64ro + - slave-24c512 + - slave-24c512ro + + reg: + maxItems: 1 + description: + Own address of the controller on the bus. The I2C_OWN_SLAVE_ADDRESS + flag must be set. + + firmware-name: + maxItems: 1 + description: + File with the initial content. Without it all bytes start as 0xff. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/i2c/i2c.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + eeprom@64 { + compatible = "slave-24c02"; + reg = <(0x64 | I2C_OWN_SLAVE_ADDRESS)>; + }; + }; -- 2.55.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] dt-bindings: i2c: Add the slave EEPROM backend @ 2026-11-20 4:32 ` Arun Iyengar 0 siblings, 0 replies; 7+ messages in thread From: Arun Iyengar @ 2026-11-20 4:32 UTC (permalink / raw) To: Andi Shyti, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: Wolfram Sang, Uwe Kleine-König, Björn Ardö, linux-i2c, devicetree, linux-kernel, Arun Iyengar A node with one of the i2c-slave-eeprom names as compatible and I2C_OWN_SLAVE_ADDRESS in reg already binds to the backend, because the I2C core names the client after the compatible and matches the I2C id. The driver also reads firmware-name. None of this is documented. Document the names without a vendor prefix, as the driver and Documentation/i2c spell them (ipmb-dev and mctp-i2c-controller are unprefixed too). Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com> --- .../devicetree/bindings/i2c/slave-eeprom.yaml | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/slave-eeprom.yaml b/Documentation/devicetree/bindings/i2c/slave-eeprom.yaml new file mode 100644 index 000000000000..b7a6e6653a64 --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/slave-eeprom.yaml @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/i2c/slave-eeprom.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: I2C target EEPROM backend + +maintainers: + - Arun Iyengar <aiyengar1990@gmail.com> + +description: + The I2C controller answers on its own address as a target and behaves + like a 24Cxx EEPROM towards the other controllers on the bus. The + compatible selects the EEPROM type that is simulated. The "ro" variants + ignore writes from the bus. + +properties: + compatible: + enum: + - slave-24c02 + - slave-24c02ro + - slave-24c32 + - slave-24c32ro + - slave-24c64 + - slave-24c64ro + - slave-24c512 + - slave-24c512ro + + reg: + maxItems: 1 + description: + Own address of the controller on the bus. The I2C_OWN_SLAVE_ADDRESS + flag must be set. + + firmware-name: + maxItems: 1 + description: + File with the initial content. Without it all bytes start as 0xff. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/i2c/i2c.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + eeprom@64 { + compatible = "slave-24c02"; + reg = <(0x64 | I2C_OWN_SLAVE_ADDRESS)>; + }; + }; -- 2.55.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: i2c: Add the slave EEPROM backend 2026-11-20 4:32 ` Arun Iyengar (?) @ 2026-12-01 20:38 ` Rob Herring -1 siblings, 0 replies; 7+ messages in thread From: Rob Herring @ 2026-12-01 20:38 UTC (permalink / raw) To: Arun Iyengar Cc: Andi Shyti, Krzysztof Kozlowski, Conor Dooley, Wolfram Sang, Uwe Kleine-König, Björn Ardö, linux-i2c, devicetree, linux-kernel On Fri, Nov 20, 2026 at 04:32:17AM +0000, Arun Iyengar wrote: > A node with one of the i2c-slave-eeprom names as compatible and > I2C_OWN_SLAVE_ADDRESS in reg already binds to the backend, because the > I2C core names the client after the compatible and matches the I2C id. > The driver also reads firmware-name. None of this is documented. > > Document the names without a vendor prefix, as the driver and > Documentation/i2c spell them (ipmb-dev and mctp-i2c-controller are > unprefixed too). > > Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com> > --- > .../devicetree/bindings/i2c/slave-eeprom.yaml | 59 ++++++++++++++++++++++ > 1 file changed, 59 insertions(+) > > diff --git a/Documentation/devicetree/bindings/i2c/slave-eeprom.yaml b/Documentation/devicetree/bindings/i2c/slave-eeprom.yaml > new file mode 100644 > index 000000000000..b7a6e6653a64 > --- /dev/null > +++ b/Documentation/devicetree/bindings/i2c/slave-eeprom.yaml > @@ -0,0 +1,59 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/i2c/slave-eeprom.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: I2C target EEPROM backend > + > +maintainers: > + - Arun Iyengar <aiyengar1990@gmail.com> > + > +description: > + The I2C controller answers on its own address as a target and behaves > + like a 24Cxx EEPROM towards the other controllers on the bus. The > + compatible selects the EEPROM type that is simulated. The "ro" variants > + ignore writes from the bus. > + > +properties: > + compatible: > + enum: > + - slave-24c02 > + - slave-24c02ro > + - slave-24c32 > + - slave-24c32ro > + - slave-24c64 > + - slave-24c64ro > + - slave-24c512 > + - slave-24c512ro Please avoid further uses of 'slave'. For the actual devices, we have 'read-only' property IIRC. Perhaps a separate property is better here. > + > + reg: > + maxItems: 1 > + description: > + Own address of the controller on the bus. The I2C_OWN_SLAVE_ADDRESS > + flag must be set. The flag can be expressed with constraints on entry. > + > + firmware-name: > + maxItems: 1 > + description: > + File with the initial content. Without it all bytes start as 0xff. > + > +required: > + - compatible > + - reg > + > +additionalProperties: false > + > +examples: > + - | > + #include <dt-bindings/i2c/i2c.h> > + > + i2c { > + #address-cells = <1>; > + #size-cells = <0>; > + > + eeprom@64 { > + compatible = "slave-24c02"; > + reg = <(0x64 | I2C_OWN_SLAVE_ADDRESS)>; > + }; > + }; > > -- > 2.55.0 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] i2c: slave-eeprom: Add an OF match table for module autoload 2026-11-20 4:32 ` Arun Iyengar @ 2026-11-20 4:32 ` Arun Iyengar -1 siblings, 0 replies; 7+ messages in thread From: Arun Iyengar via B4 Relay @ 2026-11-20 4:32 UTC (permalink / raw) To: Andi Shyti, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: Wolfram Sang, Uwe Kleine-König, Björn Ardö, linux-i2c, devicetree, linux-kernel, Arun Iyengar From: Arun Iyengar <aiyengar1990@gmail.com> A backend instantiated from the device tree (compatible "slave-24c02", reg = <(0x64 | I2C_OWN_SLAVE_ADDRESS)>) gets an i2c client, but the uevent of a client with an of_node carries an of: modalias (of:N...Cslave-24c02). The module only declares i2c: aliases, so udev never loads it and the client stays unbound: there is no slave-eeprom file and no target is registered, with nothing in the log. Only the sysfs new_device path (i2c: modalias) or a manual modprobe works. Declare the same names as an OF table and export it, so the module autoloads for DT and overlay clients. Nodes that bind today keep binding with the same size and flags. With an OF table the driver also matches a node that lists one of these names as a fallback compatible. Such a client is named after its first compatible and has no i2c id, so give the OF entries the same data as the i2c ids and read it with i2c_get_match_data(). Tested on an Orange Pi Zero2 (H616) with a local target-mode patch for i2c-mv64xxx: a slave-24c02 overlay node autoloads the module and binds with a 256-byte file; a node with slave-24c02 as fallback compatible binds too (v1 oopsed there); new_device slave-24c32 still gives 4096 bytes. Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com> --- drivers/i2c/i2c-slave-eeprom.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c index 226d722af662..0af48a9085b4 100644 --- a/drivers/i2c/i2c-slave-eeprom.c +++ b/drivers/i2c/i2c-slave-eeprom.c @@ -142,11 +142,11 @@ static int i2c_slave_init_eeprom_data(struct eeprom_data *eeprom, struct i2c_cli static int i2c_slave_eeprom_probe(struct i2c_client *client) { - const struct i2c_device_id *id = i2c_client_get_device_id(client); + unsigned long data = (unsigned long)i2c_get_match_data(client); struct eeprom_data *eeprom; int ret; - unsigned int size = FIELD_GET(I2C_SLAVE_BYTELEN, id->driver_data) + 1; - unsigned int flag_addr16 = FIELD_GET(I2C_SLAVE_FLAG_ADDR16, id->driver_data); + unsigned int size = FIELD_GET(I2C_SLAVE_BYTELEN, data) + 1; + unsigned int flag_addr16 = FIELD_GET(I2C_SLAVE_FLAG_ADDR16, data); eeprom = devm_kzalloc(&client->dev, sizeof(struct eeprom_data) + size, GFP_KERNEL); if (!eeprom) @@ -154,7 +154,7 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client) eeprom->num_address_bytes = flag_addr16 ? 2 : 1; eeprom->address_mask = size - 1; - eeprom->read_only = FIELD_GET(I2C_SLAVE_FLAG_RO, id->driver_data); + eeprom->read_only = FIELD_GET(I2C_SLAVE_FLAG_RO, data); spin_lock_init(&eeprom->buffer_lock); i2c_set_clientdata(client, eeprom); @@ -203,9 +203,35 @@ static const struct i2c_device_id i2c_slave_eeprom_id[] = { }; MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id); +/* Same data as the I2C ids, for clients matched by a fallback compatible */ +#define I2C_SLAVE_OF_DATA(_len, _flags) \ + ((void *)(unsigned long)I2C_SLAVE_DEVICE_MAGIC(_len, _flags)) + +static const struct of_device_id i2c_slave_eeprom_of_match[] = { + { .compatible = "slave-24c02", + .data = I2C_SLAVE_OF_DATA(2048 / 8, 0) }, + { .compatible = "slave-24c02ro", + .data = I2C_SLAVE_OF_DATA(2048 / 8, I2C_SLAVE_FLAG_RO) }, + { .compatible = "slave-24c32", + .data = I2C_SLAVE_OF_DATA(32768 / 8, I2C_SLAVE_FLAG_ADDR16) }, + { .compatible = "slave-24c32ro", + .data = I2C_SLAVE_OF_DATA(32768 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) }, + { .compatible = "slave-24c64", + .data = I2C_SLAVE_OF_DATA(65536 / 8, I2C_SLAVE_FLAG_ADDR16) }, + { .compatible = "slave-24c64ro", + .data = I2C_SLAVE_OF_DATA(65536 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) }, + { .compatible = "slave-24c512", + .data = I2C_SLAVE_OF_DATA(524288 / 8, I2C_SLAVE_FLAG_ADDR16) }, + { .compatible = "slave-24c512ro", + .data = I2C_SLAVE_OF_DATA(524288 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) }, + { } +}; +MODULE_DEVICE_TABLE(of, i2c_slave_eeprom_of_match); + static struct i2c_driver i2c_slave_eeprom_driver = { .driver = { .name = "i2c-slave-eeprom", + .of_match_table = i2c_slave_eeprom_of_match, }, .probe = i2c_slave_eeprom_probe, .remove = i2c_slave_eeprom_remove, -- 2.55.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] i2c: slave-eeprom: Add an OF match table for module autoload @ 2026-11-20 4:32 ` Arun Iyengar 0 siblings, 0 replies; 7+ messages in thread From: Arun Iyengar @ 2026-11-20 4:32 UTC (permalink / raw) To: Andi Shyti, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: Wolfram Sang, Uwe Kleine-König, Björn Ardö, linux-i2c, devicetree, linux-kernel, Arun Iyengar A backend instantiated from the device tree (compatible "slave-24c02", reg = <(0x64 | I2C_OWN_SLAVE_ADDRESS)>) gets an i2c client, but the uevent of a client with an of_node carries an of: modalias (of:N...Cslave-24c02). The module only declares i2c: aliases, so udev never loads it and the client stays unbound: there is no slave-eeprom file and no target is registered, with nothing in the log. Only the sysfs new_device path (i2c: modalias) or a manual modprobe works. Declare the same names as an OF table and export it, so the module autoloads for DT and overlay clients. Nodes that bind today keep binding with the same size and flags. With an OF table the driver also matches a node that lists one of these names as a fallback compatible. Such a client is named after its first compatible and has no i2c id, so give the OF entries the same data as the i2c ids and read it with i2c_get_match_data(). Tested on an Orange Pi Zero2 (H616) with a local target-mode patch for i2c-mv64xxx: a slave-24c02 overlay node autoloads the module and binds with a 256-byte file; a node with slave-24c02 as fallback compatible binds too (v1 oopsed there); new_device slave-24c32 still gives 4096 bytes. Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com> --- drivers/i2c/i2c-slave-eeprom.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c index 226d722af662..0af48a9085b4 100644 --- a/drivers/i2c/i2c-slave-eeprom.c +++ b/drivers/i2c/i2c-slave-eeprom.c @@ -142,11 +142,11 @@ static int i2c_slave_init_eeprom_data(struct eeprom_data *eeprom, struct i2c_cli static int i2c_slave_eeprom_probe(struct i2c_client *client) { - const struct i2c_device_id *id = i2c_client_get_device_id(client); + unsigned long data = (unsigned long)i2c_get_match_data(client); struct eeprom_data *eeprom; int ret; - unsigned int size = FIELD_GET(I2C_SLAVE_BYTELEN, id->driver_data) + 1; - unsigned int flag_addr16 = FIELD_GET(I2C_SLAVE_FLAG_ADDR16, id->driver_data); + unsigned int size = FIELD_GET(I2C_SLAVE_BYTELEN, data) + 1; + unsigned int flag_addr16 = FIELD_GET(I2C_SLAVE_FLAG_ADDR16, data); eeprom = devm_kzalloc(&client->dev, sizeof(struct eeprom_data) + size, GFP_KERNEL); if (!eeprom) @@ -154,7 +154,7 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client) eeprom->num_address_bytes = flag_addr16 ? 2 : 1; eeprom->address_mask = size - 1; - eeprom->read_only = FIELD_GET(I2C_SLAVE_FLAG_RO, id->driver_data); + eeprom->read_only = FIELD_GET(I2C_SLAVE_FLAG_RO, data); spin_lock_init(&eeprom->buffer_lock); i2c_set_clientdata(client, eeprom); @@ -203,9 +203,35 @@ static const struct i2c_device_id i2c_slave_eeprom_id[] = { }; MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id); +/* Same data as the I2C ids, for clients matched by a fallback compatible */ +#define I2C_SLAVE_OF_DATA(_len, _flags) \ + ((void *)(unsigned long)I2C_SLAVE_DEVICE_MAGIC(_len, _flags)) + +static const struct of_device_id i2c_slave_eeprom_of_match[] = { + { .compatible = "slave-24c02", + .data = I2C_SLAVE_OF_DATA(2048 / 8, 0) }, + { .compatible = "slave-24c02ro", + .data = I2C_SLAVE_OF_DATA(2048 / 8, I2C_SLAVE_FLAG_RO) }, + { .compatible = "slave-24c32", + .data = I2C_SLAVE_OF_DATA(32768 / 8, I2C_SLAVE_FLAG_ADDR16) }, + { .compatible = "slave-24c32ro", + .data = I2C_SLAVE_OF_DATA(32768 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) }, + { .compatible = "slave-24c64", + .data = I2C_SLAVE_OF_DATA(65536 / 8, I2C_SLAVE_FLAG_ADDR16) }, + { .compatible = "slave-24c64ro", + .data = I2C_SLAVE_OF_DATA(65536 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) }, + { .compatible = "slave-24c512", + .data = I2C_SLAVE_OF_DATA(524288 / 8, I2C_SLAVE_FLAG_ADDR16) }, + { .compatible = "slave-24c512ro", + .data = I2C_SLAVE_OF_DATA(524288 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) }, + { } +}; +MODULE_DEVICE_TABLE(of, i2c_slave_eeprom_of_match); + static struct i2c_driver i2c_slave_eeprom_driver = { .driver = { .name = "i2c-slave-eeprom", + .of_match_table = i2c_slave_eeprom_of_match, }, .probe = i2c_slave_eeprom_probe, .remove = i2c_slave_eeprom_remove, -- 2.55.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-01 20:38 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-20 4:32 [PATCH v2 0/2] i2c: slave-eeprom: DT binding and OF match table for module autoload Arun Iyengar via B4 Relay 2026-11-20 4:32 ` Arun Iyengar 2026-11-20 4:32 ` [PATCH v2 1/2] dt-bindings: i2c: Add the slave EEPROM backend Arun Iyengar via B4 Relay 2026-11-20 4:32 ` Arun Iyengar 2026-12-01 20:38 ` Rob Herring 2026-11-20 4:32 ` [PATCH v2 2/2] i2c: slave-eeprom: Add an OF match table for module autoload Arun Iyengar via B4 Relay 2026-11-20 4:32 ` Arun Iyengar
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.