devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] i2c: Introduce I2C bus extensions
@ 2025-04-30 15:21 Herve Codina
  2025-04-30 15:22 ` [PATCH v2 1/1] schemas: " Herve Codina
  0 siblings, 1 reply; 4+ messages in thread
From: Herve Codina @ 2025-04-30 15:21 UTC (permalink / raw)
  To: Ayush Singh, Wolfram Sang, Andi Shyti, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-i2c, devicetree, linux-kernel, devicetree-spec,
	Luca Ceresoli, Thomas Petazzoni, Herve Codina

Hi,

This is a resend of the series in order to continue discussion started
previously. In this resend, patch 2 previously available has been
removed (already applied).

An I2C bus can be wired to the connector and allows an add-on board to
connect additional I2C devices to this bus.

Those additional I2C devices could be described as sub-nodes of the I2C
bus controller node however for hotplug connectors described via device
tree overlays there is additional level of indirection, which is needed
to decouple the overlay and the base tree.

This decoupling is performed thanks to the I2C bus extension feature
which is introduced and detailed in patch 2 of this series.

The implementation related to I2C bus extension has been already
proposed as an RFC in Linux [0]. The missing part in this RFC was the
binding.

This binding related to I2C controller is not available in the Linux
repository but in dt-schema repository and so, this series update the
I2C controller binding to introduce the feature.

Compare to the previous iteration, patch 1 available in v1 has been
removed (already applied). No other modification has been done excep
adding a reviewed-by tag. Indeed conclusions were not reached in the
previous iteration discussion.

As a reminder, topics started in the v1 series discussion were the
following:
 - i2c-bus-extension@0: usage of a subnode with unit address
 - Presence of phandles in both direction (double linked list)

Best regards,
Hervé Codina

Changes v1 -> v2
  v1: https://lore.kernel.org/all/20250401081041.114333-1-herve.codina@bootlin.com/

  Patch 1 in v1:
  Removed (already applied)

  Patch 1 (2 in v1):
  Add 'Reviewed-by: Ayush Singh <ayush@beagleboard.org>'

Herve Codina (1):
  schemas: i2c: Introduce I2C bus extensions

 dtschema/schemas/i2c/i2c-controller.yaml | 67 ++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/1] schemas: i2c: Introduce I2C bus extensions
  2025-04-30 15:21 [PATCH v2 0/1] i2c: Introduce I2C bus extensions Herve Codina
@ 2025-04-30 15:22 ` Herve Codina
  2025-05-02 14:09   ` Luca Ceresoli
  0 siblings, 1 reply; 4+ messages in thread
From: Herve Codina @ 2025-04-30 15:22 UTC (permalink / raw)
  To: Ayush Singh, Wolfram Sang, Andi Shyti, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-i2c, devicetree, linux-kernel, devicetree-spec,
	Luca Ceresoli, Thomas Petazzoni, Herve Codina

An I2C bus can be wired to the connector and allows an add-on board to
connect additional I2C devices to this bus.

Those additional I2C devices could be described as sub-nodes of the I2C
bus controller node however for hotplug connectors described via device
tree overlays there is additional level of indirection, which is needed
to decouple the overlay and the base tree:

  --- base device tree ---

  i2c1: i2c@abcd0000 {
      compatible = "xyz,i2c-ctrl";
      i2c-bus-extension@0 {
          i2c-bus = <&i2c_ctrl>;
      };
      ...
  };

  i2c5: i2c@cafe0000 {
      compatible = "xyz,i2c-ctrl";
      i2c-bus-extension@0 {
          i2c-bus = <&i2c-sensors>;
      };
      ...
  };

  connector {
      i2c_ctrl: i2c-ctrl {
          i2c-parent = <&i2c1>;
          #address-cells = <1>;
          #size-cells = <0>;
      };

      i2c-sensors {
          i2c-parent = <&i2c5>;
          #address-cells = <1>;
          #size-cells = <0>;
      };
  };

  --- device tree overlay ---

  ...
  // This node will overlay on the i2c-ctrl node of the base tree
  i2c-ctrl {
      eeprom@50 { compatible = "atmel,24c64"; ... };
  };
  ...

  --- resulting device tree ---

  i2c1: i2c@abcd0000 {
      compatible = "xyz,i2c-ctrl";
      i2c-bus-extension@0 {
          i2c-bus = <&i2c_ctrl>;
      };
      ...
  };

  i2c5: i2c@cafe0000 {
      compatible = "xyz,i2c-ctrl";
      i2c-bus-extension@0 {
          i2c-bus = <&i2c-sensors>;
      };
      ...
  };

  connector {
      i2c-ctrl {
          i2c-parent = <&i2c1>;
          #address-cells = <1>;
          #size-cells = <0>;

          eeprom@50 { compatible = "atmel,24c64"; ... };
      };

      i2c-sensors {
          i2c-parent = <&i2c5>;
          #address-cells = <1>;
          #size-cells = <0>;
      };
  };

Here i2c-ctrl (same goes for i2c-sensors) represent the part of I2C bus
that is on the hot-pluggable add-on. On hot-plugging it will physically
connect to the I2C adapter on the base board. Let's call the 'i2c-ctrl'
node an "extension node".

In order to decouple the overlay from the base tree, the I2C adapter
(i2c@abcd0000) and the extension node (i2c-ctrl) are separate nodes.

The extension node is linked to the I2C bus controller in two ways. The
first one with the i2c-bus-extension available in I2C controller
sub-node and the second one with the i2c-parent property available in
the extension node itself.

The purpose of those two links is to provide the link in both direction
from the I2C controller to the I2C extension and from the I2C extension
to the I2C controller.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Ayush Singh <ayush@beagleboard.org>
---
 dtschema/schemas/i2c/i2c-controller.yaml | 67 ++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/dtschema/schemas/i2c/i2c-controller.yaml b/dtschema/schemas/i2c/i2c-controller.yaml
index 8488edd..8ab7fec 100644
--- a/dtschema/schemas/i2c/i2c-controller.yaml
+++ b/dtschema/schemas/i2c/i2c-controller.yaml
@@ -30,6 +30,13 @@ properties:
     minimum: 1
     maximum: 5000000
 
+  i2c-parent:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      In case of an I2C bus extension, reference to the I2C bus controller
+      this extension is connected to. In other word, reference the I2C bus
+      controller on the fixed side that drives the bus extension.
+
   i2c-scl-falling-time-ns:
     description:
       Number of nanoseconds the SCL signal takes to fall; t(f) in the I2C
@@ -159,6 +166,25 @@ allOf:
         - i2c-scl-has-clk-low-timeout
 
 patternProperties:
+  'i2c-bus-extension@[0-9a-f]+$':
+    type: object
+    description:
+      An I2C bus extension connected to an I2C bus. Those extensions allow to
+      decouple I2C busses when they are wired to connectors.
+
+    properties:
+      reg:
+        maxItems: 1
+
+      i2c-bus:
+        $ref: /schemas/types.yaml#/definitions/phandle
+        description:
+          Reference to the extension bus.
+
+    required:
+      - reg
+      - i2c-bus
+
   '@[0-9a-f]+$':
     type: object
 
@@ -221,3 +247,44 @@ dependentRequired:
   i2c-digital-filter-width-ns: [ i2c-digital-filter ]
 
 additionalProperties: true
+
+examples:
+  # I2C bus extension example involving an I2C bus controller and a connector.
+  #
+  #  +--------------+     +-------------+     +-------------+
+  #  | i2c@abcd0000 |     |  Connector  |     | Addon board |
+  #  |    (i2c1)    +-----+ (i2c-addon) +-----+ (device@10) |
+  #  |              |     |             |     |             |
+  #  +--------------+     +-------------+     +-------------+
+  #
+  # The i2c1 I2C bus is wired from a I2C controller to a connector. It is
+  # identified at connector level as i2c-addon bus.
+  # An addon board can be connected to this connector and connects a device
+  # (device@10) to this i2c-addon extension bus.
+  - |
+    i2c1: i2c@abcd0000 {
+        compatible = "xyz,i2c-ctrl";
+        reg = <0xabcd0000 0x100>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        i2c-bus-extension@0 {
+            reg = <0>;
+            i2c-bus = <&i2c_addon>;
+        };
+    };
+
+    connector {
+        i2c_addon: i2c-addon {
+            i2c-parent = <&i2c1>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            device@10 {
+                compatible = "xyz,foo";
+                reg = <0x10>;
+            };
+        };
+    };
+
+...
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] schemas: i2c: Introduce I2C bus extensions
  2025-04-30 15:22 ` [PATCH v2 1/1] schemas: " Herve Codina
