Skip to contentSkip to conversation

leds: as3668: Driver for the ams Osram 4-channel i2c LED driver

PATCH Superseded Lukas Timmermann 1 participant 1 message Sep 10, 2025 1 message not in the archive LED

v8 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v8 2/2 leds: as3668: Driver for the ams Osram 4-channel i2c LED driver

Quoted 107 lines · Lee Jones
Quoted 97 lines · Lukas Timmermann
Quoted 95 lines · Lukas Timmermann
Quoted 75 lines

Since there were no existing drivers for the AS3668 or related devices, a new driver was introduced in a separate file. Similar devices were reviewed, but none shared enough characteristics to justify code reuse. As a result, this driver is written specifically for the AS3668.

---
MAINTAINERS | 1 +
drivers/leds/Kconfig | 13 +++
drivers/leds/Makefile | 1 +
drivers/leds/leds-as3668.c | 202 +++++++++++++++++++++++++++++++++++++

4 files changed, 217 insertions(+)

create mode 100644 drivers/leds/leds-as3668.c

MAINTAINERS +0 -0
index 091206c54c63..945d78fef380 100644
@@ -3511,6 +3511,7 @@ M: Lukas Timmermann <[email protected]>

L: [email protected]
S: Maintained
F: Documentation/devicetree/bindings/leds/ams,as3668.yaml +F: drivers/leds/leds-as3668.c
ASAHI KASEI AK7375 LENS VOICE COIL DRIVER
M: Tianshu Qiu <[email protected]>

drivers/leds/Kconfig +0 -0
index a104cbb0a001..8cfb423ddf82 100644
@@ -100,6 +100,19 @@ config LEDS_ARIEL

Say Y to if your machine is a Dell Wyse 3020 thin client.

drivers/leds/Kconfig +13 -0
+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.
+ The AS3668 provides up to four LED channels and is controlled via
+ the I2C bus. This driver offers basic brightness control for each
+ channel, without support for blinking or other advanced features.
+
+ 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 +0 -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 +9 -0
new file mode 100644
index 000000000000..0cfd3b68f90c
@@ -0,0 +1,202 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Osram AMS AS3668 LED Driver IC
+ *
+ * Copyright (C) 2025 Lukas Timmermann <[email protected]>
+ */
+
+#include <linux/bitfield.h>
+#include <linux/i2c.h>

drivers/leds/leds-as3668.c line 19

Quoted 10 lines
drivers/leds/leds-as3668.c new file +10 -0
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/uleds.h>
+
+#define AS3668_MAX_LEDS 4
+#define AS3668_EXPECTED_I2C_ADDR 0x42
+
+/* Chip Ident */
+
+#define AS3668_CHIP_ID1_REG 0x3e

Can you tab out all of the values please.

drivers/leds/leds-as3668.c line 21

Quoted 2 lines
drivers/leds/leds-as3668.c new file +2 -0
+#define AS3668_CHIP_ID2_REG 0x3f
+#define AS3668_CHIP_ID1_EXPECTED_IDENTIFIER 0xa5

This is odd. What do you mean by expected?

What kind of ID is this? Board ID, platform ID, Chip ID?

Quoted 7 lines
Quoted 1 line

Call it that instead.

Calling it just AS3668_CHIP_ID1 then?
It's the identifier of the chip model burned into silicon in the CHIP_ID1 register. Checking it isn't critical in the first place.
It catches errors made in DT files but nothing else. You haven't commented about that so i guess it's okay. Are drivers in the led subsystem supposed to check that?>

Quoted 6 lines

CHIP_ID1 is the register, but what does the number signify?

What version of the chip? Does the chip have a name?

What's the difference between the values in ID1 and ID2?

CHIP_ID1 is a register which contains a fixed magic number so a driver can check if it's talking to the correct chip. There is no deeper meaning to the number as far as the datasheet is concerned. We simply check the number. It's supposed to be 10100101b according to the datasheet. CHIP_ID2 contains two fixed values. The upper four bits indicate a serial number of some sorts. The datasheet doesn't specify an expected value and doesn't state it's purpose. I suspect it to change between production runs. The lower four bits of the CHIP_ID2 register contains the revision of the chip. None of these values are particulary important for the function of the driver. My suggested driver does check CHIP_ID1 just to fail early.

Quoted 17 lines
Quoted 8 lines
Quoted 8 lines

drivers/leds/leds-as3668.c line 26

Quoted 5 lines
drivers/leds/leds-as3668.c new file +5 -0
+#define AS3668_CHIP_ID2_SERIAL_MASK GENMASK(7, 4)
+#define AS3668_CHIP_ID2_REV_MASK GENMASK(3, 0)
+
+/* Current Control */
+

The X thing (below) is weirding me out.

Quoted 8 lines
Quoted 3 lines

drivers/leds/leds-as3668.c line 27

Quoted 1 line
drivers/leds/leds-as3668.c new file +1 -0
+#define AS3668_CURRX_CONTROL_REG 0x01

Drop the X.

The datasheet explictly calls this "CurrX control". It configures the outputs for different modes like off/on and pwm or pattern generation for all four channels simultaneously.
I could imagine AS3668_MODE_REG being more descriptive but we would diverge from the datasheet. Is that acceptable?>

Quoted 4 lines

It is if you say it is. Some authors like to stick to the datasheet, which I would respect. Others think that datasheet authors / register namers are bonkers and the S/W should be much more friendly to readers.

All the register names are taken from the datasheet. I considered renaming them but I think it would do more harm than good as the datasheet is publicly available and could be helpful for future changes.