diff options
author | Vasily Khoruzhick <anarsoul@gmail.com> | 2011-01-06 14:52:48 -0500 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2011-03-20 19:14:55 -0400 |
commit | 50e2d10da82774e0733ab561c15c84cb92d9ab33 (patch) | |
tree | 95e2589290ce2e06372271286a9190d0f2896a40 /arch/arm/mach-s3c2410/mach-h1940.c | |
parent | 4119242876d7d6ff539e1aa3d736a87a28fe7b67 (diff) |
ARM: S3C2410: H1940: Use leds-gpio driver for LEDs managing
We can use generic leds-gpio driver, as latch api was converted
to gpiolib.
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/mach-s3c2410/mach-h1940.c')
-rw-r--r-- | arch/arm/mach-s3c2410/mach-h1940.c | 93 |
1 files changed, 91 insertions, 2 deletions
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c index 07564404fb89..36cdb7210879 100644 --- a/arch/arm/mach-s3c2410/mach-h1940.c +++ b/arch/arm/mach-s3c2410/mach-h1940.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <linux/gpio_keys.h> | 27 | #include <linux/gpio_keys.h> |
28 | #include <linux/pwm_backlight.h> | 28 | #include <linux/pwm_backlight.h> |
29 | #include <linux/i2c.h> | 29 | #include <linux/i2c.h> |
30 | #include <linux/leds.h> | ||
31 | |||
30 | #include <video/platform_lcd.h> | 32 | #include <video/platform_lcd.h> |
31 | 33 | ||
32 | #include <linux/mmc/host.h> | 34 | #include <linux/mmc/host.h> |
@@ -216,9 +218,87 @@ static struct s3c2410fb_mach_info h1940_fb_info __initdata = { | |||
216 | .gpdup_mask= 0xffffffff, | 218 | .gpdup_mask= 0xffffffff, |
217 | }; | 219 | }; |
218 | 220 | ||
221 | DEFINE_SPINLOCK(h1940_blink_spin); | ||
222 | |||
223 | int h1940_led_blink_set(unsigned gpio, int state, | ||
224 | unsigned long *delay_on, unsigned long *delay_off) | ||
225 | { | ||
226 | int blink_gpio, check_gpio1, check_gpio2; | ||
227 | |||
228 | switch (gpio) { | ||
229 | case H1940_LATCH_LED_GREEN: | ||
230 | blink_gpio = S3C2410_GPA(7); | ||
231 | check_gpio1 = S3C2410_GPA(1); | ||
232 | check_gpio2 = S3C2410_GPA(3); | ||
233 | break; | ||
234 | case H1940_LATCH_LED_RED: | ||
235 | blink_gpio = S3C2410_GPA(1); | ||
236 | check_gpio1 = S3C2410_GPA(7); | ||
237 | check_gpio2 = S3C2410_GPA(3); | ||
238 | break; | ||
239 | default: | ||
240 | blink_gpio = S3C2410_GPA(3); | ||
241 | check_gpio1 = S3C2410_GPA(1); | ||
242 | check_gpio1 = S3C2410_GPA(7); | ||
243 | break; | ||
244 | } | ||
245 | |||
246 | if (delay_on && delay_off && !*delay_on && !*delay_off) | ||
247 | *delay_on = *delay_off = 500; | ||
248 | |||
249 | spin_lock(&h1940_blink_spin); | ||
250 | |||
251 | switch (state) { | ||
252 | case GPIO_LED_NO_BLINK_LOW: | ||
253 | case GPIO_LED_NO_BLINK_HIGH: | ||
254 | if (!gpio_get_value(check_gpio1) && | ||
255 | !gpio_get_value(check_gpio2)) | ||
256 | gpio_set_value(H1940_LATCH_LED_FLASH, 0); | ||
257 | gpio_set_value(blink_gpio, 0); | ||
258 | if (gpio_is_valid(gpio)) | ||
259 | gpio_set_value(gpio, state); | ||
260 | break; | ||
261 | case GPIO_LED_BLINK: | ||
262 | if (gpio_is_valid(gpio)) | ||
263 | gpio_set_value(gpio, 0); | ||
264 | gpio_set_value(H1940_LATCH_LED_FLASH, 1); | ||
265 | gpio_set_value(blink_gpio, 1); | ||
266 | break; | ||
267 | } | ||
268 | |||
269 | spin_unlock(&h1940_blink_spin); | ||
270 | |||
271 | return 0; | ||
272 | } | ||
273 | EXPORT_SYMBOL(h1940_led_blink_set); | ||
274 | |||
275 | static struct gpio_led h1940_leds_desc[] = { | ||
276 | { | ||
277 | .name = "Green", | ||
278 | .default_trigger = "main-battery-charging-or-full", | ||
279 | .gpio = H1940_LATCH_LED_GREEN, | ||
280 | .retain_state_suspended = 1, | ||
281 | }, | ||
282 | { | ||
283 | .name = "Red", | ||
284 | .default_trigger = "main-battery-full", | ||
285 | .gpio = H1940_LATCH_LED_RED, | ||
286 | .retain_state_suspended = 1, | ||
287 | }, | ||
288 | }; | ||
289 | |||
290 | static struct gpio_led_platform_data h1940_leds_pdata = { | ||
291 | .num_leds = ARRAY_SIZE(h1940_leds_desc), | ||
292 | .leds = h1940_leds_desc, | ||
293 | .gpio_blink_set = h1940_led_blink_set, | ||
294 | }; | ||
295 | |||
219 | static struct platform_device h1940_device_leds = { | 296 | static struct platform_device h1940_device_leds = { |
220 | .name = "h1940-leds", | 297 | .name = "leds-gpio", |
221 | .id = -1, | 298 | .id = -1, |
299 | .dev = { | ||
300 | .platform_data = &h1940_leds_pdata, | ||
301 | }, | ||
222 | }; | 302 | }; |
223 | 303 | ||
224 | static struct platform_device h1940_device_bluetooth = { | 304 | static struct platform_device h1940_device_bluetooth = { |
@@ -500,6 +580,15 @@ static void __init h1940_init(void) | |||
500 | 580 | ||
501 | platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices)); | 581 | platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices)); |
502 | 582 | ||
583 | gpio_request(S3C2410_GPA(1), "Red LED blink"); | ||
584 | gpio_request(S3C2410_GPA(3), "Blue LED blink"); | ||
585 | gpio_request(S3C2410_GPA(7), "Green LED blink"); | ||
586 | gpio_request(H1940_LATCH_LED_FLASH, "LED blink"); | ||
587 | gpio_direction_output(S3C2410_GPA(1), 0); | ||
588 | gpio_direction_output(S3C2410_GPA(3), 0); | ||
589 | gpio_direction_output(S3C2410_GPA(7), 0); | ||
590 | gpio_direction_output(H1940_LATCH_LED_FLASH, 0); | ||
591 | |||
503 | i2c_register_board_info(0, h1940_i2c_devices, | 592 | i2c_register_board_info(0, h1940_i2c_devices, |
504 | ARRAY_SIZE(h1940_i2c_devices)); | 593 | ARRAY_SIZE(h1940_i2c_devices)); |
505 | } | 594 | } |