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 | |
Randy Dunlap | c001fb7 | 2011-06-14 17:05:11 -0700 | [diff] [blame] | 6 | /* make these flag values available regardless of GPIO kconfig options */ |
| 7 | #define GPIOF_DIR_OUT (0 << 0) |
| 8 | #define GPIOF_DIR_IN (1 << 0) |
| 9 | |
| 10 | #define GPIOF_INIT_LOW (0 << 1) |
| 11 | #define GPIOF_INIT_HIGH (1 << 1) |
| 12 | |
| 13 | #define GPIOF_IN (GPIOF_DIR_IN) |
| 14 | #define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW) |
| 15 | #define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH) |
| 16 | |
Mark Brown | feb8369 | 2011-10-24 15:24:10 +0200 | [diff] [blame] | 17 | /** |
| 18 | * struct gpio - a structure describing a GPIO with configuration |
| 19 | * @gpio: the GPIO number |
| 20 | * @flags: GPIO configuration as specified by GPIOF_* |
| 21 | * @label: a literal description string of this GPIO |
| 22 | */ |
| 23 | struct gpio { |
| 24 | unsigned gpio; |
| 25 | unsigned long flags; |
| 26 | const char *label; |
| 27 | }; |
| 28 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 29 | #ifdef CONFIG_GENERIC_GPIO |
| 30 | #include <asm/gpio.h> |
| 31 | |
| 32 | #else |
| 33 | |
Uwe Kleine-König | 3d599d1 | 2008-10-15 22:03:12 -0700 | [diff] [blame] | 34 | #include <linux/kernel.h> |
David Brownell | 6ea0205 | 2008-05-23 13:04:58 -0700 | [diff] [blame] | 35 | #include <linux/types.h> |
| 36 | #include <linux/errno.h> |
| 37 | |
Jani Nikula | a4177ee | 2009-09-22 16:46:33 -0700 | [diff] [blame] | 38 | struct device; |
Anton Vorontsov | 4e4438b | 2010-09-01 08:55:24 -0600 | [diff] [blame] | 39 | struct gpio_chip; |
Jani Nikula | a4177ee | 2009-09-22 16:46:33 -0700 | [diff] [blame] | 40 | |
Joe Perches | 3474cb3 | 2011-05-10 16:23:07 -0700 | [diff] [blame] | 41 | static inline bool gpio_is_valid(int number) |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 42 | { |
Joe Perches | 3474cb3 | 2011-05-10 16:23:07 -0700 | [diff] [blame] | 43 | return false; |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 44 | } |
| 45 | |
Linus Torvalds | d8a3515 | 2011-01-13 17:26:46 -0800 | [diff] [blame] | 46 | static inline int gpio_request(unsigned gpio, const char *label) |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 47 | { |
| 48 | return -ENOSYS; |
| 49 | } |
| 50 | |
Wolfram Sang | 323b7fe | 2011-01-14 09:34:29 +0100 | [diff] [blame] | 51 | static inline int gpio_request_one(unsigned gpio, |
Wolfram Sang | 5f829e4 | 2011-01-12 17:00:24 -0800 | [diff] [blame] | 52 | unsigned long flags, const char *label) |
| 53 | { |
| 54 | return -ENOSYS; |
| 55 | } |
| 56 | |
Lars-Peter Clausen | 7c29597 | 2011-05-25 16:20:31 -0700 | [diff] [blame] | 57 | static inline int gpio_request_array(const struct gpio *array, size_t num) |
Wolfram Sang | 5f829e4 | 2011-01-12 17:00:24 -0800 | [diff] [blame] | 58 | { |
| 59 | return -ENOSYS; |
| 60 | } |
| 61 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 62 | static inline void gpio_free(unsigned gpio) |
| 63 | { |
Uwe Kleine-König | 3d599d1 | 2008-10-15 22:03:12 -0700 | [diff] [blame] | 64 | might_sleep(); |
| 65 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 66 | /* GPIO can never have been requested */ |
| 67 | WARN_ON(1); |
| 68 | } |
| 69 | |
Lars-Peter Clausen | 7c29597 | 2011-05-25 16:20:31 -0700 | [diff] [blame] | 70 | static inline void gpio_free_array(const struct gpio *array, size_t num) |
Wolfram Sang | 5f829e4 | 2011-01-12 17:00:24 -0800 | [diff] [blame] | 71 | { |
| 72 | might_sleep(); |
| 73 | |
| 74 | /* GPIO can never have been requested */ |
| 75 | WARN_ON(1); |
| 76 | } |
| 77 | |
Linus Torvalds | d8a3515 | 2011-01-13 17:26:46 -0800 | [diff] [blame] | 78 | static inline int gpio_direction_input(unsigned gpio) |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 79 | { |
| 80 | return -ENOSYS; |
| 81 | } |
| 82 | |
Linus Torvalds | d8a3515 | 2011-01-13 17:26:46 -0800 | [diff] [blame] | 83 | static inline int gpio_direction_output(unsigned gpio, int value) |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 84 | { |
| 85 | return -ENOSYS; |
| 86 | } |
| 87 | |
Felipe Balbi | c4b5be9 | 2010-05-26 14:42:23 -0700 | [diff] [blame] | 88 | static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) |
| 89 | { |
| 90 | return -ENOSYS; |
| 91 | } |
| 92 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 93 | static inline int gpio_get_value(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 void gpio_set_value(unsigned gpio, int value) |
| 101 | { |
| 102 | /* GPIO can never have been requested or set as output */ |
| 103 | WARN_ON(1); |
| 104 | } |
| 105 | |
| 106 | static inline int gpio_cansleep(unsigned gpio) |
| 107 | { |
| 108 | /* GPIO can never have been requested or set as {in,out}put */ |
| 109 | WARN_ON(1); |
| 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | static inline int gpio_get_value_cansleep(unsigned gpio) |
| 114 | { |
| 115 | /* GPIO can never have been requested or set as {in,out}put */ |
| 116 | WARN_ON(1); |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | static inline void gpio_set_value_cansleep(unsigned gpio, int value) |
| 121 | { |
| 122 | /* GPIO can never have been requested or set as output */ |
| 123 | WARN_ON(1); |
| 124 | } |
| 125 | |
David Brownell | d8f388d8 | 2008-07-25 01:46:07 -0700 | [diff] [blame] | 126 | static inline int gpio_export(unsigned gpio, bool direction_may_change) |
| 127 | { |
| 128 | /* GPIO can never have been requested or set as {in,out}put */ |
| 129 | WARN_ON(1); |
| 130 | return -EINVAL; |
| 131 | } |
| 132 | |
Jani Nikula | a4177ee | 2009-09-22 16:46:33 -0700 | [diff] [blame] | 133 | static inline int gpio_export_link(struct device *dev, const char *name, |
| 134 | unsigned gpio) |
| 135 | { |
| 136 | /* GPIO can never have been exported */ |
| 137 | WARN_ON(1); |
| 138 | return -EINVAL; |
| 139 | } |
| 140 | |
Jani Nikula | 0769746 | 2009-12-15 16:46:20 -0800 | [diff] [blame] | 141 | static inline int gpio_sysfs_set_active_low(unsigned gpio, int value) |
| 142 | { |
| 143 | /* GPIO can never have been requested */ |
| 144 | WARN_ON(1); |
| 145 | return -EINVAL; |
| 146 | } |
Jani Nikula | a4177ee | 2009-09-22 16:46:33 -0700 | [diff] [blame] | 147 | |
David Brownell | d8f388d8 | 2008-07-25 01:46:07 -0700 | [diff] [blame] | 148 | static inline void gpio_unexport(unsigned gpio) |
| 149 | { |
| 150 | /* GPIO can never have been exported */ |
| 151 | WARN_ON(1); |
| 152 | } |
| 153 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 154 | static inline int gpio_to_irq(unsigned gpio) |
| 155 | { |
| 156 | /* GPIO can never have been requested or set as input */ |
| 157 | WARN_ON(1); |
| 158 | return -EINVAL; |
| 159 | } |
| 160 | |
| 161 | static inline int irq_to_gpio(unsigned irq) |
| 162 | { |
| 163 | /* irq can never have been returned from gpio_to_irq() */ |
| 164 | WARN_ON(1); |
| 165 | return -EINVAL; |
| 166 | } |
| 167 | |
| 168 | #endif |
| 169 | |
| 170 | #endif /* __LINUX_GPIO_H */ |