blob: c2743f59f9acb1ce9479ecf7e39926a9caa404a4 [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
30The chip provides 3 engines. Each engine can control channels without
31interaction from the main CPU. Details of the micro engine code can be found
32from the public data sheet. Leds can be muxed to different channels.
33
34Control interface for the engines:
35x is 1 .. 3
36enginex_mode : disabled, load, run
37enginex_load : microcode load (visible only in load mode)
38enginex_leds : led mux control (visible only in load mode)
39
40cd /sys/class/leds/lp5523:channel2/device
41echo "load" > engine3_mode
42echo "9d80400004ff05ff437f0000" > engine3_load
43echo "111111111" > engine3_leds
44echo "run" > engine3_mode
45
46sysfs contains a selftest entry. It measures each channel
47voltage level and checks if it looks reasonable. If the level is too high,
48the led is missing; if the level is too low, there is a short circuit.
49
50Selftest uses always the current from the platform data.
51
52Each channel contains led current settings.
53/sys/class/leds/lp5523:channel2/led_current - RW
54/sys/class/leds/lp5523:channel2/max_current - RO
55Format: 10x mA i.e 10 means 1.0 mA
56
57Example platform data:
58
59Note - chan_nr can have values between 0 and 8.
60
61static struct lp5523_led_config lp5523_led_config[] = {
62 {
Kim, Milo94b43b62012-08-22 15:32:29 +080063 .name = "D1",
Samu Onkalo5991e152010-11-11 14:05:23 -080064 .chan_nr = 0,
65 .led_current = 50,
66 .max_current = 130,
67 },
68...
Kim, Milo94b43b62012-08-22 15:32:29 +080069 {
Samu Onkalo5991e152010-11-11 14:05:23 -080070 .chan_nr = 8,
71 .led_current = 50,
72 .max_current = 130,
73 }
74};
75
76static int lp5523_setup(void)
77{
78 /* Setup HW resources */
79}
80
81static void lp5523_release(void)
82{
83 /* Release HW resources */
84}
85
86static void lp5523_enable(bool state)
87{
88 /* Control chip enable signal */
89}
90
91static struct lp5523_platform_data lp5523_platform_data = {
92 .led_config = lp5523_led_config,
93 .num_channels = ARRAY_SIZE(lp5523_led_config),
94 .clock_mode = LP5523_CLOCK_EXT,
95 .setup_resources = lp5523_setup,
96 .release_resources = lp5523_release,
97 .enable = lp5523_enable,
98};