mbox series

[v10,0/6] leds: mt6360: Add LED driver for MT6360

Message ID 1606447736-7944-1-git-send-email-gene.chen.richtek@gmail.com
Headers show
Series leds: mt6360: Add LED driver for MT6360 | expand

Message

Gene Chen Nov. 27, 2020, 3:28 a.m. UTC
[PATCH v10 0/6] leds: mt6360: Add LED driver for MT6360

This patch series add MT6360 LED support contains driver and binding document

Gene Chen (6)
 leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
 leds: flash: Fix multicolor no-ops registration by return 0
 dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions
 dt-bindings: leds: common: Increase LED_COLOR_ID_* maximum size
 dt-bindings: leds: Add bindings for MT6360 LED
 leds: mt6360: Add LED driver for MT6360

 Documentation/devicetree/bindings/leds/common.yaml      |    2 
 Documentation/devicetree/bindings/leds/leds-mt6360.yaml |  164 +++
 drivers/leds/Kconfig                                    |   13 
 drivers/leds/Makefile                                   |    1 
 drivers/leds/leds-mt6360.c                              |  811 ++++++++++++++++
 include/dt-bindings/leds/common.h                       |    1 
 include/linux/led-class-flash.h                         |   42 
 include/linux/led-class-multicolor.h                    |   42 
 8 files changed, 1039 insertions(+), 37 deletions(-)

changelogs between v1 & v2
 - add led driver with mfd

changelogs between v2 & v3
 - independent add led driver
 - add dt-binding document
 - refactor macros definition for easy to debug
 - parse device tree by fwnode
 - use devm*ext to register led class device

changelogs between v3 & v4
 - fix binding document description
 - use GENMASK and add unit postfix to definition
 - isink register led class device

changelogs between v4 & v5
 - change rgb isink to multicolor control
 - add binding reference to mfd yaml

changelogs between v5 & v6
 - Use DT to decide RGB LED is multicolor device or indicator device only

changelogs between v6 & v7
 - Add binding multicolor device sample code
 - Add flash ops mutex lock
 - Remove V4L2 init with indicator device

changelogs between v7 & v8
 - Add mutex for led fault get ops
 - Fix flash and multicolor no-ops return 0
 - Add LED_FUNCTION_MOONLIGHT

changelogs between v8 & v9
 - reuse api in flash and multicolor header

changelogs between v9 & v10
 - add comment for reuse registration functions in flash and multicolor

Comments

Jacek Anaszewski Nov. 28, 2020, 3:13 p.m. UTC | #1
Hi Gene,

On 11/27/20 4:28 AM, Gene Chen wrote:
> From: Gene Chen <gene_chen@richtek.com>

> 

> Add bindings document for LED support on MT6360 PMIC

> 

> Signed-off-by: Gene Chen <gene_chen@richtek.com>

> ---

>   .../devicetree/bindings/leds/leds-mt6360.yaml      | 164 +++++++++++++++++++++

>   1 file changed, 164 insertions(+)

>   create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml

> 

> diff --git a/Documentation/devicetree/bindings/leds/leds-mt6360.yaml b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml

> new file mode 100644

> index 0000000..b2ffbc6

> --- /dev/null

> +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml

> @@ -0,0 +1,164 @@

> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)

> +%YAML 1.2

> +---

> +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml#

> +$schema: http://devicetree.org/meta-schemas/core.yaml#

> +

> +title: LED driver for MT6360 PMIC from MediaTek Integrated.

> +

> +maintainers:

> +  - Gene Chen <gene_chen@richtek.com>

> +

> +description: |

> +  This module is part of the MT6360 MFD device.

> +  see Documentation/devicetree/bindings/mfd/mt6360.yaml

> +  Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode,

> +  and 4-channel RGB LED support Register/Flash/Breath Mode

> +

> +properties:

> +  compatible:

> +    const: mediatek,mt6360-led

> +

> +  "#address-cells":

> +    const: 1

> +

> +  "#size-cells":

> +    const: 0

> +

> +patternProperties:

> +  "^led@[0-6]$":

> +    type: object

> +    $ref: common.yaml#

> +    description:

> +      Properties for a single LED.

> +

> +    properties:

> +      reg:

> +        description: Index of the LED.

> +        enum:

> +          - 0 # LED output INDICATOR1_RED

> +          - 1 # LED output INDICATOR1_GREEN

> +          - 2 # LED output INDICATOR1_BLUE

> +          - 3 # LED output INDICATOR2_

These LED output descriptions look odd.
In the driver you have:

