Support for Osram as3668 LED driver
Subsystems (3)
Lukas Timmermann
maintainerv14 cover Support for Osram as3668 LED driver
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 google-manta which is running postmarketOS with a near mainline kernel. Also there is a patch in the linux mailing list for that device:
https://lore.kernel.org/all/[email protected]/
The register names and values are taken from the official datasheet which can be found here:
https://www.mouser.com/datasheet/2/588/AS3668_DS000196_1-00-1512816.pdf
Please note: This is my first suggested patch to the kernel. 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 v14:
- Fixed style errors caused by VSCode swapping tabs for spaces. (@Lee)
Changes in v13:
- Fixed a syntax error in ..channel_mode_set().
- Improved error handling in ..channel_mode_set().
- Link to v12: https://lore.kernel.org/all/[email protected]/
Changes in v12:
- Fixed error handling in ..channel_mode_set(). (@Lee)
- Link to v11: https://lore.kernel.org/all/[email protected]/
Changes in v11:
- Adding mask and register to struct instead of led_id. (@Lee)
- Renaming reg variables to be more clear. (@Lee)
- Simplified calling of ..channel_mode_set(). (@Lee)
- Removed unnecessary pointer dereferencing. (@Lee)
- Changed error type in ..probe() to -EINVAL. (@Lee)
- Reworded some error messages to be more clear. (@Lee)
- Removed error message when removing module. (@Lee)
- Link to v10: https://lore.kernel.org/all/[email protected]/
Changes in v10:
- Reworded some error messages to be more clear. (@Lee)
- Removed newline. (@Lee)
- Added enabling and disabling of channels during brightness set. (@Lee)
- Rearranged and renamed constants.
- Link to v9: https://lore.kernel.org/all/[email protected]/
Changes in v9:
- Tabbed out values. (@Lee)
- Removed newlines. (@Lee)
- Renamed chip id constant and variables to be more clear. (@Lee)
- Removed unnecessary comments. (@Lee)
- Removed unnecessary debug message. (@Lee)
- Separate declaration and assignment of err variable. (@Lee)
- Link to v8: https://lore.kernel.org/all/[email protected]/
Changes in v8:
- Rearranged constants.
- Removed more newlines.
- Changed error messages to be more clear.
- Renamed variables.
- Removed revision check.
- Removed extra i2c read&write functions.
- Made initalisation code more readable with bitmasks.
- The code now wraps around before 100 chars instead of 80.
- Link to v7: https://lore.kernel.org/all/[email protected]/
Changes in v7:
- Simplified multiple error messages. They now use dev_err_probe().
- Removed some newlines.
- Link to v6: https://lore.kernel.org/all/[email protected]/
Changes in v6:
- Fixed missing error handling during init
- Fixed missing newline in error messages
- Fixed size calculation for memory allocation
- Fixed error handling for memory allocation
- Link to v5: https://lore.kernel.org/lkml/[email protected]/
Changes in v5:
- Fixed debug and error messages using wrong format specifiers.
- Fixed missing include bitwise.h.
- Changed commit message for dt file to fit expected style.
- Link to v4: https://lore.kernel.org/lkml/[email protected]/
Changes in v4:
- Fixed some mistakes made in the dt file pointed out in v3.
- Swapped dt and driver in patch series. DT now comes first.
- Fixed errors in Kconfig due to last minute changes.
- Added dt file into MAINTAINERS file.
- Link to v3: https://lore.kernel.org/lkml/[email protected]/
Changes in v3:
- Fixed an extra whitespace in the dt bindings documentation.
- Sent patch to all related lists and maintainers.
- Link to v2: https://lore.kernel.org/lkml/[email protected]/
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):
dt-bindings: leds: Add new as3668 support
leds: as3668: Driver for the ams Osram 4-channel i2c LED driver
.../devicetree/bindings/leds/ams,as3668.yaml | 74 +++++++ MAINTAINERS | 7 + drivers/leds/Kconfig | 13 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-as3668.c | 202 ++++++++++++++++++ 5 files changed, 297 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/ams,as3668.yaml create mode 100644 drivers/leds/leds-as3668.c
Signature · 1 line
2.52.0
Lukas Timmermann
maintainerPATCH v14 1/2 dt-bindings: leds: Add new as3668 support
The bindings are incomplete, as the GPIO/Audio Input pin
is still undocumented. The hardware used for testing this patch series does not allow modification, so the mentioned pin has been omitted.
--- .../devicetree/bindings/leds/ams,as3668.yaml | 74 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/ams,as3668.yaml
Documentation/devicetree/bindings/leds/ams,as3668.yaml new file +74 -0
@@ -0,0 +1,74 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/ams,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 + + "#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>; + }; + }; + }; +
MAINTAINERS +6 -0
@@ -3506,6 +3506,12 @@ L: [email protected] S: Maintained F: drivers/leds/flash/leds-as3645a.c +AS3668 LED DRIVER +M: Lukas Timmermann <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/leds/ams,as3668.yaml + ASAHI KASEI AK7375 LENS VOICE COIL DRIVER M: Tianshu Qiu <[email protected]> L: [email protected]
Signature · 1 line
2.52.0
Lukas Timmermann
maintainerPATCH v14 2/2 leds: as3668: Driver for the ams Osram 4-channel i2c LED driver
In reply to Lukas TimmermannSince 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 +1 -0
@@ -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 +13 -0
@@ -100,6 +100,19 @@ config LEDS_ARIEL Say Y to if your machine is a Dell Wyse 3020 thin client. +config LEDS_OSRAM_AMS_AS3668 + tristate "LED support for Osram AMS AS3668" + depends on LEDS_CLASS + depends on I2C + help + This option enables support for the Osram 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 +1 -0
@@ -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 +202 -0
202 lines not on this page · raw message
Signature · 1 line
2.52.0
Quoted 14 lines · Lukas Timmermann
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 google-manta which is running postmarketOS with a near mainline kernel. Also there is a patch in the linux mailing list for that device:
https://lore.kernel.org/all/[email protected]/
The register names and values are taken from the official datasheet which can be found here:
https://www.mouser.com/datasheet/2/588/AS3668_DS000196_1-00-1512816.pdf
Quoted 1 line
[...]
Applied, thanks!
[1/2] dt-bindings: leds: Add new as3668 support
commit: 1e31ecb73163385b7ca764a97fb350b395bcff3c
[2/2] leds: as3668: Driver for the ams Osram 4-channel i2c LED driver
commit: 68d2a846952f81cd01331fffdec9a67299b22319--
Lee Jones [李琼斯]