diff mbox series

[1/2,v4] dt-bindings: leds: Add DT binding for Richtek RT8515

Message ID 20201112115646.2562467-1-linus.walleij@linaro.org (mailing list archive)
State New, archived
Headers show
Series [1/2,v4] dt-bindings: leds: Add DT binding for Richtek RT8515 | expand

Commit Message

Linus Walleij Nov. 12, 2020, 11:56 a.m. UTC
Add a YAML devicetree binding for the Richtek RT8515
dual channel flash/torch LED driver.

Cc: Sakari Ailus <sakari.ailus@iki.fi>
Cc: newbytee@protonmail.com
Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: phone-devel@vger.kernel.org
Cc: linux-media@vger.kernel.org
Cc: devicetree@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v3->v4:
- Add DT attributes for the RFS and RTS resistors, so that
  the hardware-defined maximum current can be determined.
- Add torch-max-microamp to the common bindings so we can
  set an attribute for the max microamp in torch mode.
- Add flash-max-microamp and torch-max-microamp as optional
  to the LED node.
- Slot in some elabortative descriptions of the new
  properties and describe what the hardware is doing.
- Cc phone-devel@vger.kernel.org
ChangeLog v2->v3:
- Add Sakari to CC
- Resend
ChangeLog v1->v2:
- Explicitly inherit function, color and flash-max-timeout-us
  from common.yaml
- Add "led" node as required.
---
 .../devicetree/bindings/leds/common.yaml      |   6 +
 .../bindings/leds/richtek,rt8515.yaml         | 111 ++++++++++++++++++
 2 files changed, 117 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/richtek,rt8515.yaml

Comments

Rob Herring (Arm) Nov. 12, 2020, 2:58 p.m. UTC | #1
On Thu, 12 Nov 2020 12:56:45 +0100, Linus Walleij wrote:
> Add a YAML devicetree binding for the Richtek RT8515
> dual channel flash/torch LED driver.
> 
> Cc: Sakari Ailus <sakari.ailus@iki.fi>
> Cc: newbytee@protonmail.com
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Cc: phone-devel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v3->v4:
> - Add DT attributes for the RFS and RTS resistors, so that
>   the hardware-defined maximum current can be determined.
> - Add torch-max-microamp to the common bindings so we can
>   set an attribute for the max microamp in torch mode.
> - Add flash-max-microamp and torch-max-microamp as optional
>   to the LED node.
> - Slot in some elabortative descriptions of the new
>   properties and describe what the hardware is doing.
> - Cc phone-devel@vger.kernel.org
> ChangeLog v2->v3:
> - Add Sakari to CC
> - Resend
> ChangeLog v1->v2:
> - Explicitly inherit function, color and flash-max-timeout-us
>   from common.yaml
> - Add "led" node as required.
> ---
>  .../devicetree/bindings/leds/common.yaml      |   6 +
>  .../bindings/leds/richtek,rt8515.yaml         | 111 ++++++++++++++++++
>  2 files changed, 117 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
> 


My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rts:maximum: False schema does not allow 367000
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rts:minimum: False schema does not allow 7680
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rfs:maximum: False schema does not allow 367000
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rfs:minimum: False schema does not allow 7680
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rts: 'oneOf' conditional failed, one must be fixed:
	'type' is a required property
	Additional properties are not allowed ('maximum', 'minimum', 'maxItems' were unexpected)
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rts: 'oneOf' conditional failed, one must be fixed:
		'enum' is a required property
		'const' is a required property
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rts: 'oneOf' conditional failed, one must be fixed:
		'$ref' is a required property
		'allOf' is a required property
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rfs: 'oneOf' conditional failed, one must be fixed:
	'type' is a required property
	Additional properties are not allowed ('maximum', 'minimum', 'maxItems' were unexpected)
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rfs: 'oneOf' conditional failed, one must be fixed:
		'enum' is a required property
		'const' is a required property
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rfs: 'oneOf' conditional failed, one must be fixed:
		'$ref' is a required property
		'allOf' is a required property
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: ignoring, error in schema: properties: richtek,rfs: maximum
warning: no schema found in file: ./Documentation/devicetree/bindings/leds/richtek,rt8515.yaml


