[PATCH 1/5] dt-bindings: i2c: Add RTL9300 I2C controller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add dtschema for the I2C controller on the RTL9300 SoC. The I2C
controllers on this SoC are part of the "switch" block which is
represented here as a syscon node. The SCL pins are dependent on the I2C
controller (GPIO8 for the first controller, GPIO 17 for the second). The
SDA pins can be assigned to either one of the I2C controllers (but not
both).

Signed-off-by: Chris Packham <chris.packham@xxxxxxxxxxxxxxxxxxx>
---

Notes:
    This does hit generate the following dt_binding_check warning
    
    realtek,rtl9300-i2c.example.dts:22.19-30.13: Warning (unit_address_vs_reg): /example-0/switch@1b000000/i2c@36c: node has a unit name, but no reg or ranges property
    
    Which is totally correct. I haven't given this thing a reg property
    because I'm using an offset from the parent syscon node. I'm also not
    calling the first offset "offset" but I don't think that'd help.
    
    I looked at a couple of other examples of devices that are children of
    syscon nodes (e.g. armada-ap806-thermal, ap806-cpu-clock) these do have
    a reg property in the dts but as far as I can see from the code it's not
    actually used, instead the register offsets are in the code looked up
    from the driver data (in at least one-case the reg offset is for a
    legacy usage).
    
    So I'm a little unsure what to do here. I can add a reg property and
    update the driver to use that to get the offset for the first set of
    registers (or just not use it). Or I could drop the @36c from the node
    names but then I coudn't distinguish the two controllers without failing
    the $nodename: requirement from i2c-controller.yaml.

 .../bindings/i2c/realtek,rtl9300-i2c.yaml     | 73 +++++++++++++++++++
 MAINTAINERS                                   |  6 ++
 2 files changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/realtek,rtl9300-i2c.yaml

diff --git a/Documentation/devicetree/bindings/i2c/realtek,rtl9300-i2c.yaml b/Documentation/devicetree/bindings/i2c/realtek,rtl9300-i2c.yaml
new file mode 100644
index 000000000000..5b74a1986720
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/realtek,rtl9300-i2c.yaml
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/realtek,rtl9300-i2c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek RTL I2C Controller
+
+maintainers:
+  - Chris Packham <chris.packham@xxxxxxxxxxxxxxxxxxx>
+
+description: |
+  The RTL9300 SoC has two I2C controllers. Each of these has an SCL line (which
+  if not-used for SCL can be a GPIO). There are 8 common SDA lines that can be
+  assigned to either I2C controller.
+
+properties:
+  compatible:
+    const: realtek,rtl9300-i2c
+
+  realtek,control-offset:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Offset of the registers for this I2C controller
+
+  realtek,global-control-offset:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Offset of the I2C global control register (common between
+      controllers).
+
+  clock-frequency:
+    enum: [ 100000, 400000 ]
+
+  realtek,sda-pin:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 0
+    maximum: 7
+    description:
+      SDA pin associated with this I2C controller.
+
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+
+unevaluatedProperties: false
+
+required:
+  - compatible
+  - realtek,control-offset
+  - realtek,global-control-offset
+
+examples:
+  - |
+    switch@1b000000 {
+      compatible = "realtek,rtl9302c-switch", "syscon", "simple-mfd";
+      reg = <0x1b000000 0x10000>;
+
+      i2c@36c {
+        compatible = "realtek,rtl9300-i2c";
+        realtek,control-offset = <0x36c>;
+        realtek,global-control-offset = <0x384>;
+        clock-frequency = <100000>;
+        realtek,sda-pin = <2>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+      };
+
+      i2c@388 {
+        compatible = "realtek,rtl9300-i2c";
+        realtek,control-offset = <0x388>;
+        realtek,global-control-offset = <0x384>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+      };
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index f328373463b0..ccb1125444f4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19887,6 +19887,12 @@ S:	Maintained
 T:	git https://github.com/pkshih/rtw.git
 F:	drivers/net/wireless/realtek/rtl8xxxu/
 
+RTL9300 I2C DRIVER (rtl9300-i2c)
+M:	Chris Packham <chris.packham@xxxxxxxxxxxxxxxxxxx>
+L:	linux-i2c@xxxxxxxxxxxxxxx
+S:	Maintained
+F:	Documentation/devicetree/bindings/i2c/realtek,rtl9300-i2c.yaml
+
 RTRS TRANSPORT DRIVERS
 M:	Md. Haris Iqbal <haris.iqbal@xxxxxxxxx>
 M:	Jack Wang <jinpu.wang@xxxxxxxxx>
-- 
2.46.1





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux