diff mbox series

[v2,1/4] dt-bindings: leds: Add binding for qcom-spmi-flash

Message ID 20210126140240.1517044-2-nfraprado@protonmail.com (mailing list archive)
State New
Headers show
Series Add support for QCOM SPMI Flash LEDs | expand

Commit Message

Nícolas F. R. A. Prado Jan. 26, 2021, 2:04 p.m. UTC
Add devicetree binding for QCOM SPMI Flash LEDs, which are part of
PM8941, and are used both as lantern and camera flash.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@protonmail.com>
---
Changes in v2:
- Add this commit

 .../bindings/leds/leds-qcom-spmi-flash.yaml   | 94 +++++++++++++++++++
 .../dt-bindings/leds/leds-qcom-spmi-flash.h   | 15 +++
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml
 create mode 100644 include/dt-bindings/leds/leds-qcom-spmi-flash.h

Comments

Rob Herring Jan. 27, 2021, 2 p.m. UTC | #1
On Tue, 26 Jan 2021 14:04:08 +0000, Nícolas F. R. A. Prado wrote:
> Add devicetree binding for QCOM SPMI Flash LEDs, which are part of
> PM8941, and are used both as lantern and camera flash.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@protonmail.com>
> ---
> Changes in v2:
> - Add this commit
> 
>  .../bindings/leds/leds-qcom-spmi-flash.yaml   | 94 +++++++++++++++++++
>  .../dt-bindings/leds/leds-qcom-spmi-flash.h   | 15 +++
>  2 files changed, 109 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml
>  create mode 100644 include/dt-bindings/leds/leds-qcom-spmi-flash.h
> 

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/leds-qcom-spmi-flash.yaml: patternProperties:^led[0-1]$:properties:qcom,startup-dly: 'oneOf' conditional failed, one must be fixed:
	'type' is a required property
	Additional properties are not allowed ('maximum', '$ref', 'minimum' were unexpected)
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml: patternProperties:^led[0-1]$:properties:qcom,startup-dly: 'oneOf' conditional failed, one must be fixed:
		'enum' is a required property
		'const' is a required property
	'/schemas/types.yaml#definitions/uint32' does not match 'types.yaml#/definitions/'
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml: patternProperties:^led[0-1]$:properties:qcom,clamp-curr: 'oneOf' conditional failed, one must be fixed:
	'type' is a required property
	Additional properties are not allowed ('$ref' was unexpected)
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml: patternProperties:^led[0-1]$:properties:qcom,clamp-curr: 'oneOf' conditional failed, one must be fixed:
		'enum' is a required property
		'const' is a required property
	'/schemas/types.yaml#definitions/uint32' does not match 'types.yaml#/definitions/'
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml: patternProperties:^led[0-1]$:properties:qcom,headroom: 'oneOf' conditional failed, one must be fixed:
	'type' is a required property
	Additional properties are not allowed ('maximum', '$ref', 'minimum' were unexpected)
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml: patternProperties:^led[0-1]$:properties:qcom,headroom: 'oneOf' conditional failed, one must be fixed:
		'enum' is a required property
		'const' is a required property
	'/schemas/types.yaml#definitions/uint32' does not match 'types.yaml#/definitions/'
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml: ignoring, error in schema: patternProperties: ^led[0-1]$: properties: qcom,startup-dly
warning: no schema found in file: ./Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml

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

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

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.
Bjorn Andersson Jan. 27, 2021, 2:28 p.m. UTC | #2
On Tue 26 Jan 08:04 CST 2021, N?colas F. R. A. Prado wrote:

> Add devicetree binding for QCOM SPMI Flash LEDs, which are part of
> PM8941, and are used both as lantern and camera flash.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@protonmail.com>
> ---
> Changes in v2:
> - Add this commit
> 
>  .../bindings/leds/leds-qcom-spmi-flash.yaml   | 94 +++++++++++++++++++
>  .../dt-bindings/leds/leds-qcom-spmi-flash.h   | 15 +++
>  2 files changed, 109 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml
>  create mode 100644 include/dt-bindings/leds/leds-qcom-spmi-flash.h
> 
> diff --git a/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml b/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml
> new file mode 100644
> index 000000000000..169716e14f67
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml
> @@ -0,0 +1,94 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/leds-qcom-spmi-flash.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Qualcomm SPMI Flash LEDs
> +
> +maintainers:
> +  - Nícolas F. R. A. Prado <nfraprado@protonmail.com>
> +
> +description: |
> +  The Qualcomm SPMI Flash LEDs are part of Qualcomm PMICs and are used primarily
> +  as a camera or video flash. They can also be used as a lantern when on torch
> +  mode.
> +  The PMIC is connected to Host processor via SPMI bus.
> +
> +properties:
> +  compatible:
> +    const: qcom,spmi-flash
> +
> +  reg:
> +    maxItems: 1
> +
> +  flash-boost-supply:
> +    description: SMBB regulator for LED flash mode
> +
> +  torch-boost-supply:
> +    description: SMBB regulator for LED torch mode
> +
> +patternProperties:
> +  "^led[0-1]$":
> +    type: object
> +    $ref: common.yaml#
> +
> +    properties:
> +      qcom,clamp-curr:
> +        description: current to clamp at, in uA
> +        $ref: /schemas/types.yaml#definitions/uint32
> +
> +      qcom,headroom:
> +        description: |
> +          headroom to use. Use one of QCOM_SPMI_FLASH_HEADROOM_* defined in
> +          include/dt-bindings/leds/leds-qcom-spmi-flash.h

