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