Skip to contentSkip to conversation

dt-bindings: leds: Add NCP5623 multi-LED Controller

PATCH Applied Abdel Alkuor 2 participants 5 messages Mar 5, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 dt-bindings: leds: Add NCP5623 multi-LED Controller

NCP5623 is DC-DC multi-LED controller which can be used for RGB illumination or backlight LCD display.

---
Changes in v3:
- Add Reviewed-by tag
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Fix commit subject prefix
- drop | from the main description
- Use const in address reg
- Remove LEDs reg description
- Link to v1: https://lore.kernel.org/linux-kernel/[email protected]/T/

 .../bindings/leds/onnn,ncp5623.yaml           | 96 +++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/onnn,ncp5623.yaml
Documentation/devicetree/bindings/leds/onnn,ncp5623.yaml new file +96 -0
new file mode 100644
index 000000000000..9c9f3a682ba2
@@ -0,0 +1,96 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/onnn,ncp5623.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor NCP5623 multi-LED Driver
+
+maintainers:
+  - Abdel Alkuor <[email protected]>
+
+description:
+  NCP5623 Triple Output I2C Controlled LED Driver.
+  https://www.onsemi.com/pdf/datasheet/ncp5623-d.pdf
+
+properties:
+  compatible:
+    enum:
+      - onnn,ncp5623
+
+  reg:
+    const: 0x38
+
+  multi-led:
+    type: object
+    $ref: leds-class-multicolor.yaml#
+    unevaluatedProperties: false
+
+    properties:
+      "#address-cells":
+        const: 1
+
+      "#size-cells":
+        const: 0
+
+    patternProperties:
+      "^led@[0-2]$":
+        type: object
+        $ref: common.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          reg:
+            minimum: 0
+            maximum: 2
+
+        required:
+          - reg
+          - color
+
+    required:
+      - "#address-cells"
+      - "#size-cells"
+
+required:
+  - compatible
+  - reg
+  - multi-led
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/leds/common.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        led-controller@38 {
+            compatible = "onnn,ncp5623";
+            reg = <0x38>;
+
+            multi-led {
+                color = <LED_COLOR_ID_RGB>;
+
+                #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>;
+                };
+            };
+        };
+    };
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 2/2 leds: Add NCP5623 multi-led driver

NCP5623 is DC-DC multi-LEDs driver which has three PWMs that can be programmed up to 32 steps giving 32768 colors hue.

NCP5623 driver supports gradual dimming upward/downward with programmable delays. Also, the driver supports driving a single LED or multi-LED like RGB.

---
Changes in v3:
- Add defines for magic numbers
- Fix code style
- Add a comment how ncp->delay is calculated
- Don't free mc_node when probe is successful
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Remove all custom attributes and use hw pattern instead
- Remove filename from the driver description
- Fix coding style
- Destroy the muttex in shutdown callback
- Register mcled device using none devm version as unregistering mcled device calls ncp5632_set_led which uses mutex hence we need to make sure the mutex is still available during the unregistering process.
- Link to v1: https://lore.kernel.org/linux-kernel/[email protected]/T/

 drivers/leds/rgb/Kconfig        |  11 ++
 drivers/leds/rgb/Makefile       |   1 +
 drivers/leds/rgb/leds-ncp5623.c | 271 ++++++++++++++++++++++++++++++++
 3 files changed, 283 insertions(+)
 create mode 100644 drivers/leds/rgb/leds-ncp5623.c
drivers/leds/rgb/Kconfig +11 -0
index a6a21f564673..81ab6a526a78 100644
@@ -27,6 +27,17 @@ config LEDS_KTD202X
 	  To compile this driver as a module, choose M here: the module
 	  will be called leds-ktd202x.
 
+config LEDS_NCP5623
+	tristate "LED support for NCP5623"
+	depends on I2C
+	depends on OF
+	help
+	  This option enables support for ON semiconductor NCP5623
+	  Triple Output I2C Controlled RGB LED Driver.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called leds-ncp5623.
+
 config LEDS_PWM_MULTICOLOR
 	tristate "PWM driven multi-color LED Support"
 	depends on PWM
drivers/leds/rgb/Makefile +1 -0
index 243f31e4d70d..a501fd27f179 100644
@@ -2,6 +2,7 @@
 
 obj-$(CONFIG_LEDS_GROUP_MULTICOLOR)	+= leds-group-multicolor.o
 obj-$(CONFIG_LEDS_KTD202X)		+= leds-ktd202x.o
+obj-$(CONFIG_LEDS_NCP5623)		+= leds-ncp5623.o
 obj-$(CONFIG_LEDS_PWM_MULTICOLOR)	+= leds-pwm-multicolor.o
 obj-$(CONFIG_LEDS_QCOM_LPG)		+= leds-qcom-lpg.o
 obj-$(CONFIG_LEDS_MT6370_RGB)		+= leds-mt6370-rgb.o
drivers/leds/rgb/leds-ncp5623.c new file +271 -0

271 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer Applied
#2 lore raw

Re: (subset) [PATCH v3 2/2] leds: Add NCP5623 multi-led driver

Quoted 8 lines · Abdel Alkuor

NCP5623 is DC-DC multi-LEDs driver which has three PWMs that can be programmed up to 32 steps giving 32768 colors hue.

NCP5623 driver supports gradual dimming upward/downward with programmable delays. Also, the driver supports driving a single LED or multi-LED like RGB.

[...]