Please make the unit of this property millivolts, instead of describing
it indirectly using the defines in the header file.

> +        $ref: /schemas/types.yaml#definitions/uint32
> +        minimum: 0
> +        maximum: 3

And you can then list out the valid values here.

> +
> +      qcom,startup-dly:
> +        description: |
> +          delay before flashing. Use one of QCOM_SPMI_FLASH_STARTUP_DLY_*
> +          defined in include/dt-bindings/leds/leds-qcom-spmi-flash.h

As above, please describe this in microseconds.

> +        $ref: /schemas/types.yaml#definitions/uint32
> +        minimum: 0
> +        maximum: 3
> +
> +      qcom,safety-timer:
> +        description: include for safety timer use, otherwise watchdog timer will be used
> +        type: boolean
> +
> +required:
> +  - compatible
> +  - reg
> +  - flash-boost-supply
> +  - torch-boost-supply
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/leds/common.h>
> +    #include <dt-bindings/leds/leds-qcom-spmi-flash.h>
> +
> +    qcom,leds@d300 {

Please no "qcom," in the node name.

Regards,
Bjorn

> +        compatible = "qcom,spmi-flash";
> +        reg = <0xd300 0x100>;
> +        flash-boost-supply = <&pm8941_5vs1>;
> +        torch-boost-supply = <&pm8941_5v>;
> +
> +        led0 {
> +            led-sources = <0>;
> +            function = LED_FUNCTION_FLASH;
> +            color = <LED_COLOR_ID_WHITE>;
> +            led-max-microamp = <200000>;
> +            flash-max-microamp = <1000000>;
> +            flash-max-timeout-us = <1280000>;
> +            default-state = "off";
> +            qcom,clamp-curr = <200000>;
> +            qcom,headroom = <QCOM_SPMI_FLASH_HEADROOM_500MV>;
> +            qcom,startup-dly = <QCOM_SPMI_FLASH_STARTUP_DLY_128US>;
> +            qcom,safety-timer;
> +        };
> +    };
> +...
> diff --git a/include/dt-bindings/leds/leds-qcom-spmi-flash.h b/include/dt-bindings/leds/leds-qcom-spmi-flash.h
> new file mode 100644
> index 000000000000..8bd54a8e831d
> --- /dev/null
> +++ b/include/dt-bindings/leds/leds-qcom-spmi-flash.h
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _DT_BINDINGS_LEDS_QCOM_SPMI_FLASH_H
> +#define _DT_BINDINGS_LEDS_QCOM_SPMI_FLASH_H
> +
> +#define QCOM_SPMI_FLASH_HEADROOM_250MV	0
> +#define QCOM_SPMI_FLASH_HEADROOM_300MV	1
> +#define QCOM_SPMI_FLASH_HEADROOM_400MV	2
> +#define QCOM_SPMI_FLASH_HEADROOM_500MV	3
> +
> +#define QCOM_SPMI_FLASH_STARTUP_DLY_10US	0
> +#define QCOM_SPMI_FLASH_STARTUP_DLY_32US	1
> +#define QCOM_SPMI_FLASH_STARTUP_DLY_64US	2
> +#define QCOM_SPMI_FLASH_STARTUP_DLY_128US	3
> +
> +#endif
> -- 
> 2.30.0
> 
>
Jacek Anaszewski Jan. 30, 2021, 8:32 p.m. UTC | #3
Hi Nicolas,

