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 changes from Bryan Wu:
 "LED subsystem updates for 3.13 are basically cleanup and also add a
  new driver for PCA9685"

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds:
  leds: lp55xx: handle enable pin in driver
  leds-gpio: of: led should not be created if its status is disabled
  of: introduce of_get_available_child_count
  leds: Added driver for the NXP PCA9685 I2C chip
  leds: pwm: Remove redundant of_match_ptr
  leds: Include linux/of.h header
  leds: dac124s085: Remove redundant spi_set_drvdata
  leds: lp55xx: enable setting default trigger
  leds: blinkm: Remove redundant break
  • Loading branch information
Linus Torvalds committed Nov 12, 2013
2 parents 2b684c0 + 30dae2f commit 85b656c
Show file tree
Hide file tree
Showing 17 changed files with 312 additions and 48 deletions.
11 changes: 8 additions & 3 deletions Documentation/devicetree/bindings/leds/leds-lp55xx.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ Each child has own specific current settings
- max-cur: Maximun current at each led channel.

Optional properties:
- enable-gpio: GPIO attached to the chip's enable pin
- label: Used for naming LEDs
- pwr-sel: LP8501 specific property. Power selection for output channels.
0: D1~9 are connected to VDD
1: D1~6 with VDD, D7~9 with VOUT
2: D1~6 with VOUT, D7~9 with VDD
3: D1~9 are connected to VOUT

Alternatively, each child can have specific channel name
- chan-name: Name of each channel name
Alternatively, each child can have a specific channel name and trigger:
- chan-name (optional): name of channel
- linux,default-trigger (optional): see
Documentation/devicetree/bindings/leds/common.txt

example 1) LP5521
3 LED channels, external clock used. Channel names are 'lp5521_pri:channel0',
'lp5521_pri:channel1' and 'lp5521_pri:channel2'
'lp5521_pri:channel1' and 'lp5521_pri:channel2', with a heartbeat trigger
on channel 0.

lp5521@32 {
compatible = "national,lp5521";
Expand All @@ -33,6 +37,7 @@ lp5521@32 {
chan0 {
led-cur = /bits/ 8 <0x2f>;
max-cur = /bits/ 8 <0x5f>;
linux,default-trigger = "heartbeat";
};

chan1 {
Expand Down
20 changes: 1 addition & 19 deletions arch/arm/mach-omap2/board-rx51-peripherals.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,29 +213,11 @@ static struct lp55xx_led_config rx51_lp5523_led_config[] = {
}
};

static int rx51_lp5523_setup(void)
{
return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
"lp5523_enable");
}

static void rx51_lp5523_release(void)
{
gpio_free(RX51_LP5523_CHIP_EN_GPIO);
}

static void rx51_lp5523_enable(bool state)
{
gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, !!state);
}

static struct lp55xx_platform_data rx51_lp5523_platform_data = {
.led_config = rx51_lp5523_led_config,
.num_channels = ARRAY_SIZE(rx51_lp5523_led_config),
.clock_mode = LP55XX_CLOCK_AUTO,
.setup_resources = rx51_lp5523_setup,
.release_resources = rx51_lp5523_release,
.enable = rx51_lp5523_enable,
.enable_gpio = RX51_LP5523_CHIP_EN_GPIO,
};
#endif

Expand Down
10 changes: 10 additions & 0 deletions drivers/leds/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@ config LEDS_PCA963X
LED driver chip accessed via the I2C bus. Supported
devices include PCA9633 and PCA9634

config LEDS_PCA9685
tristate "LED support for PCA9685 I2C chip"
depends on LEDS_CLASS
depends on I2C
help
This option enables support for LEDs connected to the PCA9685
LED driver chip accessed via the I2C bus.
The PCA9685 offers 12-bit PWM (4095 levels of brightness) on
16 individual channels.

config LEDS_WM831X_STATUS
tristate "LED support for status LEDs on WM831x PMICs"
depends on LEDS_CLASS
Expand Down
1 change: 1 addition & 0 deletions drivers/leds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ obj-$(CONFIG_LEDS_OT200) += leds-ot200.o
obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o
obj-$(CONFIG_LEDS_PCA963X) += leds-pca963x.o
obj-$(CONFIG_LEDS_PCA9685) += leds-pca9685.o
obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o
obj-$(CONFIG_LEDS_DA9052) += leds-da9052.o
obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o
Expand Down
3 changes: 0 additions & 3 deletions drivers/leds/leds-blinkm.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,10 @@ static ssize_t show_color_common(struct device *dev, char *buf, int color)
switch (color) {
case RED:
return scnprintf(buf, PAGE_SIZE, "%02X\n", data->red);
break;
case GREEN:
return scnprintf(buf, PAGE_SIZE, "%02X\n", data->green);
break;
case BLUE:
return scnprintf(buf, PAGE_SIZE, "%02X\n", data->blue);
break;
default:
return -EINVAL;
}
Expand Down
3 changes: 0 additions & 3 deletions drivers/leds/leds-dac124s085.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ static int dac124s085_probe(struct spi_device *spi)
while (i--)
led_classdev_unregister(&dac->leds[i].ldev);

