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.c85
1 files changed, 34 insertions, 51 deletions
diff --git a/arch/mips/bcm47xx/gpio.c b/arch/mips/bcm47xx/gpio.c
index f5a53acf995a..9b798800258c 100644
--- a/arch/mips/bcm47xx/gpio.c
+++ b/arch/mips/bcm47xx/gpio.c
@@ -12,68 +12,51 @@
12#include <asm/mach-bcm47xx/bcm47xx.h> 12#include <asm/mach-bcm47xx/bcm47xx.h>
13#include <asm/mach-bcm47xx/gpio.h> 13#include <asm/mach-bcm47xx/gpio.h>
14 14
15int bcm47xx_gpio_to_irq(unsigned gpio) 15#if (BCM47XX_CHIPCO_GPIO_LINES > BCM47XX_EXTIF_GPIO_LINES)
16static DECLARE_BITMAP(gpio_in_use, BCM47XX_CHIPCO_GPIO_LINES);
17#else
18static DECLARE_BITMAP(gpio_in_use, BCM47XX_EXTIF_GPIO_LINES);
19#endif
20
21int gpio_request(unsigned gpio, const char *tag)
16{ 22{
17 if (ssb_bcm47xx.chipco.dev) 23 if (ssb_chipco_available(&ssb_bcm47xx.chipco) &&
18 return ssb_mips_irq(ssb_bcm47xx.chipco.dev) + 2; 24 ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
19 else if (ssb_bcm47xx.extif.dev)
20 return ssb_mips_irq(ssb_bcm47xx.extif.dev) + 2;
21 else
22 return -EINVAL; 25 return -EINVAL;
23}
24EXPORT_SYMBOL_GPL(bcm47xx_gpio_to_irq);
25 26
26int bcm47xx_gpio_get_value(unsigned gpio) 27 if (ssb_extif_available(&ssb_bcm47xx.extif) &&
27{ 28 ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
28 if (ssb_bcm47xx.chipco.dev) 29 return -EINVAL;
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);
32 else
33 return 0;
34}
35EXPORT_SYMBOL_GPL(bcm47xx_gpio_get_value);
36 30
37void bcm47xx_gpio_set_value(unsigned gpio, int value) 31 if (test_and_set_bit(gpio, gpio_in_use))
38{ 32 return -EBUSY;
39 if (ssb_bcm47xx.chipco.dev)
40 ssb_chipco_gpio_out(&ssb_bcm47xx.chipco,
41 1 << gpio,
42 value ? 1 << gpio : 0);
43 else if (ssb_bcm47xx.extif.dev)
44 ssb_extif_gpio_out(&ssb_bcm47xx.extif,
45 1 << gpio,
46 value ? 1 << gpio : 0);
47}
48EXPORT_SYMBOL_GPL(bcm47xx_gpio_set_value);
49 33
50int bcm47xx_gpio_direction_input(unsigned gpio)
51{
52 if (ssb_bcm47xx.chipco.dev && (gpio < BCM47XX_CHIPCO_GPIO_LINES))
53 ssb_chipco_gpio_outen(&ssb_bcm47xx.chipco,
54 1 << gpio, 0);
55 else if (ssb_bcm47xx.extif.dev && (gpio < BCM47XX_EXTIF_GPIO_LINES))
56 ssb_extif_gpio_outen(&ssb_bcm47xx.extif,
57 1 << gpio, 0);
58 else
59 return -EINVAL;
60 return 0; 34 return 0;
61} 35}
62EXPORT_SYMBOL_GPL(bcm47xx_gpio_direction_input); 36EXPORT_SYMBOL(gpio_request);
63 37
64int bcm47xx_gpio_direction_output(unsigned gpio, int value) 38void gpio_free(unsigned gpio)
65{ 39{
66 bcm47xx_gpio_set_value(gpio, value); 40 if (ssb_chipco_available(&ssb_bcm47xx.chipco) &&
41 ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
42 return;
43
44 if (ssb_extif_available(&ssb_bcm47xx.extif) &&
45 ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
46 return;
47
48 clear_bit(gpio, gpio_in_use);
49}
50EXPORT_SYMBOL(gpio_free);
67 51
68 if (ssb_bcm47xx.chipco.dev && (gpio < BCM47XX_CHIPCO_GPIO_LINES)) 52int gpio_to_irq(unsigned gpio)
69 ssb_chipco_gpio_outen(&ssb_bcm47xx.chipco, 53{
70 1 << gpio, 1 << gpio); 54 if (ssb_chipco_available(&ssb_bcm47xx.chipco))
71 else if (ssb_bcm47xx.extif.dev && (gpio < BCM47XX_EXTIF_GPIO_LINES)) 55 return ssb_mips_irq(ssb_bcm47xx.chipco.dev) + 2;
72 ssb_extif_gpio_outen(&ssb_bcm47xx.extif, 56 else if (ssb_extif_available(&ssb_bcm47xx.extif))
73 1 << gpio, 1 << gpio); 57 return ssb_mips_irq(ssb_bcm47xx.extif.dev) + 2;
74 else 58 else
75 return -EINVAL; 59 return -EINVAL;
76 return 0;
77} 60}
78EXPORT_SYMBOL_GPL(bcm47xx_gpio_direction_output); 61EXPORT_SYMBOL_GPL(gpio_to_irq);
79 62