See https://patchwork.ozlabs.org/patch/1398897

The base for the patch is generally the last rc1. Any dependencies
should be noted.

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.
Linus Walleij Nov. 12, 2020, 3:03 p.m. UTC | #2
On Thu, Nov 12, 2020 at 3:58 PM Rob Herring <robh@kernel.org> wrote:

> My bot found errors running 'make dt_binding_check' on your patch:

I have a real hard time even testing YAML bindings after updating to the lates
dtschema, I just get so many errors from all over the tree and then it stops:

make[3]: *** [../Documentation/devicetree/bindings/Makefile:59:
Documentation/devicetree/bindings/processed-schema-examples.json]
Error 123
make[3]: Target '__build' not remade because of errors.
make[2]: *** [/var/linus/linux-nomadik/Makefile:1364: dt_binding_check] Error 2
make[2]: Leaving directory '/var/linus/linux-nomadik/build-ux500'
make[1]: *** [Makefile:185: __sub-make] Error 2
make[1]: Target 'dt_binding_check' not remade because of errors.
make[1]: Leaving directory '/var/linus/linux-nomadik'
make: *** [ux500.mak:573: check-bindings] Error 2

Is it necessary to run on linux-next to test schema/DTS for the moment?

Yours,
Linus Walleij
Rob Herring (Arm) Nov. 12, 2020, 3:45 p.m. UTC | #3
On Thu, Nov 12, 2020 at 9:04 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Thu, Nov 12, 2020 at 3:58 PM Rob Herring <robh@kernel.org> wrote:
>
> > My bot found errors running 'make dt_binding_check' on your patch:
>
> I have a real hard time even testing YAML bindings after updating to the lates
> dtschema, I just get so many errors from all over the tree and then it stops:
>
> make[3]: *** [../Documentation/devicetree/bindings/Makefile:59:
> Documentation/devicetree/bindings/processed-schema-examples.json]

I assume there was some error message more useful before this.

> Error 123
> make[3]: Target '__build' not remade because of errors.
> make[2]: *** [/var/linus/linux-nomadik/Makefile:1364: dt_binding_check] Error 2
> make[2]: Leaving directory '/var/linus/linux-nomadik/build-ux500'
> make[1]: *** [Makefile:185: __sub-make] Error 2
> make[1]: Target 'dt_binding_check' not remade because of errors.
> make[1]: Leaving directory '/var/linus/linux-nomadik'
> make: *** [ux500.mak:573: check-bindings] Error 2
>
> Is it necessary to run on linux-next to test schema/DTS for the moment?

next and rc3 are broken thanks to flexcan changes that should be v5.11
material. next pretty much always has something warning. It's like
maintainers just apply bindings without checking or something. rc2 and
rc1 should be good.

You can see current master and next builds here:

https://gitlab.com/robherring/linux-dt-bindings/-/jobs

You can also use 'make -k' to get all the warnings/errors.

