0001 ========================
0002 Kernel driver for lp5521
0003 ========================
0004
0005 * National Semiconductor LP5521 led driver chip
0006 * Datasheet: http://www.national.com/pf/LP/LP5521.html
0007
0008 Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
0009
0010 Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
0011
0012 Description
0013 -----------
0014
0015 LP5521 can drive up to 3 channels. Leds can be controlled directly via
0016 the led class control interface. Channels have generic names:
0017 lp5521:channelx, where x is 0 .. 2
0018
0019 All three channels can be also controlled using the engine micro programs.
0020 More details of the instructions can be found from the public data sheet.
0021
0022 LP5521 has the internal program memory for running various LED patterns.
0023 There are two ways to run LED patterns.
0024
0025 1) Legacy interface - enginex_mode and enginex_load
0026 Control interface for the engines:
0027
0028 x is 1 .. 3
0029
0030 enginex_mode:
0031 disabled, load, run
0032 enginex_load:
0033 store program (visible only in engine load mode)
0034
0035 Example (start to blink the channel 2 led)::
0036
0037 cd /sys/class/leds/lp5521:channel2/device
0038 echo "load" > engine3_mode
0039 echo "037f4d0003ff6000" > engine3_load
0040 echo "run" > engine3_mode
0041
0042 To stop the engine::
0043
0044 echo "disabled" > engine3_mode
0045
0046 2) Firmware interface - LP55xx common interface
0047
0048 For the details, please refer to 'firmware' section in leds-lp55xx.txt
0049
0050 sysfs contains a selftest entry.
0051
0052 The test communicates with the chip and checks that
0053 the clock mode is automatically set to the requested one.
0054
0055 Each channel has its own led current settings.
0056
0057 - /sys/class/leds/lp5521:channel0/led_current - RW
0058 - /sys/class/leds/lp5521:channel0/max_current - RO
0059
0060 Format: 10x mA i.e 10 means 1.0 mA
0061
0062 example platform data::
0063
0064 static struct lp55xx_led_config lp5521_led_config[] = {
0065 {
0066 .name = "red",
0067 .chan_nr = 0,
0068 .led_current = 50,
0069 .max_current = 130,
0070 }, {
0071 .name = "green",
0072 .chan_nr = 1,
0073 .led_current = 0,
0074 .max_current = 130,
0075 }, {
0076 .name = "blue",
0077 .chan_nr = 2,
0078 .led_current = 0,
0079 .max_current = 130,
0080 }
0081 };
0082
0083 static int lp5521_setup(void)
0084 {
0085 /* setup HW resources */
0086 }
0087
0088 static void lp5521_release(void)
0089 {
0090 /* Release HW resources */
0091 }
0092
0093 static void lp5521_enable(bool state)
0094 {
0095 /* Control of chip enable signal */
0096 }
0097
0098 static struct lp55xx_platform_data lp5521_platform_data = {
0099 .led_config = lp5521_led_config,
0100 .num_channels = ARRAY_SIZE(lp5521_led_config),
0101 .clock_mode = LP55XX_CLOCK_EXT,
0102 .setup_resources = lp5521_setup,
0103 .release_resources = lp5521_release,
0104 .enable = lp5521_enable,
0105 };
0106
0107 Note:
0108 chan_nr can have values between 0 and 2.
0109 The name of each channel can be configurable.
0110 If the name field is not defined, the default name will be set to 'xxxx:channelN'
0111 (XXXX : pdata->label or i2c client name, N : channel number)
0112
0113
0114 If the current is set to 0 in the platform data, that channel is
0115 disabled and it is not visible in the sysfs.