1 ======================== 1 ======================== 2 Kernel driver for lp5521 2 Kernel driver for lp5521 3 ======================== 3 ======================== 4 4 5 * National Semiconductor LP5521 led driver chi 5 * National Semiconductor LP5521 led driver chip 6 * Datasheet: http://www.national.com/pf/LP/LP5 6 * Datasheet: http://www.national.com/pf/LP/LP5521.html 7 7 8 Authors: Mathias Nyman, Yuri Zaporozhets, Samu 8 Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo 9 9 10 Contact: Samu Onkalo (samu.p.onkalo-at-nokia.c 10 Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com) 11 11 12 Description 12 Description 13 ----------- 13 ----------- 14 14 15 LP5521 can drive up to 3 channels. Leds can be 15 LP5521 can drive up to 3 channels. Leds can be controlled directly via 16 the led class control interface. Channels have 16 the led class control interface. Channels have generic names: 17 lp5521:channelx, where x is 0 .. 2 17 lp5521:channelx, where x is 0 .. 2 18 18 19 All three channels can be also controlled usin 19 All three channels can be also controlled using the engine micro programs. 20 More details of the instructions can be found 20 More details of the instructions can be found from the public data sheet. 21 21 22 LP5521 has the internal program memory for run 22 LP5521 has the internal program memory for running various LED patterns. 23 There are two ways to run LED patterns. 23 There are two ways to run LED patterns. 24 24 25 1) Legacy interface - enginex_mode and enginex 25 1) Legacy interface - enginex_mode and enginex_load 26 Control interface for the engines: 26 Control interface for the engines: 27 27 28 x is 1 .. 3 28 x is 1 .. 3 29 29 30 enginex_mode: 30 enginex_mode: 31 disabled, load, run 31 disabled, load, run 32 enginex_load: 32 enginex_load: 33 store program (visible only in engine 33 store program (visible only in engine load mode) 34 34 35 Example (start to blink the channel 2 led):: 35 Example (start to blink the channel 2 led):: 36 36 37 cd /sys/class/leds/lp5521:channel2/d 37 cd /sys/class/leds/lp5521:channel2/device 38 echo "load" > engine3_mode 38 echo "load" > engine3_mode 39 echo "037f4d0003ff6000" > engine3_load 39 echo "037f4d0003ff6000" > engine3_load 40 echo "run" > engine3_mode 40 echo "run" > engine3_mode 41 41 42 To stop the engine:: 42 To stop the engine:: 43 43 44 echo "disabled" > engine3_mode 44 echo "disabled" > engine3_mode 45 45 46 2) Firmware interface - LP55xx common interfac 46 2) Firmware interface - LP55xx common interface 47 47 48 For the details, please refer to 'firmware' se 48 For the details, please refer to 'firmware' section in leds-lp55xx.txt 49 49 50 sysfs contains a selftest entry. 50 sysfs contains a selftest entry. 51 51 52 The test communicates with the chip and checks 52 The test communicates with the chip and checks that 53 the clock mode is automatically set to the req 53 the clock mode is automatically set to the requested one. 54 54 55 Each channel has its own led current settings. 55 Each channel has its own led current settings. 56 56 57 - /sys/class/leds/lp5521:channel0/led_current 57 - /sys/class/leds/lp5521:channel0/led_current - RW 58 - /sys/class/leds/lp5521:channel0/max_current 58 - /sys/class/leds/lp5521:channel0/max_current - RO 59 59 60 Format: 10x mA i.e 10 means 1.0 mA 60 Format: 10x mA i.e 10 means 1.0 mA 61 61 62 example platform data:: 62 example platform data:: 63 63 64 static struct lp55xx_led_config lp5521_led_c 64 static struct lp55xx_led_config lp5521_led_config[] = { 65 { 65 { 66 .name = "red", 66 .name = "red", 67 .chan_nr = 0, 67 .chan_nr = 0, 68 .led_current = 50, 68 .led_current = 50, 69 .max_current = 130, 69 .max_current = 130, 70 }, { 70 }, { 71 .name = "green", 71 .name = "green", 72 .chan_nr = 1, 72 .chan_nr = 1, 73 .led_current = 0, 73 .led_current = 0, 74 .max_current = 130, 74 .max_current = 130, 75 }, { 75 }, { 76 .name = "blue", 76 .name = "blue", 77 .chan_nr = 2, 77 .chan_nr = 2, 78 .led_current = 0, 78 .led_current = 0, 79 .max_current = 130, 79 .max_current = 130, 80 } 80 } 81 }; 81 }; 82 82 83 static int lp5521_setup(void) 83 static int lp5521_setup(void) 84 { 84 { 85 /* setup HW resources */ 85 /* setup HW resources */ 86 } 86 } 87 87 88 static void lp5521_release(void) 88 static void lp5521_release(void) 89 { 89 { 90 /* Release HW resources */ 90 /* Release HW resources */ 91 } 91 } 92 92 93 static void lp5521_enable(bool state) 93 static void lp5521_enable(bool state) 94 { 94 { 95 /* Control of chip enable signal */ 95 /* Control of chip enable signal */ 96 } 96 } 97 97 98 static struct lp55xx_platform_data lp5521_pl 98 static struct lp55xx_platform_data lp5521_platform_data = { 99 .led_config = lp5521_led_config, 99 .led_config = lp5521_led_config, 100 .num_channels = ARRAY_SIZE(lp5521_ 100 .num_channels = ARRAY_SIZE(lp5521_led_config), 101 .clock_mode = LP55XX_CLOCK_EXT, 101 .clock_mode = LP55XX_CLOCK_EXT, 102 .setup_resources = lp5521_setup, 102 .setup_resources = lp5521_setup, 103 .release_resources = lp5521_release, 103 .release_resources = lp5521_release, 104 .enable = lp5521_enable, 104 .enable = lp5521_enable, 105 }; 105 }; 106 106 107 Note: 107 Note: 108 chan_nr can have values between 0 and 2. 108 chan_nr can have values between 0 and 2. 109 The name of each channel can be configurable 109 The name of each channel can be configurable. 110 If the name field is not defined, the defaul 110 If the name field is not defined, the default name will be set to 'xxxx:channelN' 111 (XXXX : pdata->label or i2c client name, N : 111 (XXXX : pdata->label or i2c client name, N : channel number) 112 112 113 113 114 If the current is set to 0 in the platform dat 114 If the current is set to 0 in the platform data, that channel is 115 disabled and it is not visible in the sysfs. 115 disabled and it is not visible in the sysfs.
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.