Re: [PATCH v2 6/6] led: add TI LP5562 LED driver

2023-11-29 Thread Rasmus Villemoes
On 29/11/2023 16.23, Tom Rini wrote:
> On Fri, Nov 17, 2023 at 12:38:11PM +0100, Rasmus Villemoes wrote:
> 
>> ---
>>  doc/device-tree-bindings/leds/leds-lp5562.txt |  63 ++
>>  drivers/led/Kconfig   |   8 +
>>  drivers/led/Makefile  |   1 +
>>  drivers/led/led_lp5562.c  | 578 ++
>>  4 files changed, 650 insertions(+)
>>  create mode 100644 doc/device-tree-bindings/leds/leds-lp5562.txt
>>  create mode 100644 drivers/led/led_lp5562.c
> 
> If there's no further comments, I'll update the MAINTAINERS file to list
> this driver under your name as well, OK?
> 

Fine by me.

Thanks,
Rasmus



Re: [PATCH v2 6/6] led: add TI LP5562 LED driver

2023-11-29 Thread Tom Rini
On Fri, Nov 17, 2023 at 12:38:11PM +0100, Rasmus Villemoes wrote:

> From: Doug Zobel 
> 
> Driver for the TI LP5562 4 channel LED controller. Supports
> independent on/off control of all 4 channels. Supports LED_BLINK on 3
> independent channels: blue/green/red. The white channel can blink, but
> shares the blue channel blink rate.
> 
> Heavily based on patch originally from Doug Zobel [1].
> 
> I have modified it so it matches the DT bindings in the linux tree,
> and also follows the linux driver implementation more closely. This
> should address Tom's concerns, and also matches my goal of making the
> U-Boot driver work with our existing .dts which is known to work in
> linux.
> 
> As our boards only have the R,G,B outputs connected, I have not
> actually tested how the white channel behaves, but the R,G,B work
> exactly as expected.
> 
> [1] 
> https://lore.kernel.org/u-boot/1547150757-1561-1-git-send-email-douglas.zo...@climate.com/
> 
> Cc: Doug Zobel 
> Signed-off-by: Rasmus Villemoes 
> ---
>  doc/device-tree-bindings/leds/leds-lp5562.txt |  63 ++
>  drivers/led/Kconfig   |   8 +
>  drivers/led/Makefile  |   1 +
>  drivers/led/led_lp5562.c  | 578 ++
>  4 files changed, 650 insertions(+)
>  create mode 100644 doc/device-tree-bindings/leds/leds-lp5562.txt
>  create mode 100644 drivers/led/led_lp5562.c

If there's no further comments, I'll update the MAINTAINERS file to list
this driver under your name as well, OK?

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v2 6/6] led: add TI LP5562 LED driver

2023-11-17 Thread Rasmus Villemoes
From: Doug Zobel 

Driver for the TI LP5562 4 channel LED controller. Supports
independent on/off control of all 4 channels. Supports LED_BLINK on 3
independent channels: blue/green/red. The white channel can blink, but
shares the blue channel blink rate.

Heavily based on patch originally from Doug Zobel [1].

I have modified it so it matches the DT bindings in the linux tree,
and also follows the linux driver implementation more closely. This
should address Tom's concerns, and also matches my goal of making the
U-Boot driver work with our existing .dts which is known to work in
linux.

As our boards only have the R,G,B outputs connected, I have not
actually tested how the white channel behaves, but the R,G,B work
exactly as expected.

[1] 
https://lore.kernel.org/u-boot/1547150757-1561-1-git-send-email-douglas.zo...@climate.com/

Cc: Doug Zobel 
Signed-off-by: Rasmus Villemoes 
---
 doc/device-tree-bindings/leds/leds-lp5562.txt |  63 ++
 drivers/led/Kconfig   |   8 +
 drivers/led/Makefile  |   1 +
 drivers/led/led_lp5562.c  | 578 ++
 4 files changed, 650 insertions(+)
 create mode 100644 doc/device-tree-bindings/leds/leds-lp5562.txt
 create mode 100644 drivers/led/led_lp5562.c