Rob
Rob Herring (Arm) Nov. 12, 2020, 10:16 p.m. UTC | #4
On Thu, Nov 12, 2020 at 5:57 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> Add a YAML devicetree binding for the Richtek RT8515
> dual channel flash/torch LED driver.
>
> Cc: Sakari Ailus <sakari.ailus@iki.fi>
> Cc: newbytee@protonmail.com
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Cc: phone-devel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v3->v4:
> - Add DT attributes for the RFS and RTS resistors, so that
>   the hardware-defined maximum current can be determined.
> - Add torch-max-microamp to the common bindings so we can
>   set an attribute for the max microamp in torch mode.
> - Add flash-max-microamp and torch-max-microamp as optional
>   to the LED node.
> - Slot in some elabortative descriptions of the new
>   properties and describe what the hardware is doing.
> - Cc phone-devel@vger.kernel.org
> ChangeLog v2->v3:
> - Add Sakari to CC
> - Resend
> ChangeLog v1->v2:
> - Explicitly inherit function, color and flash-max-timeout-us
>   from common.yaml
> - Add "led" node as required.
> ---
>  .../devicetree/bindings/leds/common.yaml      |   6 +
>  .../bindings/leds/richtek,rt8515.yaml         | 111 ++++++++++++++++++
>  2 files changed, 117 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
>
> diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml
> index 08b6700ca61e..28bdf09b4af4 100644
> --- a/Documentation/devicetree/bindings/leds/common.yaml
> +++ b/Documentation/devicetree/bindings/leds/common.yaml
> @@ -151,6 +151,12 @@ properties:
>        Maximum flash LED supply current in microamperes. Required for flash LED
>        nodes with configurable current.
>
> +  torch-max-microamp:
> +    description:
> +      Maximum flash LED supply current in microamperes, when the flash LED is
> +      used as a torch (flashlight). This is usually lower than the flash mode
> +      maximum current, if the LED supports torch mode.
> +
>    flash-max-timeout-us:
>      description:
>        Maximum timeout in microseconds after which the flash LED is turned off.
> diff --git a/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml b/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
> new file mode 100644
> index 000000000000..5f65a20b997d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
> @@ -0,0 +1,111 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/richtek,rt8515.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Richtek RT8515 1.5A dual channel LED driver
> +
> +maintainers:
> +  - Linus Walleij <linus.walleij@linaro.org>
> +
> +description: |
> +  The Richtek RT8515 is a dual channel (two mode) LED driver that
> +  supports driving a white LED in flash or torch mode. The maximum
> +  current for each mode is defined in hardware using two resistors
> +  RFS and RTS.
> +
> +properties:
> +  compatible:
> +    const: richtek,rt8515
> +
> +  enf-gpios:
> +    maxItems: 1
> +    description: A connection to the 'ENF' (enable flash) pin.
> +
> +  ent-gpios:
> +    maxItems: 1
> +    description: A connection to the 'ENT' (enable torch) pin.
> +
> +  richtek,rfs:
> +    maxItems: 1
> +    minimum: 7680
> +    maximum: 367000

You've mixed vocabulary for arrays (maxItems) and scalars.

You need a type reference.

> +    description: The resistance value of the RFS resisitor. This

typo

> +      resistors limits the maximum flash current. This must be set
> +      for the property flash-max-microamp to work, the RFS resistor
> +      defines the range of the dimmer setting (brightness) of the
> +      flash LED.
> +
> +  richtek,rts:
> +    maxItems: 1
> +    minimum: 7680
> +    maximum: 367000
> +    description: The resistance value of the RTS resisitor. This

Same issues here.

