Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 1 | Kernel driver for lp5521 |
| 2 | ======================== |
| 3 | |
| 4 | * National Semiconductor LP5521 led driver chip |
| 5 | * Datasheet: http://www.national.com/pf/LP/LP5521.html |
| 6 | |
| 7 | Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo |
| 8 | Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com) |
| 9 | |
| 10 | Description |
| 11 | ----------- |
| 12 | |
| 13 | LP5521 can drive up to 3 channels. Leds can be controlled directly via |
| 14 | the led class control interface. Channels have generic names: |
| 15 | lp5521:channelx, where x is 0 .. 2 |
| 16 | |
| 17 | All three channels can be also controlled using the engine micro programs. |
| 18 | More details of the instructions can be found from the public data sheet. |
| 19 | |
Milo(Woogyom) Kim | c0285f8 | 2013-02-05 20:22:48 +0900 | [diff] [blame] | 20 | LP5521 has the internal program memory for running various LED patterns. |
| 21 | For the details, please refer to 'firmware' section in leds-lp55xx.txt |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 22 | |
| 23 | sysfs contains a selftest entry. |
| 24 | The test communicates with the chip and checks that |
| 25 | the clock mode is automatically set to the requested one. |
| 26 | |
| 27 | Each 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 |
| 30 | Format: 10x mA i.e 10 means 1.0 mA |
| 31 | |
| 32 | example platform data: |
| 33 | |
| 34 | Note: chan_nr can have values between 0 and 2. |
Kim, Milo | 5ae4e8a | 2012-03-23 15:02:08 -0700 | [diff] [blame] | 35 | The name of each channel can be configurable. |
| 36 | If 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 Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 38 | |
Milo(Woogyom) Kim | c0285f8 | 2013-02-05 20:22:48 +0900 | [diff] [blame] | 39 | static struct lp55xx_led_config lp5521_led_config[] = { |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 40 | { |
Kim, Milo | 5ae4e8a | 2012-03-23 15:02:08 -0700 | [diff] [blame] | 41 | .name = "red", |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 42 | .chan_nr = 0, |
| 43 | .led_current = 50, |
| 44 | .max_current = 130, |
| 45 | }, { |
Kim, Milo | 5ae4e8a | 2012-03-23 15:02:08 -0700 | [diff] [blame] | 46 | .name = "green", |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 47 | .chan_nr = 1, |
| 48 | .led_current = 0, |
| 49 | .max_current = 130, |
| 50 | }, { |
Kim, Milo | 5ae4e8a | 2012-03-23 15:02:08 -0700 | [diff] [blame] | 51 | .name = "blue", |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 52 | .chan_nr = 2, |
| 53 | .led_current = 0, |
| 54 | .max_current = 130, |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | static int lp5521_setup(void) |
| 59 | { |
| 60 | /* setup HW resources */ |
| 61 | } |
| 62 | |
| 63 | static void lp5521_release(void) |
| 64 | { |
| 65 | /* Release HW resources */ |
| 66 | } |
| 67 | |
| 68 | static void lp5521_enable(bool state) |
| 69 | { |
| 70 | /* Control of chip enable signal */ |
| 71 | } |
| 72 | |
Milo(Woogyom) Kim | c0285f8 | 2013-02-05 20:22:48 +0900 | [diff] [blame] | 73 | static struct lp55xx_platform_data lp5521_platform_data = { |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 74 | .led_config = lp5521_led_config, |
| 75 | .num_channels = ARRAY_SIZE(lp5521_led_config), |
Milo(Woogyom) Kim | c0285f8 | 2013-02-05 20:22:48 +0900 | [diff] [blame] | 76 | .clock_mode = LP55XX_CLOCK_EXT, |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 77 | .setup_resources = lp5521_setup, |
| 78 | .release_resources = lp5521_release, |
| 79 | .enable = lp5521_enable, |
| 80 | }; |
| 81 | |
| 82 | If the current is set to 0 in the platform data, that channel is |
| 83 | disabled and it is not visible in the sysfs. |