Applied, thanks!

[2/2] leds: Add NCP5623 multi-led driver

      commit: 535a2262514d7d4016411707c9f8ac106062615f

--
Lee Jones [李琼斯]

maintainer
#3 lore raw

Re: [PATCH v3 2/2] leds: Add NCP5623 multi-led driver

In reply to Abdel Alkuor
Quoted 87 lines · Abdel Alkuor

NCP5623 is DC-DC multi-LEDs driver which has three PWMs that can be programmed up to 32 steps giving 32768 colors hue.

NCP5623 driver supports gradual dimming upward/downward with programmable delays. Also, the driver supports driving a single LED or multi-LED like RGB.

---
Changes in v3:
- Add defines for magic numbers
- Fix code style
- Add a comment how ncp->delay is calculated
- Don't free mc_node when probe is successful
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Remove all custom attributes and use hw pattern instead
- Remove filename from the driver description
- Fix coding style
- Destroy the muttex in shutdown callback
- Register mcled device using none devm version as unregistering mcled device calls ncp5632_set_led which uses mutex hence we need to make sure the mutex is still available during the unregistering process.
- Link to v1: https://lore.kernel.org/linux-kernel/[email protected]/T/

 drivers/leds/rgb/Kconfig        |  11 ++
 drivers/leds/rgb/Makefile       |   1 +
 drivers/leds/rgb/leds-ncp5623.c | 271 ++++++++++++++++++++++++++++++++
 3 files changed, 283 insertions(+)
 create mode 100644 drivers/leds/rgb/leds-ncp5623.c
drivers/leds/rgb/Kconfig +11 -0
index a6a21f564673..81ab6a526a78 100644
@@ -27,6 +27,17 @@ config LEDS_KTD202X
 	  To compile this driver as a module, choose M here: the module
 	  will be called leds-ktd202x.
 
+config LEDS_NCP5623
+	tristate "LED support for NCP5623"
+	depends on I2C
+	depends on OF
+	help
+	  This option enables support for ON semiconductor NCP5623
+	  Triple Output I2C Controlled RGB LED Driver.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called leds-ncp5623.
+
 config LEDS_PWM_MULTICOLOR
 	tristate "PWM driven multi-color LED Support"
 	depends on PWM
drivers/leds/rgb/Makefile +1 -0
index 243f31e4d70d..a501fd27f179 100644
@@ -2,6 +2,7 @@
 
 obj-$(CONFIG_LEDS_GROUP_MULTICOLOR)	+= leds-group-multicolor.o
 obj-$(CONFIG_LEDS_KTD202X)		+= leds-ktd202x.o
+obj-$(CONFIG_LEDS_NCP5623)		+= leds-ncp5623.o
 obj-$(CONFIG_LEDS_PWM_MULTICOLOR)	+= leds-pwm-multicolor.o
 obj-$(CONFIG_LEDS_QCOM_LPG)		+= leds-qcom-lpg.o
 obj-$(CONFIG_LEDS_MT6370_RGB)		+= leds-mt6370-rgb.o
drivers/leds/rgb/leds-ncp5623.c new file +16 -0
new file mode 100644
index 000000000000..b669c55c5483
@@ -0,0 +1,271 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * NCP5623 Multi-LED Driver
+ *
+ * Author: Abdel Alkuor <[email protected]>
+ * Datasheet: https://www.onsemi.com/pdf/datasheet/ncp5623-d.pdf
+ */
+
+#include <linux/i2c.h>
+#include <linux/module.h>
+
+#include <linux/led-class-multicolor.h>
+
+#define NCP5623_FUNCTION_OFFSET		0x5
+#define NCP5623_REG(x)			((x) << NCP5623_FUNCTION_OFFSET)
+

drivers/leds/rgb/leds-ncp5623.c line 26

Quoted 10 lines
drivers/leds/rgb/leds-ncp5623.c new file +10 -0
+#define NCP5623_SHUTDOWN_REG		NCP5623_REG(0x0)
+#define NCP5623_ILED_REG		NCP5623_REG(0x1)
+#define NCP5623_PWM_REG(index)		NCP5623_REG(0x2 + (index))
+#define NCP5623_UPWARD_STEP_REG		NCP5623_REG(0x5)
+#define NCP5623_DOWNWARD_STEP_REG	NCP5623_REG(0x6)
+#define NCP5623_DIMMING_TIME_REG	NCP5623_REG(0x7)
+
+#define NCP5623_MAX_BRIGHTNESS		0x1f
+#define NCP5623_MAX_DIM_TIME		240 /* ms */
+#define NCP5623_DIM_STEP		8   /* ms */

Patch applied, however ...

Please follow-up with the following changes:

#define NCP5623_MAX_DIM_TIME_MS 240
#define NCP5623_DIM_STEP_MS 8

Signature · 1 line
Lee Jones [李琼斯]
maintainer Applied
#4 lore raw
In reply to Abdel Alkuor
Quoted 4 lines · Abdel Alkuor

NCP5623 is DC-DC multi-LED controller which can be used for RGB illumination or backlight LCD display.

Applied, thanks!

[1/2] dt-bindings: leds: Add NCP5623 multi-LED Controller

      commit: 1d81703a2e41fe95531b1408e0f836d5623f5b45
[2/2] leds: Add NCP5623 multi-led driver
      commit: 535a2262514d7d4016411707c9f8ac106062615f

--
Lee Jones [李琼斯]