1*8dab9197SMauro Carvalho Chehab======================== 2*8dab9197SMauro Carvalho ChehabKernel driver for lp5523 3*8dab9197SMauro Carvalho Chehab======================== 4*8dab9197SMauro Carvalho Chehab 5*8dab9197SMauro Carvalho Chehab* National Semiconductor LP5523 led driver chip 6*8dab9197SMauro Carvalho Chehab* Datasheet: http://www.national.com/pf/LP/LP5523.html 7*8dab9197SMauro Carvalho Chehab 8*8dab9197SMauro Carvalho ChehabAuthors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo 9*8dab9197SMauro Carvalho ChehabContact: Samu Onkalo (samu.p.onkalo-at-nokia.com) 10*8dab9197SMauro Carvalho Chehab 11*8dab9197SMauro Carvalho ChehabDescription 12*8dab9197SMauro Carvalho Chehab----------- 13*8dab9197SMauro Carvalho ChehabLP5523 can drive up to 9 channels. Leds can be controlled directly via 14*8dab9197SMauro Carvalho Chehabthe led class control interface. 15*8dab9197SMauro Carvalho ChehabThe name of each channel is configurable in the platform data - name and label. 16*8dab9197SMauro Carvalho ChehabThere are three options to make the channel name. 17*8dab9197SMauro Carvalho Chehab 18*8dab9197SMauro Carvalho Chehaba) Define the 'name' in the platform data 19*8dab9197SMauro Carvalho Chehab 20*8dab9197SMauro Carvalho ChehabTo make specific channel name, then use 'name' platform data. 21*8dab9197SMauro Carvalho Chehab 22*8dab9197SMauro Carvalho Chehab- /sys/class/leds/R1 (name: 'R1') 23*8dab9197SMauro Carvalho Chehab- /sys/class/leds/B1 (name: 'B1') 24*8dab9197SMauro Carvalho Chehab 25*8dab9197SMauro Carvalho Chehabb) Use the 'label' with no 'name' field 26*8dab9197SMauro Carvalho Chehab 27*8dab9197SMauro Carvalho ChehabFor one device name with channel number, then use 'label'. 28*8dab9197SMauro Carvalho Chehab- /sys/class/leds/RGB:channelN (label: 'RGB', N: 0 ~ 8) 29*8dab9197SMauro Carvalho Chehab 30*8dab9197SMauro Carvalho Chehabc) Default 31*8dab9197SMauro Carvalho Chehab 32*8dab9197SMauro Carvalho ChehabIf both fields are NULL, 'lp5523' is used by default. 33*8dab9197SMauro Carvalho Chehab- /sys/class/leds/lp5523:channelN (N: 0 ~ 8) 34*8dab9197SMauro Carvalho Chehab 35*8dab9197SMauro Carvalho ChehabLP5523 has the internal program memory for running various LED patterns. 36*8dab9197SMauro Carvalho ChehabThere are two ways to run LED patterns. 37*8dab9197SMauro Carvalho Chehab 38*8dab9197SMauro Carvalho Chehab1) Legacy interface - enginex_mode, enginex_load and enginex_leds 39*8dab9197SMauro Carvalho Chehab 40*8dab9197SMauro Carvalho Chehab Control interface for the engines: 41*8dab9197SMauro Carvalho Chehab 42*8dab9197SMauro Carvalho Chehab x is 1 .. 3 43*8dab9197SMauro Carvalho Chehab 44*8dab9197SMauro Carvalho Chehab enginex_mode: 45*8dab9197SMauro Carvalho Chehab disabled, load, run 46*8dab9197SMauro Carvalho Chehab enginex_load: 47*8dab9197SMauro Carvalho Chehab microcode load 48*8dab9197SMauro Carvalho Chehab enginex_leds: 49*8dab9197SMauro Carvalho Chehab led mux control 50*8dab9197SMauro Carvalho Chehab 51*8dab9197SMauro Carvalho Chehab :: 52*8dab9197SMauro Carvalho Chehab 53*8dab9197SMauro Carvalho Chehab cd /sys/class/leds/lp5523:channel2/device 54*8dab9197SMauro Carvalho Chehab echo "load" > engine3_mode 55*8dab9197SMauro Carvalho Chehab echo "9d80400004ff05ff437f0000" > engine3_load 56*8dab9197SMauro Carvalho Chehab echo "111111111" > engine3_leds 57*8dab9197SMauro Carvalho Chehab echo "run" > engine3_mode 58*8dab9197SMauro Carvalho Chehab 59*8dab9197SMauro Carvalho Chehab To stop the engine:: 60*8dab9197SMauro Carvalho Chehab 61*8dab9197SMauro Carvalho Chehab echo "disabled" > engine3_mode 62*8dab9197SMauro Carvalho Chehab 63*8dab9197SMauro Carvalho Chehab2) Firmware interface - LP55xx common interface 64*8dab9197SMauro Carvalho Chehab 65*8dab9197SMauro Carvalho ChehabFor the details, please refer to 'firmware' section in leds-lp55xx.txt 66*8dab9197SMauro Carvalho Chehab 67*8dab9197SMauro Carvalho ChehabLP5523 has three master faders. If a channel is mapped to one of 68*8dab9197SMauro Carvalho Chehabthe master faders, its output is dimmed based on the value of the master 69*8dab9197SMauro Carvalho Chehabfader. 70*8dab9197SMauro Carvalho Chehab 71*8dab9197SMauro Carvalho ChehabFor example:: 72*8dab9197SMauro Carvalho Chehab 73*8dab9197SMauro Carvalho Chehab echo "123000123" > master_fader_leds 74*8dab9197SMauro Carvalho Chehab 75*8dab9197SMauro Carvalho Chehabcreates the following channel-fader mappings:: 76*8dab9197SMauro Carvalho Chehab 77*8dab9197SMauro Carvalho Chehab channel 0,6 to master_fader1 78*8dab9197SMauro Carvalho Chehab channel 1,7 to master_fader2 79*8dab9197SMauro Carvalho Chehab channel 2,8 to master_fader3 80*8dab9197SMauro Carvalho Chehab 81*8dab9197SMauro Carvalho ChehabThen, to have 25% of the original output on channel 0,6:: 82*8dab9197SMauro Carvalho Chehab 83*8dab9197SMauro Carvalho Chehab echo 64 > master_fader1 84*8dab9197SMauro Carvalho Chehab 85*8dab9197SMauro Carvalho ChehabTo have 0% of the original output (i.e. no output) channel 1,7:: 86*8dab9197SMauro Carvalho Chehab 87*8dab9197SMauro Carvalho Chehab echo 0 > master_fader2 88*8dab9197SMauro Carvalho Chehab 89*8dab9197SMauro Carvalho ChehabTo have 100% of the original output (i.e. no dimming) on channel 2,8:: 90*8dab9197SMauro Carvalho Chehab 91*8dab9197SMauro Carvalho Chehab echo 255 > master_fader3 92*8dab9197SMauro Carvalho Chehab 93*8dab9197SMauro Carvalho ChehabTo clear all master fader controls:: 94*8dab9197SMauro Carvalho Chehab 95*8dab9197SMauro Carvalho Chehab echo "000000000" > master_fader_leds 96*8dab9197SMauro Carvalho Chehab 97*8dab9197SMauro Carvalho ChehabSelftest uses always the current from the platform data. 98*8dab9197SMauro Carvalho Chehab 99*8dab9197SMauro Carvalho ChehabEach channel contains led current settings. 100*8dab9197SMauro Carvalho Chehab- /sys/class/leds/lp5523:channel2/led_current - RW 101*8dab9197SMauro Carvalho Chehab- /sys/class/leds/lp5523:channel2/max_current - RO 102*8dab9197SMauro Carvalho Chehab 103*8dab9197SMauro Carvalho ChehabFormat: 10x mA i.e 10 means 1.0 mA 104*8dab9197SMauro Carvalho Chehab 105*8dab9197SMauro Carvalho ChehabExample platform data:: 106*8dab9197SMauro Carvalho Chehab 107*8dab9197SMauro Carvalho Chehab static struct lp55xx_led_config lp5523_led_config[] = { 108*8dab9197SMauro Carvalho Chehab { 109*8dab9197SMauro Carvalho Chehab .name = "D1", 110*8dab9197SMauro Carvalho Chehab .chan_nr = 0, 111*8dab9197SMauro Carvalho Chehab .led_current = 50, 112*8dab9197SMauro Carvalho Chehab .max_current = 130, 113*8dab9197SMauro Carvalho Chehab }, 114*8dab9197SMauro Carvalho Chehab ... 115*8dab9197SMauro Carvalho Chehab { 116*8dab9197SMauro Carvalho Chehab .chan_nr = 8, 117*8dab9197SMauro Carvalho Chehab .led_current = 50, 118*8dab9197SMauro Carvalho Chehab .max_current = 130, 119*8dab9197SMauro Carvalho Chehab } 120*8dab9197SMauro Carvalho Chehab }; 121*8dab9197SMauro Carvalho Chehab 122*8dab9197SMauro Carvalho Chehab static int lp5523_setup(void) 123*8dab9197SMauro Carvalho Chehab { 124*8dab9197SMauro Carvalho Chehab /* Setup HW resources */ 125*8dab9197SMauro Carvalho Chehab } 126*8dab9197SMauro Carvalho Chehab 127*8dab9197SMauro Carvalho Chehab static void lp5523_release(void) 128*8dab9197SMauro Carvalho Chehab { 129*8dab9197SMauro Carvalho Chehab /* Release HW resources */ 130*8dab9197SMauro Carvalho Chehab } 131*8dab9197SMauro Carvalho Chehab 132*8dab9197SMauro Carvalho Chehab static void lp5523_enable(bool state) 133*8dab9197SMauro Carvalho Chehab { 134*8dab9197SMauro Carvalho Chehab /* Control chip enable signal */ 135*8dab9197SMauro Carvalho Chehab } 136*8dab9197SMauro Carvalho Chehab 137*8dab9197SMauro Carvalho Chehab static struct lp55xx_platform_data lp5523_platform_data = { 138*8dab9197SMauro Carvalho Chehab .led_config = lp5523_led_config, 139*8dab9197SMauro Carvalho Chehab .num_channels = ARRAY_SIZE(lp5523_led_config), 140*8dab9197SMauro Carvalho Chehab .clock_mode = LP55XX_CLOCK_EXT, 141*8dab9197SMauro Carvalho Chehab .setup_resources = lp5523_setup, 142*8dab9197SMauro Carvalho Chehab .release_resources = lp5523_release, 143*8dab9197SMauro Carvalho Chehab .enable = lp5523_enable, 144*8dab9197SMauro Carvalho Chehab }; 145*8dab9197SMauro Carvalho Chehab 146*8dab9197SMauro Carvalho ChehabNote 147*8dab9197SMauro Carvalho Chehab chan_nr can have values between 0 and 8. 148