diff mbox series

[1/4] dt-bindings: arm: add cznic,turris-omnia-mcu binding

Message ID 20230823161012.6986-2-kabel@kernel.org (mailing list archive)
State Superseded
Headers show
Series Turris Omnia MCU driver | expand

Commit Message

Marek Behún Aug. 23, 2023, 4:10 p.m. UTC
Add binding for cznic,turris-omnia-mcu, the device-tree node
representing the system-controller features provided by the MCU on the
Turris Omnia router.

Signed-off-by: Marek Behún <kabel@kernel.org>
---
 .../bindings/arm/cznic,turris-omnia-mcu.yaml  | 72 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/cznic,turris-omnia-mcu.yaml

Comments

Krzysztof Kozlowski Aug. 24, 2023, 7:37 a.m. UTC | #1
On 23/08/2023 18:10, Marek Behún wrote:
> Add binding for cznic,turris-omnia-mcu, the device-tree node
> representing the system-controller features provided by the MCU on the
> Turris Omnia router.
> 
> Signed-off-by: Marek Behún <kabel@kernel.org>

Please use scripts/get_maintainers.pl to get a list of necessary people
and lists to CC (and consider --no-git-fallback argument). It might
happen, that command when run on an older kernel, gives you outdated
entries. Therefore please be sure you base your patches on recent Linux
kernel.

> ---
>  .../bindings/arm/cznic,turris-omnia-mcu.yaml  | 72 +++++++++++++++++++
>  MAINTAINERS                                   |  1 +
>  2 files changed, 73 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/arm/cznic,turris-omnia-mcu.yaml
> 
> diff --git a/Documentation/devicetree/bindings/arm/cznic,turris-omnia-mcu.yaml b/Documentation/devicetree/bindings/arm/cznic,turris-omnia-mcu.yaml
> new file mode 100644
> index 000000000000..055485847e71
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/cznic,turris-omnia-mcu.yaml

ARM directory is only for top-level bindings, so this should go to soc.

> @@ -0,0 +1,72 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/arm/cznic,turris-omnia-mcu.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: CZ.NIC's Turris Omnia MCU
> +
> +maintainers:
> +  - Marek Behún <kabel@kernel.org>
> +
> +description:
> +  The MCU on Turris Omnia acts as a system controller providing additional
> +  GPIOs, interrupts, watchdog, system power off and wakeup configuration.
> +
> +properties:
> +  compatible:
> +    const: cznic,turris-omnia-mcu
> +
> +  reg:
> +    description: MCU I2C slave address
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  interrupt-controller: true
> +
> +  '#interrupt-cells':
> +    const: 2
> +
> +  gpio-controller: true
> +
> +  '#gpio-cells':
> +    const: 2
> +
> +required:
> +  - compatible
> +  - reg
> +  - interrupts
> +  - interrupt-controller
> +  - gpio-controller
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +
> +    ic: interrupt-controller {
> +        interrupt-controller;
> +        #interrupt-cells = <2>;
> +    };

Drop this node, not relevant.

> +
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        system-controller@2a {
> +            compatible = "cznic,turris-omnia-mcu";
> +            reg = <0x2a>;
> +
> +            interrupt-parent = <&ic>;
> +            interrupts = <11 IRQ_TYPE_NONE>;

Are you sure interrupt is type none?

> +
> +            gpio-controller;
> +            #gpio-cells = <2>;
> +
> +            interrupt-controller;
> +            #interrupt-cells = <2>;
> +        };


Best regards,
Krzysztof
Marek Behún Aug. 24, 2023, 11:17 a.m. UTC | #2
On Thu, 24 Aug 2023 10:23:27 +0200
Krzysztof Kozlowski <krzk@kernel.org> wrote:

> You replied only to me. Instead please reply-to-all to keep discussions
> public.

Sorry about that, I've redirected the messages to the other people.

