diff options
Diffstat (limited to 'arch/arm/mach-ep93xx/core.c')
-rw-r--r-- | arch/arm/mach-ep93xx/core.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c index b4357c388d2e..1f0d66561bbe 100644 --- a/arch/arm/mach-ep93xx/core.c +++ b/arch/arm/mach-ep93xx/core.c | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include <mach/hardware.h> | 32 | #include <mach/hardware.h> |
33 | #include <mach/fb.h> | 33 | #include <mach/fb.h> |
34 | #include <mach/ep93xx_keypad.h> | ||
34 | 35 | ||
35 | #include <asm/mach/map.h> | 36 | #include <asm/mach/map.h> |
36 | #include <asm/mach/time.h> | 37 | #include <asm/mach/time.h> |
@@ -728,6 +729,82 @@ void __init ep93xx_register_fb(struct ep93xxfb_mach_info *data) | |||
728 | platform_device_register(&ep93xx_fb_device); | 729 | platform_device_register(&ep93xx_fb_device); |
729 | } | 730 | } |
730 | 731 | ||
732 | |||
733 | /************************************************************************* | ||
734 | * EP93xx matrix keypad peripheral handling | ||
735 | *************************************************************************/ | ||
736 | static struct resource ep93xx_keypad_resource[] = { | ||
737 | { | ||
738 | .start = EP93XX_KEY_MATRIX_PHYS_BASE, | ||
739 | .end = EP93XX_KEY_MATRIX_PHYS_BASE + 0x0c - 1, | ||
740 | .flags = IORESOURCE_MEM, | ||
741 | }, { | ||
742 | .start = IRQ_EP93XX_KEY, | ||
743 | .end = IRQ_EP93XX_KEY, | ||
744 | .flags = IORESOURCE_IRQ, | ||
745 | }, | ||
746 | }; | ||
747 | |||
748 | static struct platform_device ep93xx_keypad_device = { | ||
749 | .name = "ep93xx-keypad", | ||
750 | .id = -1, | ||
751 | .num_resources = ARRAY_SIZE(ep93xx_keypad_resource), | ||
752 | .resource = ep93xx_keypad_resource, | ||
753 | }; | ||
754 | |||
755 | void __init ep93xx_register_keypad(struct ep93xx_keypad_platform_data *data) | ||
756 | { | ||
757 | ep93xx_keypad_device.dev.platform_data = data; | ||
758 | platform_device_register(&ep93xx_keypad_device); | ||
759 | } | ||
760 | |||
761 | int ep93xx_keypad_acquire_gpio(struct platform_device *pdev) | ||
762 | { | ||
763 | int err; | ||
764 | int i; | ||
765 | |||
766 | for (i = 0; i < 8; i++) { | ||
767 | err = gpio_request(EP93XX_GPIO_LINE_C(i), dev_name(&pdev->dev)); | ||
768 | if (err) | ||
769 | goto fail_gpio_c; | ||
770 | err = gpio_request(EP93XX_GPIO_LINE_D(i), dev_name(&pdev->dev)); | ||
771 | if (err) | ||
772 | goto fail_gpio_d; | ||
773 | } | ||
774 | |||
775 | /* Enable the keypad controller; GPIO ports C and D used for keypad */ | ||
776 | ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_KEYS | | ||
777 | EP93XX_SYSCON_DEVCFG_GONK); | ||
778 | |||
779 | return 0; | ||
780 | |||
781 | fail_gpio_d: | ||
782 | gpio_free(EP93XX_GPIO_LINE_C(i)); | ||
783 | fail_gpio_c: | ||
784 | for ( ; i >= 0; --i) { | ||
785 | gpio_free(EP93XX_GPIO_LINE_C(i)); | ||
786 | gpio_free(EP93XX_GPIO_LINE_D(i)); | ||
787 | } | ||
788 | return err; | ||
789 | } | ||
790 | EXPORT_SYMBOL(ep93xx_keypad_acquire_gpio); | ||
791 | |||
792 | void ep93xx_keypad_release_gpio(struct platform_device *pdev) | ||
793 | { | ||
794 | int i; | ||
795 | |||
796 | for (i = 0; i < 8; i++) { | ||
797 | gpio_free(EP93XX_GPIO_LINE_C(i)); | ||
798 | gpio_free(EP93XX_GPIO_LINE_D(i)); | ||
799 | } | ||
800 | |||
801 | /* Disable the keypad controller; GPIO ports C and D used for GPIO */ | ||
802 | ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_KEYS | | ||
803 | EP93XX_SYSCON_DEVCFG_GONK); | ||
804 | } | ||
805 | EXPORT_SYMBOL(ep93xx_keypad_release_gpio); | ||
806 | |||
807 | |||
731 | extern void ep93xx_gpio_init(void); | 808 | extern void ep93xx_gpio_init(void); |
732 | 809 | ||
733 | void __init ep93xx_init_devices(void) | 810 | void __init ep93xx_init_devices(void) |