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 if (ssb_chipco_available(&ssb_bcm47xx.chipco) &&
24 ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
27 if (ssb_extif_available(&ssb_bcm47xx.extif) &&
28 ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
31 if (test_and_set_bit(gpio, gpio_in_use))
36 EXPORT_SYMBOL(gpio_request);
38 void gpio_free(unsigned gpio)
40 if (ssb_chipco_available(&ssb_bcm47xx.chipco) &&
41 ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
44 if (ssb_extif_available(&ssb_bcm47xx.extif) &&
45 ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
48 clear_bit(gpio, gpio_in_use);
50 EXPORT_SYMBOL(gpio_free);
52 int gpio_to_irq(unsigned gpio)
54 if (ssb_chipco_available(&ssb_bcm47xx.chipco))
55 return ssb_mips_irq(ssb_bcm47xx.chipco.dev) + 2;
56 else if (ssb_extif_available(&ssb_bcm47xx.extif))
57 return ssb_mips_irq(ssb_bcm47xx.extif.dev) + 2;
61 EXPORT_SYMBOL_GPL(gpio_to_irq);