diff options
Diffstat (limited to 'arch/mips/bcm47xx/gpio.c')
-rw-r--r-- | arch/mips/bcm47xx/gpio.c | 83 |
1 files changed, 62 insertions, 21 deletions
diff --git a/arch/mips/bcm47xx/gpio.c b/arch/mips/bcm47xx/gpio.c index e4a5ee9c9721..5ebdf62e96bb 100644 --- a/arch/mips/bcm47xx/gpio.c +++ b/arch/mips/bcm47xx/gpio.c | |||
@@ -6,6 +6,7 @@ | |||
6 | * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net> | 6 | * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net> |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/export.h> | ||
9 | #include <linux/ssb/ssb.h> | 10 | #include <linux/ssb/ssb.h> |
10 | #include <linux/ssb/ssb_driver_chipcommon.h> | 11 | #include <linux/ssb/ssb_driver_chipcommon.h> |
11 | #include <linux/ssb/ssb_driver_extif.h> | 12 | #include <linux/ssb/ssb_driver_extif.h> |
@@ -20,42 +21,82 @@ static DECLARE_BITMAP(gpio_in_use, BCM47XX_EXTIF_GPIO_LINES); | |||
20 | 21 | ||
21 | int gpio_request(unsigned gpio, const char *tag) | 22 | int gpio_request(unsigned gpio, const char *tag) |
22 | { | 23 | { |
23 | if (ssb_chipco_available(&ssb_bcm47xx.chipco) && | 24 | switch (bcm47xx_bus_type) { |
24 | ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) | 25 | #ifdef CONFIG_BCM47XX_SSB |
25 | return -EINVAL; | 26 | case BCM47XX_BUS_TYPE_SSB: |
27 | if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) && | ||
28 | ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) | ||
29 | return -EINVAL; | ||
26 | 30 | ||
27 | if (ssb_extif_available(&ssb_bcm47xx.extif) && | 31 | if (ssb_extif_available(&bcm47xx_bus.ssb.extif) && |
28 | ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) | 32 | ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) |
29 | return -EINVAL; | 33 | return -EINVAL; |
30 | 34 | ||
31 | if (test_and_set_bit(gpio, gpio_in_use)) | 35 | if (test_and_set_bit(gpio, gpio_in_use)) |
32 | return -EBUSY; | 36 | return -EBUSY; |
33 | 37 | ||
34 | return 0; | 38 | return 0; |
39 | #endif | ||
40 | #ifdef CONFIG_BCM47XX_BCMA | ||
41 | case BCM47XX_BUS_TYPE_BCMA: | ||
42 | if (gpio >= BCM47XX_CHIPCO_GPIO_LINES) | ||
43 | return -EINVAL; | ||
44 | |||
45 | if (test_and_set_bit(gpio, gpio_in_use)) | ||
46 | return -EBUSY; | ||
47 | |||
48 | return 0; | ||
49 | #endif | ||
50 | } | ||
51 | return -EINVAL; | ||
35 | } | 52 | } |
36 | EXPORT_SYMBOL(gpio_request); | 53 | EXPORT_SYMBOL(gpio_request); |
37 | 54 | ||
38 | void gpio_free(unsigned gpio) | 55 | void gpio_free(unsigned gpio) |
39 | { | 56 | { |
40 | if (ssb_chipco_available(&ssb_bcm47xx.chipco) && | 57 | switch (bcm47xx_bus_type) { |
41 | ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) | 58 | #ifdef CONFIG_BCM47XX_SSB |
42 | return; | 59 | case BCM47XX_BUS_TYPE_SSB: |
60 | if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) && | ||
61 | ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) | ||
62 | return; | ||
63 | |||
64 | if (ssb_extif_available(&bcm47xx_bus.ssb.extif) && | ||
65 | ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) | ||
66 | return; | ||
43 | 67 | ||
44 | if (ssb_extif_available(&ssb_bcm47xx.extif) && | 68 | clear_bit(gpio, gpio_in_use); |
45 | ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) | ||
46 | return; | 69 | return; |
70 | #endif | ||
71 | #ifdef CONFIG_BCM47XX_BCMA | ||
72 | case BCM47XX_BUS_TYPE_BCMA: | ||
73 | if (gpio >= BCM47XX_CHIPCO_GPIO_LINES) | ||
74 | return; | ||
47 | 75 | ||
48 | clear_bit(gpio, gpio_in_use); | 76 | clear_bit(gpio, gpio_in_use); |
77 | return; | ||
78 | #endif | ||
79 | } | ||
49 | } | 80 | } |
50 | EXPORT_SYMBOL(gpio_free); | 81 | EXPORT_SYMBOL(gpio_free); |
51 | 82 | ||
52 | int gpio_to_irq(unsigned gpio) | 83 | int gpio_to_irq(unsigned gpio) |
53 | { | 84 | { |
54 | if (ssb_chipco_available(&ssb_bcm47xx.chipco)) | 85 | switch (bcm47xx_bus_type) { |
55 | return ssb_mips_irq(ssb_bcm47xx.chipco.dev) + 2; | 86 | #ifdef CONFIG_BCM47XX_SSB |
56 | else if (ssb_extif_available(&ssb_bcm47xx.extif)) | 87 | case BCM47XX_BUS_TYPE_SSB: |
57 | return ssb_mips_irq(ssb_bcm47xx.extif.dev) + 2; | 88 | if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco)) |
58 | else | 89 | return ssb_mips_irq(bcm47xx_bus.ssb.chipco.dev) + 2; |
59 | return -EINVAL; | 90 | else if (ssb_extif_available(&bcm47xx_bus.ssb.extif)) |
91 | return ssb_mips_irq(bcm47xx_bus.ssb.extif.dev) + 2; | ||
92 | else | ||
93 | return -EINVAL; | ||
94 | #endif | ||
95 | #ifdef CONFIG_BCM47XX_BCMA | ||
96 | case BCM47XX_BUS_TYPE_BCMA: | ||
97 | return bcma_core_mips_irq(bcm47xx_bus.bcma.bus.drv_cc.core) + 2; | ||
98 | #endif | ||
99 | } | ||
100 | return -EINVAL; | ||
60 | } | 101 | } |
61 | EXPORT_SYMBOL_GPL(gpio_to_irq); | 102 | EXPORT_SYMBOL_GPL(gpio_to_irq); |