diff options
author | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2008-06-14 06:43:36 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-07-07 08:22:05 -0400 |
commit | 53b14ea336ca45f34821ad78a1b45c2315283621 (patch) | |
tree | 74d73cb94f26581624c108e8f8312060d1f668bb /arch/arm | |
parent | 4440cbd69fc71bab8ed932e237b2a453b365ab9b (diff) |
[ARM] 5099/1: Tosa: support AC-in detection.
Add support for ac-in via pda_power device.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-pxa/tosa.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c index 2fe0998ac3fb..f3b12d2897a6 100644 --- a/arch/arm/mach-pxa/tosa.c +++ b/arch/arm/mach-pxa/tosa.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/gpio_keys.h> | 27 | #include <linux/gpio_keys.h> |
28 | #include <linux/input.h> | 28 | #include <linux/input.h> |
29 | #include <linux/gpio.h> | 29 | #include <linux/gpio.h> |
30 | #include <linux/pda_power.h> | ||
30 | 31 | ||
31 | #include <asm/setup.h> | 32 | #include <asm/setup.h> |
32 | #include <asm/mach-types.h> | 33 | #include <asm/mach-types.h> |
@@ -410,6 +411,70 @@ static struct pxaficp_platform_data tosa_ficp_platform_data = { | |||
410 | }; | 411 | }; |
411 | 412 | ||
412 | /* | 413 | /* |
414 | * Tosa AC IN | ||
415 | */ | ||
416 | static int tosa_power_init(struct device *dev) | ||
417 | { | ||
418 | int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in"); | ||
419 | if (ret) | ||
420 | goto err_gpio_req; | ||
421 | |||
422 | ret = gpio_direction_input(TOSA_GPIO_AC_IN); | ||
423 | if (ret) | ||
424 | goto err_gpio_in; | ||
425 | |||
426 | return 0; | ||
427 | |||
428 | err_gpio_in: | ||
429 | gpio_free(TOSA_GPIO_AC_IN); | ||
430 | err_gpio_req: | ||
431 | return ret; | ||
432 | } | ||
433 | |||
434 | static void tosa_power_exit(struct device *dev) | ||
435 | { | ||
436 | gpio_free(TOSA_GPIO_AC_IN); | ||
437 | } | ||
438 | |||
439 | static int tosa_power_ac_online(void) | ||
440 | { | ||
441 | return gpio_get_value(TOSA_GPIO_AC_IN) == 0; | ||
442 | } | ||
443 | |||
444 | static char *tosa_ac_supplied_to[] = { | ||
445 | "main-battery", | ||
446 | "backup-battery", | ||
447 | "jacket-battery", | ||
448 | }; | ||
449 | |||
450 | static struct pda_power_pdata tosa_power_data = { | ||
451 | .init = tosa_power_init, | ||
452 | .is_ac_online = tosa_power_ac_online, | ||
453 | .exit = tosa_power_exit, | ||
454 | .supplied_to = tosa_ac_supplied_to, | ||
455 | .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to), | ||
456 | }; | ||
457 | |||
458 | static struct resource tosa_power_resource[] = { | ||
459 | { | ||
460 | .name = "ac", | ||
461 | .start = gpio_to_irq(TOSA_GPIO_AC_IN), | ||
462 | .end = gpio_to_irq(TOSA_GPIO_AC_IN), | ||
463 | .flags = IORESOURCE_IRQ | | ||
464 | IORESOURCE_IRQ_HIGHEDGE | | ||
465 | IORESOURCE_IRQ_LOWEDGE, | ||
466 | }, | ||
467 | }; | ||
468 | |||
469 | static struct platform_device tosa_power_device = { | ||
470 | .name = "pda-power", | ||
471 | .id = -1, | ||
472 | .dev.platform_data = &tosa_power_data, | ||
473 | .resource = tosa_power_resource, | ||
474 | .num_resources = ARRAY_SIZE(tosa_power_resource), | ||
475 | }; | ||
476 | |||
477 | /* | ||
413 | * Tosa Keyboard | 478 | * Tosa Keyboard |
414 | */ | 479 | */ |
415 | static struct platform_device tosakbd_device = { | 480 | static struct platform_device tosakbd_device = { |
@@ -633,6 +698,7 @@ static struct platform_device *devices[] __initdata = { | |||
633 | &tosascoop_device, | 698 | &tosascoop_device, |
634 | &tosascoop_jc_device, | 699 | &tosascoop_jc_device, |
635 | &tc6393xb_device, | 700 | &tc6393xb_device, |
701 | &tosa_power_device, | ||
636 | &tosakbd_device, | 702 | &tosakbd_device, |
637 | &tosa_gpio_keys_device, | 703 | &tosa_gpio_keys_device, |
638 | &tosaled_device, | 704 | &tosaled_device, |