diff options
Diffstat (limited to 'drivers/leds/leds-lp55xx-common.c')
-rw-r--r-- | drivers/leds/leds-lp55xx-common.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 075acf5b9fab..9acc6bb7deef 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/platform_data/leds-lp55xx.h> | 21 | #include <linux/platform_data/leds-lp55xx.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/gpio.h> | ||
24 | #include <linux/of_gpio.h> | ||
23 | 25 | ||
24 | #include "leds-lp55xx-common.h" | 26 | #include "leds-lp55xx-common.h" |
25 | 27 | ||
@@ -407,18 +409,18 @@ int lp55xx_init_device(struct lp55xx_chip *chip) | |||
407 | if (!pdata || !cfg) | 409 | if (!pdata || !cfg) |
408 | return -EINVAL; | 410 | return -EINVAL; |
409 | 411 | ||
410 | if (pdata->setup_resources) { | 412 | if (gpio_is_valid(pdata->enable_gpio)) { |
411 | ret = pdata->setup_resources(); | 413 | ret = devm_gpio_request_one(dev, pdata->enable_gpio, |
414 | GPIOF_DIR_OUT, "lp5523_enable"); | ||
412 | if (ret < 0) { | 415 | if (ret < 0) { |
413 | dev_err(dev, "setup resoure err: %d\n", ret); | 416 | dev_err(dev, "could not acquire enable gpio (err=%d)\n", |
417 | ret); | ||
414 | goto err; | 418 | goto err; |
415 | } | 419 | } |
416 | } | ||
417 | 420 | ||
418 | if (pdata->enable) { | 421 | gpio_set_value(pdata->enable_gpio, 0); |
419 | pdata->enable(0); | ||
420 | usleep_range(1000, 2000); /* Keep enable down at least 1ms */ | 422 | usleep_range(1000, 2000); /* Keep enable down at least 1ms */ |
421 | pdata->enable(1); | 423 | gpio_set_value(pdata->enable_gpio, 1); |
422 | usleep_range(1000, 2000); /* 500us abs min. */ | 424 | usleep_range(1000, 2000); /* 500us abs min. */ |
423 | } | 425 | } |
424 | 426 | ||
@@ -459,11 +461,8 @@ void lp55xx_deinit_device(struct lp55xx_chip *chip) | |||
459 | if (chip->clk) | 461 | if (chip->clk) |
460 | clk_disable_unprepare(chip->clk); | 462 | clk_disable_unprepare(chip->clk); |
461 | 463 | ||
462 | if (pdata->enable) | 464 | if (gpio_is_valid(pdata->enable_gpio)) |
463 | pdata->enable(0); | 465 | gpio_set_value(pdata->enable_gpio, 0); |
464 | |||
465 | if (pdata->release_resources) | ||
466 | pdata->release_resources(); | ||
467 | } | 466 | } |
468 | EXPORT_SYMBOL_GPL(lp55xx_deinit_device); | 467 | EXPORT_SYMBOL_GPL(lp55xx_deinit_device); |
469 | 468 | ||
@@ -596,6 +595,8 @@ int lp55xx_of_populate_pdata(struct device *dev, struct device_node *np) | |||
596 | of_property_read_string(np, "label", &pdata->label); | 595 | of_property_read_string(np, "label", &pdata->label); |
597 | of_property_read_u8(np, "clock-mode", &pdata->clock_mode); | 596 | of_property_read_u8(np, "clock-mode", &pdata->clock_mode); |
598 | 597 | ||
598 | pdata->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0); | ||
599 | |||
599 | /* LP8501 specific */ | 600 | /* LP8501 specific */ |
600 | of_property_read_u8(np, "pwr-sel", (u8 *)&pdata->pwr_sel); | 601 | of_property_read_u8(np, "pwr-sel", (u8 *)&pdata->pwr_sel); |
601 | 602 | ||