spi_set_drvdata(spi, NULL);
return ret;
}

Expand All @@ -115,8 +114,6 @@ static int dac124s085_remove(struct spi_device *spi)
cancel_work_sync(&dac->leds[i].work);
}

spi_set_drvdata(spi, NULL);

return 0;
}

Expand Down
7 changes: 4 additions & 3 deletions drivers/leds/leds-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/leds.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/of_gpio.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -170,11 +171,11 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
int count, ret;

/* count LEDs in this device, so we know how much to allocate */
count = of_get_child_count(np);
count = of_get_available_child_count(np);
if (!count)
return ERR_PTR(-ENODEV);

for_each_child_of_node(np, child)
for_each_available_child_of_node(np, child)
if (of_get_gpio(child, 0) == -EPROBE_DEFER)
return ERR_PTR(-EPROBE_DEFER);

Expand All @@ -183,7 +184,7 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
if (!priv)
return ERR_PTR(-ENOMEM);

for_each_child_of_node(np, child) {
for_each_available_child_of_node(np, child) {
struct gpio_led led = {};
enum of_gpio_flags flags;
const char *state;
Expand Down
1 change: 1 addition & 0 deletions drivers/leds/leds-lp5523.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/platform_data/leds-lp55xx.h>
#include <linux/slab.h>

Expand Down
1 change: 1 addition & 0 deletions drivers/leds/leds-lp5562.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/platform_data/leds-lp55xx.h>
#include <linux/slab.h>

Expand Down
28 changes: 16 additions & 12 deletions drivers/leds/leds-lp55xx-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <linux/module.h>
#include <linux/platform_data/leds-lp55xx.h>
#include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>

#include "leds-lp55xx-common.h"

Expand Down Expand Up @@ -165,6 +167,7 @@ static int lp55xx_init_led(struct lp55xx_led *led,
led->led_current = pdata->led_config[chan].led_current;
led->max_current = pdata->led_config[chan].max_current;
led->chan_nr = pdata->led_config[chan].chan_nr;
led->cdev.default_trigger = pdata->led_config[chan].default_trigger;

if (led->chan_nr >= max_channel) {
dev_err(dev, "Use channel numbers between 0 and %d\n",
Expand Down Expand Up @@ -406,18 +409,18 @@ int lp55xx_init_device(struct lp55xx_chip *chip)
if (!pdata || !cfg)
return -EINVAL;

if (pdata->setup_resources) {
ret = pdata->setup_resources();
if (gpio_is_valid(pdata->enable_gpio)) {
ret = devm_gpio_request_one(dev, pdata->enable_gpio,
GPIOF_DIR_OUT, "lp5523_enable");
if (ret < 0) {
dev_err(dev, "setup resoure err: %d\n", ret);
dev_err(dev, "could not acquire enable gpio (err=%d)\n",
ret);
goto err;
}
}

if (pdata->enable) {
pdata->enable(0);
gpio_set_value(pdata->enable_gpio, 0);
usleep_range(1000, 2000); /* Keep enable down at least 1ms */
pdata->enable(1);
gpio_set_value(pdata->enable_gpio, 1);
usleep_range(1000, 2000); /* 500us abs min. */
}

Expand Down Expand Up @@ -458,11 +461,8 @@ void lp55xx_deinit_device(struct lp55xx_chip *chip)
if (chip->clk)
clk_disable_unprepare(chip->clk);

if (pdata->enable)
pdata->enable(0);

if (pdata->release_resources)
pdata->release_resources();
if (gpio_is_valid(pdata->enable_gpio))
gpio_set_value(pdata->enable_gpio, 0);
}
EXPORT_SYMBOL_GPL(lp55xx_deinit_device);

Expand Down Expand Up @@ -586,13 +586,17 @@ int lp55xx_of_populate_pdata(struct device *dev, struct device_node *np)
of_property_read_string(child, "chan-name", &cfg[i].name);
of_property_read_u8(child, "led-cur", &cfg[i].led_current);
of_property_read_u8(child, "max-cur", &cfg[i].max_current);
cfg[i].default_trigger =
of_get_property(child, "linux,default-trigger", NULL);

i++;
}

of_property_read_string(np, "label", &pdata->label);
of_property_read_u8(np, "clock-mode", &pdata->clock_mode);

pdata->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0);

/* LP8501 specific */
of_property_read_u8(np, "pwr-sel", (u8 *)&pdata->pwr_sel);

Expand Down
1 change: 1 addition & 0 deletions drivers/leds/leds-lp8501.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/platform_data/leds-lp55xx.h>
#include <linux/slab.h>

Expand Down
1 change: 1 addition & 0 deletions drivers/leds/leds-ns2.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/platform_data/leds-kirkwood-ns2.h>
#include <linux/of.h>
#include <linux/of_gpio.h>

/*
Expand Down
Loading

0 comments on commit 85b656c

Please sign in to comment.