Skip to content

Commit 93ad8a1

Browse files
Milo Kimcooloney
authored andcommitted
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>
1 parent 28c9266 commit 93ad8a1

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎Documentation/leds/leds-lp55xx.txt‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ select_engine : Select which engine is used for running program
7373
run_engine : Start program which is loaded via the firmware interface
7474
firmware : Load program data
7575

76+
In case of LP5523, one more command is required, 'enginex_leds'.
77+
It is used for selecting LED output(s) at each engine number.
78+
In more details, please refer to 'leds-lp5523.txt'.
79+
7680
For example, run blinking pattern in engine #1 of LP5521
7781
echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
7882
echo 1 > /sys/class/firmware/lp5521/loading
@@ -81,10 +85,12 @@ echo 0 > /sys/class/firmware/lp5521/loading
8185
echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
8286

8387
For example, run blinking pattern in engine #3 of LP55231
88+
Two LEDs are configured as pattern output channels.
8489
echo 3 > /sys/bus/i2c/devices/xxxx/select_engine
8590
echo 1 > /sys/class/firmware/lp55231/loading
8691
echo "9d0740ff7e0040007e00a0010000" > /sys/class/firmware/lp55231/data
8792
echo 0 > /sys/class/firmware/lp55231/loading
93+
echo "000001100" > /sys/bus/i2c/devices/xxxx/engine3_leds
8894
echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
8995

9096
To start blinking patterns in engine #2 and #3 simultaneously,
@@ -99,17 +105,19 @@ done
99105
echo 1 > /sys/class/leds/red/device/run_engine
100106

101107
Here is another example for LP5523.
108+
Full LED strings are selected by 'engine2_leds'.
102109
echo 2 > /sys/bus/i2c/devices/xxxx/select_engine
103110
echo 1 > /sys/class/firmware/lp5523/loading
104111
echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data
105112
echo 0 > /sys/class/firmware/lp5523/loading
113+
echo "111111111" > /sys/bus/i2c/devices/xxxx/engine2_leds
106114
echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
107115

108116
As soon as 'loading' is set to 0, registered callback is called.
109117
Inside the callback, the selected engine is loaded and memory is updated.
110118
To run programmed pattern, 'run_engine' attribute should be enabled.
111119

112-
The pattern sqeuence of LP8501 is same as LP5523.
120+
The pattern sqeuence of LP8501 is similar to LP5523.
113121
However pattern data is specific.
114122
Ex 1) Engine 1 is used
115123
echo 1 > /sys/bus/i2c/devices/xxxx/select_engine

‎drivers/leds/leds-lp55xx-common.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)
210210
{
211211
struct lp55xx_chip *chip = context;
212212
struct device *dev = &chip->cl->dev;
213+
enum lp55xx_engine_index idx = chip->engine_idx;
213214

214215
if (!fw) {
215216
dev_err(dev, "firmware request failed\n");
@@ -219,6 +220,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)
219220
/* handling firmware data is chip dependent */
220221
mutex_lock(&chip->lock);
221222

223+
chip->engines[idx - 1].mode = LP55XX_ENGINE_LOAD;
222224
chip->fw = fw;
223225
if (chip->cfg->firmware_cb)
224226
chip->cfg->firmware_cb(chip);

0 commit comments

Comments
 (0)