diff --git a/doc/device-tree-bindings/leds/leds-lp5562.txt 
b/doc/device-tree-bindings/leds/leds-lp5562.txt
new file mode 100644
index 000..4e0c742959a
--- /dev/null
+++ b/doc/device-tree-bindings/leds/leds-lp5562.txt
@@ -0,0 +1,63 @@
+LEDs connected to TI LP5562 controller
+
+This driver works with a TI LP5562 4-channel LED controller.
+CONFIG_LED_BLINK is supported using the controller engines.  However
+there are only 3 engines available for the 4 channels.  This means
+that the blue and white channels share the same engine.  When both
+blue and white LEDs are set to blink, they will share the same blink
+rate.  Changing the blink rate of the blue LED will affect the white
+LED and vice-versa.  Manual on/off is handled independently for all 4
+channels.
+
+Required properties:
+  - compatible : should be "ti,lp5562".
+  - #address-cells : must be 1.
+  - #size-cells : must be 0.
+  - reg : LP5562 LED controller I2C address.
+
+Optional properties:
+  - enable-gpios : Enable GPIO
+  - clock-mode : u8, configures the clock mode:
+  - 0 # automode
+  - 1 # internal
+  - 2 # external
+
+Each LED is represented as a sub-node of the ti,lp5562 device.
+
+LED sub-node required properties:
+  - reg : Zero-based channel identifier:
+- 0 red
+- 1 green
+- 2 blue
+- 3 white
+
+LED sub-node optional properties:
+  - chan-name : name of LED
+  - max-cur : LED current at max brightness in 100uA steps (0x00 - 0xFF)
+Default : 100 (10 mA)
+
+Example:
+leds0: lp5562@30 {
+compatible = "ti,lp5562";
+#address-cells = <1>;
+#size-cells = <0>;
+enable-gpios = < 9 GPIO_ACTIVE_HIGH>;
+reg = <0x30>;
+   clock-mode = /bits/8 <1>;
+
+led@0 {
+reg = <0>;
+chan-name = "red";
+max-cur = /bits/ 8 <200>; /* 20mA */
+};
+led@1 {
+reg = <1>;
+chan-name = "green";
+max-cur = /bits/ 8 <200>; /* 20mA */
+};
+led@2 {
+reg = <2>;
+chan-name = "blue";
+max-cur = /bits/ 8 <200>; /* 20mA */
+};
+};
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index 996b757e6d0..9837960198d 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -49,6 +49,14 @@ config LED_CORTINA
  This option enables support for LEDs connected to the Cortina
  Access CA SOCs.
 
+config LED_LP5562
+   bool "LED Support for LP5562"
+   depends on LED && DM_I2C
+   help
+ This option enables support for LEDs connected to the TI LP5562
+ 4 channel I2C LED controller.  Driver fully supports blink on the
+ B/G/R LEDs.  White LED can blink, but re-uses the period from blue.
+
 config LED_PWM
bool "LED PWM"
depends on LED && DM_PWM
diff --git a/drivers/led/Makefile b/drivers/led/Makefile
index 49ae91961d5..2bcb8589087 100644
--- a/drivers/led/Makefile
+++ b/drivers/led/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_LED_BCM6858) += led_bcm6858.o
 obj-$(CONFIG_LED_PWM) += led_pwm.o
 obj-$(CONFIG_$(SPL_)LED_GPIO) += led_gpio.o
 obj-$(CONFIG_LED_CORTINA) += led_cortina.o
+obj-$(CONFIG_LED_LP5562) += led_lp5562.o
diff --git a/drivers/led/led_lp5562.c b/drivers/led/led_lp5562.c
new file mode 100644
index 000..87479ec5515
--- /dev/null
+++ b/drivers/led/led_lp5562.c
@@ -0,0 +1,578 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Doug Zobel 
+ *
+ * Driver for TI lp5562 4