Commit | Line | Data |
---|---|---|
7560fa60 DB |
1 | #ifndef __LINUX_GPIO_H |
2 | #define __LINUX_GPIO_H | |
3 | ||
4 | /* see Documentation/gpio.txt */ | |
5 | ||
6 | #ifdef CONFIG_GENERIC_GPIO | |
7 | #include <asm/gpio.h> | |
8 | ||
9 | #else | |
10 | ||
3d599d1c | 11 | #include <linux/kernel.h> |
6ea0205b DB |
12 | #include <linux/types.h> |
13 | #include <linux/errno.h> | |
14 | ||
a4177ee7 JN |
15 | struct device; |
16 | ||
7560fa60 DB |
17 | /* |
18 | * Some platforms don't support the GPIO programming interface. | |
19 | * | |
20 | * In case some driver uses it anyway (it should normally have | |
21 | * depended on GENERIC_GPIO), these routines help the compiler | |
22 | * optimize out much GPIO-related code ... or trigger a runtime | |
23 | * warning when something is wrongly called. | |
24 | */ | |
25 | ||
26 | static inline int gpio_is_valid(int number) | |
27 | { | |
28 | return 0; | |
29 | } | |
30 | ||
31 | static inline int gpio_request(unsigned gpio, const char *label) | |
32 | { | |
33 | return -ENOSYS; | |
34 | } | |
35 | ||
36 | static inline void gpio_free(unsigned gpio) | |
37 | { | |
3d599d1c UKK |
38 | might_sleep(); |
39 | ||
7560fa60 DB |
40 | /* GPIO can never have been requested */ |
41 | WARN_ON(1); | |
42 | } | |
43 | ||
44 | static inline int gpio_direction_input(unsigned gpio) | |
45 | { | |
46 | return -ENOSYS; | |
47 | } | |
48 | ||
49 | static inline int gpio_direction_output(unsigned gpio, int value) | |
50 | { | |
51 | return -ENOSYS; | |
52 | } | |
53 | ||
54 | static inline int gpio_get_value(unsigned gpio) | |
55 | { | |
56 | /* GPIO can never have been requested or set as {in,out}put */ | |
57 | WARN_ON(1); | |
58 | return 0; | |
59 | } | |
60 | ||
61 | static inline void gpio_set_value(unsigned gpio, int value) | |
62 | { | |
63 | /* GPIO can never have been requested or set as output */ | |
64 | WARN_ON(1); | |
65 | } | |
66 | ||
67 | static inline int gpio_cansleep(unsigned gpio) | |
68 | { | |
69 | /* GPIO can never have been requested or set as {in,out}put */ | |
70 | WARN_ON(1); | |
71 | return 0; | |
72 | } | |
73 | ||
74 | static inline int gpio_get_value_cansleep(unsigned gpio) | |
75 | { | |
76 | /* GPIO can never have been requested or set as {in,out}put */ | |
77 | WARN_ON(1); | |
78 | return 0; | |
79 | } | |
80 | ||
81 | static inline void gpio_set_value_cansleep(unsigned gpio, int value) | |
82 | { | |
83 | /* GPIO can never have been requested or set as output */ | |
84 | WARN_ON(1); | |
85 | } | |
86 | ||
d8f388d8 DB |
87 | static inline int gpio_export(unsigned gpio, bool direction_may_change) |
88 | { | |
89 | /* GPIO can never have been requested or set as {in,out}put */ | |
90 | WARN_ON(1); | |
91 | return -EINVAL; | |
92 | } | |
93 | ||
a4177ee7 JN |
94 | static inline int gpio_export_link(struct device *dev, const char *name, |
95 | unsigned gpio) | |
96 | { | |
97 | /* GPIO can never have been exported */ | |
98 | WARN_ON(1); | |
99 | return -EINVAL; | |
100 | } | |
101 | ||
07697461 JN |
102 | static inline int gpio_sysfs_set_active_low(unsigned gpio, int value) |
103 | { | |
104 | /* GPIO can never have been requested */ | |
105 | WARN_ON(1); | |
106 | return -EINVAL; | |
107 | } | |
a4177ee7 | 108 | |
d8f388d8 DB |
109 | static inline void gpio_unexport(unsigned gpio) |
110 | { | |
111 | /* GPIO can never have been exported */ | |
112 | WARN_ON(1); | |
113 | } | |
114 | ||
7560fa60 DB |
115 | static inline int gpio_to_irq(unsigned gpio) |
116 | { | |
117 | /* GPIO can never have been requested or set as input */ | |
118 | WARN_ON(1); | |
119 | return -EINVAL; | |
120 | } | |
121 | ||
122 | static inline int irq_to_gpio(unsigned irq) | |
123 | { | |
124 | /* irq can never have been returned from gpio_to_irq() */ | |
125 | WARN_ON(1); | |
126 | return -EINVAL; | |
127 | } | |
128 | ||
129 | #endif | |
130 | ||
131 | #endif /* __LINUX_GPIO_H */ |