Skip to contentSkip to conversation

Support for Osram as3668 LED driver

PATCH Superseded Lukas Timmermann 2 participants 4 messages May 31, 2025

Subsystems (3)

v2 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

Lukas Timmermann

author maintainer
#0 lore raw

v2 cover Support for Osram as3668 LED driver

This is v2 of the patch series adding support for the as3668 LED driver. I am sending v2 because I discovered major issues in v1 that required correction before review.

This patch adds basic support for the as3668 driver IC via I2C interface. The IC is capable of driving four individual LEDs up to 25.5mA per channel. Hardware blinking would be theoretically possible, but this chip only supports a few set on/off-delays which makes using that feature unfeasable, therefore my driver doesn't offer that capability. It's intended applications is in mobile devices such as phones, tablets and cameras. This driver was tested and is working on a samsung-manta which is running postmarketOS with a near mainline kernel.

Please note: This is my first suggested patch to the kernel. checkpatch.pl runs without warnings or errors. I've read the docs in regards to the led subsystem, coding style and submission of patches, but I'm still a bit unsure about the general workflow. I will try my best.

Changes in v2:
- Fixed reading led subnodes in dt incorrectly, which caused wrong numbering and a segfault when removing the driver module
- Fixed calling of_property_read_u8 with an int, causing a compiler error
- Added more error checking during writes to the i2c bus
- Link to v1: https://lore.kernel.org/linux-leds/[email protected]/

Lukas Timmermann (2):
leds: as3668: Driver for the ams Osram 4-channel i2c LED driver
dt-bindings: leds: Add new as3668 support

 .../devicetree/bindings/leds/leds-as3668.yaml |  76 +++++++
 drivers/leds/Kconfig                          |  10 +
 drivers/leds/Makefile                         |   1 +
 drivers/leds/leds-as3668.c                    | 192 ++++++++++++++++++
 4 files changed, 279 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-as3668.yaml
 create mode 100644 drivers/leds/leds-as3668.c
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH v2 1/2 leds: as3668: Driver for the ams Osram 4-channel i2c

From: Lukas Timmermann <[email protected]>

This is the actual driver for the as3668.

There were no related drivers in the kernel until now, so I created a new file. I've checked around for relatives of the as3668 but all of them are quite different, which is why wrote the driver just for the as3668.

---
 drivers/leds/Kconfig       |  10 ++
 drivers/leds/Makefile      |   1 +
 drivers/leds/leds-as3668.c | 192 +++++++++++++++++++++++++++++++++++++
 3 files changed, 203 insertions(+)
 create mode 100644 drivers/leds/leds-as3668.c
drivers/leds/Kconfig +10 -0
index a104cbb0a001..56477c170f0a 100644
@@ -100,6 +100,16 @@ config LEDS_ARIEL
 
 	  Say Y to if your machine is a Dell Wyse 3020 thin client.
 
+config LEDS_AS3668
+	tristate "LED support for AMS AS3668"
+	depends on LEDS_CLASS
+	depends on I2C
+	help
+		This option enables support for the AMS AS3668 LED controller.
+
+		To compile this driver as a module, choose M here: the module
+		will be called leds-as3668.
+
 config LEDS_AW200XX
 	tristate "LED support for Awinic AW20036/AW20054/AW20072/AW20108"
 	depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 2f170d69dcbf..983811384fec 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_LEDS_ADP5520)		+= leds-adp5520.o
 obj-$(CONFIG_LEDS_AN30259A)		+= leds-an30259a.o
 obj-$(CONFIG_LEDS_APU)			+= leds-apu.o
 obj-$(CONFIG_LEDS_ARIEL)		+= leds-ariel.o
+obj-$(CONFIG_LEDS_AS3668)		+= leds-as3668.o
 obj-$(CONFIG_LEDS_AW200XX)		+= leds-aw200xx.o
 obj-$(CONFIG_LEDS_AW2013)		+= leds-aw2013.o
 obj-$(CONFIG_LEDS_BCM6328)		+= leds-bcm6328.o
drivers/leds/leds-as3668.c new file +192 -0

192 lines not on this page · raw message

Signature · 1 line
2.49.0
author maintainer
#2 lore raw

PATCH v2 2/2 dt-bindings: leds: Add new as3668 support

In reply to Lukas Timmermann

From: Lukas Timmermann <[email protected]>

Document Osram as3668 LED driver devicetree bindings.

---
 .../devicetree/bindings/leds/leds-as3668.yaml | 76 +++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-as3668.yaml
Documentation/devicetree/bindings/leds/leds-as3668.yaml new file +76 -0
new file mode 100644
index 000000000000..aae6248f5712
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/leds-as3668.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Osram 4-channel i2c LED driver.
+
+maintainers:
+  - Lukas Timmermann <[email protected]>
+
+description: |
+  This IC can drive up to four separate LEDs.
+  Having four channels suggests it could be used with a single RGBW LED.
+
+properties:
+  compatible:
+    const: ams,as3668 
+
+  reg:
+    maxItems: 1
+    description:
+      I2C slave address
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+patternProperties:
+  "^led@[0-3]$":
+    type: object
+    $ref: common.yaml#
+    unevaluatedProperties: false
+
+    properties:
+      reg:
+        maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/leds/common.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      led-controller@42 {
+        compatible = "ams,as3668";
+        reg = <0x42>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        led@0 {
+          reg = <0x0>;
+          function = LED_FUNCTION_STATUS;
+          color = <LED_COLOR_ID_RED>;
+        };
+
+        led@1 {
+          reg = <0x1>;
+          function = LED_FUNCTION_STATUS;
+          color = <LED_COLOR_ID_GREEN>;
+        };
+      };
+    };
+
Signature · 1 line
2.49.0
#3 lore raw

Re: [PATCH v2 2/2] dt-bindings: leds: Add new as3668 support

Quoted 3 lines · Lukas Timmermann

From: Lukas Timmermann <[email protected]>

Document Osram as3668 LED driver devicetree bindings.

Please run scripts/checkpatch.pl on the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl --strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.

<form letter>
Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.

Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline) or work on fork of kernel (don't, instead use mainline). Just use b4 and everything should be fine, although remember about b4 prep --auto-to-cc if you added new patches to the patchset.

You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time.

Please kindly resend and include all necessary To/Cc entries. </form letter>

Best regards,
Krzysztof