diff options
author | Lucas Correia Villa Real <lucasvr@gobolinux.org> | 2006-02-01 16:24:23 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-02-01 16:24:23 -0500 |
commit | 0ca5bc3de715f6e031d44ffecdd2d127891eccf5 (patch) | |
tree | ec963c52b7c60d1cd6862798f5bdfce87387082b /arch/arm/mach-s3c2410/s3c2410-gpio.c | |
parent | 7610dfa3723e87705964b29db9775620d96bf618 (diff) |
[ARM] 3284/1: S3C2400 - adds support to GPIO
Patch from Lucas Correia Villa Real
This patch adds support to GPIO on the S3C2400, which is going to
be used by the GP32 machine and the SMDK2400 development board.
Signed-off-by: Lucas Correia Villa Real <lucasvr@gobolinux.org>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-s3c2410/s3c2410-gpio.c')
-rw-r--r-- | arch/arm/mach-s3c2410/s3c2410-gpio.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c2410/s3c2410-gpio.c b/arch/arm/mach-s3c2410/s3c2410-gpio.c new file mode 100644 index 000000000000..d5e1caea1d23 --- /dev/null +++ b/arch/arm/mach-s3c2410/s3c2410-gpio.c | |||
@@ -0,0 +1,93 @@ | |||
1 | /* linux/arch/arm/mach-s3c2410/gpio.c | ||
2 | * | ||
3 | * Copyright (c) 2004-2006 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * S3C2410 GPIO support | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | * | ||
22 | * Changelog | ||
23 | * 15-Jan-2006 LCVR Splitted from gpio.c | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/init.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/interrupt.h> | ||
30 | #include <linux/ioport.h> | ||
31 | |||
32 | #include <asm/hardware.h> | ||
33 | #include <asm/irq.h> | ||
34 | #include <asm/io.h> | ||
35 | |||
36 | #include <asm/arch/regs-gpio.h> | ||
37 | |||
38 | int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on, | ||
39 | unsigned int config) | ||
40 | { | ||
41 | void __iomem *reg = S3C2410_EINFLT0; | ||
42 | unsigned long flags; | ||
43 | unsigned long val; | ||
44 | |||
45 | if (pin < S3C2410_GPG8 || pin > S3C2410_GPG15) | ||
46 | return -1; | ||
47 | |||
48 | config &= 0xff; | ||
49 | |||
50 | pin -= S3C2410_GPG8_EINT16; | ||
51 | reg += pin & ~3; | ||
52 | |||
53 | local_irq_save(flags); | ||
54 | |||
55 | /* update filter width and clock source */ | ||
56 | |||
57 | val = __raw_readl(reg); | ||
58 | val &= ~(0xff << ((pin & 3) * 8)); | ||
59 | val |= config << ((pin & 3) * 8); | ||
60 | __raw_writel(val, reg); | ||
61 | |||
62 | /* update filter enable */ | ||
63 | |||
64 | val = __raw_readl(S3C2410_EXTINT2); | ||
65 | val &= ~(1 << ((pin * 4) + 3)); | ||
66 | val |= on << ((pin * 4) + 3); | ||
67 | __raw_writel(val, S3C2410_EXTINT2); | ||
68 | |||
69 | local_irq_restore(flags); | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | EXPORT_SYMBOL(s3c2410_gpio_irqfilter); | ||
75 | |||
76 | int s3c2410_gpio_getirq(unsigned int pin) | ||
77 | { | ||
78 | if (pin < S3C2410_GPF0 || pin > S3C2410_GPG15_EINT23) | ||
79 | return -1; /* not valid interrupts */ | ||
80 | |||
81 | if (pin < S3C2410_GPG0 && pin > S3C2410_GPF7) | ||
82 | return -1; /* not valid pin */ | ||
83 | |||
84 | if (pin < S3C2410_GPF4) | ||
85 | return (pin - S3C2410_GPF0) + IRQ_EINT0; | ||
86 | |||
87 | if (pin < S3C2410_GPG0) | ||
88 | return (pin - S3C2410_GPF4) + IRQ_EINT4; | ||
89 | |||
90 | return (pin - S3C2410_GPG0) + IRQ_EINT8; | ||
91 | } | ||
92 | |||
93 | EXPORT_SYMBOL(s3c2410_gpio_getirq); | ||