enum {
     MT6360_LED_ISNK1 = 0,
     MT6360_LED_ISNK2,
     MT6360_LED_ISNK3,
     MT6360_LED_ISNKML
     ...

I think the same names should be used for DT reg property documentation:

- 0 # LED output ISNK1
- 1 # LED output ISNK2
- 2 # LED output ISNK3
- 3 # LED output ISNKML

Here you're describing hardware, i.e. current sinks as they are
defined in the device documentation, and not the functions you're
assigning in DT to the connected LEDs.

> +          - 4 # LED output FLED1

> +          - 5 # LED output FLED2

> +          - 6 # LED output MULTICOLOR



This last enum is also disputable, since it is driver specific, and not
hardware specific. Actually you should rather check LED color id and
basing on that treat the LED as multicolor (for LED_COLOR_ID_RGB).
See drivers/leds/leds-lp55xx-common.c for a reference.

> +unevaluatedProperties: false

> +

> +required:

> +  - compatible

> +  - "#address-cells"

> +  - "#size-cells"

> +

> +additionalProperties: false

> +

> +examples:

> + - |

> +   #include <dt-bindings/leds/common.h>

> +   led-controller {

> +     compatible = "mediatek,mt6360-led";

> +     #address-cells = <1>;

> +     #size-cells = <0>;

> +

> +     led@3 {

> +       reg = <3>;

> +       function 


= LED_FUNCTION_MOONLIGHT;
> +       color = <LED_COLOR_ID_WHITE>;

> +       led-max-microamp = <150000>;

> +     };

> +     led@4 {

> +       reg = <4>;

> +       function = LED_FUNCTION_FLASH;

> +       color = <LED_COLOR_ID_WHITE>;

> +       function-enumerator = <1>;

> +       led-max-microamp = <200000>;

> +       flash-max-microamp = <500000>;

> +       flash-max-timeout-us = <1024000>;

> +     };

> +     led@5 {

> +       reg = <5>;

> +       function = LED_FUNCTION_FLASH;

> +       color = <LED_COLOR_ID_WHITE>;

> +       function-enumerator = <2>;

> +       led-max-microamp = <200000>;

> +       flash-max-microamp = <500000>;

> +       flash-max-timeout-us = <1024000>;

> +     };

> +     led@6 {

> +       reg = <6>;

> +       function = LED_FUNCTION_INDICATOR;

> +       color = <LED_COLOR_ID_RGB>;

> +       led-max-microamp = <24000>;

> +       #address-cells = <1>;

> +       #size-cells = <0>;

> +

> +       led@0 {

> +         reg = <0>;

> +         function = LED_FUNCTION_INDICATOR;


The function is unused in case of the multicolor subleds.
Please drop it from here.

> +         color = <LED_COLOR_ID_RED>;

> +       };

> +       led@1 {

> +         reg = <1>;

> +         function = LED_FUNCTION_INDICATOR;


Ditto.

> +         color = <LED_COLOR_ID_GREEN>;

> +       };

> +       led@2 {

> +         reg = <2>;

> +         function = LED_FUNCTION_INDICATOR;


Ditto.

> +         color = <LED_COLOR_ID_BLUE>;

> +       };

> +     };

> +   };

> +

> + - |

> +

> +   led-controller {

> +     compatible = "mediatek,mt6360-led";

> +     #address-cells = <1>;

> +     #size-cells = <0>;

> +

> +     led@0 {

> +       reg = <0>;

> +       function = LED_FUNCTION_INDICATOR;

> +       color = <LED_COLOR_ID_RED>;

> +       led-max-microamp = <24000>;

> +     };

> +     led@1 {

> +       reg = <1>;

> +       function = LED_FUNCTION_INDICATOR;

> +       color = <LED_COLOR_ID_GREEN>;

> +       led-max-microamp = <24000>;

> +     };

> +     led@2 {

> +       reg = <2>;

> +       function = LED_FUNCTION_INDICATOR;

> +       color = <LED_COLOR_ID_BLUE>;

> +       led-max-microamp = <24000>;

> +     };

> +     led@3 {

> +       reg = <3>;

> +       function = LED_FUNCTION_MOONLIGHT;

> +       color = <LED_COLOR_ID_WHITE>;

> +       led-max-microamp = <150000>;

> +     };

> +     led@4 {

> +       reg = <4>;

> +       function = LED_FUNCTION_FLASH;

> +       color = <LED_COLOR_ID_WHITE>;

> +       function-enumerator = <1>;

> +       led-max-microamp = <200000>;

> +       flash-max-microamp = <500000>;

> +       flash-max-timeout-us = <1024000>;

> +     };

> +     led@5 {

> +       reg = <5>;

> +       function = LED_FUNCTION_FLASH;

> +       color = <LED_COLOR_ID_WHITE>;

> +       function-enumerator = <2>;

> +       led-max-microamp = <200000>;

> +       flash-max-microamp = <500000>;

> +       flash-max-timeout-us = <1024000>;

> +     };

> +   };

> +...

> 


-- 
Best regards,
Jacek Anaszewski
Rob Herring (Arm) Nov. 30, 2020, 5:33 p.m. UTC | #2
On Fri, 27 Nov 2020 11:28:55 +0800, Gene Chen wrote:
> From: Gene Chen <gene_chen@richtek.com>

> 

> Add bindings document for LED support on MT6360 PMIC

> 

> Signed-off-by: Gene Chen <gene_chen@richtek.com>

> ---

>  .../devicetree/bindings/leds/leds-mt6360.yaml      | 164 +++++++++++++++++++++

>  1 file changed, 164 insertions(+)

>  create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml

> 



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

yamllint warnings/errors:
./Documentation/devicetree/bindings/leds/leds-mt6360.yaml:57:2: [warning] wrong indentation: expected 2 but found 1 (indentation)

dtschema/dtc warnings/errors:


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

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.
Rob Herring (Arm) Nov. 30, 2020, 9:11 p.m. UTC | #3
On Fri, 27 Nov 2020 11:28:53 +0800, Gene Chen wrote:
> From: Gene Chen <gene_chen@richtek.com>
> 
> Add LED_FUNCTION_MOONLIGHT definitions
> 
> Signed-off-by: Gene Chen <gene_chen@richtek.com>
> Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
> ---
>  include/dt-bindings/leds/common.h | 1 +
>  1 file changed, 1 insertion(+)
> 

Acked-by: Rob Herring <robh@kernel.org>