]>
Commit | Line | Data |
---|---|---|
67d729ad BD |
1 | /* linux/arch/arm/mach-s3c2412/gpio.c |
2 | * | |
3 | * Copyright (c) 2007 Simtec Electronics | |
4 | * Ben Dooks <[email protected]> | |
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> | |
7987bd7a | 19 | #include <linux/gpio.h> |
67d729ad BD |
20 | |
21 | #include <asm/mach/arch.h> | |
22 | #include <asm/mach/map.h> | |
23 | ||
a09e64fb | 24 | #include <mach/regs-gpio.h> |
a09e64fb | 25 | #include <mach/hardware.h> |
67d729ad | 26 | |
7987bd7a BD |
27 | #include <plat/gpio-core.h> |
28 | ||
67d729ad BD |
29 | int s3c2412_gpio_set_sleepcfg(unsigned int pin, unsigned int state) |
30 | { | |
7987bd7a BD |
31 | struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); |
32 | unsigned long offs = pin - chip->chip.base; | |
67d729ad BD |
33 | unsigned long flags; |
34 | unsigned long slpcon; | |
35 | ||
36 | offs *= 2; | |
37 | ||
2c8fcfbf | 38 | if (pin < S3C2410_GPB(0)) |
67d729ad BD |
39 | return -EINVAL; |
40 | ||
2c8fcfbf BD |
41 | if (pin >= S3C2410_GPF(0) && |
42 | pin <= S3C2410_GPG(16)) | |
67d729ad BD |
43 | return -EINVAL; |
44 | ||
2c8fcfbf | 45 | if (pin > S3C2410_GPH(16)) |
67d729ad BD |
46 | return -EINVAL; |
47 | ||
48 | local_irq_save(flags); | |
49 | ||
7987bd7a | 50 | slpcon = __raw_readl(chip->base + 0x0C); |
67d729ad BD |
51 | |
52 | slpcon &= ~(3 << offs); | |
53 | slpcon |= state << offs; | |
54 | ||
7987bd7a | 55 | __raw_writel(slpcon, chip->base + 0x0C); |
67d729ad BD |
56 | |
57 | local_irq_restore(flags); | |
58 | ||
59 | return 0; | |
60 | } | |
61 | ||
62 | EXPORT_SYMBOL(s3c2412_gpio_set_sleepcfg); |