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