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