diff options
Diffstat (limited to 'arch/arm/mach-s3c2412/gpio.c')
-rw-r--r-- | arch/arm/mach-s3c2412/gpio.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c2412/gpio.c b/arch/arm/mach-s3c2412/gpio.c new file mode 100644 index 000000000000..4526f6ba31a8 --- /dev/null +++ b/arch/arm/mach-s3c2412/gpio.c | |||
@@ -0,0 +1,62 @@ | |||
1 | /* linux/arch/arm/mach-s3c2412/gpio.c | ||
2 | * | ||
3 | * Copyright (c) 2007 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * http://armlinux.simtec.co.uk/. | ||
7 | * | ||
8 | * S3C2412/S3C2413 specific GPIO support | ||
9 | * | ||
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. | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/types.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/gpio.h> | ||
20 | |||
21 | #include <asm/mach/arch.h> | ||
22 | #include <asm/mach/map.h> | ||
23 | |||
24 | #include <mach/regs-gpio.h> | ||
25 | #include <mach/hardware.h> | ||
26 | |||
27 | #include <plat/gpio-core.h> | ||
28 | |||
29 | int s3c2412_gpio_set_sleepcfg(unsigned int pin, unsigned int state) | ||
30 | { | ||
31 | struct samsung_gpio_chip *chip = samsung_gpiolib_getchip(pin); | ||
32 | unsigned long offs = pin - chip->chip.base; | ||
33 | unsigned long flags; | ||
34 | unsigned long slpcon; | ||
35 | |||
36 | offs *= 2; | ||
37 | |||
38 | if (pin < S3C2410_GPB(0)) | ||
39 | return -EINVAL; | ||
40 | |||
41 | if (pin >= S3C2410_GPF(0) && | ||
42 | pin <= S3C2410_GPG(16)) | ||
43 | return -EINVAL; | ||
44 | |||
45 | if (pin > S3C2410_GPH(16)) | ||
46 | return -EINVAL; | ||
47 | |||
48 | local_irq_save(flags); | ||
49 | |||
50 | slpcon = __raw_readl(chip->base + 0x0C); | ||
51 | |||
52 | slpcon &= ~(3 << offs); | ||
53 | slpcon |= state << offs; | ||
54 | |||
55 | __raw_writel(slpcon, chip->base + 0x0C); | ||
56 | |||
57 | local_irq_restore(flags); | ||
58 | |||
59 | return 0; | ||
60 | } | ||
61 | |||
62 | EXPORT_SYMBOL(s3c2412_gpio_set_sleepcfg); | ||