On 1/26/21 3:04 PM, Nícolas F. R. A. Prado wrote:
> Add devicetree binding for QCOM SPMI Flash LEDs, which are part of
> PM8941, and are used both as lantern and camera flash.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@protonmail.com>
> ---
> Changes in v2:
> - Add this commit
> 
>   .../bindings/leds/leds-qcom-spmi-flash.yaml   | 94 +++++++++++++++++++
>   .../dt-bindings/leds/leds-qcom-spmi-flash.h   | 15 +++
>   2 files changed, 109 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml
>   create mode 100644 include/dt-bindings/leds/leds-qcom-spmi-flash.h
> 
> diff --git a/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml b/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml
> new file mode 100644
> index 000000000000..169716e14f67
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml
> @@ -0,0 +1,94 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/leds-qcom-spmi-flash.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Qualcomm SPMI Flash LEDs
> +
> +maintainers:
> +  - Nícolas F. R. A. Prado <nfraprado@protonmail.com>
> +
> +description: |
> +  The Qualcomm SPMI Flash LEDs are part of Qualcomm PMICs and are used primarily
> +  as a camera or video flash. They can also be used as a lantern when on torch
> +  mode.
> +  The PMIC is connected to Host processor via SPMI bus.
> +
> +properties:
> +  compatible:
> +    const: qcom,spmi-flash
> +
> +  reg:
> +    maxItems: 1
> +
> +  flash-boost-supply:
> +    description: SMBB regulator for LED flash mode
> +
> +  torch-boost-supply:
> +    description: SMBB regulator for LED torch mode
> +
> +patternProperties:
> +  "^led[0-1]$":
> +    type: object
> +    $ref: common.yaml#
> +
> +    properties:
> +      qcom,clamp-curr:
> +        description: current to clamp at, in uA

You're already using led-max-microamp and flash-max-microamp,
so I'm not sure how this is related to those.

> +        $ref: /schemas/types.yaml#definitions/uint32
> +
> +      qcom,headroom:
> +        description: |
> +          headroom to use. Use one of QCOM_SPMI_FLASH_HEADROOM_* defined in
> +          include/dt-bindings/leds/leds-qcom-spmi-flash.h

More information would be welcome here on how it impacts device
operation.

> +        $ref: /schemas/types.yaml#definitions/uint32
> +        minimum: 0
> +        maximum: 3
> +
> +      qcom,startup-dly:
> +        description: |
> +          delay before flashing. Use one of QCOM_SPMI_FLASH_STARTUP_DLY_*
> +          defined in include/dt-bindings/leds/leds-qcom-spmi-flash.h

I don't see much gain in having this exposed.
We don't have related constructs in the API to handle that, so I propose
to always set it to 0 and not expose this setting at all.

> +        $ref: /schemas/types.yaml#definitions/uint32
> +        minimum: 0
> +        maximum: 3
> +
> +      qcom,safety-timer:
> +        description: include for safety timer use, otherwise watchdog timer will be used
> +        type: boolean

What's the difference between watchdog timer and safety timer?
Either way, I propose to choose the option best fitting for handling
flash timeout setting and hide this inside the driver.

