Skip to content

Commit

Permalink
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/cooloney/linux-leds

Pull LED subsystem update from Bryan Wu:
 "Basically this cycle is mostly cleanup for LED subsystem"

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds:
  leds: s3c24xx: Remove hardware.h inclusion
  leds: replace list_for_each with list_for_each_entry
  leds: kirkwood: Cleanup in header files
  leds: pwm: Remove a warning on non-DT platforms
  leds: leds-pwm: fix duty time overflow.
  leds: leds-mc13783: Remove unneeded mc13xxx_{un}lock
  leds: leds-mc13783: Remove duplicate field in platform data
  drivers: leds: leds-tca6507: check CONFIG_GPIOLIB whether defined for 'gpio_base'
  leds: lp5523: Support LED MUX configuration on running a pattern
  leds: lp5521/5523: Fix multiple engine usage bug
  LEDS: tca6507 - fix up some comments.
  LEDS: tca6507: add device-tree support for GPIO configuration.
  LEDS: tca6507 - fix bugs in parsing of device-tree configuration.
  • Loading branch information
Linus Torvalds committed Jan 29, 2014
2 parents 2ad48ee + 3cb6f44 commit 268943f
Show file tree
Hide file tree
Showing 14 changed files with 227 additions and 231 deletions.
16 changes: 16 additions & 0 deletions Documentation/devicetree/bindings/leds/tca6507.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ LEDs connected to tca6507

Required properties:
- compatible : should be : "ti,tca6507".
- #address-cells: must be 1
- #size-cells: must be 0
- reg: typically 0x45.

Optional properties:
- gpio-controller: allows lines to be used as output-only GPIOs.
- #gpio-cells: if present, must be 0.

Each led is represented as a sub-node of the ti,tca6507 device.

Expand All @@ -10,6 +17,7 @@ LED sub-node properties:
- reg : number of LED line (could be from 0 to 6)
- linux,default-trigger : (optional)
see Documentation/devicetree/bindings/leds/common.txt
- compatible: either "led" (the default) or "gpio".

Examples:

Expand All @@ -19,6 +27,9 @@ tca6507@45 {
#size-cells = <0>;
reg = <0x45>;

gpio-controller;
#gpio-cells = <2>;

led0: red-aux@0 {
label = "red:aux";
reg = <0x0>;
Expand All @@ -29,5 +40,10 @@ tca6507@45 {
reg = <0x5>;
linux,default-trigger = "default-on";
};

wifi-reset@6 {
reg = <0x6>;
compatible = "gpio";
};
};

10 changes: 9 additions & 1 deletion Documentation/leds/leds-lp55xx.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ select_engine : Select which engine is used for running program
run_engine : Start program which is loaded via the firmware interface
firmware : Load program data

In case of LP5523, one more command is required, 'enginex_leds'.
It is used for selecting LED output(s) at each engine number.
In more details, please refer to 'leds-lp5523.txt'.

For example, run blinking pattern in engine #1 of LP5521
echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
echo 1 > /sys/class/firmware/lp5521/loading
Expand All @@ -81,10 +85,12 @@ echo 0 > /sys/class/firmware/lp5521/loading
echo 1 > /sys/bus/i2c/devices/xxxx/run_engine

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

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

Here is another example for LP5523.
Full LED strings are selected by 'engine2_leds'.
echo 2 > /sys/bus/i2c/devices/xxxx/select_engine
echo 1 > /sys/class/firmware/lp5523/loading
echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data
echo 0 > /sys/class/firmware/lp5523/loading
echo "111111111" > /sys/bus/i2c/devices/xxxx/engine2_leds
echo 1 > /sys/bus/i2c/devices/xxxx/run_engine

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

The pattern sqeuence of LP8501 is same as LP5523.
The pattern sqeuence of LP8501 is similar to LP5523.
However pattern data is specific.
Ex 1) Engine 1 is used
echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
Expand Down
16 changes: 8 additions & 8 deletions arch/arm/mach-imx/mach-mx31moboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,32 +236,26 @@ static struct mc13xxx_led_platform_data moboard_led[] = {
{
.id = MC13783_LED_R1,
.name = "coreboard-led-4:red",
.max_current = 2,
},
{
.id = MC13783_LED_G1,
.name = "coreboard-led-4:green",
.max_current = 2,
},
{
.id = MC13783_LED_B1,
.name = "coreboard-led-4:blue",
.max_current = 2,
},
{
.id = MC13783_LED_R2,
.name = "coreboard-led-5:red",
.max_current = 3,
},
{
.id = MC13783_LED_G2,
.name = "coreboard-led-5:green",
.max_current = 3,
},
{
.id = MC13783_LED_B2,
.name = "coreboard-led-5:blue",
.max_current = 3,
},
};

Expand All @@ -271,8 +265,14 @@ static struct mc13xxx_leds_platform_data moboard_leds = {
.led_control[0] = MC13783_LED_C0_ENABLE | MC13783_LED_C0_ABMODE(0),
.led_control[1] = MC13783_LED_C1_SLEWLIM,
.led_control[2] = MC13783_LED_C2_SLEWLIM,
.led_control[3] = MC13783_LED_C3_PERIOD(0),
.led_control[4] = MC13783_LED_C3_PERIOD(0),
.led_control[3] = MC13783_LED_C3_PERIOD(0) |
MC13783_LED_C3_CURRENT_R1(2) |
MC13783_LED_C3_CURRENT_G1(2) |
MC13783_LED_C3_CURRENT_B1(2),
.led_control[4] = MC13783_LED_C4_PERIOD(0) |
MC13783_LED_C4_CURRENT_R2(3) |
MC13783_LED_C4_CURRENT_G2(3) |
MC13783_LED_C4_CURRENT_B2(3),
};

