Ben Dooks | 67d729a | 2008-01-28 13:01:19 +0100 | [diff] [blame] | 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> |
Ben Dooks | 7987bd7 | 2010-05-17 14:28:44 +0900 | [diff] [blame] | 19 | #include <linux/gpio.h> |
Ben Dooks | 67d729a | 2008-01-28 13:01:19 +0100 | [diff] [blame] | 20 | |
| 21 | #include <asm/mach/arch.h> |
| 22 | #include <asm/mach/map.h> |
| 23 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/regs-gpio.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 25 | #include <mach/hardware.h> |
Ben Dooks | 67d729a | 2008-01-28 13:01:19 +0100 | [diff] [blame] | 26 | |
Ben Dooks | 7987bd7 | 2010-05-17 14:28:44 +0900 | [diff] [blame] | 27 | #include <plat/gpio-core.h> |
| 28 | |
Ben Dooks | 67d729a | 2008-01-28 13:01:19 +0100 | [diff] [blame] | 29 | int s3c2412_gpio_set_sleepcfg(unsigned int pin, unsigned int state) |
| 30 | { |
Kukjin Kim | 782d8a3 | 2011-08-30 20:47:32 +0900 | [diff] [blame] | 31 | struct samsung_gpio_chip *chip = samsung_gpiolib_getchip(pin); |
Ben Dooks | 7987bd7 | 2010-05-17 14:28:44 +0900 | [diff] [blame] | 32 | unsigned long offs = pin - chip->chip.base; |
Ben Dooks | 67d729a | 2008-01-28 13:01:19 +0100 | [diff] [blame] | 33 | unsigned long flags; |
| 34 | unsigned long slpcon; |
| 35 | |
| 36 | offs *= 2; |
| 37 | |
Ben Dooks | 2c8fcfb | 2010-05-17 14:13:16 +0900 | [diff] [blame] | 38 | if (pin < S3C2410_GPB(0)) |
Ben Dooks | 67d729a | 2008-01-28 13:01:19 +0100 | [diff] [blame] | 39 | return -EINVAL; |
| 40 | |
Ben Dooks | 2c8fcfb | 2010-05-17 14:13:16 +0900 | [diff] [blame] | 41 | if (pin >= S3C2410_GPF(0) && |
| 42 | pin <= S3C2410_GPG(16)) |
Ben Dooks | 67d729a | 2008-01-28 13:01:19 +0100 | [diff] [blame] | 43 | return -EINVAL; |
| 44 | |
Ben Dooks | 2c8fcfb | 2010-05-17 14:13:16 +0900 | [diff] [blame] | 45 | if (pin > S3C2410_GPH(16)) |
Ben Dooks | 67d729a | 2008-01-28 13:01:19 +0100 | [diff] [blame] | 46 | return -EINVAL; |
| 47 | |
| 48 | local_irq_save(flags); |
| 49 | |
Ben Dooks | 7987bd7 | 2010-05-17 14:28:44 +0900 | [diff] [blame] | 50 | slpcon = __raw_readl(chip->base + 0x0C); |
Ben Dooks | 67d729a | 2008-01-28 13:01:19 +0100 | [diff] [blame] | 51 | |
| 52 | slpcon &= ~(3 << offs); |
| 53 | slpcon |= state << offs; |
| 54 | |
Ben Dooks | 7987bd7 | 2010-05-17 14:28:44 +0900 | [diff] [blame] | 55 | __raw_writel(slpcon, chip->base + 0x0C); |
Ben Dooks | 67d729a | 2008-01-28 13:01:19 +0100 | [diff] [blame] | 56 | |
| 57 | local_irq_restore(flags); |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | EXPORT_SYMBOL(s3c2412_gpio_set_sleepcfg); |