diff options
author | Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org> | 2012-04-18 17:16:40 -0400 |
---|---|---|
committer | Jason Cooper <jason@lakedaemon.net> | 2012-05-14 23:12:14 -0400 |
commit | ff3e660b5a881b401b2b6735aa5334f433237dcb (patch) | |
tree | 275ddcb9365d4cc6ac7320b18a29b5d57fe2ada4 /arch/arm | |
parent | 92a486eabefadca1169fbf15d737feeaf2bda844 (diff) |
orion/kirkwood: create a generic function for gpio led blinking
dns323 and (at least) iconnect platforms are using hw led blinking, so,
instead of having 2 identicals .gpio_blink_set gpio-led hooks, move
dns323 code into gpio.c
Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Tested-By: Adam Baker <linux@baker-net.org.uk>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-orion5x/dns323-setup.c | 25 | ||||
-rw-r--r-- | arch/arm/plat-orion/gpio.c | 23 | ||||
-rw-r--r-- | arch/arm/plat-orion/include/plat/gpio.h | 2 |
3 files changed, 27 insertions, 23 deletions
diff --git a/arch/arm/mach-orion5x/dns323-setup.c b/arch/arm/mach-orion5x/dns323-setup.c index c3ed15b8ea25..13d2bece1bae 100644 --- a/arch/arm/mach-orion5x/dns323-setup.c +++ b/arch/arm/mach-orion5x/dns323-setup.c | |||
@@ -253,27 +253,6 @@ error_fail: | |||
253 | * GPIO LEDs (simple - doesn't use hardware blinking support) | 253 | * GPIO LEDs (simple - doesn't use hardware blinking support) |
254 | */ | 254 | */ |
255 | 255 | ||
256 | #define ORION_BLINK_HALF_PERIOD 100 /* ms */ | ||
257 | |||
258 | static int dns323_gpio_blink_set(unsigned gpio, int state, | ||
259 | unsigned long *delay_on, unsigned long *delay_off) | ||
260 | { | ||
261 | |||
262 | if (delay_on && delay_off && !*delay_on && !*delay_off) | ||
263 | *delay_on = *delay_off = ORION_BLINK_HALF_PERIOD; | ||
264 | |||
265 | switch(state) { | ||
266 | case GPIO_LED_NO_BLINK_LOW: | ||
267 | case GPIO_LED_NO_BLINK_HIGH: | ||
268 | orion_gpio_set_blink(gpio, 0); | ||
269 | gpio_set_value(gpio, state); | ||
270 | break; | ||
271 | case GPIO_LED_BLINK: | ||
272 | orion_gpio_set_blink(gpio, 1); | ||
273 | } | ||
274 | return 0; | ||
275 | } | ||
276 | |||
277 | static struct gpio_led dns323ab_leds[] = { | 256 | static struct gpio_led dns323ab_leds[] = { |
278 | { | 257 | { |
279 | .name = "power:blue", | 258 | .name = "power:blue", |
@@ -312,13 +291,13 @@ static struct gpio_led dns323c_leds[] = { | |||
312 | static struct gpio_led_platform_data dns323ab_led_data = { | 291 | static struct gpio_led_platform_data dns323ab_led_data = { |
313 | .num_leds = ARRAY_SIZE(dns323ab_leds), | 292 | .num_leds = ARRAY_SIZE(dns323ab_leds), |
314 | .leds = dns323ab_leds, | 293 | .leds = dns323ab_leds, |
315 | .gpio_blink_set = dns323_gpio_blink_set, | 294 | .gpio_blink_set = orion_gpio_led_blink_set, |
316 | }; | 295 | }; |
317 | 296 | ||
318 | static struct gpio_led_platform_data dns323c_led_data = { | 297 | static struct gpio_led_platform_data dns323c_led_data = { |
319 | .num_leds = ARRAY_SIZE(dns323c_leds), | 298 | .num_leds = ARRAY_SIZE(dns323c_leds), |
320 | .leds = dns323c_leds, | 299 | .leds = dns323c_leds, |
321 | .gpio_blink_set = dns323_gpio_blink_set, | 300 | .gpio_blink_set = orion_gpio_led_blink_set, |
322 | }; | 301 | }; |
323 | 302 | ||
324 | static struct platform_device dns323_gpio_leds = { | 303 | static struct platform_device dns323_gpio_leds = { |
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c index d3401e77ff3d..af95af257301 100644 --- a/arch/arm/plat-orion/gpio.c +++ b/arch/arm/plat-orion/gpio.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/bitops.h> | 16 | #include <linux/bitops.h> |
17 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/gpio.h> | 18 | #include <linux/gpio.h> |
19 | #include <linux/leds.h> | ||
19 | 20 | ||
20 | /* | 21 | /* |
21 | * GPIO unit register offsets. | 22 | * GPIO unit register offsets. |
@@ -295,6 +296,28 @@ void orion_gpio_set_blink(unsigned pin, int blink) | |||
295 | } | 296 | } |
296 | EXPORT_SYMBOL(orion_gpio_set_blink); | 297 | EXPORT_SYMBOL(orion_gpio_set_blink); |
297 | 298 | ||
299 | #define ORION_BLINK_HALF_PERIOD 100 /* ms */ | ||
300 | |||
301 | int orion_gpio_led_blink_set(unsigned gpio, int state, | ||
302 | unsigned long *delay_on, unsigned long *delay_off) | ||
303 | { | ||
304 | |||
305 | if (delay_on && delay_off && !*delay_on && !*delay_off) | ||
306 | *delay_on = *delay_off = ORION_BLINK_HALF_PERIOD; | ||
307 | |||
308 | switch (state) { | ||
309 | case GPIO_LED_NO_BLINK_LOW: | ||
310 | case GPIO_LED_NO_BLINK_HIGH: | ||
311 | orion_gpio_set_blink(gpio, 0); | ||
312 | gpio_set_value(gpio, state); | ||
313 | break; | ||
314 | case GPIO_LED_BLINK: | ||
315 | orion_gpio_set_blink(gpio, 1); | ||
316 | } | ||
317 | return 0; | ||
318 | } | ||
319 | EXPORT_SYMBOL_GPL(orion_gpio_led_blink_set); | ||
320 | |||
298 | 321 | ||
299 | /***************************************************************************** | 322 | /***************************************************************************** |
300 | * Orion GPIO IRQ | 323 | * Orion GPIO IRQ |
diff --git a/arch/arm/plat-orion/include/plat/gpio.h b/arch/arm/plat-orion/include/plat/gpio.h index 3abf30428bee..bec0c98ce41f 100644 --- a/arch/arm/plat-orion/include/plat/gpio.h +++ b/arch/arm/plat-orion/include/plat/gpio.h | |||
@@ -19,6 +19,8 @@ | |||
19 | */ | 19 | */ |
20 | void orion_gpio_set_unused(unsigned pin); | 20 | void orion_gpio_set_unused(unsigned pin); |
21 | void orion_gpio_set_blink(unsigned pin, int blink); | 21 | void orion_gpio_set_blink(unsigned pin, int blink); |
22 | int orion_gpio_led_blink_set(unsigned gpio, int state, | ||
23 | unsigned long *delay_on, unsigned long *delay_off); | ||
22 | 24 | ||
23 | #define GPIO_INPUT_OK (1 << 0) | 25 | #define GPIO_INPUT_OK (1 << 0) |
24 | #define GPIO_OUTPUT_OK (1 << 1) | 26 | #define GPIO_OUTPUT_OK (1 << 1) |