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 unsigned int s3c2410_gpio_getcfg(unsigned int pin
)
38 void __iomem
*base
= S3C24XX_GPIO_BASE(pin
);
39 unsigned long val
= __raw_readl(base
);
41 if (pin
< S3C2410_GPIO_BANKB
) {
42 val
>>= S3C2410_GPIO_OFFSET(pin
);
46 val
>>= S3C2410_GPIO_OFFSET(pin
)*2;
50 return val
| S3C2410_GPIO_INPUT
;
53 EXPORT_SYMBOL(s3c2410_gpio_getcfg
);
55 void s3c2410_gpio_pullup(unsigned int pin
, unsigned int to
)
57 void __iomem
*base
= S3C24XX_GPIO_BASE(pin
);
58 unsigned long offs
= S3C2410_GPIO_OFFSET(pin
);
62 if (pin
< S3C2410_GPIO_BANKB
)
65 local_irq_save(flags
);
67 up
= __raw_readl(base
+ 0x08);
70 __raw_writel(up
, base
+ 0x08);
72 local_irq_restore(flags
);
75 EXPORT_SYMBOL(s3c2410_gpio_pullup
);
78 void s3c2410_gpio_setpin(unsigned int pin
, unsigned int to
)
80 void __iomem
*base
= S3C24XX_GPIO_BASE(pin
);
81 unsigned long offs
= S3C2410_GPIO_OFFSET(pin
);
85 local_irq_save(flags
);
87 dat
= __raw_readl(base
+ 0x04);
90 __raw_writel(dat
, base
+ 0x04);
92 local_irq_restore(flags
);
95 EXPORT_SYMBOL(s3c2410_gpio_setpin
);
97 unsigned int s3c2410_gpio_getpin(unsigned int pin
)
99 void __iomem
*base
= S3C24XX_GPIO_BASE(pin
);
100 unsigned long offs
= S3C2410_GPIO_OFFSET(pin
);
102 return __raw_readl(base
+ 0x04) & (1<< offs
);
105 EXPORT_SYMBOL(s3c2410_gpio_getpin
);
107 unsigned int s3c2410_modify_misccr(unsigned int clear
, unsigned int change
)
110 unsigned long misccr
;
112 local_irq_save(flags
);
113 misccr
= __raw_readl(S3C24XX_MISCCR
);
116 __raw_writel(misccr
, S3C24XX_MISCCR
);
117 local_irq_restore(flags
);
122 EXPORT_SYMBOL(s3c2410_modify_misccr
);
124 int s3c2410_gpio_getirq(unsigned int pin
)
126 if (pin
< S3C2410_GPF(0) || pin
> S3C2410_GPG(15))
127 return -EINVAL
; /* not valid interrupts */
129 if (pin
< S3C2410_GPG(0) && pin
> S3C2410_GPF(7))
130 return -EINVAL
; /* not valid pin */
132 if (pin
< S3C2410_GPF(4))
133 return (pin
- S3C2410_GPF(0)) + IRQ_EINT0
;
135 if (pin
< S3C2410_GPG(0))
136 return (pin
- S3C2410_GPF(4)) + IRQ_EINT4
;
138 return (pin
- S3C2410_GPG(0)) + IRQ_EINT8
;
141 EXPORT_SYMBOL(s3c2410_gpio_getirq
);
This page took 0.044174 seconds and 5 git commands to generate.