Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / arm / mach-s3c2412 / gpio.c
blob8e55c3a2eab82e404ba3299600a3f69377206e48
1 /* linux/arch/arm/mach-s3c2412/gpio.c
3 * Copyright (c) 2007 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * http://armlinux.simtec.co.uk/.
8 * S3C2412/S3C2413 specific GPIO support
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/kernel.h>
16 #include <linux/types.h>
17 #include <linux/module.h>
18 #include <linux/interrupt.h>
20 #include <asm/mach/arch.h>
21 #include <asm/mach/map.h>
23 #include <asm/arch/regs-gpio.h>
25 #include <asm/hardware.h>
27 int s3c2412_gpio_set_sleepcfg(unsigned int pin, unsigned int state)
29 void __iomem *base = S3C24XX_GPIO_BASE(pin);
30 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
31 unsigned long flags;
32 unsigned long slpcon;
34 offs *= 2;
36 if (pin < S3C2410_GPIO_BANKB)
37 return -EINVAL;
39 if (pin >= S3C2410_GPIO_BANKF &&
40 pin <= S3C2410_GPIO_BANKG)
41 return -EINVAL;
43 if (pin > (S3C2410_GPIO_BANKH + 32))
44 return -EINVAL;
46 local_irq_save(flags);
48 slpcon = __raw_readl(base + 0x0C);
50 slpcon &= ~(3 << offs);
51 slpcon |= state << offs;
53 __raw_writel(slpcon, base + 0x0C);
55 local_irq_restore(flags);
57 return 0;
60 EXPORT_SYMBOL(s3c2412_gpio_set_sleepcfg);