Skip to content

Commit 2b69703

Browse files
committed
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds
Pull LED subsystem updates from Bryan Wu: - move LED trigger drivers into a new directory - lp55xx common driver updates - other led drivers updates and bug fixing * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: leds: leds-asic3: switch to using SIMPLE_DEV_PM_OPS leds: leds-bd2802: add CONFIG_PM_SLEEP to suspend/resume functions leds: lp55xx: configure the clock detection leds: lp55xx: use common clock framework when external clock is used leds: leds-ns2: fix oops at module removal leds: leds-pwm: Defer led_pwm_set() if PWM can sleep leds: lp55xx: fix the sysfs read operation leds: lm355x, lm3642: support camera LED triggers for flash and torch leds: add camera LED triggers leds: trigger: use inline functions instead of macros leds: tca6507: Use of_match_ptr() macro leds: wm8350: Complain if we fail to reenable DCDC leds: renesas: set gpio_request_one() flags param correctly leds: leds-ns2: set devm_gpio_request_one() flags param correctly leds: leds-lt3593: set devm_gpio_request_one() flags param correctly leds: leds-bd2802: remove erroneous __exit annotation leds: atmel-pwm: remove erroneous __exit annotation leds: move LED trigger drivers into new subdirectory leds: add new LP5562 LED driver
2 parents 30c67e9 + df92d5f commit 2b69703

36 files changed

Lines changed: 1149 additions & 220 deletions

‎Documentation/leds/00-INDEX‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ leds-lp5521.txt
66
- notes on how to use the leds-lp5521 driver.
77
leds-lp5523.txt
88
- notes on how to use the leds-lp5523 driver.
9+
leds-lp5562.txt
10+
- notes on how to use the leds-lp5562 driver.
911
leds-lp55xx.txt
1012
- description about lp55xx common driver.
1113
leds-lm3556.txt

‎Documentation/leds/leds-lp5521.txt‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,3 @@ static struct lp55xx_platform_data lp5521_platform_data = {
8181

8282
If the current is set to 0 in the platform data, that channel is
8383
disabled and it is not visible in the sysfs.
84-
85-
The 'update_config' : CONFIG register (ADDR 08h)
86-
This value is platform-specific data.
87-
If update_config is not defined, the CONFIG register is set with
88-
'LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT'.
89-
(Enable auto-powersave, set charge pump to auto, red to battery)
90-
91-
example of update_config :
92-
93-
#define LP5521_CONFIGS (LP5521_PWM_HF | LP5521_PWRSAVE_EN | \
94-
LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT | \
95-
LP5521_CLK_INT)
96-
97-
static struct lp55xx_platform_data lp5521_pdata = {
98-
.led_config = lp5521_led_config,
99-
.num_channels = ARRAY_SIZE(lp5521_led_config),
100-
.clock_mode = LP55XX_CLOCK_INT,
101-
.update_config = LP5521_CONFIGS,
102-
};

