Blame view
arch/mips/bcm47xx/gpio.c
2.46 KB
34cc662f8 [MIPS] Add gpio s... |
1 2 3 4 5 6 7 |
/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net> */ |
cae39d138 mips: add export.... |
8 |
#include <linux/export.h> |
34cc662f8 [MIPS] Add gpio s... |
9 10 11 12 13 |
#include <linux/ssb/ssb.h> #include <linux/ssb/ssb_driver_chipcommon.h> #include <linux/ssb/ssb_driver_extif.h> #include <asm/mach-bcm47xx/bcm47xx.h> #include <asm/mach-bcm47xx/gpio.h> |
b06f3e19a MIPS: BCM47xx: Us... |
14 15 16 17 18 19 20 |
#if (BCM47XX_CHIPCO_GPIO_LINES > BCM47XX_EXTIF_GPIO_LINES) static DECLARE_BITMAP(gpio_in_use, BCM47XX_CHIPCO_GPIO_LINES); #else static DECLARE_BITMAP(gpio_in_use, BCM47XX_EXTIF_GPIO_LINES); #endif int gpio_request(unsigned gpio, const char *tag) |
34cc662f8 [MIPS] Add gpio s... |
21 |
{ |
08ccf5728 bcm47xx: prepare ... |
22 |
switch (bcm47xx_bus_type) { |
a656ffcbc bcm47xx: make it ... |
23 |
#ifdef CONFIG_BCM47XX_SSB |
08ccf5728 bcm47xx: prepare ... |
24 25 26 27 |
case BCM47XX_BUS_TYPE_SSB: if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) && ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) return -EINVAL; |
34cc662f8 [MIPS] Add gpio s... |
28 |
|
08ccf5728 bcm47xx: prepare ... |
29 30 31 |
if (ssb_extif_available(&bcm47xx_bus.ssb.extif) && ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) return -EINVAL; |
34cc662f8 [MIPS] Add gpio s... |
32 |
|
08ccf5728 bcm47xx: prepare ... |
33 34 |
if (test_and_set_bit(gpio, gpio_in_use)) return -EBUSY; |
34cc662f8 [MIPS] Add gpio s... |
35 |
|
08ccf5728 bcm47xx: prepare ... |
36 |
return 0; |
a656ffcbc bcm47xx: make it ... |
37 |
#endif |
c1d1c5d42 bcm47xx: add supp... |
38 39 40 41 42 43 44 45 46 47 |
#ifdef CONFIG_BCM47XX_BCMA case BCM47XX_BUS_TYPE_BCMA: if (gpio >= BCM47XX_CHIPCO_GPIO_LINES) return -EINVAL; if (test_and_set_bit(gpio, gpio_in_use)) return -EBUSY; return 0; #endif |
08ccf5728 bcm47xx: prepare ... |
48 49 |
} return -EINVAL; |
34cc662f8 [MIPS] Add gpio s... |
50 |
} |
b06f3e19a MIPS: BCM47xx: Us... |
51 |
EXPORT_SYMBOL(gpio_request); |
34cc662f8 [MIPS] Add gpio s... |
52 |
|
b06f3e19a MIPS: BCM47xx: Us... |
53 |
void gpio_free(unsigned gpio) |
34cc662f8 [MIPS] Add gpio s... |
54 |
{ |
08ccf5728 bcm47xx: prepare ... |
55 |
switch (bcm47xx_bus_type) { |
a656ffcbc bcm47xx: make it ... |
56 |
#ifdef CONFIG_BCM47XX_SSB |
08ccf5728 bcm47xx: prepare ... |
57 58 59 60 |
case BCM47XX_BUS_TYPE_SSB: if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) && ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) return; |
b06f3e19a MIPS: BCM47xx: Us... |
61 |
|
08ccf5728 bcm47xx: prepare ... |
62 63 64 |
if (ssb_extif_available(&bcm47xx_bus.ssb.extif) && ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) return; |
b06f3e19a MIPS: BCM47xx: Us... |
65 |
|
08ccf5728 bcm47xx: prepare ... |
66 67 |
clear_bit(gpio, gpio_in_use); return; |
a656ffcbc bcm47xx: make it ... |
68 |
#endif |
c1d1c5d42 bcm47xx: add supp... |
69 70 71 72 73 74 75 76 |
#ifdef CONFIG_BCM47XX_BCMA case BCM47XX_BUS_TYPE_BCMA: if (gpio >= BCM47XX_CHIPCO_GPIO_LINES) return; clear_bit(gpio, gpio_in_use); return; #endif |
08ccf5728 bcm47xx: prepare ... |
77 |
} |
b06f3e19a MIPS: BCM47xx: Us... |
78 79 |
} EXPORT_SYMBOL(gpio_free); |
34cc662f8 [MIPS] Add gpio s... |
80 |
|
b06f3e19a MIPS: BCM47xx: Us... |
81 82 |
int gpio_to_irq(unsigned gpio) { |
08ccf5728 bcm47xx: prepare ... |
83 |
switch (bcm47xx_bus_type) { |
a656ffcbc bcm47xx: make it ... |
84 |
#ifdef CONFIG_BCM47XX_SSB |
08ccf5728 bcm47xx: prepare ... |
85 86 87 88 89 90 91 |
case BCM47XX_BUS_TYPE_SSB: if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco)) return ssb_mips_irq(bcm47xx_bus.ssb.chipco.dev) + 2; else if (ssb_extif_available(&bcm47xx_bus.ssb.extif)) return ssb_mips_irq(bcm47xx_bus.ssb.extif.dev) + 2; else return -EINVAL; |
a656ffcbc bcm47xx: make it ... |
92 |
#endif |
c1d1c5d42 bcm47xx: add supp... |
93 94 95 96 |
#ifdef CONFIG_BCM47XX_BCMA case BCM47XX_BUS_TYPE_BCMA: return bcma_core_mips_irq(bcm47xx_bus.bcma.bus.drv_cc.core) + 2; #endif |
08ccf5728 bcm47xx: prepare ... |
97 98 |
} return -EINVAL; |
34cc662f8 [MIPS] Add gpio s... |
99 |
} |
b06f3e19a MIPS: BCM47xx: Us... |
100 |
EXPORT_SYMBOL_GPL(gpio_to_irq); |