aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ep93xx
diff options
context:
space:
mode:
authorHartley Sweeten <hartleys@visionengravers.com>2009-10-28 16:04:46 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-11-24 05:04:16 -0500
commit12f56c6889b02453fe050268e9c676e0f8678560 (patch)
tree7b2fca872e1db5d9c6b0d107709142eef0c12e4f /arch/arm/mach-ep93xx
parenta8a8a669ea13d792296737505adc43ccacf3a648 (diff)
ARM: 5775/1: ep93xx: add keypad core support
Add the core support needed by the ep93xx matrix keypad driver. The keypad driver unfortunately was merged early and the core support is missing. The clkdev support has been resolved and is now merged. This adds the platform device to the ep93xx core and supplies the functions needed to acquire/free the gpio pins and actually enable/disable the controller peripheral. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Acked-by: Ryan Mallon <ryan@bluewatersys.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-ep93xx')
-rw-r--r--arch/arm/mach-ep93xx/core.c77
-rw-r--r--arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h1
-rw-r--r--arch/arm/mach-ep93xx/include/mach/platform.h4
3 files changed, 82 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 *************************************************************************/
736static 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
748static 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
755void __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
761int 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
781fail_gpio_d:
782 gpio_free(EP93XX_GPIO_LINE_C(i));
783fail_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}
790EXPORT_SYMBOL(ep93xx_keypad_acquire_gpio);
791
792void 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}
805EXPORT_SYMBOL(ep93xx_keypad_release_gpio);
806
807
731extern void ep93xx_gpio_init(void); 808extern void ep93xx_gpio_init(void);
732 809
733void __init ep93xx_init_devices(void) 810void __init ep93xx_init_devices(void)
diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
index b1f937eda29c..d55194a4c093 100644
--- a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
+++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
@@ -134,6 +134,7 @@
134#define EP93XX_UART3_PHYS_BASE EP93XX_APB_PHYS(0x000e0000) 134#define EP93XX_UART3_PHYS_BASE EP93XX_APB_PHYS(0x000e0000)
135#define EP93XX_UART3_BASE EP93XX_APB_IOMEM(0x000e0000) 135#define EP93XX_UART3_BASE EP93XX_APB_IOMEM(0x000e0000)
136 136
137#define EP93XX_KEY_MATRIX_PHYS_BASE EP93XX_APB_PHYS(0x000f0000)
137#define EP93XX_KEY_MATRIX_BASE EP93XX_APB_IOMEM(0x000f0000) 138#define EP93XX_KEY_MATRIX_BASE EP93XX_APB_IOMEM(0x000f0000)
138 139
139#define EP93XX_ADC_BASE EP93XX_APB_IOMEM(0x00100000) 140#define EP93XX_ADC_BASE EP93XX_APB_IOMEM(0x00100000)
diff --git a/arch/arm/mach-ep93xx/include/mach/platform.h b/arch/arm/mach-ep93xx/include/mach/platform.h
index 469fd968d517..c6dc14dbca18 100644
--- a/arch/arm/mach-ep93xx/include/mach/platform.h
+++ b/arch/arm/mach-ep93xx/include/mach/platform.h
@@ -8,6 +8,7 @@ struct i2c_gpio_platform_data;
8struct i2c_board_info; 8struct i2c_board_info;
9struct platform_device; 9struct platform_device;
10struct ep93xxfb_mach_info; 10struct ep93xxfb_mach_info;
11struct ep93xx_keypad_platform_data;
11 12
12struct ep93xx_eth_data 13struct ep93xx_eth_data
13{ 14{
@@ -39,6 +40,9 @@ void ep93xx_register_fb(struct ep93xxfb_mach_info *data);
39void ep93xx_register_pwm(int pwm0, int pwm1); 40void ep93xx_register_pwm(int pwm0, int pwm1);
40int ep93xx_pwm_acquire_gpio(struct platform_device *pdev); 41int ep93xx_pwm_acquire_gpio(struct platform_device *pdev);
41void ep93xx_pwm_release_gpio(struct platform_device *pdev); 42void ep93xx_pwm_release_gpio(struct platform_device *pdev);
43void ep93xx_register_keypad(struct ep93xx_keypad_platform_data *data);
44int ep93xx_keypad_acquire_gpio(struct platform_device *pdev);
45void ep93xx_keypad_release_gpio(struct platform_device *pdev);
42 46
43void ep93xx_init_devices(void); 47void ep93xx_init_devices(void);
44extern struct sys_timer ep93xx_timer; 48extern struct sys_timer ep93xx_timer;