‎Documentation/leds/leds-lp5562.txt‎

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
Kernel driver for LP5562
2+
========================
3+
4+
* TI LP5562 LED Driver
5+
6+
Author: Milo(Woogyom) Kim <milo.kim@ti.com>
7+
8+
Description
9+
10+
LP5562 can drive up to 4 channels. R/G/B and White.
11+
LEDs can be controlled directly via the led class control interface.
12+
13+
All four channels can be also controlled using the engine micro programs.
14+
LP5562 has the internal program memory for running various LED patterns.
15+
For the details, please refer to 'firmware' section in leds-lp55xx.txt
16+
17+
Device attribute: engine_mux
18+
19+
3 Engines are allocated in LP5562, but the number of channel is 4.
20+
Therefore each channel should be mapped to the engine number.
21+
Value : RGB or W
22+
23+
This attribute is used for programming LED data with the firmware interface.
24+
Unlike the LP5521/LP5523/55231, LP5562 has unique feature for the engine mux,
25+
so additional sysfs is required.
26+
27+
LED Map
28+
Red ... Engine 1 (fixed)
29+
Green ... Engine 2 (fixed)
30+
Blue ... Engine 3 (fixed)
31+
White ... Engine 1 or 2 or 3 (selective)
32+
33+
How to load the program data using engine_mux
34+
35+
Before loading the LP5562 program data, engine_mux should be written between
36+
the engine selection and loading the firmware.
37+
Engine mux has two different mode, RGB and W.
38+
RGB is used for loading RGB program data, W is used for W program data.
39+
40+
For example, run blinking green channel pattern,
41+
echo 2 > /sys/bus/i2c/devices/xxxx/select_engine # 2 is for green channel
42+
echo "RGB" > /sys/bus/i2c/devices/xxxx/engine_mux # engine mux for RGB
43+
echo 1 > /sys/class/firmware/lp5562/loading
44+
echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
45+
echo 0 > /sys/class/firmware/lp5562/loading
46+
echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
47+
48+
To run a blinking white pattern,
49+
echo 1 or 2 or 3 > /sys/bus/i2c/devices/xxxx/select_engine
50+
echo "W" > /sys/bus/i2c/devices/xxxx/engine_mux
51+
echo 1 > /sys/class/firmware/lp5562/loading
52+
echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
53+
echo 0 > /sys/class/firmware/lp5562/loading
54+
echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
55+
56+
How to load the predefined patterns
57+
58+
Please refer to 'leds-lp55xx.txt"
59+
60+
Setting Current of Each Channel
61+
62+
Like LP5521 and LP5523/55231, LP5562 provides LED current settings.
63+
The 'led_current' and 'max_current' are used.
64+
65+
(Example of Platform data)
66+
67+
To configure the platform specific data, lp55xx_platform_data structure is used.
68+
69+
static struct lp55xx_led_config lp5562_led_config[] = {
70+
{
71+
.name = "R",
72+
.chan_nr = 0,
73+
.led_current = 20,
74+
.max_current = 40,
75+
},
76+
{
77+
.name = "G",
78+
.chan_nr = 1,
79+
.led_current = 20,
80+
.max_current = 40,
81+
},
82+
{
83+
.name = "B",
84+
.chan_nr = 2,
85+
.led_current = 20,
86+
.max_current = 40,
87+
},
88+
{
89+
.name = "W",
90+
.chan_nr = 3,
91+
.led_current = 20,
92+
.max_current = 40,
93+
},
94+
};
95+
96+
static int lp5562_setup(void)
97+
{
98+
/* setup HW resources */
99+
}
100+
101+
static void lp5562_release(void)
102+
{
103+
/* Release HW resources */
104+
}
105+
106+
static void lp5562_enable(bool state)
107+
{
108+
/* Control of chip enable signal */
109+
}
110+
111+
static struct lp55xx_platform_data lp5562_platform_data = {
112+
.led_config = lp5562_led_config,
113+
.num_channels = ARRAY_SIZE(lp5562_led_config),
114+
.setup_resources = lp5562_setup,
115+
.release_resources = lp5562_release,
116+
.enable = lp5562_enable,
117+
};
118+
119+
If the current is set to 0 in the platform data, that channel is
120+
disabled and it is not visible in the sysfs.

‎Documentation/leds/leds-lp55xx.txt‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Milo(Woogyom) Kim <milo.kim@ti.com>
55

66
Description
77
-----------
8-
LP5521, LP5523/55231 have common features as below.
8+
LP5521, LP5523/55231 and LP5562 have common features as below.
99

1010
Register access via the I2C
1111
Device initialization/deinitialization
@@ -116,3 +116,47 @@ To support this, 'run_engine' and 'firmware_cb' are configurable in each driver.
116116
run_engine : Control the selected engine
117117
firmware_cb : The callback function after loading the firmware is done.
118118
Chip specific commands for loading and updating program memory.
119+
120+
( Predefined pattern data )
121+
122+
Without the firmware interface, LP55xx driver provides another method for
123+
loading a LED pattern. That is 'predefined' pattern.
124+
A predefined pattern is defined in the platform data and load it(or them)
125+
via the sysfs if needed.
126+
To use the predefined pattern concept, 'patterns' and 'num_patterns' should be
127+
configured.
128+
129+
Example of predefined pattern data:
130+
131+
/* mode_1: blinking data */
132+
static const u8 mode_1[] = {
133+
0x40, 0x00, 0x60, 0x00, 0x40, 0xFF, 0x60, 0x00,
134+
};
135+
136+
/* mode_2: always on */
137+
static const u8 mode_2[] = { 0x40, 0xFF, };
138+
139+
struct lp55xx_predef_pattern board_led_patterns[] = {
140+
{
141+
.r = mode_1,
142+
.size_r = ARRAY_SIZE(mode_1),
143+
},
144+
{
145+
.b = mode_2,
146+
.size_b = ARRAY_SIZE(mode_2),
147+
},
148+
}
149+
150+
struct lp55xx_platform_data lp5562_pdata = {
151+
...
152+
.patterns = board_led_patterns,
153+
.num_patterns = ARRAY_SIZE(board_led_patterns),
154+
};
155+
156+
Then, mode_1 and mode_2 can be run via through the sysfs.
157+
158+
echo 1 > /sys/bus/i2c/devices/xxxx/led_pattern # red blinking LED pattern
159+
echo 2 > /sys/bus/i2c/devices/xxxx/led_pattern # blue LED always on
160+
161+
To stop running pattern,
162+
echo 0 > /sys/bus/i2c/devices/xxxx/led_pattern

