diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
| commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
| tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/mips/bcm47xx | |
| parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) | |
Diffstat (limited to 'arch/mips/bcm47xx')
| -rw-r--r-- | arch/mips/bcm47xx/gpio.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/mips/bcm47xx/gpio.c b/arch/mips/bcm47xx/gpio.c new file mode 100644 index 00000000000..e4a5ee9c972 --- /dev/null +++ b/arch/mips/bcm47xx/gpio.c | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | /* | ||
| 2 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 3 | * License. See the file "COPYING" in the main directory of this archive | ||
| 4 | * for more details. | ||
| 5 | * | ||
| 6 | * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net> | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include <linux/ssb/ssb.h> | ||
| 10 | #include <linux/ssb/ssb_driver_chipcommon.h> | ||
| 11 | #include <linux/ssb/ssb_driver_extif.h> | ||
| 12 | #include <asm/mach-bcm47xx/bcm47xx.h> | ||
| 13 | #include <asm/mach-bcm47xx/gpio.h> | ||
| 14 | |||
| 15 | #if (BCM47XX_CHIPCO_GPIO_LINES > BCM47XX_EXTIF_GPIO_LINES) | ||
| 16 | static DECLARE_BITMAP(gpio_in_use, BCM47XX_CHIPCO_GPIO_LINES); | ||
| 17 | #else | ||
| 18 | static DECLARE_BITMAP(gpio_in_use, BCM47XX_EXTIF_GPIO_LINES); | ||
| 19 | #endif | ||
| 20 | |||
| 21 | int gpio_request(unsigned gpio, const char *tag) | ||
| 22 | { | ||
| 23 | if (ssb_chipco_available(&ssb_bcm47xx.chipco) && | ||
| 24 | ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) | ||
| 25 | return -EINVAL; | ||
| 26 | |||
| 27 | if (ssb_extif_available(&ssb_bcm47xx.extif) && | ||
| 28 | ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) | ||
| 29 | return -EINVAL; | ||
| 30 | |||
| 31 | if (test_and_set_bit(gpio, gpio_in_use)) | ||
| 32 | return -EBUSY; | ||
| 33 | |||
| 34 | return 0; | ||
| 35 | } | ||
| 36 | EXPORT_SYMBOL(gpio_request); | ||
| 37 | |||
| 38 | void gpio_free(unsigned gpio) | ||
| 39 | { | ||
| 40 | if (ssb_chipco_available(&ssb_bcm47xx.chipco) && | ||
| 41 | ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) | ||
| 42 | return; | ||
| 43 | |||
| 44 | if (ssb_extif_available(&ssb_bcm47xx.extif) && | ||
| 45 | ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) | ||
| 46 | return; | ||
| 47 | |||
| 48 | clear_bit(gpio, gpio_in_use); | ||
| 49 | } | ||
| 50 | EXPORT_SYMBOL(gpio_free); | ||
| 51 | |||
| 52 | int gpio_to_irq(unsigned gpio) | ||
| 53 | { | ||
| 54 | if (ssb_chipco_available(&ssb_bcm47xx.chipco)) | ||
| 55 | return ssb_mips_irq(ssb_bcm47xx.chipco.dev) + 2; | ||
| 56 | else if (ssb_extif_available(&ssb_bcm47xx.extif)) | ||
| 57 | return ssb_mips_irq(ssb_bcm47xx.extif.dev) + 2; | ||
| 58 | else | ||
| 59 | return -EINVAL; | ||
| 60 | } | ||
| 61 | EXPORT_SYMBOL_GPL(gpio_to_irq); | ||
