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 int bcm47xx_gpio_to_irq(unsigned gpio)
17 if (ssb_bcm47xx.chipco.dev)
18 return ssb_mips_irq(ssb_bcm47xx.chipco.dev) + 2;
19 else if (ssb_bcm47xx.extif.dev)
20 return ssb_mips_irq(ssb_bcm47xx.extif.dev) + 2;
24 EXPORT_SYMBOL_GPL(bcm47xx_gpio_to_irq);
26 int bcm47xx_gpio_get_value(unsigned gpio)
28 if (ssb_bcm47xx.chipco.dev)
29 return ssb_chipco_gpio_in(&ssb_bcm47xx.chipco, 1 << gpio);
30 else if (ssb_bcm47xx.extif.dev)
31 return ssb_extif_gpio_in(&ssb_bcm47xx.extif, 1 << gpio);
35 EXPORT_SYMBOL_GPL(bcm47xx_gpio_get_value);
37 void bcm47xx_gpio_set_value(unsigned gpio, int value)
39 if (ssb_bcm47xx.chipco.dev)
40 ssb_chipco_gpio_out(&ssb_bcm47xx.chipco,
42 value ? 1 << gpio : 0);
43 else if (ssb_bcm47xx.extif.dev)
44 ssb_extif_gpio_out(&ssb_bcm47xx.extif,
46 value ? 1 << gpio : 0);
48 EXPORT_SYMBOL_GPL(bcm47xx_gpio_set_value);
50 int bcm47xx_gpio_direction_input(unsigned gpio)
52 if (ssb_bcm47xx.chipco.dev && (gpio < BCM47XX_CHIPCO_GPIO_LINES))
53 ssb_chipco_gpio_outen(&ssb_bcm47xx.chipco,
55 else if (ssb_bcm47xx.extif.dev && (gpio < BCM47XX_EXTIF_GPIO_LINES))
56 ssb_extif_gpio_outen(&ssb_bcm47xx.extif,
62 EXPORT_SYMBOL_GPL(bcm47xx_gpio_direction_input);
64 int bcm47xx_gpio_direction_output(unsigned gpio, int value)
66 bcm47xx_gpio_set_value(gpio, value);
68 if (ssb_bcm47xx.chipco.dev && (gpio < BCM47XX_CHIPCO_GPIO_LINES))
69 ssb_chipco_gpio_outen(&ssb_bcm47xx.chipco,
70 1 << gpio, 1 << gpio);
71 else if (ssb_bcm47xx.extif.dev && (gpio < BCM47XX_EXTIF_GPIO_LINES))
72 ssb_extif_gpio_outen(&ssb_bcm47xx.extif,
73 1 << gpio, 1 << gpio);
78 EXPORT_SYMBOL_GPL(bcm47xx_gpio_direction_output);