aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic/gpio.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-generic/gpio.h')
-rw-r--r--include/asm-generic/gpio.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 485eeb6c4ef3..4f3d75e1ad39 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -60,7 +60,9 @@ struct module;
60 * @names: if set, must be an array of strings to use as alternative 60 * @names: if set, must be an array of strings to use as alternative
61 * names for the GPIOs in this chip. Any entry in the array 61 * names for the GPIOs in this chip. Any entry in the array
62 * may be NULL if there is no alias for the GPIO, however the 62 * may be NULL if there is no alias for the GPIO, however the
63 * array must be @ngpio entries long. 63 * array must be @ngpio entries long. A name can include a single printk
64 * format specifier for an unsigned int. It is substituted by the actual
65 * number of the gpio.
64 * 66 *
65 * A gpio_chip can help platforms abstract various sources of GPIOs so 67 * A gpio_chip can help platforms abstract various sources of GPIOs so
66 * they can all be accessed through a common programing interface. 68 * they can all be accessed through a common programing interface.
@@ -88,6 +90,9 @@ struct gpio_chip {
88 unsigned offset); 90 unsigned offset);
89 int (*direction_output)(struct gpio_chip *chip, 91 int (*direction_output)(struct gpio_chip *chip,
90 unsigned offset, int value); 92 unsigned offset, int value);
93 int (*set_debounce)(struct gpio_chip *chip,
94 unsigned offset, unsigned debounce);
95
91 void (*set)(struct gpio_chip *chip, 96 void (*set)(struct gpio_chip *chip,
92 unsigned offset, int value); 97 unsigned offset, int value);
93 98
@@ -98,7 +103,7 @@ struct gpio_chip {
98 struct gpio_chip *chip); 103 struct gpio_chip *chip);
99 int base; 104 int base;
100 u16 ngpio; 105 u16 ngpio;
101 char **names; 106 const char *const *names;
102 unsigned can_sleep:1; 107 unsigned can_sleep:1;
103 unsigned exported:1; 108 unsigned exported:1;
104}; 109};
@@ -121,6 +126,8 @@ extern void gpio_free(unsigned gpio);
121extern int gpio_direction_input(unsigned gpio); 126extern int gpio_direction_input(unsigned gpio);
122extern int gpio_direction_output(unsigned gpio, int value); 127extern int gpio_direction_output(unsigned gpio, int value);
123 128
129extern int gpio_set_debounce(unsigned gpio, unsigned debounce);
130
124extern int gpio_get_value_cansleep(unsigned gpio); 131extern int gpio_get_value_cansleep(unsigned gpio);
125extern void gpio_set_value_cansleep(unsigned gpio, int value); 132extern void gpio_set_value_cansleep(unsigned gpio, int value);
126 133
@@ -136,6 +143,32 @@ extern int __gpio_cansleep(unsigned gpio);
136 143
137extern int __gpio_to_irq(unsigned gpio); 144extern int __gpio_to_irq(unsigned gpio);
138 145
146#define GPIOF_DIR_OUT (0 << 0)
147#define GPIOF_DIR_IN (1 << 0)
148
149#define GPIOF_INIT_LOW (0 << 1)
150#define GPIOF_INIT_HIGH (1 << 1)
151
152#define GPIOF_IN (GPIOF_DIR_IN)
153#define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
154#define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
155
156/**
157 * struct gpio - a structure describing a GPIO with configuration
158 * @gpio: the GPIO number
159 * @flags: GPIO configuration as specified by GPIOF_*
160 * @label: a literal description string of this GPIO
161 */
162struct gpio {
163 unsigned gpio;
164 unsigned long flags;
165 const char *label;
166};
167
168extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
169extern int gpio_request_array(struct gpio *array, size_t num);
170extern void gpio_free_array(struct gpio *array, size_t num);
171
139#ifdef CONFIG_GPIO_SYSFS 172#ifdef CONFIG_GPIO_SYSFS
140 173
141/* 174/*