diff mbox series

[v2,02/10] dt-bindings: mfd: Add binding for Netronix's embedded controller

Message ID 20200905133230.1014581-3-j.neuschaefer@gmx.net
State Changes Requested
Headers show
Series Netronix embedded controller driver for Kobo and Tolino ebook readers | expand

Commit Message

Jonathan Neuschäfer Sept. 5, 2020, 1:32 p.m. UTC
This EC is found in e-book readers of multiple brands (e.g. Kobo,
Tolino), and is typically implemented as a TI MSP430 microcontroller.

It controls different functions of the system, such as power on/off,
RTC, PWM for the backlight. The exact functionality provided can vary
between boards.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
v2:
- Add the plaintext DT binding for comparison


For reference, here is the binding in text form:

  Netronix Embedded Controller

  This EC is found in e-book readers of multiple brands (e.g. Kobo, Tolino), and
  is typically implemented as a TI MSP430 microcontroller.


  Required properties:
  - compatible: should be "netronix,ntxec"
  - reg: The I2C address of the EC

  Optional properties:
  - system-power-controller:
    See Documentation/devicetree/bindings/power/power-controller.txt
  - interrupts or interrupts-extended
  - interrupt-controller
  - #interrupt-cells: Should be 1

  Optional subnodes:

  Sub-nodes are identified by their compatible string.

   compatible string              | description
  --------------------------------|--------------------------------------
   netronix,ntxec-pwm             | PWM (used for backlight)
   netronix,ntxec-rtc             | real time clock


  Example:

  &i2c3 {
  	pinctrl-names = "default";
  	pinctrl-0 = <&pinctrl_i2c3>;
  	status = "okay";

  	ec: embedded-controller@43 {
  		pinctrl-names = "default";
  		pinctrl-0 = <&pinctrl_ntxec>;

  		compatible = "netronix,ntxec";
  		reg = <0x43>;
  		system-power-controller;
  		interrupt-parent = <&gpio4>;
  		interrupts = <11 IRQ_TYPE_EDGE_FALLING>;
  		interrupt-controller;
  		#interrupt-cells = <1>;

  		pwm {
  			compatible = "netronix,ntxec-pwm";
  			#pwm-cells = <2>;
  		};

  		rtc {
  			compatible = "netronix,ntxec-rtc";
  			interrupts-extended = <&ec 15>;
  			interrupt-names = "alarm";
  		};
  	};
  };
---
 .../bindings/mfd/netronix,ntxec.yaml          | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml

--
2.28.0

Comments

Rob Herring Sept. 15, 2020, 12:50 a.m. UTC | #1
On Sat, Sep 05, 2020 at 03:32:22PM +0200, Jonathan Neuschäfer wrote:
> This EC is found in e-book readers of multiple brands (e.g. Kobo,
> Tolino), and is typically implemented as a TI MSP430 microcontroller.
> 
> It controls different functions of the system, such as power on/off,
> RTC, PWM for the backlight. The exact functionality provided can vary
> between boards.
> 
> Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
> ---
> v2:
> - Add the plaintext DT binding for comparison
> 
> 
> For reference, here is the binding in text form:
> 
>   Netronix Embedded Controller
> 
>   This EC is found in e-book readers of multiple brands (e.g. Kobo, Tolino), and
>   is typically implemented as a TI MSP430 microcontroller.
> 
> 
>   Required properties:
>   - compatible: should be "netronix,ntxec"
>   - reg: The I2C address of the EC
> 
>   Optional properties:
>   - system-power-controller:
>     See Documentation/devicetree/bindings/power/power-controller.txt
>   - interrupts or interrupts-extended
>   - interrupt-controller
>   - #interrupt-cells: Should be 1
> 
>   Optional subnodes:
> 
>   Sub-nodes are identified by their compatible string.
> 
>    compatible string              | description
>   --------------------------------|--------------------------------------
>    netronix,ntxec-pwm             | PWM (used for backlight)
>    netronix,ntxec-rtc             | real time clock
> 
> 
>   Example:
> 
>   &i2c3 {
>   	pinctrl-names = "default";
>   	pinctrl-0 = <&pinctrl_i2c3>;
>   	status = "okay";
> 
>   	ec: embedded-controller@43 {
>   		pinctrl-names = "default";
>   		pinctrl-0 = <&pinctrl_ntxec>;
> 
>   		compatible = "netronix,ntxec";
>   		reg = <0x43>;
>   		system-power-controller;
>   		interrupt-parent = <&gpio4>;
>   		interrupts = <11 IRQ_TYPE_EDGE_FALLING>;
>   		interrupt-controller;
>   		#interrupt-cells = <1>;
> 
>   		pwm {
>   			compatible = "netronix,ntxec-pwm";
>   			#pwm-cells = <2>;
>   		};
> 
>   		rtc {
>   			compatible = "netronix,ntxec-rtc";
>   			interrupts-extended = <&ec 15>;
>   			interrupt-names = "alarm";
>   		};
>   	};
>   };
> ---
>  .../bindings/mfd/netronix,ntxec.yaml          | 57 +++++++++++++++++++
>  1 file changed, 57 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml b/Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml
> new file mode 100644
> index 0000000000000..596df460f98eb
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml
> @@ -0,0 +1,57 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mfd/netronix,ntxec.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Netronix Embedded Controller
> +
> +maintainers:
> +  - Jonathan Neuschäfer <j.neuschaefer@gmx.net>
> +
> +description: |
> +  This EC is found in e-book readers of multiple brands (e.g. Kobo, Tolino), and
> +  is typically implemented as a TI MSP430 microcontroller.
> +
> +
> +properties:
> +  compatible:
> +    const: netronix,ntxec
> +
> +  reg:
> +    items:
> +      - description: The I2C address of the EC
> +
> +  system-power-controller:
> +    type: boolean
> +    description: See Documentation/devicetree/bindings/power/power-controller.txt
> +
> +  interrupts:
> +    minItems: 1
> +    description:
> +      The EC can signal interrupts via a GPIO line
> +
> +required:
> +  - compatible
> +  - reg

