diff options
author | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-09 06:33:45 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-09 06:33:45 -0400 |
commit | be8e58d93fba531b12ef2fce4fb33c9c5fb5b69f (patch) | |
tree | 3885862d1cf28bfdc4033bd9b20267c61cb8f5ab | |
parent | b6100f10bdc2019a65297d2597c388de2f7dd653 (diff) |
Revert "[media] Add device tree support to adp1653 flash driver"
As requested by Sakari:
"The driver changes are still being reviewed.
It's been proposed that the max-microamp property be renamed."
So, as the DT bindings are not agreed upstream yet, let's revert
it.
Requested-by: Sakari Ailus <sakari.ailus@iki.fi>
This reverts commit b6100f10bdc2019a65297d2597c388de2f7dd653.
-rw-r--r-- | Documentation/devicetree/bindings/media/i2c/adp1653.txt | 37 | ||||
-rw-r--r-- | drivers/media/i2c/adp1653.c | 90 |
2 files changed, 9 insertions, 118 deletions
diff --git a/Documentation/devicetree/bindings/media/i2c/adp1653.txt b/Documentation/devicetree/bindings/media/i2c/adp1653.txt deleted file mode 100644 index 0fc28a95e2f4..000000000000 --- a/Documentation/devicetree/bindings/media/i2c/adp1653.txt +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | * Analog Devices ADP1653 flash LED driver | ||
2 | |||
3 | Required Properties: | ||
4 | |||
5 | - compatible: Must contain be "adi,adp1653" | ||
6 | |||
7 | - reg: I2C slave address | ||
8 | |||
9 | - gpios: References to the GPIO that controls the power for the chip. | ||
10 | |||
11 | There are two led outputs available - flash and indicator. One led is | ||
12 | represented by one child node, nodes need to be named "flash" and "indicator". | ||
13 | |||
14 | Required properties of the LED child node: | ||
15 | - max-microamp : see Documentation/devicetree/bindings/leds/common.txt | ||
16 | |||
17 | Required properties of the flash LED child node: | ||
18 | |||
19 | - flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt | ||
20 | - flash-timeout-us : see Documentation/devicetree/bindings/leds/common.txt | ||
21 | |||
22 | Example: | ||
23 | |||
24 | adp1653: led-controller@30 { | ||
25 | compatible = "adi,adp1653"; | ||
26 | reg = <0x30>; | ||
27 | gpios = <&gpio3 24 GPIO_ACTIVE_HIGH>; /* 88 */ | ||
28 | |||
29 | flash { | ||
30 | flash-timeout-us = <500000>; | ||
31 | flash-max-microamp = <320000>; | ||
32 | max-microamp = <50000>; | ||
33 | }; | ||
34 | indicator { | ||
35 | max-microamp = <17500>; | ||
36 | }; | ||
37 | }; | ||
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index 0341009d71fc..873fe1949e98 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * Contributors: | 8 | * Contributors: |
9 | * Sakari Ailus <sakari.ailus@iki.fi> | 9 | * Sakari Ailus <sakari.ailus@iki.fi> |
10 | * Tuukka Toivonen <tuukkat76@gmail.com> | 10 | * Tuukka Toivonen <tuukkat76@gmail.com> |
11 | * Pavel Machek <pavel@ucw.cz> | ||
12 | * | 11 | * |
13 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
14 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
@@ -35,8 +34,6 @@ | |||
35 | #include <linux/module.h> | 34 | #include <linux/module.h> |
36 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
37 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
38 | #include <linux/of_gpio.h> | ||
39 | #include <linux/gpio.h> | ||
40 | #include <media/adp1653.h> | 37 | #include <media/adp1653.h> |
41 | #include <media/v4l2-device.h> | 38 | #include <media/v4l2-device.h> |
42 | 39 | ||
@@ -309,17 +306,9 @@ adp1653_init_device(struct adp1653_flash *flash) | |||
309 | static int | 306 | static int |
310 | __adp1653_set_power(struct adp1653_flash *flash, int on) | 307 | __adp1653_set_power(struct adp1653_flash *flash, int on) |
311 | { | 308 | { |
312 | int ret = 0; | 309 | int ret; |
313 | |||
314 | if (flash->platform_data->power) { | ||
315 | ret = flash->platform_data->power(&flash->subdev, on); | ||
316 | } else { | ||
317 | gpio_set_value(flash->platform_data->power_gpio, on); | ||
318 | if (on) | ||
319 | /* Some delay is apparently required. */ | ||
320 | udelay(20); | ||
321 | } | ||
322 | 310 | ||
311 | ret = flash->platform_data->power(&flash->subdev, on); | ||
323 | if (ret < 0) | 312 | if (ret < 0) |
324 | return ret; | 313 | return ret; |
325 | 314 | ||
@@ -327,13 +316,8 @@ __adp1653_set_power(struct adp1653_flash *flash, int on) | |||
327 | return 0; | 316 | return 0; |
328 | 317 | ||
329 | ret = adp1653_init_device(flash); | 318 | ret = adp1653_init_device(flash); |
330 | if (ret >= 0) | 319 | if (ret < 0) |
331 | return ret; | ||
332 | |||
333 | if (flash->platform_data->power) | ||
334 | flash->platform_data->power(&flash->subdev, 0); | 320 | flash->platform_data->power(&flash->subdev, 0); |
335 | else | ||
336 | gpio_set_value(flash->platform_data->power_gpio, 0); | ||
337 | 321 | ||
338 | return ret; | 322 | return ret; |
339 | } | 323 | } |
@@ -423,77 +407,21 @@ static int adp1653_resume(struct device *dev) | |||
423 | 407 | ||
424 | #endif /* CONFIG_PM */ | 408 | #endif /* CONFIG_PM */ |
425 | 409 | ||
426 | static int adp1653_of_init(struct i2c_client *client, | ||
427 | struct adp1653_flash *flash, | ||
428 | struct device_node *node) | ||
429 | { | ||
430 | u32 val; | ||
431 | struct adp1653_platform_data *pd; | ||
432 | enum of_gpio_flags flags; | ||
433 | int gpio; | ||
434 | struct device_node *child; | ||
435 | |||
436 | if (!node) | ||
437 | return -EINVAL; | ||
438 | |||
439 | pd = devm_kzalloc(&client->dev, sizeof(*pd), GFP_KERNEL); | ||
440 | if (!pd) | ||
441 | return -ENOMEM; | ||
442 | flash->platform_data = pd; | ||
443 | |||
444 | child = of_get_child_by_name(node, "flash"); | ||
445 | if (!child) | ||
446 | return -EINVAL; | ||
447 | if (of_property_read_u32(child, "flash-timeout-microsec", &val)) | ||
448 | return -EINVAL; | ||
449 | |||
450 | pd->max_flash_timeout = val; | ||
451 | if (of_property_read_u32(child, "flash-max-microamp", &val)) | ||
452 | return -EINVAL; | ||
453 | pd->max_flash_intensity = val/1000; | ||
454 | |||
455 | if (of_property_read_u32(child, "max-microamp", &val)) | ||
456 | return -EINVAL; | ||
457 | pd->max_torch_intensity = val/1000; | ||
458 | |||
459 | child = of_get_child_by_name(node, "indicator"); | ||
460 | if (!child) | ||
461 | return -EINVAL; | ||
462 | if (of_property_read_u32(child, "max-microamp", &val)) | ||
463 | return -EINVAL; | ||
464 | pd->max_indicator_intensity = val; | ||
465 | |||
466 | if (!of_find_property(node, "gpios", NULL)) { | ||
467 | dev_err(&client->dev, "No gpio node\n"); | ||
468 | return -EINVAL; | ||
469 | } | ||
470 | |||
471 | pd->power_gpio = of_get_gpio_flags(node, 0, &flags); | ||
472 | if (pd->power_gpio < 0) { | ||
473 | dev_err(&client->dev, "Error getting GPIO\n"); | ||
474 | return -EINVAL; | ||
475 | } | ||
476 | |||
477 | return 0; | ||
478 | } | ||
479 | |||
480 | |||
481 | static int adp1653_probe(struct i2c_client *client, | 410 | static int adp1653_probe(struct i2c_client *client, |
482 | const struct i2c_device_id *devid) | 411 | const struct i2c_device_id *devid) |
483 | { | 412 | { |
484 | struct adp1653_flash *flash; | 413 | struct adp1653_flash *flash; |
485 | int ret; | 414 | int ret; |
486 | 415 | ||
416 | /* we couldn't work without platform data */ | ||
417 | if (client->dev.platform_data == NULL) | ||
418 | return -ENODEV; | ||
419 | |||
487 | flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); | 420 | flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); |
488 | if (flash == NULL) | 421 | if (flash == NULL) |
489 | return -ENOMEM; | 422 | return -ENOMEM; |
490 | 423 | ||
491 | flash->platform_data = client->dev.platform_data; | 424 | flash->platform_data = client->dev.platform_data; |
492 | if (!flash->platform_data) { | ||
493 | ret = adp1653_of_init(client, flash, client->dev.of_node); | ||
494 | if (ret) | ||
495 | return ret; | ||
496 | } | ||
497 | 425 | ||
498 | mutex_init(&flash->power_lock); | 426 | mutex_init(&flash->power_lock); |
499 | 427 | ||
@@ -510,10 +438,10 @@ static int adp1653_probe(struct i2c_client *client, | |||
510 | goto free_and_quit; | 438 | goto free_and_quit; |
511 | 439 | ||
512 | flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; | 440 | flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; |
441 | |||
513 | return 0; | 442 | return 0; |
514 | 443 | ||
515 | free_and_quit: | 444 | free_and_quit: |
516 | dev_err(&client->dev, "adp1653: failed to register device\n"); | ||
517 | v4l2_ctrl_handler_free(&flash->ctrls); | 445 | v4l2_ctrl_handler_free(&flash->ctrls); |
518 | return ret; | 446 | return ret; |
519 | } | 447 | } |
@@ -536,7 +464,7 @@ static const struct i2c_device_id adp1653_id_table[] = { | |||
536 | }; | 464 | }; |
537 | MODULE_DEVICE_TABLE(i2c, adp1653_id_table); | 465 | MODULE_DEVICE_TABLE(i2c, adp1653_id_table); |
538 | 466 | ||
539 | static const struct dev_pm_ops adp1653_pm_ops = { | 467 | static struct dev_pm_ops adp1653_pm_ops = { |
540 | .suspend = adp1653_suspend, | 468 | .suspend = adp1653_suspend, |
541 | .resume = adp1653_resume, | 469 | .resume = adp1653_resume, |
542 | }; | 470 | }; |