blob: f48ab757d12079d51eee0a39ef5ec16a891cfa5f [file] [log] [blame]
Samu Onkalo5991e152010-11-11 14:05:23 -08001Kernel driver for lp5521
2========================
3
4* National Semiconductor LP5521 led driver chip
5* Datasheet: http://www.national.com/pf/LP/LP5521.html
6
7Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
8Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
9
10Description
11-----------
12
13LP5521 can drive up to 3 channels. Leds can be controlled directly via
14the led class control interface. Channels have generic names:
15lp5521:channelx, where x is 0 .. 2
16
17All three channels can be also controlled using the engine micro programs.
18More details of the instructions can be found from the public data sheet.
19
20Control interface for the engines:
21x is 1 .. 3
22enginex_mode : disabled, load, run
23enginex_load : store program (visible only in engine load mode)
24
25Example (start to blink the channel 2 led):
26cd /sys/class/leds/lp5521:channel2/device
27echo "load" > engine3_mode
28echo "037f4d0003ff6000" > engine3_load
29echo "run" > engine3_mode
30
31stop the engine:
32echo "disabled" > engine3_mode
33
34sysfs contains a selftest entry.
35The test communicates with the chip and checks that
36the clock mode is automatically set to the requested one.
37
38Each channel has its own led current settings.
39/sys/class/leds/lp5521:channel0/led_current - RW
40/sys/class/leds/lp5521:channel0/max_current - RO
41Format: 10x mA i.e 10 means 1.0 mA
42
43example platform data:
44
45Note: chan_nr can have values between 0 and 2.
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070046The name of each channel can be configurable.
47If the name field is not defined, the default name will be set to 'xxxx:channelN'
48(XXXX : pdata->label or i2c client name, N : channel number)
Samu Onkalo5991e152010-11-11 14:05:23 -080049
50static struct lp5521_led_config lp5521_led_config[] = {
51 {
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070052 .name = "red",
Samu Onkalo5991e152010-11-11 14:05:23 -080053 .chan_nr = 0,
54 .led_current = 50,
55 .max_current = 130,
56 }, {
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070057 .name = "green",
Samu Onkalo5991e152010-11-11 14:05:23 -080058 .chan_nr = 1,
59 .led_current = 0,
60 .max_current = 130,
61 }, {
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070062 .name = "blue",
Samu Onkalo5991e152010-11-11 14:05:23 -080063 .chan_nr = 2,
64 .led_current = 0,
65 .max_current = 130,
66 }
67};
68
69static int lp5521_setup(void)
70{
71 /* setup HW resources */
72}
73
74static void lp5521_release(void)
75{
76 /* Release HW resources */
77}
78
79static void lp5521_enable(bool state)
80{
81 /* Control of chip enable signal */
82}
83
84static struct lp5521_platform_data lp5521_platform_data = {
85 .led_config = lp5521_led_config,
86 .num_channels = ARRAY_SIZE(lp5521_led_config),
87 .clock_mode = LP5521_CLOCK_EXT,
88 .setup_resources = lp5521_setup,
89 .release_resources = lp5521_release,
90 .enable = lp5521_enable,
91};
92
93If the current is set to 0 in the platform data, that channel is
94disabled and it is not visible in the sysfs.