e7807ce723ca3ced9ff27c47c02d830de772bab6
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / files-2.6.25 / include / asm-mips / mach-bcm947xx / gpio.h
1 #ifndef __BCM947XX_GPIO_H
2 #define __BCM947XX_GPIO_H
3
4 #include <linux/ssb/ssb_embedded.h>
5
6 extern struct ssb_bus ssb;
7
8 static inline int gpio_request(unsigned gpio, const char *label)
9 {
10 return 0;
11 }
12
13 static inline void gpio_free(unsigned gpio)
14 {
15 }
16
17 static inline int gpio_direction_input(unsigned gpio)
18 {
19 ssb_gpio_outen(&ssb, 1 << gpio, 0);
20 return 0;
21 }
22
23 static inline int gpio_direction_output(unsigned gpio, int value)
24 {
25 ssb_gpio_out(&ssb, 1 << gpio, (value ? 1 << gpio : 0));
26 ssb_gpio_outen(&ssb, 1 << gpio, 1 << gpio);
27 return 0;
28 }
29
30
31 static inline int gpio_to_irq(unsigned gpio)
32 {
33 struct ssb_device *dev;
34
35 dev = ssb.chipco.dev;
36 if (!dev)
37 dev = ssb.extif.dev;
38 if (!dev)
39 return -EINVAL;
40
41 return ssb_mips_irq(dev) + 2;
42 }
43
44 static inline int irq_to_gpio(unsigned gpio)
45 {
46 return -EINVAL;
47 }
48
49
50 static inline int gpio_get_value(unsigned gpio)
51 {
52 return !!ssb_gpio_in(&ssb, 1 << gpio);
53 }
54
55 static inline int gpio_set_value(unsigned gpio, int value)
56 {
57 ssb_gpio_out(&ssb, 1 << gpio, (value ? 1 << gpio : 0));
58 return 0;
59 }
60
61
62 /* cansleep wrappers */
63 #include <asm-generic/gpio.h>
64
65
66 #endif /* __BCM947XX_GPIO_H */
67