diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2013-04-29 19:17:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:18 -0400 |
commit | 59eb2b5e57eaf0ae70b7d8d51b051cb754724a7a (patch) | |
tree | 2157003b541647c40e126851acf40b36de7d8e6c /drivers/video | |
parent | 514f920a4a37bce427ec4aab591619b158e29115 (diff) |
drivers/video/backlight/as3711_bl.c: add OF support
Add support for configuring AS3711 backlight driver from DT.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/backlight/as3711_bl.c | 118 |
1 files changed, 117 insertions, 1 deletions
diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c index 41d52fe52543..123887cd76bd 100644 --- a/drivers/video/backlight/as3711_bl.c +++ b/drivers/video/backlight/as3711_bl.c | |||
@@ -258,6 +258,109 @@ static int as3711_bl_register(struct platform_device *pdev, | |||
258 | return 0; | 258 | return 0; |
259 | } | 259 | } |
260 | 260 | ||
261 | static int as3711_backlight_parse_dt(struct device *dev) | ||
262 | { | ||
263 | struct as3711_bl_pdata *pdata = dev_get_platdata(dev); | ||
264 | struct device_node *bl = | ||
265 | of_find_node_by_name(dev->parent->of_node, "backlight"), *fb; | ||
266 | int ret; | ||
267 | |||
268 | if (!bl) { | ||
269 | dev_dbg(dev, "backlight node not found\n"); | ||
270 | return -ENODEV; | ||
271 | } | ||
272 | |||
273 | fb = of_parse_phandle(bl, "su1-dev", 0); | ||
274 | if (fb) { | ||
275 | pdata->su1_fb = fb->full_name; | ||
276 | |||
277 | ret = of_property_read_u32(bl, "su1-max-uA", &pdata->su1_max_uA); | ||
278 | if (pdata->su1_max_uA <= 0) | ||
279 | ret = -EINVAL; | ||
280 | if (ret < 0) | ||
281 | return ret; | ||
282 | } | ||
283 | |||
284 | fb = of_parse_phandle(bl, "su2-dev", 0); | ||
285 | if (fb) { | ||
286 | int count = 0; | ||
287 | |||
288 | pdata->su2_fb = fb->full_name; | ||
289 | |||
290 | ret = of_property_read_u32(bl, "su2-max-uA", &pdata->su2_max_uA); | ||
291 | if (pdata->su2_max_uA <= 0) | ||
292 | ret = -EINVAL; | ||
293 | if (ret < 0) | ||
294 | return ret; | ||
295 | |||
296 | if (of_find_property(bl, "su2-feedback-voltage", NULL)) { | ||
297 | pdata->su2_feedback = AS3711_SU2_VOLTAGE; | ||
298 | count++; | ||
299 | } | ||
300 | if (of_find_property(bl, "su2-feedback-curr1", NULL)) { | ||
301 | pdata->su2_feedback = AS3711_SU2_CURR1; | ||
302 | count++; | ||
303 | } | ||
304 | if (of_find_property(bl, "su2-feedback-curr2", NULL)) { | ||
305 | pdata->su2_feedback = AS3711_SU2_CURR2; | ||
306 | count++; | ||
307 | } | ||
308 | if (of_find_property(bl, "su2-feedback-curr3", NULL)) { | ||
309 | pdata->su2_feedback = AS3711_SU2_CURR3; | ||
310 | count++; | ||
311 | } | ||
312 | if (of_find_property(bl, "su2-feedback-curr-auto", NULL)) { | ||
313 | pdata->su2_feedback = AS3711_SU2_CURR_AUTO; | ||
314 | count++; | ||
315 | } | ||
316 | if (count != 1) | ||
317 | return -EINVAL; | ||
318 | |||
319 | count = 0; | ||
320 | if (of_find_property(bl, "su2-fbprot-lx-sd4", NULL)) { | ||
321 | pdata->su2_fbprot = AS3711_SU2_LX_SD4; | ||
322 | count++; | ||
323 | } | ||
324 | if (of_find_property(bl, "su2-fbprot-gpio2", NULL)) { | ||
325 | pdata->su2_fbprot = AS3711_SU2_GPIO2; | ||
326 | count++; | ||
327 | } | ||
328 | if (of_find_property(bl, "su2-fbprot-gpio3", NULL)) { | ||
329 | pdata->su2_fbprot = AS3711_SU2_GPIO3; | ||
330 | count++; | ||
331 | } | ||
332 | if (of_find_property(bl, "su2-fbprot-gpio4", NULL)) { | ||
333 | pdata->su2_fbprot = AS3711_SU2_GPIO4; | ||
334 | count++; | ||
335 | } | ||
336 | if (count != 1) | ||
337 | return -EINVAL; | ||
338 | |||
339 | count = 0; | ||
340 | if (of_find_property(bl, "su2-auto-curr1", NULL)) { | ||
341 | pdata->su2_auto_curr1 = true; | ||
342 | count++; | ||
343 | } | ||
344 | if (of_find_property(bl, "su2-auto-curr2", NULL)) { | ||
345 | pdata->su2_auto_curr2 = true; | ||
346 | count++; | ||
347 | } | ||
348 | if (of_find_property(bl, "su2-auto-curr3", NULL)) { | ||
349 | pdata->su2_auto_curr3 = true; | ||
350 | count++; | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | * At least one su2-auto-curr* must be specified iff | ||
355 | * AS3711_SU2_CURR_AUTO is used | ||
356 | */ | ||
357 | if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) | ||
358 | return -EINVAL; | ||
359 | } | ||
360 | |||
361 | return 0; | ||
362 | } | ||
363 | |||
261 | static int as3711_backlight_probe(struct platform_device *pdev) | 364 | static int as3711_backlight_probe(struct platform_device *pdev) |
262 | { | 365 | { |
263 | struct as3711_bl_pdata *pdata = dev_get_platdata(&pdev->dev); | 366 | struct as3711_bl_pdata *pdata = dev_get_platdata(&pdev->dev); |
@@ -267,11 +370,24 @@ static int as3711_backlight_probe(struct platform_device *pdev) | |||
267 | unsigned int max_brightness; | 370 | unsigned int max_brightness; |
268 | int ret; | 371 | int ret; |
269 | 372 | ||
270 | if (!pdata || (!pdata->su1_fb && !pdata->su2_fb)) { | 373 | if (!pdata) { |
271 | dev_err(&pdev->dev, "No platform data, exiting...\n"); | 374 | dev_err(&pdev->dev, "No platform data, exiting...\n"); |
272 | return -ENODEV; | 375 | return -ENODEV; |
273 | } | 376 | } |
274 | 377 | ||
378 | if (pdev->dev.parent->of_node) { | ||
379 | ret = as3711_backlight_parse_dt(&pdev->dev); | ||
380 | if (ret < 0) { | ||
381 | dev_err(&pdev->dev, "DT parsing failed: %d\n", ret); | ||
382 | return ret; | ||
383 | } | ||
384 | } | ||
385 | |||
386 | if (!pdata->su1_fb && !pdata->su2_fb) { | ||
387 | dev_err(&pdev->dev, "No framebuffer specified\n"); | ||
388 | return -EINVAL; | ||
389 | } | ||
390 | |||
275 | /* | 391 | /* |
276 | * Due to possible hardware damage I chose to block all modes, | 392 | * Due to possible hardware damage I chose to block all modes, |
277 | * unsupported on my hardware. Anyone, wishing to use any of those modes | 393 | * unsupported on my hardware. Anyone, wishing to use any of those modes |