‎drivers/leds/Kconfig‎

Lines changed: 13 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ config LEDS_LP3944
194194
module will be called leds-lp3944.
195195

196196
config LEDS_LP55XX_COMMON
197-
tristate "Common Driver for TI/National LP5521 and LP5523/55231"
198-
depends on LEDS_LP5521 || LEDS_LP5523
197+
tristate "Common Driver for TI/National LP5521, LP5523/55231 and LP5562"
198+
depends on LEDS_LP5521 || LEDS_LP5523 || LEDS_LP5562
199199
select FW_LOADER
200200
help
201201
This option supports common operations for LP5521 and LP5523/55231
@@ -222,6 +222,16 @@ config LEDS_LP5523
222222
Driver provides direct control via LED class and interface for
223223
programming the engines.
224224

225+
config LEDS_LP5562
226+
tristate "LED Support for TI LP5562 LED driver chip"
227+
depends on LEDS_CLASS && I2C
228+
select LEDS_LP55XX_COMMON
229+
help
230+
If you say yes here you get support for TI LP5562 LED driver.
231+
It is 4 channels chip with programmable engines.
232+
Driver provides direct control via LED class and interface for
233+
programming the engines.
234+
225235
config LEDS_LP8788
226236
tristate "LED support for the TI LP8788 PMIC"
227237
depends on LEDS_CLASS
@@ -469,106 +479,7 @@ config LEDS_BLINKM
469479
This option enables support for the BlinkM RGB LED connected
470480
through I2C. Say Y to enable support for the BlinkM LED.
471481

