aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilo Kim <milo.kim@ti.com>2013-11-21 01:14:34 -0500
committerBryan Wu <cooloney@gmail.com>2014-01-27 20:28:48 -0500
commit93ad8a1d59a35ef7b489a83552daee6506f47815 (patch)
tree06a2f03a7b613da719200780ff03e1c027ce5a90
parent28c9266b38a00a07497daad0237f7fa154652ece (diff)
leds: lp5523: Support LED MUX configuration on running a pattern
There are two ways to run a pattern in LP5523. One is using legacy sysfs files such as 'enginex_mode','enginex_load' and 'enginex_leds'. ('x' is from 1 to 3). Among them, 'enginex_leds' are used for selecting specific LED channel MUX. (MUX means which LEDs are used for running a pattern from LED 1 to 9.) The other way is using the firmware interface. In this mode, the default LED MUX strings are used. In other words, LED MUX is not configurable on the fly. This patch enables dynamic LED MUX configuration when the firmware is loaded. By accessing the sysfs file 'enginex_leds', the LED channels can be configured. To synchronize the operation mode, each engine mode should be set to 'LOAD'. The documentation is updated as well. Cc: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Milo Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
-rw-r--r--Documentation/leds/leds-lp55xx.txt10
-rw-r--r--drivers/leds/leds-lp55xx-common.c2
2 files changed, 11 insertions, 1 deletions
diff --git a/Documentation/leds/leds-lp55xx.txt b/Documentation/leds/leds-lp55xx.txt
index 82713ff92eb3..bcea12a0c584 100644
--- a/Documentation/leds/leds-lp55xx.txt
+++ b/Documentation/leds/leds-lp55xx.txt
@@ -73,6 +73,10 @@ select_engine : Select which engine is used for running program
73run_engine : Start program which is loaded via the firmware interface 73run_engine : Start program which is loaded via the firmware interface
74firmware : Load program data 74firmware : Load program data
75 75
76In case of LP5523, one more command is required, 'enginex_leds'.
77It is used for selecting LED output(s) at each engine number.
78In more details, please refer to 'leds-lp5523.txt'.
79
76For example, run blinking pattern in engine #1 of LP5521 80For example, run blinking pattern in engine #1 of LP5521
77echo 1 > /sys/bus/i2c/devices/xxxx/select_engine 81echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
78echo 1 > /sys/class/firmware/lp5521/loading 82echo 1 > /sys/class/firmware/lp5521/loading
@@ -81,10 +85,12 @@ echo 0 > /sys/class/firmware/lp5521/loading
81echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 85echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
82 86
83For example, run blinking pattern in engine #3 of LP55231 87For example, run blinking pattern in engine #3 of LP55231
88Two LEDs are configured as pattern output channels.
84echo 3 > /sys/bus/i2c/devices/xxxx/select_engine 89echo 3 > /sys/bus/i2c/devices/xxxx/select_engine
85echo 1 > /sys/class/firmware/lp55231/loading 90echo 1 > /sys/class/firmware/lp55231/loading
86echo "9d0740ff7e0040007e00a0010000" > /sys/class/firmware/lp55231/data 91echo "9d0740ff7e0040007e00a0010000" > /sys/class/firmware/lp55231/data
87echo 0 > /sys/class/firmware/lp55231/loading 92echo 0 > /sys/class/firmware/lp55231/loading
93echo "000001100" > /sys/bus/i2c/devices/xxxx/engine3_leds
88echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 94echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
89 95
90To start blinking patterns in engine #2 and #3 simultaneously, 96To start blinking patterns in engine #2 and #3 simultaneously,
@@ -99,17 +105,19 @@ done
99echo 1 > /sys/class/leds/red/device/run_engine 105echo 1 > /sys/class/leds/red/device/run_engine
100 106
101Here is another example for LP5523. 107Here is another example for LP5523.
108Full LED strings are selected by 'engine2_leds'.
102echo 2 > /sys/bus/i2c/devices/xxxx/select_engine 109echo 2 > /sys/bus/i2c/devices/xxxx/select_engine
103echo 1 > /sys/class/firmware/lp5523/loading 110echo 1 > /sys/class/firmware/lp5523/loading
104echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data 111echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data
105echo 0 > /sys/class/firmware/lp5523/loading 112echo 0 > /sys/class/firmware/lp5523/loading
113echo "111111111" > /sys/bus/i2c/devices/xxxx/engine2_leds
106echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 114echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
107 115
108As soon as 'loading' is set to 0, registered callback is called. 116As soon as 'loading' is set to 0, registered callback is called.
109Inside the callback, the selected engine is loaded and memory is updated. 117Inside the callback, the selected engine is loaded and memory is updated.
110To run programmed pattern, 'run_engine' attribute should be enabled. 118To run programmed pattern, 'run_engine' attribute should be enabled.
111 119
112The pattern sqeuence of LP8501 is same as LP5523. 120The pattern sqeuence of LP8501 is similar to LP5523.
113However pattern data is specific. 121However pattern data is specific.
114Ex 1) Engine 1 is used 122Ex 1) Engine 1 is used
115echo 1 > /sys/bus/i2c/devices/xxxx/select_engine 123echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
index 9acc6bb7deef..88317b4f7bf3 100644
--- a/drivers/leds/leds-lp55xx-common.c
+++ b/drivers/leds/leds-lp55xx-common.c
@@ -210,6 +210,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)
210{ 210{
211 struct lp55xx_chip *chip = context; 211 struct lp55xx_chip *chip = context;
212 struct device *dev = &chip->cl->dev; 212 struct device *dev = &chip->cl->dev;
213 enum lp55xx_engine_index idx = chip->engine_idx;
213 214
214 if (!fw) { 215 if (!fw) {
215 dev_err(dev, "firmware request failed\n"); 216 dev_err(dev, "firmware request failed\n");
@@ -219,6 +220,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)
219 /* handling firmware data is chip dependent */ 220 /* handling firmware data is chip dependent */
220 mutex_lock(&chip->lock); 221 mutex_lock(&chip->lock);
221 222
223 chip->engines[idx - 1].mode = LP55XX_ENGINE_LOAD;
222 chip->fw = fw; 224 chip->fw = fw;
223 if (chip->cfg->firmware_cb) 225 if (chip->cfg->firmware_cb)
224 chip->cfg->firmware_cb(chip); 226 chip->cfg->firmware_cb(chip);