blob: 5b3e91d4ac5912011f0f4dfc59e1022f9ac24476 [file] [log] [blame]
Samu Onkalo5991e152010-11-11 14:05:23 -08001Kernel driver for lp5523
2========================
3
4* National Semiconductor LP5523 led driver chip
5* Datasheet: http://www.national.com/pf/LP/LP5523.html
6
7Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
8Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
9
10Description
11-----------
12LP5523 can drive up to 9 channels. Leds can be controlled directly via
Kim, Milo94b43b62012-08-22 15:32:29 +080013the led class control interface.
14The name of each channel is configurable in the platform data - name and label.
15There are three options to make the channel name.
16
17a) Define the 'name' in the platform data
18To make specific channel name, then use 'name' platform data.
19/sys/class/leds/R1 (name: 'R1')
20/sys/class/leds/B1 (name: 'B1')
21
22b) Use the 'label' with no 'name' field
23For one device name with channel number, then use 'label'.
24/sys/class/leds/RGB:channelN (label: 'RGB', N: 0 ~ 8)
25
26c) Default
27If both fields are NULL, 'lp5523' is used by default.
28/sys/class/leds/lp5523:channelN (N: 0 ~ 8)
Samu Onkalo5991e152010-11-11 14:05:23 -080029
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090030LP5523 has the internal program memory for running various LED patterns.
Milo Kim863724a2013-08-08 14:11:29 +090031There are two ways to run LED patterns.
32
331) Legacy interface - enginex_mode, enginex_load and enginex_leds
34 Control interface for the engines:
35 x is 1 .. 3
36 enginex_mode : disabled, load, run
37 enginex_load : microcode load (visible only in load mode)
38 enginex_leds : led mux control (visible only in load mode)
39
40 cd /sys/class/leds/lp5523:channel2/device
41 echo "load" > engine3_mode
42 echo "9d80400004ff05ff437f0000" > engine3_load
43 echo "111111111" > engine3_leds
44 echo "run" > engine3_mode
45
46 To stop the engine:
47 echo "disabled" > engine3_mode
48
492) Firmware interface - LP55xx common interface
50 For the details, please refer to 'firmware' section in leds-lp55xx.txt
Samu Onkalo5991e152010-11-11 14:05:23 -080051
52Selftest uses always the current from the platform data.
53
54Each channel contains led current settings.
55/sys/class/leds/lp5523:channel2/led_current - RW
56/sys/class/leds/lp5523:channel2/max_current - RO
57Format: 10x mA i.e 10 means 1.0 mA
58
59Example platform data:
60
61Note - chan_nr can have values between 0 and 8.
62
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090063static struct lp55xx_led_config lp5523_led_config[] = {
Samu Onkalo5991e152010-11-11 14:05:23 -080064 {
Kim, Milo94b43b62012-08-22 15:32:29 +080065 .name = "D1",
Samu Onkalo5991e152010-11-11 14:05:23 -080066 .chan_nr = 0,
67 .led_current = 50,
68 .max_current = 130,
69 },
70...
Kim, Milo94b43b62012-08-22 15:32:29 +080071 {
Samu Onkalo5991e152010-11-11 14:05:23 -080072 .chan_nr = 8,
73 .led_current = 50,
74 .max_current = 130,
75 }
76};
77
78static int lp5523_setup(void)
79{
80 /* Setup HW resources */
81}
82
83static void lp5523_release(void)
84{
85 /* Release HW resources */
86}
87
88static void lp5523_enable(bool state)
89{
90 /* Control chip enable signal */
91}
92
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090093static struct lp55xx_platform_data lp5523_platform_data = {
Samu Onkalo5991e152010-11-11 14:05:23 -080094 .led_config = lp5523_led_config,
95 .num_channels = ARRAY_SIZE(lp5523_led_config),
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090096 .clock_mode = LP55XX_CLOCK_EXT,
Samu Onkalo5991e152010-11-11 14:05:23 -080097 .setup_resources = lp5523_setup,
98 .release_resources = lp5523_release,
99 .enable = lp5523_enable,
100};