blob: d08d8c179f857e9973461b1d80892b9ed2b0ac2a [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
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090020LP5521 has the internal program memory for running various LED patterns.
Milo Kim863724a2013-08-08 14:11:29 +090021There are two ways to run LED patterns.
22
231) Legacy interface - enginex_mode and enginex_load
24 Control interface for the engines:
25 x is 1 .. 3
26 enginex_mode : disabled, load, run
27 enginex_load : store program (visible only in engine load mode)
28
29 Example (start to blink the channel 2 led):
30 cd /sys/class/leds/lp5521:channel2/device
31 echo "load" > engine3_mode
32 echo "037f4d0003ff6000" > engine3_load
33 echo "run" > engine3_mode
34
35 To stop the engine:
36 echo "disabled" > engine3_mode
37
382) Firmware interface - LP55xx common interface
39 For the details, please refer to 'firmware' section in leds-lp55xx.txt
Samu Onkalo5991e152010-11-11 14:05:23 -080040
41sysfs contains a selftest entry.
42The test communicates with the chip and checks that
43the clock mode is automatically set to the requested one.
44
45Each channel has its own led current settings.
46/sys/class/leds/lp5521:channel0/led_current - RW
47/sys/class/leds/lp5521:channel0/max_current - RO
48Format: 10x mA i.e 10 means 1.0 mA
49
50example platform data:
51
52Note: chan_nr can have values between 0 and 2.
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070053The name of each channel can be configurable.
54If the name field is not defined, the default name will be set to 'xxxx:channelN'
55(XXXX : pdata->label or i2c client name, N : channel number)
Samu Onkalo5991e152010-11-11 14:05:23 -080056
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090057static struct lp55xx_led_config lp5521_led_config[] = {
Samu Onkalo5991e152010-11-11 14:05:23 -080058 {
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070059 .name = "red",
Samu Onkalo5991e152010-11-11 14:05:23 -080060 .chan_nr = 0,
61 .led_current = 50,
62 .max_current = 130,
63 }, {
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070064 .name = "green",
Samu Onkalo5991e152010-11-11 14:05:23 -080065 .chan_nr = 1,
66 .led_current = 0,
67 .max_current = 130,
68 }, {
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070069 .name = "blue",
Samu Onkalo5991e152010-11-11 14:05:23 -080070 .chan_nr = 2,
71 .led_current = 0,
72 .max_current = 130,
73 }
74};
75
76static int lp5521_setup(void)
77{
78 /* setup HW resources */
79}
80
81static void lp5521_release(void)
82{
83 /* Release HW resources */
84}
85
86static void lp5521_enable(bool state)
87{
88 /* Control of chip enable signal */
89}
90
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090091static struct lp55xx_platform_data lp5521_platform_data = {
Samu Onkalo5991e152010-11-11 14:05:23 -080092 .led_config = lp5521_led_config,
93 .num_channels = ARRAY_SIZE(lp5521_led_config),
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090094 .clock_mode = LP55XX_CLOCK_EXT,
Samu Onkalo5991e152010-11-11 14:05:23 -080095 .setup_resources = lp5521_setup,
96 .release_resources = lp5521_release,
97 .enable = lp5521_enable,
98};
99
100If the current is set to 0 in the platform data, that channel is
101disabled and it is not visible in the sysfs.