aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-88pm860x.c
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@gmail.com>2012-09-21 06:06:52 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-10-02 05:43:13 -0400
commit2e57d56747e601b3e0ff6697e524025d0504d161 (patch)
tree29a7c677878d39f64e90dfbdf7063a11c08d4c15 /drivers/leds/leds-88pm860x.c
parent837c8293ba24d08cd7438d82ad9bb8d2fb0f8a5b (diff)
mfd: 88pm860x: Device tree support
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/leds/leds-88pm860x.c')
-rw-r--r--drivers/leds/leds-88pm860x.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c
index 70232b1756f9..b7e8cc0957fc 100644
--- a/drivers/leds/leds-88pm860x.c
+++ b/drivers/leds/leds-88pm860x.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/of.h>
15#include <linux/platform_device.h> 16#include <linux/platform_device.h>
16#include <linux/i2c.h> 17#include <linux/i2c.h>
17#include <linux/leds.h> 18#include <linux/leds.h>
@@ -123,6 +124,33 @@ static void pm860x_led_set(struct led_classdev *cdev,
123 schedule_work(&data->work); 124 schedule_work(&data->work);
124} 125}
125 126
127#ifdef CONFIG_OF
128static int pm860x_led_dt_init(struct platform_device *pdev,
129 struct pm860x_led *data)
130{
131 struct device_node *nproot = pdev->dev.parent->of_node, *np;
132 int iset = 0;
133 if (!nproot)
134 return -ENODEV;
135 nproot = of_find_node_by_name(nproot, "leds");
136 if (!nproot) {
137 dev_err(&pdev->dev, "failed to find leds node\n");
138 return -ENODEV;
139 }
140 for_each_child_of_node(nproot, np) {
141 if (!of_node_cmp(np->name, data->name)) {
142 of_property_read_u32(np, "marvell,88pm860x-iset",
143 &iset);
144 data->iset = PM8606_LED_CURRENT(iset);
145 break;
146 }
147 }
148 return 0;
149}
150#else
151#define pm860x_led_dt_init(x, y) (-1)
152#endif
153
126static int pm860x_led_probe(struct platform_device *pdev) 154static int pm860x_led_probe(struct platform_device *pdev)
127{ 155{
128 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 156 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -179,8 +207,9 @@ static int pm860x_led_probe(struct platform_device *pdev)
179 data->chip = chip; 207 data->chip = chip;
180 data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; 208 data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion;
181 data->port = pdev->id; 209 data->port = pdev->id;
182 if (pdata && pdata->iset) 210 if (pm860x_led_dt_init(pdev, data))
183 data->iset = pdata->iset; 211 if (pdata)
212 data->iset = pdata->iset;
184 213
185 data->current_brightness = 0; 214 data->current_brightness = 0;
186 data->cdev.name = data->name; 215 data->cdev.name = data->name;