diff options
author | Haojian Zhuang <haojian.zhuang@gmail.com> | 2012-09-21 06:06:52 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-10-02 05:43:13 -0400 |
commit | 2e57d56747e601b3e0ff6697e524025d0504d161 (patch) | |
tree | 29a7c677878d39f64e90dfbdf7063a11c08d4c15 /drivers/video | |
parent | 837c8293ba24d08cd7438d82ad9bb8d2fb0f8a5b (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/video')
-rw-r--r-- | drivers/video/backlight/88pm860x_bl.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c index 965161cacefa..b7ec34c57f46 100644 --- a/drivers/video/backlight/88pm860x_bl.c +++ b/drivers/video/backlight/88pm860x_bl.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/of.h> | ||
14 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
15 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
16 | #include <linux/fb.h> | 17 | #include <linux/fb.h> |
@@ -159,6 +160,36 @@ static const struct backlight_ops pm860x_backlight_ops = { | |||
159 | .get_brightness = pm860x_backlight_get_brightness, | 160 | .get_brightness = pm860x_backlight_get_brightness, |
160 | }; | 161 | }; |
161 | 162 | ||
163 | #ifdef CONFIG_OF | ||
164 | static int pm860x_backlight_dt_init(struct platform_device *pdev, | ||
165 | struct pm860x_backlight_data *data, | ||
166 | char *name) | ||
167 | { | ||
168 | struct device_node *nproot = pdev->dev.parent->of_node, *np; | ||
169 | int iset = 0; | ||
170 | if (!nproot) | ||
171 | return -ENODEV; | ||
172 | nproot = of_find_node_by_name(nproot, "backlights"); | ||
173 | if (!nproot) { | ||
174 | dev_err(&pdev->dev, "failed to find backlights node\n"); | ||
175 | return -ENODEV; | ||
176 | } | ||
177 | for_each_child_of_node(nproot, np) { | ||
178 | if (!of_node_cmp(np->name, name)) { | ||
179 | of_property_read_u32(np, "marvell,88pm860x-iset", | ||
180 | &iset); | ||
181 | data->iset = PM8606_WLED_CURRENT(iset); | ||
182 | of_property_read_u32(np, "marvell,88pm860x-pwm", | ||
183 | &data->pwm); | ||
184 | break; | ||
185 | } | ||
186 | } | ||
187 | return 0; | ||
188 | } | ||
189 | #else | ||
190 | #define pm860x_backlight_dt_init(x, y, z) (-1) | ||
191 | #endif | ||
192 | |||
162 | static int pm860x_backlight_probe(struct platform_device *pdev) | 193 | static int pm860x_backlight_probe(struct platform_device *pdev) |
163 | { | 194 | { |
164 | struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); | 195 | struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); |
@@ -203,9 +234,11 @@ static int pm860x_backlight_probe(struct platform_device *pdev) | |||
203 | data->i2c = (chip->id == CHIP_PM8606) ? chip->client \ | 234 | data->i2c = (chip->id == CHIP_PM8606) ? chip->client \ |
204 | : chip->companion; | 235 | : chip->companion; |
205 | data->current_brightness = MAX_BRIGHTNESS; | 236 | data->current_brightness = MAX_BRIGHTNESS; |
206 | if (pdata) { | 237 | if (pm860x_backlight_dt_init(pdev, data, name)) { |
207 | data->pwm = pdata->pwm; | 238 | if (pdata) { |
208 | data->iset = pdata->iset; | 239 | data->pwm = pdata->pwm; |
240 | data->iset = pdata->iset; | ||
241 | } | ||
209 | } | 242 | } |
210 | 243 | ||
211 | memset(&props, 0, sizeof(struct backlight_properties)); | 244 | memset(&props, 0, sizeof(struct backlight_properties)); |