Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* linux/arch/arm/mach-s3c2410/gpio.c |
2 | * | |
a21765a7 | 3 | * Copyright (c) 2004-2006 Simtec Electronics |
1da177e4 LT |
4 | * Ben Dooks <ben@simtec.co.uk> |
5 | * | |
a21765a7 | 6 | * S3C2410 GPIO support |
1da177e4 LT |
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 | |
a21765a7 | 21 | */ |
1da177e4 LT |
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> | |
fced80c7 | 28 | #include <linux/io.h> |
1da177e4 | 29 | |
a09e64fb | 30 | #include <mach/hardware.h> |
1da177e4 | 31 | #include <asm/irq.h> |
1da177e4 | 32 | |
a09e64fb | 33 | #include <mach/regs-gpio.h> |
1da177e4 | 34 | |
a21765a7 BD |
35 | int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on, |
36 | unsigned int config) | |
1da177e4 | 37 | { |
a21765a7 | 38 | void __iomem *reg = S3C24XX_EINFLT0; |
1da177e4 | 39 | unsigned long flags; |
a21765a7 | 40 | unsigned long val; |
1da177e4 | 41 | |
a21765a7 BD |
42 | if (pin < S3C2410_GPG8 || pin > S3C2410_GPG15) |
43 | return -1; | |
1da177e4 | 44 | |
a21765a7 | 45 | config &= 0xff; |
1da177e4 | 46 | |
a21765a7 BD |
47 | pin -= S3C2410_GPG8; |
48 | reg += pin & ~3; | |
1da177e4 LT |
49 | |
50 | local_irq_save(flags); | |
51 | ||
a21765a7 | 52 | /* update filter width and clock source */ |
1da177e4 | 53 | |
a21765a7 BD |
54 | val = __raw_readl(reg); |
55 | val &= ~(0xff << ((pin & 3) * 8)); | |
56 | val |= config << ((pin & 3) * 8); | |
57 | __raw_writel(val, reg); | |
1da177e4 | 58 | |
a21765a7 | 59 | /* update filter enable */ |
1da177e4 | 60 | |
a21765a7 BD |
61 | val = __raw_readl(S3C24XX_EXTINT2); |
62 | val &= ~(1 << ((pin * 4) + 3)); | |
63 | val |= on << ((pin * 4) + 3); | |
64 | __raw_writel(val, S3C24XX_EXTINT2); | |
1da177e4 | 65 | |
1da177e4 LT |
66 | local_irq_restore(flags); |
67 | ||
a21765a7 | 68 | return 0; |
94c52fde BD |
69 | } |
70 | ||
a21765a7 | 71 | EXPORT_SYMBOL(s3c2410_gpio_irqfilter); |