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
6 * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
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>
15 #if (BCM47XX_CHIPCO_GPIO_LINES > BCM47XX_EXTIF_GPIO_LINES)
16 static DECLARE_BITMAP(gpio_in_use
, BCM47XX_CHIPCO_GPIO_LINES
);
18 static DECLARE_BITMAP(gpio_in_use
, BCM47XX_EXTIF_GPIO_LINES
);
21 int gpio_request(unsigned gpio
, const char *tag
)
23 switch (bcm47xx_bus_type
) {
24 #ifdef CONFIG_BCM47XX_SSB
25 case BCM47XX_BUS_TYPE_SSB
:
26 if (ssb_chipco_available(&bcm47xx_bus
.ssb
.chipco
) &&
27 ((unsigned)gpio
>= BCM47XX_CHIPCO_GPIO_LINES
))
30 if (ssb_extif_available(&bcm47xx_bus
.ssb
.extif
) &&
31 ((unsigned)gpio
>= BCM47XX_EXTIF_GPIO_LINES
))
34 if (test_and_set_bit(gpio
, gpio_in_use
))
42 EXPORT_SYMBOL(gpio_request
);
44 void gpio_free(unsigned gpio
)
46 switch (bcm47xx_bus_type
) {
47 #ifdef CONFIG_BCM47XX_SSB
48 case BCM47XX_BUS_TYPE_SSB
:
49 if (ssb_chipco_available(&bcm47xx_bus
.ssb
.chipco
) &&
50 ((unsigned)gpio
>= BCM47XX_CHIPCO_GPIO_LINES
))
53 if (ssb_extif_available(&bcm47xx_bus
.ssb
.extif
) &&
54 ((unsigned)gpio
>= BCM47XX_EXTIF_GPIO_LINES
))
57 clear_bit(gpio
, gpio_in_use
);
62 EXPORT_SYMBOL(gpio_free
);
64 int gpio_to_irq(unsigned gpio
)
66 switch (bcm47xx_bus_type
) {
67 #ifdef CONFIG_BCM47XX_SSB
68 case BCM47XX_BUS_TYPE_SSB
:
69 if (ssb_chipco_available(&bcm47xx_bus
.ssb
.chipco
))
70 return ssb_mips_irq(bcm47xx_bus
.ssb
.chipco
.dev
) + 2;
71 else if (ssb_extif_available(&bcm47xx_bus
.ssb
.extif
))
72 return ssb_mips_irq(bcm47xx_bus
.ssb
.extif
.dev
) + 2;
79 EXPORT_SYMBOL_GPL(gpio_to_irq
);