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 | |
David Brownell | 6ea0205 | 2008-05-23 13:04:58 -0700 | [diff] [blame] | 11 | #include <linux/types.h> |
| 12 | #include <linux/errno.h> |
| 13 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 14 | /* |
| 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 | |
| 23 | static inline int gpio_is_valid(int number) |
| 24 | { |
| 25 | return 0; |
| 26 | } |
| 27 | |
| 28 | static inline int gpio_request(unsigned gpio, const char *label) |
| 29 | { |
| 30 | return -ENOSYS; |
| 31 | } |
| 32 | |
| 33 | static inline void gpio_free(unsigned gpio) |
| 34 | { |
| 35 | /* GPIO can never have been requested */ |
| 36 | WARN_ON(1); |
| 37 | } |
| 38 | |
| 39 | static inline int gpio_direction_input(unsigned gpio) |
| 40 | { |
| 41 | return -ENOSYS; |
| 42 | } |
| 43 | |
| 44 | static inline int gpio_direction_output(unsigned gpio, int value) |
| 45 | { |
| 46 | return -ENOSYS; |
| 47 | } |
| 48 | |
| 49 | static 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 | |
| 56 | static 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 | |
| 62 | static 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 | |
| 69 | static 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 | |
| 76 | static 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 Brownell | d8f388d | 2008-07-25 01:46:07 -0700 | [diff] [blame] | 82 | static 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 | |
| 89 | static inline void gpio_unexport(unsigned gpio) |
| 90 | { |
| 91 | /* GPIO can never have been exported */ |
| 92 | WARN_ON(1); |
| 93 | } |
| 94 | |
David Brownell | 7560fa6 | 2008-03-04 14:28:27 -0800 | [diff] [blame] | 95 | static 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 | |
| 102 | static 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 */ |