aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-10-31 22:41:20 -0400
committerBryan Wu <cooloney@gmail.com>2014-01-27 20:28:46 -0500
commit10ead6e59934be76b6ce255d6b842a432b207b7f (patch)
treeaab76e123d6cda1cc9b3a484a3bdbf039e639c2c
parent9334129e8e956edfd51da37d5e5278478235c7b2 (diff)
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>
-rw-r--r--Documentation/devicetree/bindings/leds/tca6507.txt16
-rw-r--r--drivers/leds/leds-tca6507.c6
2 files changed, 22 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/leds/tca6507.txt b/Documentation/devicetree/bindings/leds/tca6507.txt
index 80ff3dfb1f32..d7221b84987c 100644
--- a/Documentation/devicetree/bindings/leds/tca6507.txt
+++ b/Documentation/devicetree/bindings/leds/tca6507.txt
@@ -2,6 +2,13 @@ LEDs connected to tca6507
2 2
3Required properties: 3Required properties:
4- compatible : should be : "ti,tca6507". 4- compatible : should be : "ti,tca6507".
5- #address-cells: must be 1
6- #size-cells: must be 0
7- reg: typically 0x45.
8
9Optional properties:
10- gpio-controller: allows lines to be used as output-only GPIOs.
11- #gpio-cells: if present, must be 0.
5 12
6Each led is represented as a sub-node of the ti,tca6507 device. 13Each led is represented as a sub-node of the ti,tca6507 device.
7 14
@@ -10,6 +17,7 @@ LED sub-node properties:
10- reg : number of LED line (could be from 0 to 6) 17- reg : number of LED line (could be from 0 to 6)
11- linux,default-trigger : (optional) 18- linux,default-trigger : (optional)
12 see Documentation/devicetree/bindings/leds/common.txt 19 see Documentation/devicetree/bindings/leds/common.txt
20- compatible: either "led" (the default) or "gpio".
13 21
14Examples: 22Examples:
15 23
@@ -19,6 +27,9 @@ tca6507@45 {
19 #size-cells = <0>; 27 #size-cells = <0>;
20 reg = <0x45>; 28 reg = <0x45>;
21 29
30 gpio-controller;
31 #gpio-cells = <2>;
32
22 led0: red-aux@0 { 33 led0: red-aux@0 {
23 label = "red:aux"; 34 label = "red:aux";
24 reg = <0x0>; 35 reg = <0x0>;
@@ -29,5 +40,10 @@ tca6507@45 {
29 reg = <0x5>; 40 reg = <0x5>;
30 linux,default-trigger = "default-on"; 41 linux,default-trigger = "default-on";
31 }; 42 };
43
44 wifi-reset@6 {
45 reg = <0x6>;
46 compatible = "gpio";
47 };
32}; 48};
33 49
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,
638 tca->gpio.direction_output = tca6507_gpio_direction_output; 638 tca->gpio.direction_output = tca6507_gpio_direction_output;
639 tca->gpio.set = tca6507_gpio_set_value; 639 tca->gpio.set = tca6507_gpio_set_value;
640 tca->gpio.dev = &client->dev; 640 tca->gpio.dev = &client->dev;
641#ifdef CONFIG_OF_GPIO
642 tca->gpio.of_node = of_node_get(client->dev.of_node);
643#endif
641 err = gpiochip_add(&tca->gpio); 644 err = gpiochip_add(&tca->gpio);
642 if (err) { 645 if (err) {
643 tca->gpio.ngpio = 0; 646 tca->gpio.ngpio = 0;
@@ -696,6 +699,8 @@ tca6507_led_dt_init(struct i2c_client *client)
696 led.default_trigger = 699 led.default_trigger =
697 of_get_property(child, "linux,default-trigger", NULL); 700 of_get_property(child, "linux,default-trigger", NULL);
698 led.flags = 0; 701 led.flags = 0;
702 if (of_property_match_string(child, "compatible", "gpio") >= 0)
703 led.flags |= TCA6507_MAKE_GPIO;
699 ret = of_property_read_u32(child, "reg", &reg); 704 ret = of_property_read_u32(child, "reg", &reg);
700 if (ret != 0 || reg < 0 || reg >= NUM_LEDS) 705 if (ret != 0 || reg < 0 || reg >= NUM_LEDS)
701 continue; 706 continue;
@@ -709,6 +714,7 @@ tca6507_led_dt_init(struct i2c_client *client)
709 714
710 pdata->leds.leds = tca_leds; 715 pdata->leds.leds = tca_leds;
711 pdata->leds.num_leds = NUM_LEDS; 716 pdata->leds.num_leds = NUM_LEDS;
717 pdata->gpio_base = -1;
712 718
713 return pdata; 719 return pdata;
714} 720}