1 /* linux/arch/arm/mach-s3c2410/gpio.c
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
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.
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.
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
25 #include <linux/init.h>
26 #include <linux/module.h>
27 #include <linux/interrupt.h>
28 #include <linux/ioport.h>
30 #include <asm/hardware.h>
34 #include <asm/arch/regs-gpio.h>
36 void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function)
38 unsigned long base = S3C2410_GPIO_BASE(pin);
39 unsigned long shift = 1;
40 unsigned long mask = 3;
44 if (pin < S3C2410_GPIO_BANKB) {
49 mask <<= S3C2410_GPIO_OFFSET(pin);
51 local_irq_save(flags);
53 con = __raw_readl(base + 0x00);
58 __raw_writel(con, base + 0x00);
60 local_irq_restore(flags);
63 void s3c2410_gpio_pullup(unsigned int pin, unsigned int to)
65 unsigned long base = S3C2410_GPIO_BASE(pin);
66 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
70 if (pin < S3C2410_GPIO_BANKB)
73 local_irq_save(flags);
75 up = __raw_readl(base + 0x08);
78 __raw_writel(up, base + 0x08);
80 local_irq_restore(flags);
83 void s3c2410_gpio_setpin(unsigned int pin, unsigned int to)
85 unsigned long base = S3C2410_GPIO_BASE(pin);
86 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
90 local_irq_save(flags);
92 dat = __raw_readl(base + 0x04);
95 __raw_writel(dat, base + 0x04);
97 local_irq_restore(flags);