mbox series

[v11,0/5] leds: mt6360: Add LED driver for MT6360

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

Message

Gene Chen Dec. 2, 2020, 10:46 a.m. UTC
This patch series add MT6360 LED support contains driver and binding document

Gene Chen (5)
 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: Add bindings for MT6360 LED
 leds: mt6360: Add LED driver for MT6360

 Documentation/devicetree/bindings/leds/leds-mt6360.yaml |  159 +++
 drivers/leds/Kconfig                                    |   13 
 drivers/leds/Makefile                                   |    1 
 drivers/leds/leds-mt6360.c                              |  827 ++++++++++++++++
 include/dt-bindings/leds/common.h                       |    1 
 include/linux/led-class-flash.h                         |   42 
 include/linux/led-class-multicolor.h                    |   42 
 7 files changed, 1049 insertions(+), 36 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

changelogs between v10 & v11
 - match dt-binding reg property comment to the functionality name
 - remove exist patch in linux-next
 - dicide multicolor channel by color definitiion

Comments

Pavel Machek Dec. 2, 2020, 12:23 p.m. UTC | #1
On Wed 2020-12-02 18:46:49, 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>
> Acked-by: Rob Herring <robh@kernel.org>
> ---
>  include/dt-bindings/leds/common.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h
> index 52b619d..843e65d 100644
> --- a/include/dt-bindings/leds/common.h
> +++ b/include/dt-bindings/leds/common.h
> @@ -78,6 +78,7 @@
>  #define LED_FUNCTION_INDICATOR "indicator"
>  #define LED_FUNCTION_LAN "lan"
>  #define LED_FUNCTION_MAIL "mail"
> +#define LED_FUNCTION_MOONLIGHT "moonlight"

There's "torch" function that should be used for this. I guess comment
should be added with explanation what exactly that is and how should
the LED be named.

Best regards,
								Pavel
Pavel Machek Dec. 3, 2020, 11:40 a.m. UTC | #2
Hi!

> > > +++ b/include/dt-bindings/leds/common.h

> > > @@ -78,6 +78,7 @@

> > >  #define LED_FUNCTION_INDICATOR "indicator"

> > >  #define LED_FUNCTION_LAN "lan"

> > >  #define LED_FUNCTION_MAIL "mail"

> > > +#define LED_FUNCTION_MOONLIGHT "moonlight"

> >

> > There's "torch" function that should be used for this. I guess comment

> > should be added with explanation what exactly that is and how should

> > the LED be named.

> >

> 

> According to mail, 11/25 "Re: [PATCH v7 2/5] dt-bindings: leds: Add

> LED_COLOR_ID_MOONLIGHT definitions",

> The Moonlight LED is LED which maximum current more than torch, but

> less than flash. Such as front camera fill light.

> I think our channel is moonlight, not torch.

> I will add this description to comment.

> We can't exactly define moonlight current level, because every vendor

> has their own specification.


So... what is the timelimit on moonlight?

But if it is used for camera illumination, I believe it should be
simply called flash.

Best regards,

								Pavel
-- 
http://www.livejournal.com/~pavelmachek
Jacek Anaszewski Dec. 3, 2020, 8:24 p.m. UTC | #3
Hi Gene,

Thanks for the update.

On 12/2/20 11:46 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      | 159 +++++++++++++++++++++
>   1 file changed, 159 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..73c67b1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml

Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Rob Herring Dec. 9, 2020, 7:53 p.m. UTC | #4
On Thu, Dec 03, 2020 at 09:06:42PM +0100, Jacek Anaszewski wrote:
> Hi Pavel,

> 

> On 12/3/20 12:40 PM, Pavel Machek wrote:

> > Hi!

> > 

> > > > > +++ b/include/dt-bindings/leds/common.h

> > > > > @@ -78,6 +78,7 @@

> > > > >   #define LED_FUNCTION_INDICATOR "indicator"

> > > > >   #define LED_FUNCTION_LAN "lan"

> > > > >   #define LED_FUNCTION_MAIL "mail"

> > > > > +#define LED_FUNCTION_MOONLIGHT "moonlight"

> > > > 

> > > > There's "torch" function that should be used for this. I guess comment

> > > > should be added with explanation what exactly that is and how should

> > > > the LED be named.

> > > > 

> > > 

> > > According to mail, 11/25 "Re: [PATCH v7 2/5] dt-bindings: leds: Add

> > > LED_COLOR_ID_MOONLIGHT definitions",

> > > The Moonlight LED is LED which maximum current more than torch, but

> > > less than flash. Such as front camera fill light.

> > > I think our channel is moonlight, not torch.

> > > I will add this description to comment.

> > > We can't exactly define moonlight current level, because every vendor

> > > has their own specification.

> > 

> > So... what is the timelimit on moonlight?

> > 

> > But if it is used for camera illumination, I believe it should be

> > simply called flash.

> 

> Let's keep FLASH reserved for LED flash class devices.

> This device has already two other flash iouts.

> 

> Also iouts amperage gives clue that they have three different

> functions.


Perhaps there should just be a table of currents and max times rather 
than trying to continually expand this while tied to function.

One could simply want an LED brighter when blinking than steady state 
would allow for.

Rob
Rob Herring Dec. 9, 2020, 7:58 p.m. UTC | #5
On Wed, Dec 02, 2020 at 06:46:50PM +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      | 159 +++++++++++++++++++++
>  1 file changed, 159 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..73c67b1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml
> @@ -0,0 +1,159 @@
> +# 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-5]$|led)":

"^(multi-)?led@[0-5]$":

> +    type: object
> +    $ref: common.yaml#
> +    description:
> +      Properties for a single LED.
> +
> +    properties:
> +      reg:
> +        description: Index of the LED.
> +        enum:
> +          - 0 # LED output ISINK1
> +          - 1 # LED output ISINK2
> +          - 2 # LED output ISINK3
> +          - 3 # LED output ISINKML
> +          - 4 # LED output FLASH1
> +          - 5 # LED output FLASH2
> +
> +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>;
> +
> +     multi-led@0 {
> +       reg = <0>;
> +       function = LED_FUNCTION_INDICATOR;
> +       color = <LED_COLOR_ID_RGB>;
> +       led-max-microamp = <24000>;
> +       #address-cells = <1>;
> +       #size-cells = <0>;
> +       led@0 {
> +         reg = <0>;
> +         color = <LED_COLOR_ID_RED>;
> +       };
> +       led@1 {
> +         reg = <1>;
> +         color = <LED_COLOR_ID_GREEN>;
> +       };
> +       led@2 {
> +         reg = <2>;
> +         color = <LED_COLOR_ID_BLUE>;
> +       };
> +     };
> +     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-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>;
> +     };
> +   };
> +...
> -- 
> 2.7.4
>