blob: 270f5719633982686f25ff460bc0493be488d95a [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.
21For the details, please refer to 'firmware' section in leds-lp55xx.txt
Samu Onkalo5991e152010-11-11 14:05:23 -080022
23sysfs contains a selftest entry.
24The test communicates with the chip and checks that
25the clock mode is automatically set to the requested one.
26
27Each channel has its own led current settings.
28/sys/class/leds/lp5521:channel0/led_current - RW
29/sys/class/leds/lp5521:channel0/max_current - RO
30Format: 10x mA i.e 10 means 1.0 mA
31
32example platform data:
33
34Note: chan_nr can have values between 0 and 2.
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070035The name of each channel can be configurable.
36If the name field is not defined, the default name will be set to 'xxxx:channelN'
37(XXXX : pdata->label or i2c client name, N : channel number)
Samu Onkalo5991e152010-11-11 14:05:23 -080038
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090039static struct lp55xx_led_config lp5521_led_config[] = {
Samu Onkalo5991e152010-11-11 14:05:23 -080040 {
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070041 .name = "red",
Samu Onkalo5991e152010-11-11 14:05:23 -080042 .chan_nr = 0,
43 .led_current = 50,
44 .max_current = 130,
45 }, {
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070046 .name = "green",
Samu Onkalo5991e152010-11-11 14:05:23 -080047 .chan_nr = 1,
48 .led_current = 0,
49 .max_current = 130,
50 }, {
Kim, Milo5ae4e8a2012-03-23 15:02:08 -070051 .name = "blue",
Samu Onkalo5991e152010-11-11 14:05:23 -080052 .chan_nr = 2,
53 .led_current = 0,
54 .max_current = 130,
55 }
56};
57
58static int lp5521_setup(void)
59{
60 /* setup HW resources */
61}
62
63static void lp5521_release(void)
64{
65 /* Release HW resources */
66}
67
68static void lp5521_enable(bool state)
69{
70 /* Control of chip enable signal */
71}
72
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090073static struct lp55xx_platform_data lp5521_platform_data = {
Samu Onkalo5991e152010-11-11 14:05:23 -080074 .led_config = lp5521_led_config,
75 .num_channels = ARRAY_SIZE(lp5521_led_config),
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090076 .clock_mode = LP55XX_CLOCK_EXT,
Samu Onkalo5991e152010-11-11 14:05:23 -080077 .setup_resources = lp5521_setup,
78 .release_resources = lp5521_release,
79 .enable = lp5521_enable,
80};
81
82If the current is set to 0 in the platform data, that channel is
83disabled and it is not visible in the sysfs.
Kim, Milo3b49aac2012-03-23 15:02:08 -070084
85The 'update_config' : CONFIG register (ADDR 08h)
86This value is platform-specific data.
87If 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
91example 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
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +090097static struct lp55xx_platform_data lp5521_pdata = {
Kim, Milo3b49aac2012-03-23 15:02:08 -070098 .led_config = lp5521_led_config,
99 .num_channels = ARRAY_SIZE(lp5521_led_config),
Milo(Woogyom) Kimc0285f82013-02-05 20:22:48 +0900100 .clock_mode = LP55XX_CLOCK_INT,
Kim, Milo3b49aac2012-03-23 15:02:08 -0700101 .update_config = LP5521_CONFIGS,
102};