0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef __LINUX_GPIO_H
0013 #define __LINUX_GPIO_H
0014
0015 #include <linux/errno.h>
0016
0017
0018
0019
0020 #define GPIOF_DIR_OUT (0 << 0)
0021 #define GPIOF_DIR_IN (1 << 0)
0022
0023 #define GPIOF_INIT_LOW (0 << 1)
0024 #define GPIOF_INIT_HIGH (1 << 1)
0025
0026 #define GPIOF_IN (GPIOF_DIR_IN)
0027 #define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
0028 #define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
0029
0030
0031 #define GPIOF_ACTIVE_LOW (1 << 2)
0032
0033
0034 #define GPIOF_OPEN_DRAIN (1 << 3)
0035
0036
0037 #define GPIOF_OPEN_SOURCE (1 << 4)
0038
0039 #define GPIOF_EXPORT (1 << 5)
0040 #define GPIOF_EXPORT_CHANGEABLE (1 << 6)
0041 #define GPIOF_EXPORT_DIR_FIXED (GPIOF_EXPORT)
0042 #define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE)
0043
0044
0045
0046
0047
0048
0049
0050 struct gpio {
0051 unsigned gpio;
0052 unsigned long flags;
0053 const char *label;
0054 };
0055
0056 #ifdef CONFIG_GPIOLIB
0057
0058 #ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
0059 #include <asm/gpio.h>
0060 #else
0061
0062 #include <asm-generic/gpio.h>
0063
0064 static inline int gpio_get_value(unsigned int gpio)
0065 {
0066 return __gpio_get_value(gpio);
0067 }
0068
0069 static inline void gpio_set_value(unsigned int gpio, int value)
0070 {
0071 __gpio_set_value(gpio, value);
0072 }
0073
0074 static inline int gpio_cansleep(unsigned int gpio)
0075 {
0076 return __gpio_cansleep(gpio);
0077 }
0078
0079 static inline int gpio_to_irq(unsigned int gpio)
0080 {
0081 return __gpio_to_irq(gpio);
0082 }
0083
0084 static inline int irq_to_gpio(unsigned int irq)
0085 {
0086 return -EINVAL;
0087 }
0088
0089 #endif
0090
0091
0092
0093 struct device;
0094
0095 int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
0096 int devm_gpio_request_one(struct device *dev, unsigned gpio,
0097 unsigned long flags, const char *label);
0098
0099 #else
0100
0101 #include <linux/kernel.h>
0102 #include <linux/types.h>
0103 #include <linux/bug.h>
0104
0105 struct device;
0106 struct gpio_chip;
0107
0108 static inline bool gpio_is_valid(int number)
0109 {
0110 return false;
0111 }
0112
0113 static inline int gpio_request(unsigned gpio, const char *label)
0114 {
0115 return -ENOSYS;
0116 }
0117
0118 static inline int gpio_request_one(unsigned gpio,
0119 unsigned long flags, const char *label)
0120 {
0121 return -ENOSYS;
0122 }
0123
0124 static inline int gpio_request_array(const struct gpio *array, size_t num)
0125 {
0126 return -ENOSYS;
0127 }
0128
0129 static inline void gpio_free(unsigned gpio)
0130 {
0131 might_sleep();
0132
0133
0134 WARN_ON(1);
0135 }
0136
0137 static inline void gpio_free_array(const struct gpio *array, size_t num)
0138 {
0139 might_sleep();
0140
0141
0142 WARN_ON(1);
0143 }
0144
0145 static inline int gpio_direction_input(unsigned gpio)
0146 {
0147 return -ENOSYS;
0148 }
0149
0150 static inline int gpio_direction_output(unsigned gpio, int value)
0151 {
0152 return -ENOSYS;
0153 }
0154
0155 static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
0156 {
0157 return -ENOSYS;
0158 }
0159
0160 static inline int gpio_get_value(unsigned gpio)
0161 {
0162
0163 WARN_ON(1);
0164 return 0;
0165 }
0166
0167 static inline void gpio_set_value(unsigned gpio, int value)
0168 {
0169
0170 WARN_ON(1);
0171 }
0172
0173 static inline int gpio_cansleep(unsigned gpio)
0174 {
0175
0176 WARN_ON(1);
0177 return 0;
0178 }
0179
0180 static inline int gpio_get_value_cansleep(unsigned gpio)
0181 {
0182
0183 WARN_ON(1);
0184 return 0;
0185 }
0186
0187 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
0188 {
0189
0190 WARN_ON(1);
0191 }
0192
0193 static inline int gpio_export(unsigned gpio, bool direction_may_change)
0194 {
0195
0196 WARN_ON(1);
0197 return -EINVAL;
0198 }
0199
0200 static inline int gpio_export_link(struct device *dev, const char *name,
0201 unsigned gpio)
0202 {
0203
0204 WARN_ON(1);
0205 return -EINVAL;
0206 }
0207
0208 static inline void gpio_unexport(unsigned gpio)
0209 {
0210
0211 WARN_ON(1);
0212 }
0213
0214 static inline int gpio_to_irq(unsigned gpio)
0215 {
0216
0217 WARN_ON(1);
0218 return -EINVAL;
0219 }
0220
0221 static inline int irq_to_gpio(unsigned irq)
0222 {
0223
0224 WARN_ON(1);
0225 return -EINVAL;
0226 }
0227
0228 static inline int devm_gpio_request(struct device *dev, unsigned gpio,
0229 const char *label)
0230 {
0231 WARN_ON(1);
0232 return -EINVAL;
0233 }
0234
0235 static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
0236 unsigned long flags, const char *label)
0237 {
0238 WARN_ON(1);
0239 return -EINVAL;
0240 }
0241
0242 #endif
0243
0244 #endif