@ 2025-05-02 14:09   ` Luca Ceresoli
  2025-05-05  8:22     ` Herve Codina
  0 siblings, 1 reply; 4+ messages in thread
From: Luca Ceresoli @ 2025-05-02 14:09 UTC (permalink / raw)
  To: Herve Codina
  Cc: Ayush Singh, Wolfram Sang, Andi Shyti, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-i2c, devicetree,
	linux-kernel, devicetree-spec, Thomas Petazzoni

Hello Hervé,

On Wed, 30 Apr 2025 17:22:00 +0200
Herve Codina <herve.codina@bootlin.com> wrote:

> An I2C bus can be wired to the connector and allows an add-on board to
> connect additional I2C devices to this bus.
> 
> Those additional I2C devices could be described as sub-nodes of the I2C
> bus controller node however for hotplug connectors described via device
> tree overlays there is additional level of indirection, which is needed
> to decouple the overlay and the base tree:
> 
>   --- base device tree ---
> 
>   i2c1: i2c@abcd0000 {
>       compatible = "xyz,i2c-ctrl";
>       i2c-bus-extension@0 {
>           i2c-bus = <&i2c_ctrl>;
>       };
>       ...
>   };
> 
>   i2c5: i2c@cafe0000 {
>       compatible = "xyz,i2c-ctrl";
>       i2c-bus-extension@0 {
>           i2c-bus = <&i2c-sensors>;
                        ^^^^^^^^^^^

This should be i2c_sensors (with an underscore)...

>       };
>       ...
>   };
> 
>   connector {
>       i2c_ctrl: i2c-ctrl {
>           i2c-parent = <&i2c1>;
>           #address-cells = <1>;
>           #size-cells = <0>;
>       };
> 
>       i2c-sensors {

...and this should have a label:

        i2c-sensors: i2c-sensors {

With those fixed you can add my:

+Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

-- 
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] schemas: i2c: Introduce I2C bus extensions
  2025-05-02 14:09   ` Luca Ceresoli
@ 2025-05-05  8:22     ` Herve Codina
  0 siblings, 0 replies; 4+ messages in thread
From: Herve Codina @ 2025-05-05  8:22 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: Ayush Singh, Wolfram Sang, Andi Shyti, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-i2c, devicetree,
	linux-kernel, devicetree-spec, Thomas Petazzoni

Hi Luca,

On Fri, 2 May 2025 16:09:10 +0200
Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:

> Hello Hervé,
> 
> On Wed, 30 Apr 2025 17:22:00 +0200
> Herve Codina <herve.codina@bootlin.com> wrote:
> 
> > An I2C bus can be wired to the connector and allows an add-on board to
> > connect additional I2C devices to this bus.
> > 
> > Those additional I2C devices could be described as sub-nodes of the I2C
> > bus controller node however for hotplug connectors described via device
> > tree overlays there is additional level of indirection, which is needed
> > to decouple the overlay and the base tree:
> > 
> >   --- base device tree ---
> > 
> >   i2c1: i2c@abcd0000 {
> >       compatible = "xyz,i2c-ctrl";
> >       i2c-bus-extension@0 {
> >           i2c-bus = <&i2c_ctrl>;
> >       };
> >       ...
> >   };
> > 
> >   i2c5: i2c@cafe0000 {
> >       compatible = "xyz,i2c-ctrl";
> >       i2c-bus-extension@0 {
> >           i2c-bus = <&i2c-sensors>;  
>                         ^^^^^^^^^^^
> 
> This should be i2c_sensors (with an underscore)...
> 
> >       };
> >       ...
> >   };
> > 
> >   connector {
> >       i2c_ctrl: i2c-ctrl {
> >           i2c-parent = <&i2c1>;
> >           #address-cells = <1>;
> >           #size-cells = <0>;
> >       };
> > 
> >       i2c-sensors {  
> 
> ...and this should have a label:
> 
>         i2c-sensors: i2c-sensors {
> 
> With those fixed you can add my:

Indeed, thanks for pointing out.

I will fix them in the next iteration and add your 'Reviewed-by' tag.

> 
> +Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> 

Best regards,
Hervé

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-05  8:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-30 15:21 [PATCH v2 0/1] i2c: Introduce I2C bus extensions Herve Codina
2025-04-30 15:22 ` [PATCH v2 1/1] schemas: " Herve Codina
2025-05-02 14:09   ` Luca Ceresoli
2025-05-05  8:22     ` Herve Codina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).