> +required:
> +  - compatible
> +  - reg
> +  - flash-boost-supply
> +  - torch-boost-supply
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/leds/common.h>
> +    #include <dt-bindings/leds/leds-qcom-spmi-flash.h>
> +
> +    qcom,leds@d300 {
> +        compatible = "qcom,spmi-flash";
> +        reg = <0xd300 0x100>;
> +        flash-boost-supply = <&pm8941_5vs1>;
> +        torch-boost-supply = <&pm8941_5v>;
> +
> +        led0 {
> +            led-sources = <0>;

Please use reg property for this purpose instead.

> +            function = LED_FUNCTION_FLASH;
> +            color = <LED_COLOR_ID_WHITE>;
> +            led-max-microamp = <200000>;
> +            flash-max-microamp = <1000000>;
> +            flash-max-timeout-us = <1280000>;

You should mention this properties above and provide constraints
(min, max, step).

> +            default-state = "off";

There's no point in having this in the example.

> +            qcom,clamp-curr = <200000>; > +            qcom,headroom = <QCOM_SPMI_FLASH_HEADROOM_500MV>;
> +            qcom,startup-dly = <QCOM_SPMI_FLASH_STARTUP_DLY_128US>;
> +            qcom,safety-timer;
> +        };
> +    };
> +...
> diff --git a/include/dt-bindings/leds/leds-qcom-spmi-flash.h b/include/dt-bindings/leds/leds-qcom-spmi-flash.h
> new file mode 100644
> index 000000000000..8bd54a8e831d
> --- /dev/null
> +++ b/include/dt-bindings/leds/leds-qcom-spmi-flash.h
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _DT_BINDINGS_LEDS_QCOM_SPMI_FLASH_H
> +#define _DT_BINDINGS_LEDS_QCOM_SPMI_FLASH_H
> +
> +#define QCOM_SPMI_FLASH_HEADROOM_250MV	0
> +#define QCOM_SPMI_FLASH_HEADROOM_300MV	1
> +#define QCOM_SPMI_FLASH_HEADROOM_400MV	2
> +#define QCOM_SPMI_FLASH_HEADROOM_500MV	3
> +
> +#define QCOM_SPMI_FLASH_STARTUP_DLY_10US	0
> +#define QCOM_SPMI_FLASH_STARTUP_DLY_32US	1
> +#define QCOM_SPMI_FLASH_STARTUP_DLY_64US	2
> +#define QCOM_SPMI_FLASH_STARTUP_DLY_128US	3
> +
> +#endif
>
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml b/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml
new file mode 100644
index 000000000000..169716e14f67
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml
@@ -0,0 +1,94 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/leds-qcom-spmi-flash.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm SPMI Flash LEDs
+
+maintainers:
+  - Nícolas F. R. A. Prado <nfraprado@protonmail.com>
+
+description: |
+  The Qualcomm SPMI Flash LEDs are part of Qualcomm PMICs and are used primarily
+  as a camera or video flash. They can also be used as a lantern when on torch
+  mode.
+  The PMIC is connected to Host processor via SPMI bus.
+
+properties:
+  compatible:
+    const: qcom,spmi-flash
+
+  reg:
+    maxItems: 1
+
+  flash-boost-supply:
+    description: SMBB regulator for LED flash mode
+
+  torch-boost-supply:
+    description: SMBB regulator for LED torch mode
+
+patternProperties:
+  "^led[0-1]$":
+    type: object
+    $ref: common.yaml#
+
+    properties:
+      qcom,clamp-curr:
+        description: current to clamp at, in uA
+        $ref: /schemas/types.yaml#definitions/uint32
+
+      qcom,headroom:
+        description: |
+          headroom to use. Use one of QCOM_SPMI_FLASH_HEADROOM_* defined in
+          include/dt-bindings/leds/leds-qcom-spmi-flash.h
+        $ref: /schemas/types.yaml#definitions/uint32
+        minimum: 0
+        maximum: 3
+
+      qcom,startup-dly:
+        description: |
+          delay before flashing. Use one of QCOM_SPMI_FLASH_STARTUP_DLY_*
+          defined in include/dt-bindings/leds/leds-qcom-spmi-flash.h
+        $ref: /schemas/types.yaml#definitions/uint32
+        minimum: 0
+        maximum: 3
+
+      qcom,safety-timer:
+        description: include for safety timer use, otherwise watchdog timer will be used
+        type: boolean
+
+required:
+  - compatible
+  - reg
+  - flash-boost-supply
+  - torch-boost-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/leds/common.h>
+    #include <dt-bindings/leds/leds-qcom-spmi-flash.h>
+
+    qcom,leds@d300 {
+        compatible = "qcom,spmi-flash";
+        reg = <0xd300 0x100>;
+        flash-boost-supply = <&pm8941_5vs1>;
+        torch-boost-supply = <&pm8941_5v>;
+
+        led0 {
+            led-sources = <0>;
+            function = LED_FUNCTION_FLASH;
+            color = <LED_COLOR_ID_WHITE>;
+            led-max-microamp = <200000>;
+            flash-max-microamp = <1000000>;
+            flash-max-timeout-us = <1280000>;
+            default-state = "off";
+            qcom,clamp-curr = <200000>;
+            qcom,headroom = <QCOM_SPMI_FLASH_HEADROOM_500MV>;
+            qcom,startup-dly = <QCOM_SPMI_FLASH_STARTUP_DLY_128US>;
+            qcom,safety-timer;
+        };
+    };
+...
diff --git a/include/dt-bindings/leds/leds-qcom-spmi-flash.h b/include/dt-bindings/leds/leds-qcom-spmi-flash.h
new file mode 100644
index 000000000000..8bd54a8e831d
--- /dev/null
+++ b/include/dt-bindings/leds/leds-qcom-spmi-flash.h
@@ -0,0 +1,15 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _DT_BINDINGS_LEDS_QCOM_SPMI_FLASH_H
+#define _DT_BINDINGS_LEDS_QCOM_SPMI_FLASH_H
+
+#define QCOM_SPMI_FLASH_HEADROOM_250MV	0
+#define QCOM_SPMI_FLASH_HEADROOM_300MV	1
+#define QCOM_SPMI_FLASH_HEADROOM_400MV	2
+#define QCOM_SPMI_FLASH_HEADROOM_500MV	3
+
+#define QCOM_SPMI_FLASH_STARTUP_DLY_10US	0
+#define QCOM_SPMI_FLASH_STARTUP_DLY_32US	1
+#define QCOM_SPMI_FLASH_STARTUP_DLY_64US	2
+#define QCOM_SPMI_FLASH_STARTUP_DLY_128US	3
+
+#endif