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; |
Wolfram Sang | 5f829e4 | 2011-01-12 17:00:24 -0800 | [diff] [blame] | 16 | struct gpio; |
Anton Vorontsov | 4e4438b | 2010-09-01 08:55:24 -0600 | [diff] [blame] | 17 | struct gpio_chip; |
Jani Nikula | a4177ee | 2009-09-22 16:46:33 -0700 | [diff] [blame] | 18 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 19 | /* |
| 20 | * Some platforms don't support the GPIO programming interface. |
| 21 | * |
| 22 | * In case some driver uses it anyway (it should normally have |
| 23 | * depended on GENERIC_GPIO), these routines help the compiler |
| 24 | * optimize out much GPIO-related code ... or trigger a runtime |
| 25 | * warning when something is wrongly called. |
| 26 | */ |
| 27 | |
| 28 | static inline int gpio_is_valid(int number) |
| 29 | { |
| 30 | return 0; |
| 31 | } |
| 32 | |
Linus Torvalds | d8a3515 | 2011-01-13 17:26:46 -0800 | [diff] [blame] | 33 | static inline int gpio_request(unsigned gpio, const char *label) |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 34 | { |
| 35 | return -ENOSYS; |
| 36 | } |
| 37 | |
Wolfram Sang | 323b7fe | 2011-01-14 09:34:29 +0100 | [diff] [blame] | 38 | static inline int gpio_request_one(unsigned gpio, |
Wolfram Sang | 5f829e4 | 2011-01-12 17:00:24 -0800 | [diff] [blame] | 39 | unsigned long flags, const char *label) |
| 40 | { |
| 41 | return -ENOSYS; |
| 42 | } |
| 43 | |
Wolfram Sang | 323b7fe | 2011-01-14 09:34:29 +0100 | [diff] [blame] | 44 | static inline int gpio_request_array(struct gpio *array, size_t num) |
Wolfram Sang | 5f829e4 | 2011-01-12 17:00:24 -0800 | [diff] [blame] | 45 | { |
| 46 | return -ENOSYS; |
| 47 | } |
| 48 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 49 | static inline void gpio_free(unsigned gpio) |
| 50 | { |
Uwe Kleine-König | 3d599d1 | 2008-10-15 22:03:12 -0700 | [diff] [blame] | 51 | might_sleep(); |
| 52 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 53 | /* GPIO can never have been requested */ |
| 54 | WARN_ON(1); |
| 55 | } |
| 56 | |
Wolfram Sang | 5f829e4 | 2011-01-12 17:00:24 -0800 | [diff] [blame] | 57 | static inline void gpio_free_array(struct gpio *array, size_t num) |
| 58 | { |
| 59 | might_sleep(); |
| 60 | |
| 61 | /* GPIO can never have been requested */ |
| 62 | WARN_ON(1); |
| 63 | } |
| 64 | |
Linus Torvalds | d8a3515 | 2011-01-13 17:26:46 -0800 | [diff] [blame] | 65 | static inline int gpio_direction_input(unsigned gpio) |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 66 | { |
| 67 | return -ENOSYS; |
| 68 | } |
| 69 | |
Linus Torvalds | d8a3515 | 2011-01-13 17:26:46 -0800 | [diff] [blame] | 70 | static inline int gpio_direction_output(unsigned gpio, int value) |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 71 | { |
| 72 | return -ENOSYS; |
| 73 | } |
| 74 | |
Felipe Balbi | c4b5be9 | 2010-05-26 14:42:23 -0700 | [diff] [blame] | 75 | static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) |
| 76 | { |
| 77 | return -ENOSYS; |
| 78 | } |
| 79 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 80 | static inline int gpio_get_value(unsigned gpio) |
| 81 | { |
| 82 | /* GPIO can never have been requested or set as {in,out}put */ |
| 83 | WARN_ON(1); |
| 84 | return 0; |
| 85 | } |
| 86 | |
| 87 | static inline void gpio_set_value(unsigned gpio, int value) |
| 88 | { |
| 89 | /* GPIO can never have been requested or set as output */ |
| 90 | WARN_ON(1); |
| 91 | } |
| 92 | |
| 93 | static inline int gpio_cansleep(unsigned gpio) |
| 94 | { |
| 95 | /* GPIO can never have been requested or set as {in,out}put */ |
| 96 | WARN_ON(1); |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | static inline int gpio_get_value_cansleep(unsigned gpio) |
| 101 | { |
| 102 | /* GPIO can never have been requested or set as {in,out}put */ |
| 103 | WARN_ON(1); |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | static inline void gpio_set_value_cansleep(unsigned gpio, int value) |
| 108 | { |
| 109 | /* GPIO can never have been requested or set as output */ |
| 110 | WARN_ON(1); |
| 111 | } |
| 112 | |
David Brownell | d8f388d | 2008-07-25 01:46:07 -0700 | [diff] [blame] | 113 | static inline int gpio_export(unsigned gpio, bool direction_may_change) |
| 114 | { |
| 115 | /* GPIO can never have been requested or set as {in,out}put */ |
| 116 | WARN_ON(1); |
| 117 | return -EINVAL; |
| 118 | } |
| 119 | |
Jani Nikula | a4177ee | 2009-09-22 16:46:33 -0700 | [diff] [blame] | 120 | static inline int gpio_export_link(struct device *dev, const char *name, |
| 121 | unsigned gpio) |
| 122 | { |
| 123 | /* GPIO can never have been exported */ |
| 124 | WARN_ON(1); |
| 125 | return -EINVAL; |
| 126 | } |
| 127 | |
Jani Nikula | 0769746 | 2009-12-15 16:46:20 -0800 | [diff] [blame] | 128 | static inline int gpio_sysfs_set_active_low(unsigned gpio, int value) |
| 129 | { |
| 130 | /* GPIO can never have been requested */ |
| 131 | WARN_ON(1); |
| 132 | return -EINVAL; |
| 133 | } |
Jani Nikula | a4177ee | 2009-09-22 16:46:33 -0700 | [diff] [blame] | 134 | |
David Brownell | d8f388d | 2008-07-25 01:46:07 -0700 | [diff] [blame] | 135 | static inline void gpio_unexport(unsigned gpio) |
| 136 | { |
| 137 | /* GPIO can never have been exported */ |
| 138 | WARN_ON(1); |
| 139 | } |
| 140 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 141 | static inline int gpio_to_irq(unsigned gpio) |
| 142 | { |
| 143 | /* GPIO can never have been requested or set as input */ |
| 144 | WARN_ON(1); |
| 145 | return -EINVAL; |
| 146 | } |
| 147 | |
| 148 | static inline int irq_to_gpio(unsigned irq) |
| 149 | { |
| 150 | /* irq can never have been returned from gpio_to_irq() */ |
| 151 | WARN_ON(1); |
| 152 | return -EINVAL; |
| 153 | } |
| 154 | |
| 155 | #endif |
| 156 | |
| 157 | #endif /* __LINUX_GPIO_H */ |