diff options
author | Eric Miao <eric.miao@marvell.com> | 2009-01-20 01:38:24 -0500 |
---|---|---|
committer | Eric Miao <eric.miao@marvell.com> | 2009-03-22 22:11:34 -0400 |
commit | e2bb6650ef94c64723e2dd35ab92410b9477bc64 (patch) | |
tree | 14dc515236c9a27d39b26005c66404dd08c8570f /arch/arm/mach-mmp | |
parent | 40305a583a3e080a8d1aa126fa810480ec8cbabd (diff) |
[ARM] pxa: add GPIO support for pxa168
Signed-off-by: Eric Miao <eric.miao@marvell.com>
Diffstat (limited to 'arch/arm/mach-mmp')
-rw-r--r-- | arch/arm/mach-mmp/include/mach/gpio.h | 36 | ||||
-rw-r--r-- | arch/arm/mach-mmp/pxa168.c | 19 |
2 files changed, 55 insertions, 0 deletions
diff --git a/arch/arm/mach-mmp/include/mach/gpio.h b/arch/arm/mach-mmp/include/mach/gpio.h new file mode 100644 index 000000000000..ab26d13295c4 --- /dev/null +++ b/arch/arm/mach-mmp/include/mach/gpio.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef __ASM_MACH_GPIO_H | ||
2 | #define __ASM_MACH_GPIO_H | ||
3 | |||
4 | #include <mach/addr-map.h> | ||
5 | #include <mach/irqs.h> | ||
6 | #include <asm-generic/gpio.h> | ||
7 | |||
8 | #define GPIO_REGS_VIRT (APB_VIRT_BASE + 0x19000) | ||
9 | |||
10 | #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2)) | ||
11 | #define GPIO_REG(x) (*((volatile u32 *)(GPIO_REGS_VIRT + (x)))) | ||
12 | |||
13 | #define NR_BUILTIN_GPIO (128) | ||
14 | |||
15 | #define gpio_to_bank(gpio) ((gpio) >> 5) | ||
16 | #define gpio_to_irq(gpio) (IRQ_GPIO_START + (gpio)) | ||
17 | #define irq_to_gpio(irq) ((irq) - IRQ_GPIO_START) | ||
18 | |||
19 | |||
20 | #define __gpio_is_inverted(gpio) (0) | ||
21 | #define __gpio_is_occupied(gpio) (0) | ||
22 | |||
23 | /* NOTE: these macros are defined here to make optimization of | ||
24 | * gpio_{get,set}_value() to work when 'gpio' is a constant. | ||
25 | * Usage of these macros otherwise is no longer recommended, | ||
26 | * use generic GPIO API whenever possible. | ||
27 | */ | ||
28 | #define GPIO_bit(gpio) (1 << ((gpio) & 0x1f)) | ||
29 | |||
30 | #define GPLR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x00) | ||
31 | #define GPDR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x0c) | ||
32 | #define GPSR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x18) | ||
33 | #define GPCR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x24) | ||
34 | |||
35 | #include <plat/gpio.h> | ||
36 | #endif /* __ASM_MACH_GPIO_H */ | ||
diff --git a/arch/arm/mach-mmp/pxa168.c b/arch/arm/mach-mmp/pxa168.c index 1935c7545117..1774682e988e 100644 --- a/arch/arm/mach-mmp/pxa168.c +++ b/arch/arm/mach-mmp/pxa168.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/list.h> | 14 | #include <linux/list.h> |
15 | #include <linux/io.h> | ||
15 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
16 | 17 | ||
17 | #include <asm/mach/time.h> | 18 | #include <asm/mach/time.h> |
@@ -19,15 +20,33 @@ | |||
19 | #include <mach/cputype.h> | 20 | #include <mach/cputype.h> |
20 | #include <mach/regs-apbc.h> | 21 | #include <mach/regs-apbc.h> |
21 | #include <mach/irqs.h> | 22 | #include <mach/irqs.h> |
23 | #include <mach/gpio.h> | ||
22 | #include <mach/dma.h> | 24 | #include <mach/dma.h> |
23 | #include <mach/devices.h> | 25 | #include <mach/devices.h> |
24 | 26 | ||
25 | #include "common.h" | 27 | #include "common.h" |
26 | #include "clock.h" | 28 | #include "clock.h" |
27 | 29 | ||
30 | #define APMASK(i) (GPIO_REGS_VIRT + BANK_OFF(i) + 0x09c) | ||
31 | |||
32 | static void __init pxa168_init_gpio(void) | ||
33 | { | ||
34 | int i; | ||
35 | |||
36 | /* enable GPIO clock */ | ||
37 | __raw_writel(APBC_APBCLK | APBC_FNCLK, APBC_PXA168_GPIO); | ||
38 | |||
39 | /* unmask GPIO edge detection for all 4 banks - APMASKx */ | ||
40 | for (i = 0; i < 4; i++) | ||
41 | __raw_writel(0xffffffff, APMASK(i)); | ||
42 | |||
43 | pxa_init_gpio(IRQ_PXA168_GPIOX, 0, 127, NULL); | ||
44 | } | ||
45 | |||
28 | void __init pxa168_init_irq(void) | 46 | void __init pxa168_init_irq(void) |
29 | { | 47 | { |
30 | icu_init_irq(); | 48 | icu_init_irq(); |
49 | pxa168_init_gpio(); | ||
31 | } | 50 | } |
32 | 51 | ||
33 | /* APB peripheral clocks */ | 52 | /* APB peripheral clocks */ |