* [PATCH 0/2] i2c: mux: reg: allow fixing the base bus number via fwnode
@ 2026-06-07 8:20 Abdurrahman Hussain
2026-06-07 8:20 ` [PATCH 1/2] dt-bindings: i2c: convert i2c-mux-reg to DT schema Abdurrahman Hussain
2026-06-07 8:20 ` [PATCH 2/2] i2c: mux: reg: allow fixing the base bus number via fwnode Abdurrahman Hussain
0 siblings, 2 replies; 6+ messages in thread
From: Abdurrahman Hussain @ 2026-06-07 8:20 UTC (permalink / raw)
To: Peter Rosin, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: linux-i2c, linux-kernel, devicetree, Abdurrahman Hussain
Add an "i2c-mux-base-bus-num" device property to i2c-mux-reg so
DT/ACPI/swnode instances can request a fixed base bus number; the
legacy platdata path already supports this via data.base_nr.
Patch 1 converts the legacy Documentation/devicetree/bindings/i2c/
i2c-mux-reg.txt binding to the YAML schema and documents the new
property. Patch 2 reads the property in the driver.
The series applies on top of the device-property accessor conversion
queued in Wolfram's wsa.git i2c/for-andi:
c191ec71250b ("i2c: mux: reg: use device property accessors")
https://lore.kernel.org/all/20260519-i2c-mux-reg-v6-1-a27ff50dee67@nexthop.ai/
Without that conversion there is no probe-time hook on the OF path
for the new property the driver reads.
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
Abdurrahman Hussain (2):
dt-bindings: i2c: convert i2c-mux-reg to DT schema
i2c: mux: reg: allow fixing the base bus number via fwnode
.../devicetree/bindings/i2c/i2c-mux-reg.txt | 74 --------------
.../devicetree/bindings/i2c/i2c-mux-reg.yaml | 110 +++++++++++++++++++++
drivers/i2c/muxes/i2c-mux-reg.c | 4 +-
3 files changed, 113 insertions(+), 75 deletions(-)
---
base-commit: aa61612ab641d7d62b0b6889f2c7c9251489f6e3
change-id: 20260607-i2c-mux-reg-base-bus-num-738e5db7e99c
prerequisite-patch-id: 3ad9f5acb365e6eb2cd3b0790e983b9049371155
Best regards,
--
Abdurrahman Hussain <abdurrahman@nexthop.ai>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] dt-bindings: i2c: convert i2c-mux-reg to DT schema
2026-06-07 8:20 [PATCH 0/2] i2c: mux: reg: allow fixing the base bus number via fwnode Abdurrahman Hussain
@ 2026-06-07 8:20 ` Abdurrahman Hussain
2026-06-07 14:06 ` Conor Dooley
2026-06-07 16:32 ` Rob Herring (Arm)
2026-06-07 8:20 ` [PATCH 2/2] i2c: mux: reg: allow fixing the base bus number via fwnode Abdurrahman Hussain
1 sibling, 2 replies; 6+ messages in thread
From: Abdurrahman Hussain @ 2026-06-07 8:20 UTC (permalink / raw)
To: Peter Rosin, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: linux-i2c, linux-kernel, devicetree, Abdurrahman Hussain
Convert Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt to
the YAML schema so the i2c-mux-reg binding is validated by
dt_binding_check.
Also document a new optional "base-bus-num" property: when
present, child adapter N is registered as Linux i2c bus number
(base-bus-num + reg), so static references such as sensors.conf
stanzas remain stable across boots. The matching driver support is
added in the following patch.
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
.../devicetree/bindings/i2c/i2c-mux-reg.txt | 74 --------------
.../devicetree/bindings/i2c/i2c-mux-reg.yaml | 110 +++++++++++++++++++++
2 files changed, 110 insertions(+), 74 deletions(-)
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt b/Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt
deleted file mode 100644
index b9d9755e4172..000000000000
--- a/Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt
+++ /dev/null
@@ -1,74 +0,0 @@
-Register-based I2C Bus Mux
-
-This binding describes an I2C bus multiplexer that uses a single register
-to route the I2C signals.
-
-Required properties:
-- compatible: i2c-mux-reg
-- i2c-parent: The phandle of the I2C bus that this multiplexer's master-side
- port is connected to.
-* Standard I2C mux properties. See i2c-mux.yaml in this directory.
-* I2C child bus nodes. See i2c-mux.yaml in this directory.
-
-Optional properties:
-- reg: this pair of <offset size> specifies the register to control the mux.
- The <offset size> depends on its parent node. It can be any memory-mapped
- address. The size must be either 1, 2, or 4 bytes. If reg is omitted, the
- resource of this device will be used.
-- little-endian: The existence indicates the register is in little endian.
-- big-endian: The existence indicates the register is in big endian.
- If both little-endian and big-endian are omitted, the endianness of the
- CPU will be used.
-- write-only: The existence indicates the register is write-only.
-- idle-state: value to set the muxer to when idle. When no value is
- given, it defaults to the last value used.
-
-Whenever an access is made to a device on a child bus, the value set
-in the relevant node's reg property will be output to the register.
-
-If an idle state is defined, using the idle-state (optional) property,
-whenever an access is not being made to a device on a child bus, the
-register will be set according to the idle value.
-
-If an idle state is not defined, the most recently used value will be
-left programmed into the register.
-
-Example of a mux on PCIe card, the host is a powerpc SoC (big endian):
-
- i2c-mux {
- /* the <offset size> depends on the address translation
- * of the parent device. If omitted, device resource
- * will be used instead. The size is to determine
- * whether iowrite32, iowrite16, or iowrite8 will be used.
- */
- reg = <0x6028 0x4>;
- little-endian; /* little endian register on PCIe */
- compatible = "i2c-mux-reg";
- #address-cells = <1>;
- #size-cells = <0>;
- i2c-parent = <&i2c1>;
- i2c@0 {
- reg = <0>;
- #address-cells = <1>;
- #size-cells = <0>;
-
- si5338: clock-generator@70 {
- compatible = "silabs,si5338";
- reg = <0x70>;
- /* other stuff */
- };
- };
-
- i2c@1 {
- /* data is written using iowrite32 */
- reg = <1>;
- #address-cells = <1>;
- #size-cells = <0>;
-
- si5338: clock-generator@70 {
- compatible = "silabs,si5338";
- reg = <0x70>;
- /* other stuff */
- };
- };
- };
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-reg.yaml b/Documentation/devicetree/bindings/i2c/i2c-mux-reg.yaml
new file mode 100644
index 000000000000..7fadedabde70
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-mux-reg.yaml
@@ -0,0 +1,110 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/i2c-mux-reg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Register-based I2C Bus Mux
+
+maintainers:
+ - Peter Rosin <peda@axentia.se>
+
+description: |
+ This binding describes an I2C bus multiplexer that uses a single
+ memory-mapped register to route the I2C signals.
+
+ Whenever an access is made to a device on a child bus, the value
+ set in the relevant node's reg property is output to the register.
+
+ If an idle state is defined via the idle-state property, the
+ register is set to that value whenever no access is being made.
+ Otherwise the most recently used value is left programmed.
+
+allOf:
+ - $ref: /schemas/i2c/i2c-mux.yaml#
+
+properties:
+ compatible:
+ const: i2c-mux-reg
+
+ reg:
+ maxItems: 1
+ description: |
+ Offset and size of the register that selects the active child
+ bus, relative to the parent node's address space. The size
+ determines the access width and must be 1, 2, or 4 bytes. If
+ omitted, the platform device's own memory resource is used
+ instead.
+
+ i2c-parent:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description:
+ Phandle of the I2C bus that this multiplexer's master-side port
+ is connected to.
+
+ little-endian:
+ type: boolean
+ description: Register is accessed in little-endian byte order.
+
+ big-endian:
+ type: boolean
+ description: Register is accessed in big-endian byte order.
+
+ write-only:
+ type: boolean
+ description:
+ Register is write-only; the driver must not read back the
+ current selection.
+
+ idle-state:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description:
+ Value to write to the register when no child bus is selected.
+
+ base-bus-num:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: |
+ Base Linux i2c-adapter number for the child buses. Child N is
+ registered as bus (base-bus-num + reg). When unset, child
+ adapters are allocated dynamically by the i2c core.
+
+required:
+ - compatible
+ - i2c-parent
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ i2c-mux@6028 {
+ compatible = "i2c-mux-reg";
+ reg = <0x6028 0x4>;
+ little-endian;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ i2c-parent = <&i2c1>;
+ base-bus-num = <16>;
+
+ i2c@0 {
+ reg = <0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ clock-generator@70 {
+ compatible = "silabs,si5338";
+ reg = <0x70>;
+ };
+ };
+
+ i2c@1 {
+ reg = <1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ clock-generator@70 {
+ compatible = "silabs,si5338";
+ reg = <0x70>;
+ };
+ };
+ };
+...
--
2.54.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] i2c: mux: reg: allow fixing the base bus number via fwnode
2026-06-07 8:20 [PATCH 0/2] i2c: mux: reg: allow fixing the base bus number via fwnode Abdurrahman Hussain
2026-06-07 8:20 ` [PATCH 1/2] dt-bindings: i2c: convert i2c-mux-reg to DT schema Abdurrahman Hussain
@ 2026-06-07 8:20 ` Abdurrahman Hussain
1 sibling, 0 replies; 6+ messages in thread
From: Abdurrahman Hussain @ 2026-06-07 8:20 UTC (permalink / raw)
To: Peter Rosin, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: linux-i2c, linux-kernel, devicetree, Abdurrahman Hussain
i2c_mux_reg supports per-channel force_nr through mux->data.base_nr
(when set, the channel-N adapter is registered as
i2c_add_numbered_adapter(base_nr + N)), but the only way to populate
base_nr was the legacy i2c_mux_reg_platform_data path. DT/ACPI/swnode
instances have always defaulted to dynamic allocation, which makes
sensors.conf bus stanzas and other static references break across
boots whenever the i2c-core pool shifts.
Read base_nr from the new "base-bus-num" device property in
i2c_mux_reg_probe_fw(). When the property is absent, base_nr stays
zero and the existing dynamic-allocation behaviour is preserved.
Anchor the per-channel bus number to the channel index (values[i]
== the child node's reg) rather than the iteration counter:
nr = base_nr ? base_nr + values[i] : 0
values[i] is the channel id encoded in the child node's reg property
(0..n-1), which is also what i2c_mux_add_adapter() receives as
chan_id. Using values[i] makes the mapping deterministic across
fwnode-iteration orderings (some OF kernels walk children in reverse
source order) and across DTS gaps (e.g. a mux that wires channels
0, 1, 3 still gets sane, consecutive bus numbers).
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
---
drivers/i2c/muxes/i2c-mux-reg.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-reg.c
index 13da757100fe..5ea59ecb4ae5 100644
--- a/drivers/i2c/muxes/i2c-mux-reg.c
+++ b/drivers/i2c/muxes/i2c-mux-reg.c
@@ -141,6 +141,8 @@ static int i2c_mux_reg_probe_fw(struct regmux *mux, struct device *dev)
if (!device_property_read_u32(dev, "idle-state", &mux->data.idle))
mux->data.idle_in_use = true;
+ device_property_read_u32(dev, "base-bus-num", &mux->data.base_nr);
+
return 0;
}
@@ -197,7 +199,7 @@ static int i2c_mux_reg_probe(struct platform_device *pdev)
muxc->deselect = i2c_mux_reg_deselect;
for (i = 0; i < mux->data.n_values; i++) {
- nr = mux->data.base_nr ? (mux->data.base_nr + i) : 0;
+ nr = mux->data.base_nr ? (mux->data.base_nr + mux->data.values[i]) : 0;
ret = i2c_mux_add_adapter(muxc, nr, mux->data.values[i]);
if (ret)
--
2.54.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: i2c: convert i2c-mux-reg to DT schema
2026-06-07 8:20 ` [PATCH 1/2] dt-bindings: i2c: convert i2c-mux-reg to DT schema Abdurrahman Hussain
@ 2026-06-07 14:06 ` Conor Dooley
2026-06-08 0:39 ` Abdurrahman Hussain
2026-06-07 16:32 ` Rob Herring (Arm)
1 sibling, 1 reply; 6+ messages in thread
From: Conor Dooley @ 2026-06-07 14:06 UTC (permalink / raw)
To: Abdurrahman Hussain
Cc: Peter Rosin, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-i2c, linux-kernel, devicetree
[-- Attachment #1: Type: text/plain, Size: 764 bytes --]
On Sun, Jun 07, 2026 at 01:20:55AM -0700, Abdurrahman Hussain wrote:
> Convert Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt to
> the YAML schema so the i2c-mux-reg binding is validated by
> dt_binding_check.
>
> Also document a new optional "base-bus-num" property: when
> present, child adapter N is registered as Linux i2c bus number
> (base-bus-num + reg), so static references such as sensors.conf
> stanzas remain stable across boots. The matching driver support is
> added in the following patch.
This should not be "hidden" inside a conversion. It must be a different
patch.
I think it is fairly likely that this property won't be acceptable.
The conversion itself looks okay to me.
pw-bot: changes-requested
Cheers,
Conor.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: i2c: convert i2c-mux-reg to DT schema
2026-06-07 8:20 ` [PATCH 1/2] dt-bindings: i2c: convert i2c-mux-reg to DT schema Abdurrahman Hussain
2026-06-07 14:06 ` Conor Dooley
@ 2026-06-07 16:32 ` Rob Herring (Arm)
1 sibling, 0 replies; 6+ messages in thread
From: Rob Herring (Arm) @ 2026-06-07 16:32 UTC (permalink / raw)
To: Abdurrahman Hussain
Cc: Krzysztof Kozlowski, Peter Rosin, linux-kernel, linux-i2c,
devicetree, Andi Shyti, Conor Dooley
On Sun, 07 Jun 2026 01:20:55 -0700, Abdurrahman Hussain wrote:
> Convert Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt to
> the YAML schema so the i2c-mux-reg binding is validated by
> dt_binding_check.
>
> Also document a new optional "base-bus-num" property: when
> present, child adapter N is registered as Linux i2c bus number
> (base-bus-num + reg), so static references such as sensors.conf
> stanzas remain stable across boots. The matching driver support is
> added in the following patch.
>
> Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
> ---
> .../devicetree/bindings/i2c/i2c-mux-reg.txt | 74 --------------
> .../devicetree/bindings/i2c/i2c-mux-reg.yaml | 110 +++++++++++++++++++++
> 2 files changed, 110 insertions(+), 74 deletions(-)
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/i2c/i2c-mux-reg.example.dtb: /example-0/i2c-mux@6028/i2c@0/clock-generator@70: failed to match any schema with compatible: ['silabs,si5338']
Documentation/devicetree/bindings/i2c/i2c-mux-reg.example.dtb: /example-0/i2c-mux@6028/i2c@1/clock-generator@70: failed to match any schema with compatible: ['silabs,si5338']
doc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/20260607-i2c-mux-reg-base-bus-num-v1-1-f193b5a8fedc@nexthop.ai
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: i2c: convert i2c-mux-reg to DT schema
2026-06-07 14:06 ` Conor Dooley
@ 2026-06-08 0:39 ` Abdurrahman Hussain
0 siblings, 0 replies; 6+ messages in thread
From: Abdurrahman Hussain @ 2026-06-08 0:39 UTC (permalink / raw)
To: Conor Dooley
Cc: Peter Rosin, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-i2c, linux-kernel, devicetree
On Sun, 7 Jun 2026 15:06:43 +0100, Conor Dooley wrote:
> I think it is fairly likely that this property won't be acceptable.
> The conversion itself looks okay to me.
Thanks for the hint -- I dug into the i2c core and realised the case
I was trying to solve already works on OF without any new binding.
i2c_mux_add_adapter() sets the child adapter's of_node to the
matching i2c@N node (drivers/i2c/i2c-mux.c:330..367), and
i2c_add_adapter() then honours of_alias_get_id(dev->of_node, "i2c")
(drivers/i2c/i2c-core-base.c:1657). So in DT, the existing aliases
mechanism already pins mux child buses:
aliases {
i2c16 = &my_mux_bus0;
i2c17 = &my_mux_bus1;
};
i2c-mux@... {
compatible = "i2c-mux-reg";
...
my_mux_bus0: i2c@0 { reg = <0>; ... };
my_mux_bus1: i2c@1 { reg = <1>; ... };
};
That's clearly the right answer; sorry for not finding it before
sending. The only wrinkle is that of_alias_get_id() is OF-only, so
this doesn't help the ACPI/swnode platform that originally motivated
me -- but that's a Linux-side problem (udev rules, stable adapter
names) and not something a new DT property should paper over.
I'll respin v2 as just the .txt -> YAML conversion (faithful port,
no new property), and fix the silabs,si5338 example that Rob's bot
flagged.
Thanks,
Abdurrahman.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-08 0:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-07 8:20 [PATCH 0/2] i2c: mux: reg: allow fixing the base bus number via fwnode Abdurrahman Hussain
2026-06-07 8:20 ` [PATCH 1/2] dt-bindings: i2c: convert i2c-mux-reg to DT schema Abdurrahman Hussain
2026-06-07 14:06 ` Conor Dooley
2026-06-08 0:39 ` Abdurrahman Hussain
2026-06-07 16:32 ` Rob Herring (Arm)
2026-06-07 8:20 ` [PATCH 2/2] i2c: mux: reg: allow fixing the base bus number via fwnode Abdurrahman Hussain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox