Bring mach-bcm947xx/gpio.h into line with new SSB code, as per #1640
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx-2.6 / files / include / asm-mips / mach-bcm947xx / gpio.h
1 #ifndef __BCM947XX_GPIO_H
2 #define __BCM947XX_GPIO_H
3
4 #include <linux/ssb/ssb.h>
5 #include <linux/ssb/ssb_driver_chipcommon.h>
6 #include <linux/ssb/ssb_driver_extif.h>
7
8 extern struct ssb_bus ssb;
9
10 static inline int gpio_request(unsigned gpio, const char *label)
11 {
12 return 0;
13 }
14
15 static inline void gpio_free(unsigned gpio)
16 {
17 }
18
19 static inline int gpio_direction_input(unsigned gpio)
20 {
21 if (ssb.chipco.dev)
22 ssb_chipco_gpio_outen(&ssb.chipco, 1 << gpio, 0);
23 else if (ssb.extif.dev)
24 ssb_extif_gpio_outen(&ssb.extif, 1 << gpio, 0);
25 else
26 return -EINVAL;
27 return 0;
28 }
29
30 static inline int gpio_direction_output(unsigned gpio)
31 {
32 if (ssb.chipco.dev)
33 ssb_chipco_gpio_outen(&ssb.chipco, 1 << gpio, 1 << gpio);
34 else if (ssb.extif.dev)
35 ssb_extif_gpio_outen(&ssb.extif, 1 << gpio, 1 << gpio);
36 else
37 return -EINVAL;
38
39 return 0;
40 }
41
42
43 static inline int gpio_to_irq(unsigned gpio)
44 {
45 struct ssb_device *dev;
46
47 dev = ssb.chipco.dev;
48 if (!dev)
49 dev = ssb.extif.dev;
50 if (!dev)
51 return -EINVAL;
52
53 return ssb_mips_irq(dev) + 2;
54 }
55
56 static inline int irq_to_gpio(unsigned gpio)
57 {
58 return -EINVAL;
59 }
60
61
62 static inline int gpio_get_value(unsigned gpio)
63 {
64 if (ssb.chipco.dev)
65 return ssb_chipco_gpio_in(&ssb.chipco, 1 << gpio) ? 1 : 0;
66 else if (ssb.extif.dev)
67 return ssb_extif_gpio_in(&ssb.extif, 1 << gpio) ? 1 : 0;
68 else
69 return 0;
70 }
71
72 static inline int gpio_set_value(unsigned gpio, int value)
73 {
74 if (ssb.chipco.dev)
75 ssb_chipco_gpio_out(&ssb.chipco, 1 << gpio, (value ? 1 << gpio : 0));
76 else if (ssb.extif.dev)
77 ssb_extif_gpio_out(&ssb.extif, 1 << gpio, (value ? 1 << gpio : 0));
78
79 return 0;
80 }
81
82
83 /* cansleep wrappers */
84 #include <asm-generic/gpio.h>
85
86
87 #endif /* __BCM947XX_GPIO_H */
88