David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 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 | |
Uwe Kleine-König | 3d599d1 | 2008-10-15 22:03:12 -0700 | [diff] [blame] | 11 | #include <linux/kernel.h> |
David Brownell | 6ea0205 | 2008-05-23 13:04:58 -0700 | [diff] [blame] | 12 | #include <linux/types.h> |
| 13 | #include <linux/errno.h> |
| 14 | |
Jani Nikula | a4177ee | 2009-09-22 16:46:33 -0700 | [diff] [blame] | 15 | struct device; |
| 16 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 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 | { |
Uwe Kleine-König | 3d599d1 | 2008-10-15 22:03:12 -0700 | [diff] [blame] | 38 | might_sleep(); |
| 39 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 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 | |
Felipe Balbi | c4b5be9 | 2010-05-26 14:42:23 -0700 | [diff] [blame] | 54 | static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) |
| 55 | { |
| 56 | return -ENOSYS; |
| 57 | } |
| 58 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 59 | static inline int gpio_get_value(unsigned gpio) |
| 60 | { |
| 61 | /* GPIO can never have been requested or set as {in,out}put */ |
| 62 | WARN_ON(1); |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | static inline void gpio_set_value(unsigned gpio, int value) |
| 67 | { |
| 68 | /* GPIO can never have been requested or set as output */ |
| 69 | WARN_ON(1); |
| 70 | } |
| 71 | |
| 72 | static inline int gpio_cansleep(unsigned gpio) |
| 73 | { |
| 74 | /* GPIO can never have been requested or set as {in,out}put */ |
| 75 | WARN_ON(1); |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | static inline int gpio_get_value_cansleep(unsigned gpio) |
| 80 | { |
| 81 | /* GPIO can never have been requested or set as {in,out}put */ |
| 82 | WARN_ON(1); |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | static inline void gpio_set_value_cansleep(unsigned gpio, int value) |
| 87 | { |
| 88 | /* GPIO can never have been requested or set as output */ |
| 89 | WARN_ON(1); |
| 90 | } |
| 91 | |
David Brownell | d8f388d | 2008-07-25 01:46:07 -0700 | [diff] [blame] | 92 | static inline int gpio_export(unsigned gpio, bool direction_may_change) |
| 93 | { |
| 94 | /* GPIO can never have been requested or set as {in,out}put */ |
| 95 | WARN_ON(1); |
| 96 | return -EINVAL; |
| 97 | } |
| 98 | |
Jani Nikula | a4177ee | 2009-09-22 16:46:33 -0700 | [diff] [blame] | 99 | static inline int gpio_export_link(struct device *dev, const char *name, |
| 100 | unsigned gpio) |
| 101 | { |
| 102 | /* GPIO can never have been exported */ |
| 103 | WARN_ON(1); |
| 104 | return -EINVAL; |
| 105 | } |
| 106 | |
Jani Nikula | 0769746 | 2009-12-15 16:46:20 -0800 | [diff] [blame] | 107 | static inline int gpio_sysfs_set_active_low(unsigned gpio, int value) |
| 108 | { |
| 109 | /* GPIO can never have been requested */ |
| 110 | WARN_ON(1); |
| 111 | return -EINVAL; |
| 112 | } |
Jani Nikula | a4177ee | 2009-09-22 16:46:33 -0700 | [diff] [blame] | 113 | |
David Brownell | d8f388d | 2008-07-25 01:46:07 -0700 | [diff] [blame] | 114 | static inline void gpio_unexport(unsigned gpio) |
| 115 | { |
| 116 | /* GPIO can never have been exported */ |
| 117 | WARN_ON(1); |
| 118 | } |
| 119 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 120 | static inline int gpio_to_irq(unsigned gpio) |
| 121 | { |
| 122 | /* GPIO can never have been requested or set as input */ |
| 123 | WARN_ON(1); |
| 124 | return -EINVAL; |
| 125 | } |
| 126 | |
| 127 | static inline int irq_to_gpio(unsigned irq) |
| 128 | { |
| 129 | /* irq can never have been returned from gpio_to_irq() */ |
| 130 | WARN_ON(1); |
| 131 | return -EINVAL; |
| 132 | } |
| 133 | |
| 134 | #endif |
| 135 | |
| 136 | #endif /* __LINUX_GPIO_H */ |