472-
config LEDS_TRIGGERS
473-
bool "LED Trigger support"
474-
depends on LEDS_CLASS
475-
help
476-
This option enables trigger support for the leds class.
477-
These triggers allow kernel events to drive the LEDs and can
478-
be configured via sysfs. If unsure, say Y.
479-
480482
comment "LED Triggers"
481-
482-
config LEDS_TRIGGER_TIMER
483-
tristate "LED Timer Trigger"
484-
depends on LEDS_TRIGGERS
485-
help
486-
This allows LEDs to be controlled by a programmable timer
487-
via sysfs. Some LED hardware can be programmed to start
488-
blinking the LED without any further software interaction.
489-
For more details read Documentation/leds/leds-class.txt.
490-
491-
If unsure, say Y.
492-
493-
config LEDS_TRIGGER_ONESHOT
494-
tristate "LED One-shot Trigger"
495-
depends on LEDS_TRIGGERS
496-
help
497-
This allows LEDs to blink in one-shot pulses with parameters
498-
controlled via sysfs. It's useful to notify the user on
499-
sporadic events, when there are no clear begin and end trap points,
500-
or on dense events, where this blinks the LED at constant rate if
501-
rearmed continuously.
502-
503-
It also shows how to use the led_blink_set_oneshot() function.
504-
505-
If unsure, say Y.
506-
507-
config LEDS_TRIGGER_IDE_DISK
508-
bool "LED IDE Disk Trigger"
509-
depends on IDE_GD_ATA
510-
depends on LEDS_TRIGGERS
511-
help
512-
This allows LEDs to be controlled by IDE disk activity.
513-
If unsure, say Y.
514-
515-
config LEDS_TRIGGER_HEARTBEAT
516-
tristate "LED Heartbeat Trigger"
517-
depends on LEDS_TRIGGERS
518-
help
519-
This allows LEDs to be controlled by a CPU load average.
520-
The flash frequency is a hyperbolic function of the 1-minute
521-
load average.
522-
If unsure, say Y.
523-
524-
config LEDS_TRIGGER_BACKLIGHT
525-
tristate "LED backlight Trigger"
526-
depends on LEDS_TRIGGERS
527-
help
528-
This allows LEDs to be controlled as a backlight device: they
529-
turn off and on when the display is blanked and unblanked.
530-
531-
If unsure, say N.
532-
533-
config LEDS_TRIGGER_CPU
534-
bool "LED CPU Trigger"
535-
depends on LEDS_TRIGGERS
536-
help
537-
This allows LEDs to be controlled by active CPUs. This shows
538-
the active CPUs across an array of LEDs so you can see which
539-
CPUs are active on the system at any given moment.
540-
541-
If unsure, say N.
542-
543-
config LEDS_TRIGGER_GPIO
544-
tristate "LED GPIO Trigger"
545-
depends on LEDS_TRIGGERS
546-
depends on GPIOLIB
547-
help
548-
This allows LEDs to be controlled by gpio events. It's good
549-
when using gpios as switches and triggering the needed LEDs
550-
from there. One use case is n810's keypad LEDs that could
551-
be triggered by this trigger when user slides up to show
552-
keypad.
553-
554-
If unsure, say N.
555-
556-
config LEDS_TRIGGER_DEFAULT_ON
557-
tristate "LED Default ON Trigger"
558-
depends on LEDS_TRIGGERS
559-
help
560-
This allows LEDs to be initialised in the ON state.
561-
If unsure, say Y.
562-
563-
comment "iptables trigger is under Netfilter config (LED target)"
564-
depends on LEDS_TRIGGERS
565-
566-
config LEDS_TRIGGER_TRANSIENT
567-
tristate "LED Transient Trigger"
568-
depends on LEDS_TRIGGERS
569-
help
570-
This allows one time activation of a transient state on
571-
GPIO/PWM based hardware.
572-
If unsure, say Y.
483+
source "drivers/leds/trigger/Kconfig"
573484

574485
endif # NEW_LEDS

‎drivers/leds/Makefile‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o
2626
obj-$(CONFIG_LEDS_LP55XX_COMMON) += leds-lp55xx-common.o
2727
obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o
2828
obj-$(CONFIG_LEDS_LP5523) += leds-lp5523.o
29+
obj-$(CONFIG_LEDS_LP5562) += leds-lp5562.o
2930
obj-$(CONFIG_LEDS_LP8788) += leds-lp8788.o
3031
obj-$(CONFIG_LEDS_TCA6507) += leds-tca6507.o
3132
obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
@@ -57,12 +58,4 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o
5758
obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
5859

5960
# LED Triggers
60-
obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
61-
obj-$(CONFIG_LEDS_TRIGGER_ONESHOT) += ledtrig-oneshot.o
62-
obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o
63-
obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o
64-
obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o
65-
obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o
66-
obj-$(CONFIG_LEDS_TRIGGER_CPU) += ledtrig-cpu.o
67-
obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
68-
obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o
61+
obj-$(CONFIG_LEDS_TRIGGERS) += trigger/

‎drivers/leds/leds-asic3.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ static int asic3_led_remove(struct platform_device *pdev)
134134
return mfd_cell_disable(pdev);
135135
}
136136

137+
#ifdef CONFIG_PM_SLEEP
137138
static int asic3_led_suspend(struct device *dev)
138139
{
139140
struct platform_device *pdev = to_platform_device(dev);
@@ -159,11 +160,9 @@ static int asic3_led_resume(struct device *dev)
159160

160161
return ret;
161162
}
163+
#endif
162164

163-
static const struct dev_pm_ops asic3_led_pm_ops = {
164-
.suspend = asic3_led_suspend,
165-
.resume = asic3_led_resume,
166-
};
165+
static SIMPLE_DEV_PM_OPS(asic3_led_pm_ops, asic3_led_suspend, asic3_led_resume);
167166

168167
static struct platform_driver asic3_led_driver = {
169168
.probe = asic3_led_probe,

0 commit comments

Comments
 (0)