> +      resistors limits the maximum torch current. This must be set
> +      for the property torch-max-microamp to work, the RTS resistor
> +      defines the range of the dimmer setting (brightness) of the
> +      torch LED.
> +
> +  led:
> +    type: object
> +    $ref: common.yaml#
> +    properties:
> +      function: true
> +      color: true
> +      flash-max-timeout-us: true
> +
> +      flash-max-microamp:
> +        maximum: 700000
> +        description: The maximum current for flash mode
> +          is hardwired to the component using the RFS resistor to
> +          ground. The maximum hardware current setting is calculated
> +          according to the formula Imax = 5500 / RFS. The lowest
> +          allowed resistance value is 7.86 kOhm giving an absolute
> +          maximum current of 700mA. By setting this attribute in
> +          the device tree, you can further restrict the maximum
> +          current below the hardware limit. This requires the RFS
> +          to be defined as it defines the maximum range.
> +
> +      torch-max-microamp:
> +        maximum: 700000
> +        description: The maximum current for torch mode
> +          is hardwired to the component using the RTS resistor to
> +          ground. The maximum hardware current setting is calculated
> +          according to the formula Imax = 5500 / RTS. The lowest
> +          allowed resistance value is 7.86 kOhm giving an absolute
> +          maximum current of 700mA. By setting this attribute in
> +          the device tree, you can further restrict the maximum
> +          current below the hardware limit. This requires the RTS
> +          to be defined as it defines the maximum range.
> +
> +required:
> +  - compatible
> +  - ent-gpios
> +  - enf-gpios
> +  - led
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +    #include <dt-bindings/leds/common.h>
> +
> +    led-controller {
> +        compatible = "richtek,rt8515";
> +        enf-gpios = <&gpio4 12 GPIO_ACTIVE_HIGH>;
> +        ent-gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>;
> +        richtek,rfs = <16000>;
> +        richtek,rts = <100000>;
> +
> +        led {
> +            function = LED_FUNCTION_FLASH;
> +            color = <LED_COLOR_ID_WHITE>;
> +            flash-max-timeout-us = <250000>;
> +            flash-max-microamp = <150000>;
> +            torch-max-microamp = <25000>;
> +        };
> +    };
> +
> +...
> --
> 2.26.2
>
Rob Herring (Arm) Nov. 12, 2020, 10:20 p.m. UTC | #5
On Thu, Nov 12, 2020 at 9:45 AM Rob Herring <robh@kernel.org> wrote:
>
> On Thu, Nov 12, 2020 at 9:04 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> > On Thu, Nov 12, 2020 at 3:58 PM Rob Herring <robh@kernel.org> wrote:
> >
> > > My bot found errors running 'make dt_binding_check' on your patch:
> >
> > I have a real hard time even testing YAML bindings after updating to the lates
> > dtschema, I just get so many errors from all over the tree and then it stops:
> >
> > make[3]: *** [../Documentation/devicetree/bindings/Makefile:59:
> > Documentation/devicetree/bindings/processed-schema-examples.json]
>
> I assume there was some error message more useful before this.
>
> > Error 123
> > make[3]: Target '__build' not remade because of errors.
> > make[2]: *** [/var/linus/linux-nomadik/Makefile:1364: dt_binding_check] Error 2
> > make[2]: Leaving directory '/var/linus/linux-nomadik/build-ux500'
> > make[1]: *** [Makefile:185: __sub-make] Error 2
> > make[1]: Target 'dt_binding_check' not remade because of errors.
> > make[1]: Leaving directory '/var/linus/linux-nomadik'
> > make: *** [ux500.mak:573: check-bindings] Error 2
> >
> > Is it necessary to run on linux-next to test schema/DTS for the moment?
>
> next and rc3 are broken thanks to flexcan changes that should be v5.11
> material. next pretty much always has something warning. It's like
> maintainers just apply bindings without checking or something. rc2 and
> rc1 should be good.

Actually, rc1 was not good. I didn't get all the fixes in since armsoc
changes came in so late.

Rob
Linus Walleij Nov. 13, 2020, 12:23 p.m. UTC | #6
On Thu, Nov 12, 2020 at 11:20 PM Rob Herring <robh@kernel.org> wrote:
> On Thu, Nov 12, 2020 at 9:45 AM Rob Herring <robh@kernel.org> wrote:
> > On Thu, Nov 12, 2020 at 9:04 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> > > On Thu, Nov 12, 2020 at 3:58 PM Rob Herring <robh@kernel.org> wrote:
> > >
> > > > My bot found errors running 'make dt_binding_check' on your patch:
> > >
> > > I have a real hard time even testing YAML bindings after updating to the lates
> > > dtschema, I just get so many errors from all over the tree and then it stops:
> > >
> > > make[3]: *** [../Documentation/devicetree/bindings/Makefile:59:
> > > Documentation/devicetree/bindings/processed-schema-examples.json]
> >
> > I assume there was some error message more useful before this.
> >
> > > Error 123
> > > make[3]: Target '__build' not remade because of errors.
> > > make[2]: *** [/var/linus/linux-nomadik/Makefile:1364: dt_binding_check] Error 2
> > > make[2]: Leaving directory '/var/linus/linux-nomadik/build-ux500'
> > > make[1]: *** [Makefile:185: __sub-make] Error 2
> > > make[1]: Target 'dt_binding_check' not remade because of errors.
> > > make[1]: Leaving directory '/var/linus/linux-nomadik'
> > > make: *** [ux500.mak:573: check-bindings] Error 2
> > >
> > > Is it necessary to run on linux-next to test schema/DTS for the moment?
> >
> > next and rc3 are broken thanks to flexcan changes that should be v5.11
> > material. next pretty much always has something warning. It's like
> > maintainers just apply bindings without checking or something. rc2 and
> > rc1 should be good.
>
> Actually, rc1 was not good. I didn't get all the fixes in since armsoc
> changes came in so late.

