summaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-10-31 19:41:20 -0700
committerBryan Wu <cooloney@gmail.com>2014-01-27 17:28:46 -0800
commit10ead6e59934be76b6ce255d6b842a432b207b7f (patch)
treeaab76e123d6cda1cc9b3a484a3bdbf039e639c2c /drivers/leds
parent9334129e8e956edfd51da37d5e5278478235c7b2 (diff)
downloadlinux-10ead6e59934be76b6ce255d6b842a432b207b7f.tar.bz2
LEDS: tca6507: add device-tree support for GPIO configuration.
The 7 lines driven by the TCA6507 can either drive LEDs or act as output-only GPIOs. To make this distinction in devicetree we use the "compatible" property. If the device attached to a line is "compatible" with "gpio", we treat it like a GPIO. If it is "compatible" with "led" (or if no "compatible" value is set) we treat it like an LED. (cooloney@gmail.com: fix typo in the subject) Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-tca6507.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index f5063f447463..93a2b1759054 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -638,6 +638,9 @@ static int tca6507_probe_gpios(struct i2c_client *client,
tca->gpio.direction_output = tca6507_gpio_direction_output;
tca->gpio.set = tca6507_gpio_set_value;
tca->gpio.dev = &client->dev;
+#ifdef CONFIG_OF_GPIO
+ tca->gpio.of_node = of_node_get(client->dev.of_node);
+#endif
err = gpiochip_add(&tca->gpio);
if (err) {
tca->gpio.ngpio = 0;
@@ -696,6 +699,8 @@ tca6507_led_dt_init(struct i2c_client *client)
led.default_trigger =
of_get_property(child, "linux,default-trigger", NULL);
led.flags = 0;
+ if (of_property_match_string(child, "compatible", "gpio") >= 0)
+ led.flags |= TCA6507_MAKE_GPIO;
ret = of_property_read_u32(child, "reg", &reg);
if (ret != 0 || reg < 0 || reg >= NUM_LEDS)
continue;
@@ -709,6 +714,7 @@ tca6507_led_dt_init(struct i2c_client *client)
pdata->leds.leds = tca_leds;
pdata->leds.num_leds = NUM_LEDS;
+ pdata->gpio_base = -1;
return pdata;
}