aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/bcm47xx/gpio.c
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2011-07-22 19:20:12 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-08-08 14:29:30 -0400
commit08ccf57283f89adbc2ff897ad82d6ad4560db7cd (patch)
tree11d715ac33eab75e57a8e62b0b7d822e316a9145 /arch/mips/bcm47xx/gpio.c
parent908debc8da0d5a91418f71c6a462f62bd2ac69ef (diff)
bcm47xx: prepare to support different buses
Prepare bcm47xx to support different System buses. Before adding support for bcma it should be possible to build bcm47xx without the need of ssb. With this patch bcm47xx does not directly contain a ssb_bus, but a union contain all the supported system buses. As a SoC just uses one system bus a union is a good choice. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Acked-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'arch/mips/bcm47xx/gpio.c')
-rw-r--r--arch/mips/bcm47xx/gpio.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/arch/mips/bcm47xx/gpio.c b/arch/mips/bcm47xx/gpio.c
index e4a5ee9c9721..99e1c50caf6b 100644
--- a/arch/mips/bcm47xx/gpio.c
+++ b/arch/mips/bcm47xx/gpio.c
@@ -20,42 +20,54 @@ 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 case BCM47XX_BUS_TYPE_SSB:
25 return -EINVAL; 25 if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) &&
26 ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
27 return -EINVAL;
26 28
27 if (ssb_extif_available(&ssb_bcm47xx.extif) && 29 if (ssb_extif_available(&bcm47xx_bus.ssb.extif) &&
28 ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) 30 ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
29 return -EINVAL; 31 return -EINVAL;
30 32
31 if (test_and_set_bit(gpio, gpio_in_use)) 33 if (test_and_set_bit(gpio, gpio_in_use))
32 return -EBUSY; 34 return -EBUSY;
33 35
34 return 0; 36 return 0;
37 }
38 return -EINVAL;
35} 39}
36EXPORT_SYMBOL(gpio_request); 40EXPORT_SYMBOL(gpio_request);
37 41
38void gpio_free(unsigned gpio) 42void gpio_free(unsigned gpio)
39{ 43{
40 if (ssb_chipco_available(&ssb_bcm47xx.chipco) && 44 switch (bcm47xx_bus_type) {
41 ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES)) 45 case BCM47XX_BUS_TYPE_SSB:
42 return; 46 if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) &&
47 ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
48 return;
43 49
44 if (ssb_extif_available(&ssb_bcm47xx.extif) && 50 if (ssb_extif_available(&bcm47xx_bus.ssb.extif) &&
45 ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES)) 51 ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
46 return; 52 return;
47 53
48 clear_bit(gpio, gpio_in_use); 54 clear_bit(gpio, gpio_in_use);
55 return;
56 }
49} 57}
50EXPORT_SYMBOL(gpio_free); 58EXPORT_SYMBOL(gpio_free);
51 59
52int gpio_to_irq(unsigned gpio) 60int gpio_to_irq(unsigned gpio)
53{ 61{
54 if (ssb_chipco_available(&ssb_bcm47xx.chipco)) 62 switch (bcm47xx_bus_type) {
55 return ssb_mips_irq(ssb_bcm47xx.chipco.dev) + 2; 63 case BCM47XX_BUS_TYPE_SSB:
56 else if (ssb_extif_available(&ssb_bcm47xx.extif)) 64 if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco))
57 return ssb_mips_irq(ssb_bcm47xx.extif.dev) + 2; 65 return ssb_mips_irq(bcm47xx_bus.ssb.chipco.dev) + 2;
58 else 66 else if (ssb_extif_available(&bcm47xx_bus.ssb.extif))
59 return -EINVAL; 67 return ssb_mips_irq(bcm47xx_bus.ssb.extif.dev) + 2;
68 else
69 return -EINVAL;
70 }
71 return -EINVAL;
60} 72}
61EXPORT_SYMBOL_GPL(gpio_to_irq); 73EXPORT_SYMBOL_GPL(gpio_to_irq);