OK I try to rebase onto -rc2 and see if that solves my problem.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml
index 08b6700ca61e..28bdf09b4af4 100644
--- a/Documentation/devicetree/bindings/leds/common.yaml
+++ b/Documentation/devicetree/bindings/leds/common.yaml
@@ -151,6 +151,12 @@  properties:
       Maximum flash LED supply current in microamperes. Required for flash LED
       nodes with configurable current.
 
+  torch-max-microamp:
+    description:
+      Maximum flash LED supply current in microamperes, when the flash LED is
+      used as a torch (flashlight). This is usually lower than the flash mode
+      maximum current, if the LED supports torch mode.
+
   flash-max-timeout-us:
     description:
       Maximum timeout in microseconds after which the flash LED is turned off.
diff --git a/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml b/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
new file mode 100644
index 000000000000..5f65a20b997d
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
@@ -0,0 +1,111 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/richtek,rt8515.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT8515 1.5A dual channel LED driver
+
+maintainers:
+  - Linus Walleij <linus.walleij@linaro.org>
+
+description: |
+  The Richtek RT8515 is a dual channel (two mode) LED driver that
+  supports driving a white LED in flash or torch mode. The maximum
+  current for each mode is defined in hardware using two resistors
+  RFS and RTS.
+
+properties:
+  compatible:
+    const: richtek,rt8515
+
+  enf-gpios:
+    maxItems: 1
+    description: A connection to the 'ENF' (enable flash) pin.
+
+  ent-gpios:
+    maxItems: 1
+    description: A connection to the 'ENT' (enable torch) pin.
+
+  richtek,rfs:
+    maxItems: 1
+    minimum: 7680
+    maximum: 367000
+    description: The resistance value of the RFS resisitor. This
+      resistors limits the maximum flash current. This must be set
+      for the property flash-max-microamp to work, the RFS resistor
+      defines the range of the dimmer setting (brightness) of the
+      flash LED.
+
+  richtek,rts:
+    maxItems: 1
+    minimum: 7680
+    maximum: 367000
+    description: The resistance value of the RTS resisitor. This
+      resistors limits the maximum torch current. This must be set
+      for the property torch-max-microamp to work, the RTS resistor
+      defines the range of the dimmer setting (brightness) of the
+      torch LED.
+
+  led:
+    type: object
+    $ref: common.yaml#
+    properties:
+      function: true
+      color: true
+      flash-max-timeout-us: true
+
+      flash-max-microamp:
+        maximum: 700000
+        description: The maximum current for flash mode
+          is hardwired to the component using the RFS resistor to
+          ground. The maximum hardware current setting is calculated
+          according to the formula Imax = 5500 / RFS. The lowest
+          allowed resistance value is 7.86 kOhm giving an absolute
+          maximum current of 700mA. By setting this attribute in
+          the device tree, you can further restrict the maximum
+          current below the hardware limit. This requires the RFS
+          to be defined as it defines the maximum range.
+
+      torch-max-microamp:
+        maximum: 700000
+        description: The maximum current for torch mode
+          is hardwired to the component using the RTS resistor to
+          ground. The maximum hardware current setting is calculated
+          according to the formula Imax = 5500 / RTS. The lowest
+          allowed resistance value is 7.86 kOhm giving an absolute
+          maximum current of 700mA. By setting this attribute in
+          the device tree, you can further restrict the maximum
+          current below the hardware limit. This requires the RTS
+          to be defined as it defines the maximum range.
+
+required:
+  - compatible
+  - ent-gpios
+  - enf-gpios
+  - led
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/leds/common.h>
+
+    led-controller {
+        compatible = "richtek,rt8515";
+        enf-gpios = <&gpio4 12 GPIO_ACTIVE_HIGH>;
+        ent-gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>;
+        richtek,rfs = <16000>;
+        richtek,rts = <100000>;
+
+        led {
+            function = LED_FUNCTION_FLASH;
+            color = <LED_COLOR_ID_WHITE>;
+            flash-max-timeout-us = <250000>;
+            flash-max-microamp = <150000>;
+            torch-max-microamp = <25000>;
+        };
+    };
+
+...