additionalProperties: false

> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +    i2c {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +
> +            ec: embedded-controller@43 {
> +                    pinctrl-names = "default";
> +                    pinctrl-0 = <&pinctrl_ntxec>;
> +
> +                    compatible = "netronix,ntxec";
> +                    reg = <0x43>;
> +                    system-power-controller;
> +                    interrupt-parent = <&gpio4>;
> +                    interrupts = <11 IRQ_TYPE_EDGE_FALLING>;

> +                    interrupt-controller;
> +                    #interrupt-cells = <1>;

These need to be documented too.

> +            };
> +    };
> --
> 2.28.0
>
Jonathan Neuschäfer Sept. 17, 2020, 11:12 a.m. UTC | #2
On Mon, Sep 14, 2020 at 06:50:34PM -0600, Rob Herring wrote:
> On Sat, Sep 05, 2020 at 03:32:22PM +0200, Jonathan Neuschäfer wrote:
> > This EC is found in e-book readers of multiple brands (e.g. Kobo,
> > Tolino), and is typically implemented as a TI MSP430 microcontroller.
[...]

> > +required:
> > +  - compatible
> > +  - reg
> 
> additionalProperties: false

Ok, I'll add that.

> > +                    interrupt-controller;
> > +                    #interrupt-cells = <1>;
> 
> These need to be documented too.

Interrupt support is something I haven't really worked out yet for this
(set of) binding(s). My idea here was to have the embedded-controller
node act as an interrupt controller, and the subnodes use specific
interrupts that are relevant for their functionality.

I think I'll rather omit the interrupt-controller and #interrupt-cells
properties now, and add them later if they become necessary. If the pwm
and rtc nodes are merged into the main node, I don't think they will
become necessary.


Thanks,
Jonathan Neuschäfer
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml b/Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml
new file mode 100644
index 0000000000000..596df460f98eb
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/netronix,ntxec.yaml
@@ -0,0 +1,57 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/netronix,ntxec.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Netronix Embedded Controller
+
+maintainers:
+  - Jonathan Neuschäfer <j.neuschaefer@gmx.net>
+
+description: |
+  This EC is found in e-book readers of multiple brands (e.g. Kobo, Tolino), and
+  is typically implemented as a TI MSP430 microcontroller.
+
+
+properties:
+  compatible:
+    const: netronix,ntxec
+
+  reg:
+    items:
+      - description: The I2C address of the EC
+
+  system-power-controller:
+    type: boolean
+    description: See Documentation/devicetree/bindings/power/power-controller.txt
+
+  interrupts:
+    minItems: 1
+    description:
+      The EC can signal interrupts via a GPIO line
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            ec: embedded-controller@43 {
+                    pinctrl-names = "default";
+                    pinctrl-0 = <&pinctrl_ntxec>;
+
+                    compatible = "netronix,ntxec";
+                    reg = <0x43>;
+                    system-power-controller;
+                    interrupt-parent = <&gpio4>;
+                    interrupts = <11 IRQ_TYPE_EDGE_FALLING>;
+                    interrupt-controller;
+                    #interrupt-cells = <1>;
+            };
+    };