Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation: leds: update LP55xx family devices

Update changed platform data information.
Add leds-lp55xx.txt which includes the firmware interface description.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>

authored by

Milo(Woogyom) Kim and committed by
Bryan Wu
c0285f8c 109b8330

+132 -78
+2
Documentation/leds/00-INDEX
··· 6 6 - notes on how to use the leds-lp5521 driver. 7 7 leds-lp5523.txt 8 8 - notes on how to use the leds-lp5523 driver. 9 + leds-lp55xx.txt 10 + - description about lp55xx common driver. 9 11 leds-lm3556.txt 10 12 - notes on how to use the leds-lm3556 driver.
+7 -56
Documentation/leds/leds-lp5521.txt
··· 17 17 All three channels can be also controlled using the engine micro programs. 18 18 More details of the instructions can be found from the public data sheet. 19 19 20 - Control interface for the engines: 21 - x is 1 .. 3 22 - enginex_mode : disabled, load, run 23 - enginex_load : store program (visible only in engine load mode) 24 - 25 - Example (start to blink the channel 2 led): 26 - cd /sys/class/leds/lp5521:channel2/device 27 - echo "load" > engine3_mode 28 - echo "037f4d0003ff6000" > engine3_load 29 - echo "run" > engine3_mode 30 - 31 - stop the engine: 32 - echo "disabled" > engine3_mode 20 + LP5521 has the internal program memory for running various LED patterns. 21 + For the details, please refer to 'firmware' section in leds-lp55xx.txt 33 22 34 23 sysfs contains a selftest entry. 35 24 The test communicates with the chip and checks that ··· 36 47 If the name field is not defined, the default name will be set to 'xxxx:channelN' 37 48 (XXXX : pdata->label or i2c client name, N : channel number) 38 49 39 - static struct lp5521_led_config lp5521_led_config[] = { 50 + static struct lp55xx_led_config lp5521_led_config[] = { 40 51 { 41 52 .name = "red", 42 53 .chan_nr = 0, ··· 70 81 /* Control of chip enable signal */ 71 82 } 72 83 73 - static struct lp5521_platform_data lp5521_platform_data = { 84 + static struct lp55xx_platform_data lp5521_platform_data = { 74 85 .led_config = lp5521_led_config, 75 86 .num_channels = ARRAY_SIZE(lp5521_led_config), 76 - .clock_mode = LP5521_CLOCK_EXT, 87 + .clock_mode = LP55XX_CLOCK_EXT, 77 88 .setup_resources = lp5521_setup, 78 89 .release_resources = lp5521_release, 79 90 .enable = lp5521_enable, ··· 94 105 LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT | \ 95 106 LP5521_CLK_INT) 96 107 97 - static struct lp5521_platform_data lp5521_pdata = { 108 + static struct lp55xx_platform_data lp5521_pdata = { 98 109 .led_config = lp5521_led_config, 99 110 .num_channels = ARRAY_SIZE(lp5521_led_config), 100 - .clock_mode = LP5521_CLOCK_INT, 111 + .clock_mode = LP55XX_CLOCK_INT, 101 112 .update_config = LP5521_CONFIGS, 102 113 }; 103 - 104 - LED patterns : LP5521 has autonomous operation without external control. 105 - Pattern data can be defined in the platform data. 106 - 107 - example of led pattern data : 108 - 109 - /* RGB(50,5,0) 500ms on, 500ms off, infinite loop */ 110 - static u8 pattern_red[] = { 111 - 0x40, 0x32, 0x60, 0x00, 0x40, 0x00, 0x60, 0x00, 112 - }; 113 - 114 - static u8 pattern_green[] = { 115 - 0x40, 0x05, 0x60, 0x00, 0x40, 0x00, 0x60, 0x00, 116 - }; 117 - 118 - static struct lp5521_led_pattern board_led_patterns[] = { 119 - { 120 - .r = pattern_red, 121 - .g = pattern_green, 122 - .size_r = ARRAY_SIZE(pattern_red), 123 - .size_g = ARRAY_SIZE(pattern_green), 124 - }, 125 - }; 126 - 127 - static struct lp5521_platform_data lp5521_platform_data = { 128 - .led_config = lp5521_led_config, 129 - .num_channels = ARRAY_SIZE(lp5521_led_config), 130 - .clock_mode = LP5521_CLOCK_EXT, 131 - .patterns = board_led_patterns, 132 - .num_patterns = ARRAY_SIZE(board_led_patterns), 133 - }; 134 - 135 - Then predefined led pattern(s) can be executed via the sysfs. 136 - To start the pattern #1, 137 - # echo 1 > /sys/bus/i2c/devices/xxxx/led_pattern 138 - (xxxx : i2c bus & slave address) 139 - To end the pattern, 140 - # echo 0 > /sys/bus/i2c/devices/xxxx/led_pattern
+5 -22
Documentation/leds/leds-lp5523.txt
··· 27 27 If both fields are NULL, 'lp5523' is used by default. 28 28 /sys/class/leds/lp5523:channelN (N: 0 ~ 8) 29 29 30 - The chip provides 3 engines. Each engine can control channels without 31 - interaction from the main CPU. Details of the micro engine code can be found 32 - from the public data sheet. Leds can be muxed to different channels. 33 - 34 - Control interface for the engines: 35 - x is 1 .. 3 36 - enginex_mode : disabled, load, run 37 - enginex_load : microcode load (visible only in load mode) 38 - enginex_leds : led mux control (visible only in load mode) 39 - 40 - cd /sys/class/leds/lp5523:channel2/device 41 - echo "load" > engine3_mode 42 - echo "9d80400004ff05ff437f0000" > engine3_load 43 - echo "111111111" > engine3_leds 44 - echo "run" > engine3_mode 45 - 46 - sysfs contains a selftest entry. It measures each channel 47 - voltage level and checks if it looks reasonable. If the level is too high, 48 - the led is missing; if the level is too low, there is a short circuit. 30 + LP5523 has the internal program memory for running various LED patterns. 31 + For the details, please refer to 'firmware' section in leds-lp55xx.txt 49 32 50 33 Selftest uses always the current from the platform data. 51 34 ··· 41 58 42 59 Note - chan_nr can have values between 0 and 8. 43 60 44 - static struct lp5523_led_config lp5523_led_config[] = { 61 + static struct lp55xx_led_config lp5523_led_config[] = { 45 62 { 46 63 .name = "D1", 47 64 .chan_nr = 0, ··· 71 88 /* Control chip enable signal */ 72 89 } 73 90 74 - static struct lp5523_platform_data lp5523_platform_data = { 91 + static struct lp55xx_platform_data lp5523_platform_data = { 75 92 .led_config = lp5523_led_config, 76 93 .num_channels = ARRAY_SIZE(lp5523_led_config), 77 - .clock_mode = LP5523_CLOCK_EXT, 94 + .clock_mode = LP55XX_CLOCK_EXT, 78 95 .setup_resources = lp5523_setup, 79 96 .release_resources = lp5523_release, 80 97 .enable = lp5523_enable,
+118
Documentation/leds/leds-lp55xx.txt
··· 1 + LP5521/LP5523/LP55231 Common Driver 2 + =================================== 3 + 4 + Authors: Milo(Woogyom) Kim <milo.kim@ti.com> 5 + 6 + Description 7 + ----------- 8 + LP5521, LP5523/55231 have common features as below. 9 + 10 + Register access via the I2C 11 + Device initialization/deinitialization 12 + Create LED class devices for multiple output channels 13 + Device attributes for user-space interface 14 + Program memory for running LED patterns 15 + 16 + The LP55xx common driver provides these features using exported functions. 17 + lp55xx_init_device() / lp55xx_deinit_device() 18 + lp55xx_register_leds() / lp55xx_unregister_leds() 19 + lp55xx_regsister_sysfs() / lp55xx_unregister_sysfs() 20 + 21 + ( Driver Structure Data ) 22 + 23 + In lp55xx common driver, two different data structure is used. 24 + 25 + o lp55xx_led 26 + control multi output LED channels such as led current, channel index. 27 + o lp55xx_chip 28 + general chip control such like the I2C and platform data. 29 + 30 + For example, LP5521 has maximum 3 LED channels. 31 + LP5523/55231 has 9 output channels. 32 + 33 + lp55xx_chip for LP5521 ... lp55xx_led #1 34 + lp55xx_led #2 35 + lp55xx_led #3 36 + 37 + lp55xx_chip for LP5523 ... lp55xx_led #1 38 + lp55xx_led #2 39 + . 40 + . 41 + lp55xx_led #9 42 + 43 + ( Chip Dependent Code ) 44 + 45 + To support device specific configurations, special structure 46 + 'lpxx_device_config' is used. 47 + 48 + Maximum number of channels 49 + Reset command, chip enable command 50 + Chip specific initialization 51 + Brightness control register access 52 + Setting LED output current 53 + Program memory address access for running patterns 54 + Additional device specific attributes 55 + 56 + ( Firmware Interface ) 57 + 58 + LP55xx family devices have the internal program memory for running 59 + various LED patterns. 60 + This pattern data is saved as a file in the user-land or 61 + hex byte string is written into the memory through the I2C. 62 + LP55xx common driver supports the firmware interface. 63 + 64 + LP55xx chips have three program engines. 65 + To load and run the pattern, the programming sequence is following. 66 + (1) Select an engine number (1/2/3) 67 + (2) Mode change to load 68 + (3) Write pattern data into selected area 69 + (4) Mode change to run 70 + 71 + The LP55xx common driver provides simple interfaces as below. 72 + select_engine : Select which engine is used for running program 73 + run_engine : Start program which is loaded via the firmware interface 74 + firmware : Load program data 75 + 76 + For example, run blinking pattern in engine #1 of LP5521 77 + echo 1 > /sys/bus/i2c/devices/xxxx/select_engine 78 + echo 1 > /sys/class/firmware/lp5521/loading 79 + echo "4000600040FF6000" > /sys/class/firmware/lp5521/data 80 + echo 0 > /sys/class/firmware/lp5521/loading 81 + echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 82 + 83 + For example, run blinking pattern in engine #3 of LP55231 84 + echo 3 > /sys/bus/i2c/devices/xxxx/select_engine 85 + echo 1 > /sys/class/firmware/lp55231/loading 86 + echo "9d0740ff7e0040007e00a0010000" > /sys/class/firmware/lp55231/data 87 + echo 0 > /sys/class/firmware/lp55231/loading 88 + echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 89 + 90 + To start blinking patterns in engine #2 and #3 simultaneously, 91 + for idx in 2 3 92 + do 93 + echo $idx > /sys/class/leds/red/device/select_engine 94 + sleep 0.1 95 + echo 1 > /sys/class/firmware/lp5521/loading 96 + echo "4000600040FF6000" > /sys/class/firmware/lp5521/data 97 + echo 0 > /sys/class/firmware/lp5521/loading 98 + done 99 + echo 1 > /sys/class/leds/red/device/run_engine 100 + 101 + Here is another example for LP5523. 102 + echo 2 > /sys/bus/i2c/devices/xxxx/select_engine 103 + echo 1 > /sys/class/firmware/lp5523/loading 104 + echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data 105 + echo 0 > /sys/class/firmware/lp5523/loading 106 + echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 107 + 108 + As soon as 'loading' is set to 0, registered callback is called. 109 + Inside the callback, the selected engine is loaded and memory is updated. 110 + To run programmed pattern, 'run_engine' attribute should be enabled. 111 + 112 + ( 'run_engine' and 'firmware_cb' ) 113 + The sequence of running the program data is common. 114 + But each device has own specific register addresses for commands. 115 + To support this, 'run_engine' and 'firmware_cb' are configurable in each driver. 116 + run_engine : Control the selected engine 117 + firmware_cb : The callback function after loading the firmware is done. 118 + Chip specific commands for loading and updating program memory.