static struct mc13xxx_buttons_platform_data moboard_buttons = {
Expand Down
15 changes: 4 additions & 11 deletions drivers/leds/led-triggers.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,14 @@ EXPORT_SYMBOL_GPL(led_trigger_unregister);
void led_trigger_event(struct led_trigger *trig,
enum led_brightness brightness)
{
struct list_head *entry;
struct led_classdev *led_cdev;

if (!trig)
return;

read_lock(&trig->leddev_list_lock);
list_for_each(entry, &trig->led_cdevs) {
struct led_classdev *led_cdev;

led_cdev = list_entry(entry, struct led_classdev, trig_list);
list_for_each_entry(led_cdev, &trig->led_cdevs, trig_list)
led_set_brightness(led_cdev, brightness);
}
read_unlock(&trig->leddev_list_lock);
}
EXPORT_SYMBOL_GPL(led_trigger_event);
Expand All @@ -264,16 +260,13 @@ static void led_trigger_blink_setup(struct led_trigger *trig,
int oneshot,
int invert)
{
struct list_head *entry;
struct led_classdev *led_cdev;

if (!trig)
return;

read_lock(&trig->leddev_list_lock);
list_for_each(entry, &trig->led_cdevs) {
struct led_classdev *led_cdev;

led_cdev = list_entry(entry, struct led_classdev, trig_list);
list_for_each_entry(led_cdev, &trig->led_cdevs, trig_list) {
if (oneshot)
led_blink_set_oneshot(led_cdev, delay_on, delay_off,
invert);
Expand Down
18 changes: 16 additions & 2 deletions drivers/leds/leds-lp5521.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,26 @@ static void lp5521_load_engine(struct lp55xx_chip *chip)
lp5521_wait_opmode_done();
}

static void lp5521_stop_engine(struct lp55xx_chip *chip)
static void lp5521_stop_all_engines(struct lp55xx_chip *chip)
{
lp55xx_write(chip, LP5521_REG_OP_MODE, 0);
lp5521_wait_opmode_done();
}

static void lp5521_stop_engine(struct lp55xx_chip *chip)
{
enum lp55xx_engine_index idx = chip->engine_idx;
u8 mask[] = {
[LP55XX_ENGINE_1] = LP5521_MODE_R_M,
[LP55XX_ENGINE_2] = LP5521_MODE_G_M,
[LP55XX_ENGINE_3] = LP5521_MODE_B_M,
};

lp55xx_update_bits(chip, LP5521_REG_OP_MODE, mask[idx], 0);

lp5521_wait_opmode_done();
}

static void lp5521_run_engine(struct lp55xx_chip *chip, bool start)
{
int ret;
Expand Down Expand Up @@ -564,7 +578,7 @@ static int lp5521_remove(struct i2c_client *client)
struct lp55xx_led *led = i2c_get_clientdata(client);
struct lp55xx_chip *chip = led->chip;

lp5521_stop_engine(chip);
lp5521_stop_all_engines(chip);
lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip);
Expand Down
20 changes: 17 additions & 3 deletions drivers/leds/leds-lp5523.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,26 @@ static void lp5523_load_engine_and_select_page(struct lp55xx_chip *chip)
lp55xx_write(chip, LP5523_REG_PROG_PAGE_SEL, page_sel[idx]);
}

static void lp5523_stop_engine(struct lp55xx_chip *chip)
static void lp5523_stop_all_engines(struct lp55xx_chip *chip)
{
lp55xx_write(chip, LP5523_REG_OP_MODE, 0);
lp5523_wait_opmode_done();
}

static void lp5523_stop_engine(struct lp55xx_chip *chip)
{
enum lp55xx_engine_index idx = chip->engine_idx;
u8 mask[] = {
[LP55XX_ENGINE_1] = LP5523_MODE_ENG1_M,
[LP55XX_ENGINE_2] = LP5523_MODE_ENG2_M,
[LP55XX_ENGINE_3] = LP5523_MODE_ENG3_M,
};

lp55xx_update_bits(chip, LP5523_REG_OP_MODE, mask[idx], 0);

lp5523_wait_opmode_done();
}

static void lp5523_turn_off_channels(struct lp55xx_chip *chip)
{
int i;
Expand Down Expand Up @@ -311,7 +325,7 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip)
}

out:
lp5523_stop_engine(chip);
lp5523_stop_all_engines(chip);
return ret;
}

Expand Down Expand Up @@ -782,7 +796,7 @@ static int lp5523_remove(struct i2c_client *client)
struct lp55xx_led *led = i2c_get_clientdata(client);
struct lp55xx_chip *chip = led->chip;

lp5523_stop_engine(chip);
lp5523_stop_all_engines(chip);
lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip);
Expand Down
2 changes: 2 additions & 0 deletions drivers/leds/leds-lp55xx-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context)
{
struct lp55xx_chip *chip = context;
struct device *dev = &chip->cl->dev;
enum lp55xx_engine_index idx = chip->engine_idx;

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

chip->engines[idx - 1].mode = LP55XX_ENGINE_LOAD;
chip->fw = fw;
if (chip->cfg->firmware_cb)
chip->cfg->firmware_cb(chip);
Expand Down
Loading

0 comments on commit 268943f

Please sign in to comment.