|
| 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 |
| 13 | +the led class control interface. Channels have generic names: |
| 14 | +lp5523:channelx where x is 0...8 |
| 15 | + |
| 16 | +The chip provides 3 engines. Each engine can control channels without |
| 17 | +interaction from the main CPU. Details of the micro engine code can be found |
| 18 | +from the public data sheet. Leds can be muxed to different channels. |
| 19 | + |
| 20 | +Control interface for the engines: |
| 21 | +x is 1 .. 3 |
| 22 | +enginex_mode : disabled, load, run |
| 23 | +enginex_load : microcode load (visible only in load mode) |
| 24 | +enginex_leds : led mux control (visible only in load mode) |
| 25 | + |
| 26 | +cd /sys/class/leds/lp5523:channel2/device |
| 27 | +echo "load" > engine3_mode |
| 28 | +echo "9d80400004ff05ff437f0000" > engine3_load |
| 29 | +echo "111111111" > engine3_leds |
| 30 | +echo "run" > engine3_mode |
| 31 | + |
| 32 | +sysfs contains a selftest entry. It measures each channel |
| 33 | +voltage level and checks if it looks reasonable. If the level is too high, |
| 34 | +the led is missing; if the level is too low, there is a short circuit. |
| 35 | + |
| 36 | +Selftest uses always the current from the platform data. |
| 37 | + |
| 38 | +Each channel contains led current settings. |
| 39 | +/sys/class/leds/lp5523:channel2/led_current - RW |
| 40 | +/sys/class/leds/lp5523:channel2/max_current - RO |
| 41 | +Format: 10x mA i.e 10 means 1.0 mA |
| 42 | + |
| 43 | +Example platform data: |
| 44 | + |
| 45 | +Note - chan_nr can have values between 0 and 8. |
| 46 | + |
| 47 | +static struct lp5523_led_config lp5523_led_config[] = { |
| 48 | + { |
| 49 | + .chan_nr = 0, |
| 50 | + .led_current = 50, |
| 51 | + .max_current = 130, |
| 52 | + }, |
| 53 | +... |
| 54 | + }, { |
| 55 | + .chan_nr = 8, |
| 56 | + .led_current = 50, |
| 57 | + .max_current = 130, |
| 58 | + } |
| 59 | +}; |
| 60 | + |
| 61 | +static int lp5523_setup(void) |
| 62 | +{ |
| 63 | + /* Setup HW resources */ |
| 64 | +} |
| 65 | + |
| 66 | +static void lp5523_release(void) |
| 67 | +{ |
| 68 | + /* Release HW resources */ |
| 69 | +} |
| 70 | + |
| 71 | +static void lp5523_enable(bool state) |
| 72 | +{ |
| 73 | + /* Control chip enable signal */ |
| 74 | +} |
| 75 | + |
| 76 | +static struct lp5523_platform_data lp5523_platform_data = { |
| 77 | + .led_config = lp5523_led_config, |
| 78 | + .num_channels = ARRAY_SIZE(lp5523_led_config), |
| 79 | + .clock_mode = LP5523_CLOCK_EXT, |
| 80 | + .setup_resources = lp5523_setup, |
| 81 | + .release_resources = lp5523_release, |
| 82 | + .enable = lp5523_enable, |
| 83 | +}; |
0 commit comments