1 /* linux/arch/arm/plat-s3c24xx/gpio.c
3 * Copyright (c) 2004-2005 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
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>
30 #include <mach/hardware.h>
31 #include <mach/gpio-fns.h>
34 #include <mach/regs-gpio.h>
36 void s3c2410_gpio_pullup(unsigned int pin, unsigned int to)
38 void __iomem *base = S3C24XX_GPIO_BASE(pin);
39 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
43 if (pin < S3C2410_GPIO_BANKB)
46 local_irq_save(flags);
48 up = __raw_readl(base + 0x08);
51 __raw_writel(up, base + 0x08);
53 local_irq_restore(flags);
56 EXPORT_SYMBOL(s3c2410_gpio_pullup);
59 void s3c2410_gpio_setpin(unsigned int pin, unsigned int to)
61 void __iomem *base = S3C24XX_GPIO_BASE(pin);
62 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
66 local_irq_save(flags);
68 dat = __raw_readl(base + 0x04);
71 __raw_writel(dat, base + 0x04);
73 local_irq_restore(flags);
76 EXPORT_SYMBOL(s3c2410_gpio_setpin);
78 unsigned int s3c2410_gpio_getpin(unsigned int pin)
80 void __iomem *base = S3C24XX_GPIO_BASE(pin);
81 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
83 return __raw_readl(base + 0x04) & (1<< offs);
86 EXPORT_SYMBOL(s3c2410_gpio_getpin);
88 unsigned int s3c2410_modify_misccr(unsigned int clear, unsigned int change)
93 local_irq_save(flags);
94 misccr = __raw_readl(S3C24XX_MISCCR);
97 __raw_writel(misccr, S3C24XX_MISCCR);
98 local_irq_restore(flags);
103 EXPORT_SYMBOL(s3c2410_modify_misccr);