ARM: S3C24XX: Remove s3c2410_gpio_getpull()
[deliverable/linux.git] / arch / arm / plat-s3c24xx / gpio.c
1 /* linux/arch/arm/plat-s3c24xx/gpio.c
2 *
3 * Copyright (c) 2004-2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C24XX 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
23 #include <linux/kernel.h>
24 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/interrupt.h>
27 #include <linux/ioport.h>
28 #include <linux/io.h>
29
30 #include <mach/hardware.h>
31 #include <mach/gpio-fns.h>
32 #include <asm/irq.h>
33
34 #include <mach/regs-gpio.h>
35
36 unsigned int s3c2410_gpio_getcfg(unsigned int pin)
37 {
38 void __iomem *base = S3C24XX_GPIO_BASE(pin);
39 unsigned long val = __raw_readl(base);
40
41 if (pin < S3C2410_GPIO_BANKB) {
42 val >>= S3C2410_GPIO_OFFSET(pin);
43 val &= 1;
44 val += 1;
45 } else {
46 val >>= S3C2410_GPIO_OFFSET(pin)*2;
47 val &= 3;
48 }
49
50 return val | S3C2410_GPIO_INPUT;
51 }
52
53 EXPORT_SYMBOL(s3c2410_gpio_getcfg);
54
55 void s3c2410_gpio_pullup(unsigned int pin, unsigned int to)
56 {
57 void __iomem *base = S3C24XX_GPIO_BASE(pin);
58 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
59 unsigned long flags;
60 unsigned long up;
61
62 if (pin < S3C2410_GPIO_BANKB)
63 return;
64
65 local_irq_save(flags);
66
67 up = __raw_readl(base + 0x08);
68 up &= ~(1L << offs);
69 up |= to << offs;
70 __raw_writel(up, base + 0x08);
71
72 local_irq_restore(flags);
73 }
74
75 EXPORT_SYMBOL(s3c2410_gpio_pullup);
76
77
78 void s3c2410_gpio_setpin(unsigned int pin, unsigned int to)
79 {
80 void __iomem *base = S3C24XX_GPIO_BASE(pin);
81 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
82 unsigned long flags;
83 unsigned long dat;
84
85 local_irq_save(flags);
86
87 dat = __raw_readl(base + 0x04);
88 dat &= ~(1 << offs);
89 dat |= to << offs;
90 __raw_writel(dat, base + 0x04);
91
92 local_irq_restore(flags);
93 }
94
95 EXPORT_SYMBOL(s3c2410_gpio_setpin);
96
97 unsigned int s3c2410_gpio_getpin(unsigned int pin)
98 {
99 void __iomem *base = S3C24XX_GPIO_BASE(pin);
100 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
101
102 return __raw_readl(base + 0x04) & (1<< offs);
103 }
104
105 EXPORT_SYMBOL(s3c2410_gpio_getpin);
106
107 unsigned int s3c2410_modify_misccr(unsigned int clear, unsigned int change)
108 {
109 unsigned long flags;
110 unsigned long misccr;
111
112 local_irq_save(flags);
113 misccr = __raw_readl(S3C24XX_MISCCR);
114 misccr &= ~clear;
115 misccr ^= change;
116 __raw_writel(misccr, S3C24XX_MISCCR);
117 local_irq_restore(flags);
118
119 return misccr;
120 }
121
122 EXPORT_SYMBOL(s3c2410_modify_misccr);
123
124 int s3c2410_gpio_getirq(unsigned int pin)
125 {
126 if (pin < S3C2410_GPF(0) || pin > S3C2410_GPG(15))
127 return -EINVAL; /* not valid interrupts */
128
129 if (pin < S3C2410_GPG(0) && pin > S3C2410_GPF(7))
130 return -EINVAL; /* not valid pin */
131
132 if (pin < S3C2410_GPF(4))
133 return (pin - S3C2410_GPF(0)) + IRQ_EINT0;
134
135 if (pin < S3C2410_GPG(0))
136 return (pin - S3C2410_GPF(4)) + IRQ_EINT4;
137
138 return (pin - S3C2410_GPG(0)) + IRQ_EINT8;
139 }
140
141 EXPORT_SYMBOL(s3c2410_gpio_getirq);
This page took 0.044174 seconds and 5 git commands to generate.