aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/leds/leds-lp55xx.txt1
-rw-r--r--arch/arm/mach-omap2/board-rx51-peripherals.c20
-rw-r--r--arch/arm/mach-ux500/board-mop500.c2
-rw-r--r--drivers/leds/leds-lp55xx-common.c25
-rw-r--r--include/linux/platform_data/leds-lp55xx.h6
5 files changed, 19 insertions, 35 deletions
diff --git a/Documentation/devicetree/bindings/leds/leds-lp55xx.txt b/Documentation/devicetree/bindings/leds/leds-lp55xx.txt
index d221e75d90fa..c55b8c016a9e 100644
--- a/Documentation/devicetree/bindings/leds/leds-lp55xx.txt
+++ b/Documentation/devicetree/bindings/leds/leds-lp55xx.txt
@@ -10,6 +10,7 @@ Each child has own specific current settings
10- max-cur: Maximun current at each led channel. 10- max-cur: Maximun current at each led channel.
11 11
12Optional properties: 12Optional properties:
13- enable-gpio: GPIO attached to the chip's enable pin
13- label: Used for naming LEDs 14- label: Used for naming LEDs
14- pwr-sel: LP8501 specific property. Power selection for output channels. 15- pwr-sel: LP8501 specific property. Power selection for output channels.
15 0: D1~9 are connected to VDD 16 0: D1~9 are connected to VDD
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index f6fe388af989..68dc998fa34b 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -211,29 +211,11 @@ static struct lp55xx_led_config rx51_lp5523_led_config[] = {
211 } 211 }
212}; 212};
213 213
214static int rx51_lp5523_setup(void)
215{
216 return gpio_request_one(RX51_LP5523_CHIP_EN_GPIO, GPIOF_DIR_OUT,
217 "lp5523_enable");
218}
219
220static void rx51_lp5523_release(void)
221{
222 gpio_free(RX51_LP5523_CHIP_EN_GPIO);
223}
224
225static void rx51_lp5523_enable(bool state)
226{
227 gpio_set_value(RX51_LP5523_CHIP_EN_GPIO, !!state);
228}
229
230static struct lp55xx_platform_data rx51_lp5523_platform_data = { 214static struct lp55xx_platform_data rx51_lp5523_platform_data = {
231 .led_config = rx51_lp5523_led_config, 215 .led_config = rx51_lp5523_led_config,
232 .num_channels = ARRAY_SIZE(rx51_lp5523_led_config), 216 .num_channels = ARRAY_SIZE(rx51_lp5523_led_config),
233 .clock_mode = LP55XX_CLOCK_AUTO, 217 .clock_mode = LP55XX_CLOCK_AUTO,
234 .setup_resources = rx51_lp5523_setup, 218 .enable_gpio = RX51_LP5523_CHIP_EN_GPIO,
235 .release_resources = rx51_lp5523_release,
236 .enable = rx51_lp5523_enable,
237}; 219};
238#endif 220#endif
239 221
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index ad0806eff762..703dec2b7d8d 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -297,6 +297,7 @@ static struct lp55xx_platform_data __initdata lp5521_pri_data = {
297 .led_config = &lp5521_pri_led[0], 297 .led_config = &lp5521_pri_led[0],
298 .num_channels = 3, 298 .num_channels = 3,
299 .clock_mode = LP55XX_CLOCK_EXT, 299 .clock_mode = LP55XX_CLOCK_EXT,
300 .enable_gpio = -1,
300}; 301};
301 302
302static struct lp55xx_led_config lp5521_sec_led[] = { 303static struct lp55xx_led_config lp5521_sec_led[] = {
@@ -322,6 +323,7 @@ static struct lp55xx_platform_data __initdata lp5521_sec_data = {
322 .led_config = &lp5521_sec_led[0], 323 .led_config = &lp5521_sec_led[0],
323 .num_channels = 3, 324 .num_channels = 3,
324 .clock_mode = LP55XX_CLOCK_EXT, 325 .clock_mode = LP55XX_CLOCK_EXT,
326 .enable_gpio = -1,
325}; 327};
326 328
327/* I2C0 devices only available on the first HREF/MOP500 */ 329/* I2C0 devices only available on the first HREF/MOP500 */
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}
468EXPORT_SYMBOL_GPL(lp55xx_deinit_device); 467EXPORT_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
diff --git a/include/linux/platform_data/leds-lp55xx.h b/include/linux/platform_data/leds-lp55xx.h
index c32de4dcec54..624ff9edad6f 100644
--- a/include/linux/platform_data/leds-lp55xx.h
+++ b/include/linux/platform_data/leds-lp55xx.h
@@ -67,10 +67,8 @@ struct lp55xx_platform_data {
67 /* Clock configuration */ 67 /* Clock configuration */
68 u8 clock_mode; 68 u8 clock_mode;
69 69
70 /* Platform specific functions */ 70 /* optional enable GPIO */
71 int (*setup_resources)(void); 71 int enable_gpio;
72 void (*release_resources)(void);
73 void (*enable)(bool state);
74 72
75 /* Predefined pattern data */ 73 /* Predefined pattern data */
76 struct lp55xx_predef_pattern *patterns; 74 struct lp55xx_predef_pattern *patterns;