Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 1 | Kernel driver for lp5523 |
| 2 | ======================== |
| 3 | |
| 4 | * National Semiconductor LP5523 led driver chip |
| 5 | * Datasheet: http://www.national.com/pf/LP/LP5523.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 | LP5523 can drive up to 9 channels. Leds can be controlled directly via |
Kim, Milo | 94b43b6 | 2012-08-22 15:32:29 +0800 | [diff] [blame] | 13 | the led class control interface. |
| 14 | The name of each channel is configurable in the platform data - name and label. |
| 15 | There are three options to make the channel name. |
| 16 | |
| 17 | a) Define the 'name' in the platform data |
| 18 | To make specific channel name, then use 'name' platform data. |
| 19 | /sys/class/leds/R1 (name: 'R1') |
| 20 | /sys/class/leds/B1 (name: 'B1') |
| 21 | |
| 22 | b) Use the 'label' with no 'name' field |
| 23 | For one device name with channel number, then use 'label'. |
| 24 | /sys/class/leds/RGB:channelN (label: 'RGB', N: 0 ~ 8) |
| 25 | |
| 26 | c) Default |
| 27 | If both fields are NULL, 'lp5523' is used by default. |
| 28 | /sys/class/leds/lp5523:channelN (N: 0 ~ 8) |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 29 | |
Milo(Woogyom) Kim | c0285f8 | 2013-02-05 20:22:48 +0900 | [diff] [blame] | 30 | LP5523 has the internal program memory for running various LED patterns. |
Milo Kim | 863724a | 2013-08-08 14:11:29 +0900 | [diff] [blame] | 31 | There are two ways to run LED patterns. |
| 32 | |
| 33 | 1) Legacy interface - enginex_mode, enginex_load and enginex_leds |
| 34 | Control interface for the engines: |
| 35 | x is 1 .. 3 |
| 36 | enginex_mode : disabled, load, run |
| 37 | enginex_load : microcode load (visible only in load mode) |
| 38 | enginex_leds : led mux control (visible only in load mode) |
| 39 | |
| 40 | cd /sys/class/leds/lp5523:channel2/device |
| 41 | echo "load" > engine3_mode |
| 42 | echo "9d80400004ff05ff437f0000" > engine3_load |
| 43 | echo "111111111" > engine3_leds |
| 44 | echo "run" > engine3_mode |
| 45 | |
| 46 | To stop the engine: |
| 47 | echo "disabled" > engine3_mode |
| 48 | |
| 49 | 2) Firmware interface - LP55xx common interface |
| 50 | For the details, please refer to 'firmware' section in leds-lp55xx.txt |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 51 | |
Toshi Kikuchi | 7ff6b23 | 2015-05-12 18:15:14 -0700 | [diff] [blame] | 52 | LP5523 has three master faders. If a channel is mapped to one of |
| 53 | the master faders, its output is dimmed based on the value of the master |
| 54 | fader. |
| 55 | |
| 56 | For example, |
| 57 | |
| 58 | echo "123000123" > master_fader_leds |
| 59 | |
| 60 | creates the following channel-fader mappings: |
| 61 | |
| 62 | channel 0,6 to master_fader1 |
| 63 | channel 1,7 to master_fader2 |
| 64 | channel 2,8 to master_fader3 |
| 65 | |
| 66 | Then, to have 25% of the original output on channel 0,6: |
| 67 | |
| 68 | echo 64 > master_fader1 |
| 69 | |
| 70 | To have 0% of the original output (i.e. no output) channel 1,7: |
| 71 | |
| 72 | echo 0 > master_fader2 |
| 73 | |
| 74 | To have 100% of the original output (i.e. no dimming) on channel 2,8: |
| 75 | |
| 76 | echo 255 > master_fader3 |
| 77 | |
| 78 | To clear all master fader controls: |
| 79 | |
| 80 | echo "000000000" > master_fader_leds |
| 81 | |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 82 | Selftest uses always the current from the platform data. |
| 83 | |
| 84 | Each channel contains led current settings. |
| 85 | /sys/class/leds/lp5523:channel2/led_current - RW |
| 86 | /sys/class/leds/lp5523:channel2/max_current - RO |
| 87 | Format: 10x mA i.e 10 means 1.0 mA |
| 88 | |
| 89 | Example platform data: |
| 90 | |
| 91 | Note - chan_nr can have values between 0 and 8. |
| 92 | |
Milo(Woogyom) Kim | c0285f8 | 2013-02-05 20:22:48 +0900 | [diff] [blame] | 93 | static struct lp55xx_led_config lp5523_led_config[] = { |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 94 | { |
Kim, Milo | 94b43b6 | 2012-08-22 15:32:29 +0800 | [diff] [blame] | 95 | .name = "D1", |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 96 | .chan_nr = 0, |
| 97 | .led_current = 50, |
| 98 | .max_current = 130, |
| 99 | }, |
| 100 | ... |
Kim, Milo | 94b43b6 | 2012-08-22 15:32:29 +0800 | [diff] [blame] | 101 | { |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 102 | .chan_nr = 8, |
| 103 | .led_current = 50, |
| 104 | .max_current = 130, |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | static int lp5523_setup(void) |
| 109 | { |
| 110 | /* Setup HW resources */ |
| 111 | } |
| 112 | |
| 113 | static void lp5523_release(void) |
| 114 | { |
| 115 | /* Release HW resources */ |
| 116 | } |
| 117 | |
| 118 | static void lp5523_enable(bool state) |
| 119 | { |
| 120 | /* Control chip enable signal */ |
| 121 | } |
| 122 | |
Milo(Woogyom) Kim | c0285f8 | 2013-02-05 20:22:48 +0900 | [diff] [blame] | 123 | static struct lp55xx_platform_data lp5523_platform_data = { |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 124 | .led_config = lp5523_led_config, |
| 125 | .num_channels = ARRAY_SIZE(lp5523_led_config), |
Milo(Woogyom) Kim | c0285f8 | 2013-02-05 20:22:48 +0900 | [diff] [blame] | 126 | .clock_mode = LP55XX_CLOCK_EXT, |
Samu Onkalo | 5991e15 | 2010-11-11 14:05:23 -0800 | [diff] [blame] | 127 | .setup_resources = lp5523_setup, |
| 128 | .release_resources = lp5523_release, |
| 129 | .enable = lp5523_enable, |
| 130 | }; |