blob: 730a20b83576b4ab39d81810085c20d61eec0225 [file] [log] [blame]
David Brownell7560fa62008-03-04 14:28:27 -08001#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
David Brownell6ea02052008-05-23 13:04:58 -070011#include <linux/types.h>
12#include <linux/errno.h>
13
David Brownell7560fa62008-03-04 14:28:27 -080014/*
15 * Some platforms don't support the GPIO programming interface.
16 *
17 * In case some driver uses it anyway (it should normally have
18 * depended on GENERIC_GPIO), these routines help the compiler
19 * optimize out much GPIO-related code ... or trigger a runtime
20 * warning when something is wrongly called.
21 */
22
23static inline int gpio_is_valid(int number)
24{
25 return 0;
26}
27
28static inline int gpio_request(unsigned gpio, const char *label)
29{
30 return -ENOSYS;
31}
32
33static inline void gpio_free(unsigned gpio)
34{
35 /* GPIO can never have been requested */
36 WARN_ON(1);
37}
38
39static inline int gpio_direction_input(unsigned gpio)
40{
41 return -ENOSYS;
42}
43
44static inline int gpio_direction_output(unsigned gpio, int value)
45{
46 return -ENOSYS;
47}
48
49static inline int gpio_get_value(unsigned gpio)
50{
51 /* GPIO can never have been requested or set as {in,out}put */
52 WARN_ON(1);
53 return 0;
54}
55
56static inline void gpio_set_value(unsigned gpio, int value)
57{
58 /* GPIO can never have been requested or set as output */
59 WARN_ON(1);
60}
61
62static inline int gpio_cansleep(unsigned gpio)
63{
64 /* GPIO can never have been requested or set as {in,out}put */
65 WARN_ON(1);
66 return 0;
67}
68
69static inline int gpio_get_value_cansleep(unsigned gpio)
70{
71 /* GPIO can never have been requested or set as {in,out}put */
72 WARN_ON(1);
73 return 0;
74}
75
76static inline void gpio_set_value_cansleep(unsigned gpio, int value)
77{
78 /* GPIO can never have been requested or set as output */
79 WARN_ON(1);
80}
81
David Brownelld8f388d2008-07-25 01:46:07 -070082static inline int gpio_export(unsigned gpio, bool direction_may_change)
83{
84 /* GPIO can never have been requested or set as {in,out}put */
85 WARN_ON(1);
86 return -EINVAL;
87}
88
89static inline void gpio_unexport(unsigned gpio)
90{
91 /* GPIO can never have been exported */
92 WARN_ON(1);
93}
94
David Brownell7560fa62008-03-04 14:28:27 -080095static inline int gpio_to_irq(unsigned gpio)
96{
97 /* GPIO can never have been requested or set as input */
98 WARN_ON(1);
99 return -EINVAL;
100}
101
102static inline int irq_to_gpio(unsigned irq)
103{
104 /* irq can never have been returned from gpio_to_irq() */
105 WARN_ON(1);
106 return -EINVAL;
107}
108
109#endif
110
111#endif /* __LINUX_GPIO_H */