> >>> +++ b/Documentation/devicetree/bindings/arm/cznic,turris-omnia-mcu.yaml    
> >>
> >> ARM directory is only for top-level bindings, so this should go to soc.  
> > 
> > Hmm. The board uses a marvell SoC, but the board is from CZ.NIC (who
> > does not create its own SoCs). So should this go into soc/marvell or
> > soc/cznic?  
> 
> Indeed and it is a dedicated MCU (some Cortex-M or similar, right?), so
> maybe arm is suitable at the end.

There are three Cortex-M options (M0, M0+ or M3, from STM, NXP or
GigaDevice), depending on the board revision.

The bindings/arm already contain for example amazon,al.yaml, which is
platform binding (not SoC).

So I guess I will stick with bindings/arm, unless someone suggests
something else.

> >>> +examples:
> >>> +  - |
> >>> +    #include <dt-bindings/interrupt-controller/irq.h>
> >>> +
> >>> +    ic: interrupt-controller {
> >>> +        interrupt-controller;
> >>> +        #interrupt-cells = <2>;
> >>> +    };    
> >>
> >> Drop this node, not relevant.  
> > 
> > Will the binding example compile without the ic node if the
> > system-controller below uses it?  
> 
> Yes.

OK

> >>> +            interrupt-parent = <&ic>;
> >>> +            interrupts = <11 IRQ_TYPE_NONE>;    
> >>
> >> Are you sure interrupt is type none?  
> > 
> > The interrupt type is either LEVEL_LOW or EDGE_FALLING, depending on
> > the version of the MCU firmware, so this has to be selected by the
> > driver.
> > 
> > I tried setting LEVEL_LOW, since that is the one that is used by the
> > newest MCU firmware. But then if the firmware is old and I want to
> > select EDGE_FALLING in the driver when requesting the IRQ, it fails
> > with message
> >   type mismatch, failed to map hwirq-%lu for %s!
> > from
> >   kernel/irq/irqdomain.c function irq_create_fwspec_mapping
> > 
> > I guess I can use irqd_set_trigger_type() before requesting the IRQ to
> > avoid this error.
> > 
> > Should I use use LEVEL_LOW in the binding example and device-tree?  
> 
> I guess in such case this NONE is okay

Thx.
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/arm/cznic,turris-omnia-mcu.yaml b/Documentation/devicetree/bindings/arm/cznic,turris-omnia-mcu.yaml
new file mode 100644
index 000000000000..055485847e71
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/cznic,turris-omnia-mcu.yaml
@@ -0,0 +1,72 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/cznic,turris-omnia-mcu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: CZ.NIC's Turris Omnia MCU
+
+maintainers:
+  - Marek Behún <kabel@kernel.org>
+
+description:
+  The MCU on Turris Omnia acts as a system controller providing additional
+  GPIOs, interrupts, watchdog, system power off and wakeup configuration.
+
+properties:
+  compatible:
+    const: cznic,turris-omnia-mcu
+
+  reg:
+    description: MCU I2C slave address
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+    const: 2
+
+  gpio-controller: true
+
+  '#gpio-cells':
+    const: 2
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - gpio-controller
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    ic: interrupt-controller {
+        interrupt-controller;
+        #interrupt-cells = <2>;
+    };
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        system-controller@2a {
+            compatible = "cznic,turris-omnia-mcu";
+            reg = <0x2a>;
+
+            interrupt-parent = <&ic>;
+            interrupts = <11 IRQ_TYPE_NONE>;
+
+            gpio-controller;
+            #gpio-cells = <2>;
+
+            interrupt-controller;
+            #interrupt-cells = <2>;
+        };
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index d590ce31aa72..00db4f1d165f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2077,6 +2077,7 @@  W:	https://www.turris.cz/
 F:	Documentation/ABI/testing/debugfs-moxtet
 F:	Documentation/ABI/testing/sysfs-bus-moxtet-devices
 F:	Documentation/ABI/testing/sysfs-firmware-turris-mox-rwtm
+F:	Documentation/devicetree/bindings/arm/cznic,turris-omnia-mcu.yaml
 F:	Documentation/devicetree/bindings/bus/moxtet.txt
 F:	Documentation/devicetree/bindings/firmware/cznic,turris-mox-rwtm.txt
 F:	Documentation/devicetree/bindings/gpio/gpio-moxtet.txt