Add LED1202 LED Controller
Subsystems (3)
v11 cover Add LED1202 LED Controller
The LED1202 is a 12-channel low quiescent current LED driver with:
* Supply range from 2.6 V to 5 V
* 20 mA current capability per channel
* 1.8 V compatible I2C control interface
* 8-bit analog dimming individual control
* 12-bit local PWM resolution
* 8 programmable patterns
Internal volatile memory allows the user to store up to 8 different patterns, each pattern is a particular output configuration in terms of PWM duty-cycle (on 4096 steps). Analog dimming (on 256 steps) is per channel but common to all patterns. Each device tree LED node will have a corresponding entry in /sys/class/leds with the label name. The brightness property corresponds to the per channel analog dimming, while the patterns[1-8] to the PWM dimming control.
Vicentiu Galanopulo (3):
Documentation:leds: Add leds-st1202.rst
dt-bindings: leds: Add LED1202 LED Controller
leds: Add LED1202 I2C driver
---
- Changes in v11: Add version history
.../devicetree/bindings/leds/st,led1202.yaml | 132 ++++++ Documentation/leds/index.rst | 1 + Documentation/leds/leds-st1202.rst | 34 ++ drivers/leds/Kconfig | 10 + drivers/leds/Makefile | 1 + drivers/leds/leds-st1202.c | 416 ++++++++++++++++++ 6 files changed, 594 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/st,led1202.yaml create mode 100644 Documentation/leds/leds-st1202.rst create mode 100644 drivers/leds/leds-st1202.c
Signature · 1 line
2.39.3 (Apple Git-145)
PATCH v11 1/3 Documentation:leds: Add leds-st1202.rst
Add usage for sysfs hw_pattern entry for leds-st1202
---
- Changes in v4: Update format (line wrapping) for leds-st1202.rst
- Changes in v3: Add leds-st1202 to index.rst
- Changes in v2: Implement review comments
Documentation/leds/index.rst | 1 + Documentation/leds/leds-st1202.rst | 34 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Documentation/leds/leds-st1202.rst
Documentation/leds/index.rst +1 -0
@@ -28,4 +28,5 @@ LEDs leds-mlxcpld leds-mt6370-rgb leds-sc27xx + leds-st1202.rst leds-qcom-lpg
Documentation/leds/leds-st1202.rst new file +34 -0
@@ -0,0 +1,34 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============================================ +Kernel driver for STMicroelectronics LED1202 +============================================ + +/sys/class/leds/<led>/hw_pattern +-------------------------------- + +Specify a hardware pattern for the ST1202 LED. The LED controller +implements 12 low-side current generators with independent dimming +control. Internal volatile memory allows the user to store up to 8 +different patterns. Each pattern is a particular output configuration +in terms of PWM duty-cycle and duration (ms). + +To be compatible with the hardware pattern format, maximum 8 tuples of +brightness (PWM) and duration must be written to hw_pattern. + +- Min pattern duration: 22 ms +- Max pattern duration: 5660 ms + +The format of the hardware pattern values should be: +"brightness duration brightness duration ..." + +/sys/class/leds/<led>/repeat +---------------------------- + +Specify a pattern repeat number, which is common for all channels. +Default is 1; negative numbers and 0 are invalid. + +This file will always return the originally written repeat number. + +When the 255 value is written to it, all patterns will repeat +indefinitely.
Signature · 1 line
2.39.3 (Apple Git-145)
PATCH v11 2/3 dt-bindings: leds: Add LED1202 LED Controller
In reply to Vicentiu GalanopuloThe LED1202 is a 12-channel low quiescent current LED driver with:
* Supply range from 2.6 V to 5 V
* 20 mA current capability per channel
* 1.8 V compatible I2C control interface
* 8-bit analog dimming individual control
* 12-bit local PWM resolution
* 8 programmable patterns
If the led node is present in the controller then the channel is set to active.
---
v1: https://lore.kernel.org/lkml/ZnCnnQfwuRueCIQ0@admins-Air/T/
v2: https://lore.kernel.org/all/ZniNdGgKyUMV-hjq@admins-Air/T/
v3: https://lore.kernel.org/all/ZniNdGgKyUMV-hjq@admins-Air/T/
Changes in v4:
- remove label property, use devm_led_classdev_register_ext instead
Changes in v3:
- remove active property
Changes in v2:
- renamed label to remove color from it
- add color property for each node
- add function and function-enumerator property for each node
.../devicetree/bindings/leds/st,led1202.yaml | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/st,led1202.yaml
Documentation/devicetree/bindings/leds/st,led1202.yaml new file +132 -0
@@ -0,0 +1,132 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/st,led1202.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ST LED1202 LED controllers + +maintainers: + - Vicentiu Galanopulo <[email protected]> + +description: | + The LED1202 is a 12-channel low quiescent current LED controller + programmable via I2C; The output current can be adjusted separately + for each channel by 8-bit analog and 12-bit digital dimming control. + Datasheet available at + https://www.st.com/en/power-management/led1202.html + +properties: + compatible: + const: st,led1202 + + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^led@[0-9a-f]$": + type: object + $ref: common.yaml# + unevaluatedProperties: false + + properties: + reg: + minimum: 0 + maximum: 11 + + required: + - reg + +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@58 { + compatible = "st,led1202"; + reg = <0x58>; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0x0>; + function = LED_FUNCTION_STATUS; + color = <LED_COLOR_ID_RED>; + function-enumerator = <1>; + }; + + led@1 { + reg = <0x1>; + function = LED_FUNCTION_STATUS; + color = <LED_COLOR_ID_GREEN>; + function-enumerator = <2>; + }; + + led@2 { + reg = <0x2>; + function = LED_FUNCTION_STATUS; + color = <LED_COLOR_ID_BLUE>; + function-enumerator = <3>; + }; + + led@3 { + reg = <0x3>; + function = LED_FUNCTION_STATUS; + color = <LED_COLOR_ID_RED>; + function-enumerator = <4>; + }; + + led@4 { + reg = <0x4>; + function = LED_FUNCTION_STATUS; + color = <LED_COLOR_ID_GREEN>; + function-enumerator = <5>; + }; + + led@5 { + reg = <0x5>; + function = LED_FUNCTION_STATUS; + color = <LED_COLOR_ID_BLUE>; + function-enumerator = <6>; + }; + + led@6 { + reg = <0x6>; + function = LED_FUNCTION_STATUS; + color = <LED_COLOR_ID_RED>; + function-enumerator = <7>; + }; + + led@7 { + reg = <0x7>; + function = LED_FUNCTION_STATUS; + color = <LED_COLOR_ID_GREEN>; + function-enumerator = <8>; + }; + + led@8 { + reg = <0x8>; + function = LED_FUNCTION_STATUS; + color = <LED_COLOR_ID_BLUE>; + function-enumerator = <9>; + }; + }; + }; +...
Signature · 1 line
2.39.3 (Apple Git-145)
PATCH v11 3/3 leds: Add LED1202 I2C driver
In reply to Vicentiu GalanopuloThe output current can be adjusted separately for each channel by 8-bit analog (current sink input) and 12-bit digital (PWM) dimming control. The LED1202 implements 12 low-side current generators with independent dimming control.
Internal volatile memory allows the user to store up to 8 different patterns, each pattern is a particular output configuration in terms of PWM duty-cycle (on 4096 steps). Analog dimming (on 256 steps) is per channel but common to all patterns. Each device tree LED node will have a corresponding entry in /sys/class/leds with the label name. The brightness property corresponds to the per channel analog dimming, while the patterns[1-8] to the PWM dimming control.
---
Changes in v10:
- update description help in Kconfig
- move st1202_led and st1202_chip into one line, declaration and definition
Changes in v9:
- log errors directly in st1202_write_reg and st1202_read_reg
- use mutex guards instead of lock/unlock
- remove i2c_set_clientdata
Changes in v7:
- fix st1202_brightness_get() error: uninitialized symbol 'value'
Changes in v6:
- fix build error
Changes in v5:
- remove unused macros
- switch to using devm_led_classdev_register_ext (struct st1202_led update)
- add prescalar_to_milliseconds (convert [22..5660]ms to [0..255] reg value)
- remove register range check in dt_init (range protected by yaml)
- address all review comments in v4
Changes in v4:
- Remove attributes/extended attributes implementation
- Use /sys/class/leds/<led>/hw_pattern (Pavel suggestion)
- Implement review findings of Christophe JAILLET
Changes in v3:
- Rename all ll1202 to st1202, including driver file name
- Convert all magic numbers to defines
- Refactor the show/store callbacks as per Lee's and Thomas's review
- Remove ll1202_get_channel and use dev_ext_attributes instead
- Log all error values for all the functions
- Use sysfs_emit for show callbacks
Changes in v2:
- Fix build error for device_attribute modes
drivers/leds/Kconfig | 10 + drivers/leds/Makefile | 1 + drivers/leds/leds-st1202.c | 416 +++++++++++++++++++++++++++++++++++++ 3 files changed, 427 insertions(+) create mode 100644 drivers/leds/leds-st1202.c
drivers/leds/Kconfig +10 -0
@@ -931,6 +931,16 @@ config LEDS_LM36274 Say Y to enable the LM36274 LED driver for TI LMU devices. This supports the LED device LM36274. +config LEDS_ST1202 + tristate "LED Support for STMicroelectronics LED1202 I2C chips" + depends on LEDS_CLASS + depends on I2C + depends on OF + select LEDS_TRIGGERS + help + Say Y to enable support for LEDs connected to LED1202 + LED driver chips accessed via the I2C bus. + config LEDS_TPS6105X tristate "LED support for TI TPS6105X" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -81,6 +81,7 @@ obj-$(CONFIG_LEDS_POWERNV) += leds-powernv.o obj-$(CONFIG_LEDS_PWM) += leds-pwm.o obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o +obj-$(CONFIG_LEDS_ST1202) += leds-st1202.o obj-$(CONFIG_LEDS_SUN50I_A100) += leds-sun50i-a100.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o
drivers/leds/leds-st1202.c new file +416 -0
416 lines not on this page · raw message
Signature · 1 line
2.39.3 (Apple Git-145)
Re: (subset) [PATCH v11 3/3] leds: Add LED1202 I2C driver
Quoted 12 lines · Vicentiu Galanopulo
The output current can be adjusted separately for each channel by 8-bit analog (current sink input) and 12-bit digital (PWM) dimming control. The LED1202 implements 12 low-side current generators with independent dimming control.
Internal volatile memory allows the user to store up to 8 different patterns, each pattern is a particular output configuration in terms of PWM duty-cycle (on 4096 steps). Analog dimming (on 256 steps) is per channel but common to all patterns. Each device tree LED node will have a corresponding entry in/sys/class/ledswith the label name. The brightness property corresponds to the per channel analog dimming, while the patterns[1-8] to the PWM dimming control.
Quoted 1 line
[...]
Applied, thanks!
[3/3] leds: Add LED1202 I2C driver
commit: 939757aafeb9c266dda37657ee5f7a73ffd35ae2
--
Lee Jones [李琼斯]
Re: (subset) [PATCH v11 3/3] leds: Add LED1202 I2C driver
Hi Lee,
Quoted 13 lines · Lee Jones
Quoted 12 lines · Vicentiu Galanopulo
The output current can be adjusted separately for each channel by 8-bit analog (current sink input) and 12-bit digital (PWM) dimming control. The LED1202 implements 12 low-side current generators with independent dimming control.
Internal volatile memory allows the user to store up to 8 different patterns, each pattern is a particular output configuration in terms of PWM duty-cycle (on 4096 steps). Analog dimming (on 256 steps) is per channel but common to all patterns. Each device tree LED node will have a corresponding entry in/sys/class/ledswith the label name. The brightness property corresponds to the per channel analog dimming, while the patterns[1-8] to the PWM dimming control.
Quoted 6 lines
Quoted 1 line
[...]
Applied, thanks!
[3/3] leds: Add LED1202 I2C driver
commit: 939757aafeb9c266dda37657ee5f7a73ffd35ae2
You also have commit 259230378c65ebb6 ("leds: Add LED1202 I2C driver") in mfd/for-mfd-next, which dropped the change to drivers/leds/Makefile, and changed the Link:-tag to point to the older version v10?
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Lee Jones
maintainerRe: (subset) [PATCH v11 3/3] leds: Add LED1202 I2C driver
Quoted 18 lines · Geert Uytterhoeven
Hi Lee,
Quoted 15 lines · Lee Jones
Quoted 13 lines · Vicentiu Galanopulo
The output current can be adjusted separately for each channel by 8-bit analog (current sink input) and 12-bit digital (PWM) dimming control. The LED1202 implements 12 low-side current generators with independent dimming control.
Internal volatile memory allows the user to store up to 8 different patterns, each pattern is a particular output configuration in terms of PWM duty-cycle (on 4096 steps). Analog dimming (on 256 steps) is per channel but common to all patterns. Each device tree LED node will have a corresponding entry in/sys/class/ledswith the label name. The brightness property corresponds to the per channel analog dimming, while the patterns[1-8] to the PWM dimming control.[...]
Quoted 8 lines
Quoted 4 lines
Applied, thanks!
[3/3] leds: Add LED1202 I2C driver
commit: 939757aafeb9c266dda37657ee5f7a73ffd35ae2You also have commit
259230378c65ebb6("leds: Add LED1202 I2C driver") in mfd/for-mfd-next, which dropped the change todrivers/leds/Makefile, and changed the Link:-tag to point to the older version v10?
Interesting. Not sure I noticed and if I did, I must have fixed it.
This is the commit that made it in:
939757aafeb9 ("leds: Add LED1202 I2C driver")
Signature · 1 line
Lee Jones [李琼斯]
Lee Jones
maintainerRe: (subset) [PATCH v11 3/3] leds: Add LED1202 I2C driver
Quoted 29 lines · Lee Jones
Quoted 18 lines · Geert Uytterhoeven
Hi Lee,
Quoted 15 lines · Lee Jones
Quoted 13 lines · Vicentiu Galanopulo
The output current can be adjusted separately for each channel by 8-bit analog (current sink input) and 12-bit digital (PWM) dimming control. The LED1202 implements 12 low-side current generators with independent dimming control.
Internal volatile memory allows the user to store up to 8 different patterns, each pattern is a particular output configuration in terms of PWM duty-cycle (on 4096 steps). Analog dimming (on 256 steps) is per channel but common to all patterns. Each device tree LED node will have a corresponding entry in/sys/class/ledswith the label name. The brightness property corresponds to the per channel analog dimming, while the patterns[1-8] to the PWM dimming control.[...]
Quoted 8 lines
Quoted 4 lines
Applied, thanks!
[3/3] leds: Add LED1202 I2C driver
commit: 939757aafeb9c266dda37657ee5f7a73ffd35ae2You also have commit
259230378c65ebb6("leds: Add LED1202 I2C driver") in mfd/for-mfd-next, which dropped the change todrivers/leds/Makefile, and changed the Link:-tag to point to the older version v10?
Quoted 5 lines
Interesting. Not sure I noticed and if I did, I must have fixed it.
This is the commit that made it in:
939757aafeb9("leds: Add LED1202 I2C driver")
Scratch that - looks like:
259230378c65 ("leds: Add LED1202 I2C driver")
... also made it in. However the Makefile line survived:
drivers/leds/Makefile:obj-$(CONFIG_LEDS_ST1202) += leds-st1202.o
Did anything break or is all as expected?
Signature · 1 line
Lee Jones [李琼斯]
Re: (subset) [PATCH v11 3/3] leds: Add LED1202 I2C driver
Hi Lee,
Quoted 38 lines · Lee Jones
Quoted 29 lines · Lee Jones
Quoted 18 lines · Geert Uytterhoeven
Hi Lee,
Quoted 15 lines · Lee Jones
Quoted 13 lines · Vicentiu Galanopulo
The output current can be adjusted separately for each channel by 8-bit analog (current sink input) and 12-bit digital (PWM) dimming control. The LED1202 implements 12 low-side current generators with independent dimming control.
Internal volatile memory allows the user to store up to 8 different patterns, each pattern is a particular output configuration in terms of PWM duty-cycle (on 4096 steps). Analog dimming (on 256 steps) is per channel but common to all patterns. Each device tree LED node will have a corresponding entry in/sys/class/ledswith the label name. The brightness property corresponds to the per channel analog dimming, while the patterns[1-8] to the PWM dimming control.[...]
Quoted 8 lines
Quoted 4 lines
Applied, thanks!
[3/3] leds: Add LED1202 I2C driver
commit: 939757aafeb9c266dda37657ee5f7a73ffd35ae2You also have commit
259230378c65ebb6("leds: Add LED1202 I2C driver") in mfd/for-mfd-next, which dropped the change todrivers/leds/Makefile, and changed the Link:-tag to point to the older version v10?Quoted 5 lines
Interesting. Not sure I noticed and if I did, I must have fixed it.
This is the commit that made it in:
939757aafeb9("leds: Add LED1202 I2C driver")Scratch that - looks like:
Quoted 7 lines
259230378c65("leds: Add LED1202 I2C driver")... also made it in. However the
Makefileline survived:drivers/leds/Makefile:obj-$(CONFIG_LEDS_ST1202) += leds-st1202.oDid anything break or is all as expected?
The end result is fine. History might confuse people (the (un)happy few who care about history ;-), as "git log -p v6.14-rc1 -- drivers/leds/Makefile" shows 939757aafeb9, while "git log -p v6.14-rc1 -- drivers/leds/leds-st1202.c" shows 259230378c65, linking to the older version.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Lee Jones
maintainerRe: (subset) [PATCH v11 3/3] leds: Add LED1202 I2C driver
Quoted 47 lines · Geert Uytterhoeven
Hi Lee,
Quoted 44 lines · Lee Jones
Quoted 29 lines · Lee Jones
Quoted 18 lines · Geert Uytterhoeven
Hi Lee,
Quoted 15 lines · Lee Jones
Quoted 13 lines · Vicentiu Galanopulo
The output current can be adjusted separately for each channel by 8-bit analog (current sink input) and 12-bit digital (PWM) dimming control. The LED1202 implements 12 low-side current generators with independent dimming control.
Internal volatile memory allows the user to store up to 8 different patterns, each pattern is a particular output configuration in terms of PWM duty-cycle (on 4096 steps). Analog dimming (on 256 steps) is per channel but common to all patterns. Each device tree LED node will have a corresponding entry in/sys/class/ledswith the label name. The brightness property corresponds to the per channel analog dimming, while the patterns[1-8] to the PWM dimming control.[...]
Quoted 8 lines
Quoted 4 lines
Applied, thanks!
[3/3] leds: Add LED1202 I2C driver
commit: 939757aafeb9c266dda37657ee5f7a73ffd35ae2You also have commit
259230378c65ebb6("leds: Add LED1202 I2C driver") in mfd/for-mfd-next, which dropped the change todrivers/leds/Makefile, and changed the Link:-tag to point to the older version v10?Quoted 5 lines
Interesting. Not sure I noticed and if I did, I must have fixed it.
This is the commit that made it in:
939757aafeb9("leds: Add LED1202 I2C driver")Scratch that - looks like:
259230378c65("leds: Add LED1202 I2C driver")... also made it in. However the
Makefileline survived:drivers/leds/Makefile:obj-$(CONFIG_LEDS_ST1202) += leds-st1202.o
Quoted 7 lines
Quoted 1 line
Did anything break or is all as expected?
The end result is fine. History might confuse people (the (un)happy few who care about history ;-), as "git log -p v6.14-rc1 --
drivers/leds/Makefile" shows939757aafeb9, while "git log -p v6.14-rc1 --drivers/leds/leds-st1202.c" shows259230378c65, linking to the older version.
Sorry about that. I am one who cares a great deal about history.
One of the pitfalls of maintaining multiple repos I guess.
#humanafterall :)
Signature · 1 line
Lee Jones [李琼斯]
Quoted 9 lines · Vicentiu Galanopulo
The LED1202 is a 12-channel low quiescent current LED driver with:
* Supply range from 2.6 V to 5 V
* 20 mA current capability per channel
* 1.8 V compatible I2C control interface
* 8-bit analog dimming individual control
* 12-bit local PWM resolution
* 8 programmable patterns[...]
Applied, thanks!
[1/3] Documentation:leds: Add leds-st1202.rst
commit: 132e6687a118cedda0f59ada4af5ce42d0d05043
[2/3] dt-bindings: leds: Add LED1202 LED Controller
commit: 599b92fd0efa8b7c43e7f58c9dd0f7951f7cbf09
[3/3] leds: Add LED1202 I2C driver
commit: 939757aafeb9c266dda37657ee5f7a73ffd35ae2--
Lee Jones [李琼斯]