diff options
Diffstat (limited to 'include/linux/gpio/driver.h')
-rw-r--r-- | include/linux/gpio/driver.h | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 3ea2cf6b0e6c..a3e181e09636 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h | |||
@@ -39,14 +39,15 @@ struct seq_file; | |||
39 | * @ngpio: the number of GPIOs handled by this controller; the last GPIO | 39 | * @ngpio: the number of GPIOs handled by this controller; the last GPIO |
40 | * handled is (base + ngpio - 1). | 40 | * handled is (base + ngpio - 1). |
41 | * @desc: array of ngpio descriptors. Private. | 41 | * @desc: array of ngpio descriptors. Private. |
42 | * @can_sleep: flag must be set iff get()/set() methods sleep, as they | ||
43 | * must while accessing GPIO expander chips over I2C or SPI | ||
44 | * @names: if set, must be an array of strings to use as alternative | 42 | * @names: if set, must be an array of strings to use as alternative |
45 | * names for the GPIOs in this chip. Any entry in the array | 43 | * names for the GPIOs in this chip. Any entry in the array |
46 | * may be NULL if there is no alias for the GPIO, however the | 44 | * may be NULL if there is no alias for the GPIO, however the |
47 | * array must be @ngpio entries long. A name can include a single printk | 45 | * array must be @ngpio entries long. A name can include a single printk |
48 | * format specifier for an unsigned int. It is substituted by the actual | 46 | * format specifier for an unsigned int. It is substituted by the actual |
49 | * number of the gpio. | 47 | * number of the gpio. |
48 | * @can_sleep: flag must be set iff get()/set() methods sleep, as they | ||
49 | * must while accessing GPIO expander chips over I2C or SPI | ||
50 | * @exported: flags if the gpiochip is exported for use from sysfs. Private. | ||
50 | * | 51 | * |
51 | * A gpio_chip can help platforms abstract various sources of GPIOs so | 52 | * A gpio_chip can help platforms abstract various sources of GPIOs so |
52 | * they can all be accessed through a common programing interface. | 53 | * they can all be accessed through a common programing interface. |
@@ -91,8 +92,8 @@ struct gpio_chip { | |||
91 | u16 ngpio; | 92 | u16 ngpio; |
92 | struct gpio_desc *desc; | 93 | struct gpio_desc *desc; |
93 | const char *const *names; | 94 | const char *const *names; |
94 | unsigned can_sleep:1; | 95 | bool can_sleep; |
95 | unsigned exported:1; | 96 | bool exported; |
96 | 97 | ||
97 | #if defined(CONFIG_OF_GPIO) | 98 | #if defined(CONFIG_OF_GPIO) |
98 | /* | 99 | /* |
@@ -136,59 +137,50 @@ enum gpio_lookup_flags { | |||
136 | }; | 137 | }; |
137 | 138 | ||
138 | /** | 139 | /** |
139 | * Lookup table for associating GPIOs to specific devices and functions using | 140 | * struct gpiod_lookup - lookup table |
140 | * platform data. | 141 | * @chip_label: name of the chip the GPIO belongs to |
142 | * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO | ||
143 | * @con_id: name of the GPIO from the device's point of view | ||
144 | * @idx: index of the GPIO in case several GPIOs share the same name | ||
145 | * @flags: mask of GPIO_* values | ||
146 | * | ||
147 | * gpiod_lookup is a lookup table for associating GPIOs to specific devices and | ||
148 | * functions using platform data. | ||
141 | */ | 149 | */ |
142 | struct gpiod_lookup { | 150 | struct gpiod_lookup { |
143 | struct list_head list; | ||
144 | /* | ||
145 | * name of the chip the GPIO belongs to | ||
146 | */ | ||
147 | const char *chip_label; | 151 | const char *chip_label; |
148 | /* | ||
149 | * hardware number (i.e. relative to the chip) of the GPIO | ||
150 | */ | ||
151 | u16 chip_hwnum; | 152 | u16 chip_hwnum; |
152 | /* | ||
153 | * name of device that can claim this GPIO | ||
154 | */ | ||
155 | const char *dev_id; | ||
156 | /* | ||
157 | * name of the GPIO from the device's point of view | ||
158 | */ | ||
159 | const char *con_id; | 153 | const char *con_id; |
160 | /* | ||
161 | * index of the GPIO in case several GPIOs share the same name | ||
162 | */ | ||
163 | unsigned int idx; | 154 | unsigned int idx; |
164 | /* | ||
165 | * mask of GPIO_* values | ||
166 | */ | ||
167 | enum gpio_lookup_flags flags; | 155 | enum gpio_lookup_flags flags; |
168 | }; | 156 | }; |
169 | 157 | ||
158 | struct gpiod_lookup_table { | ||
159 | struct list_head list; | ||
160 | const char *dev_id; | ||
161 | struct gpiod_lookup table[]; | ||
162 | }; | ||
163 | |||
170 | /* | 164 | /* |
171 | * Simple definition of a single GPIO under a con_id | 165 | * Simple definition of a single GPIO under a con_id |
172 | */ | 166 | */ |
173 | #define GPIO_LOOKUP(_chip_label, _chip_hwnum, _dev_id, _con_id, _flags) \ | 167 | #define GPIO_LOOKUP(_chip_label, _chip_hwnum, _con_id, _flags) \ |
174 | GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _dev_id, _con_id, 0, _flags) | 168 | GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, 0, _flags) |
175 | 169 | ||
176 | /* | 170 | /* |
177 | * Use this macro if you need to have several GPIOs under the same con_id. | 171 | * Use this macro if you need to have several GPIOs under the same con_id. |
178 | * Each GPIO needs to use a different index and can be accessed using | 172 | * Each GPIO needs to use a different index and can be accessed using |
179 | * gpiod_get_index() | 173 | * gpiod_get_index() |
180 | */ | 174 | */ |
181 | #define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _dev_id, _con_id, _idx, \ | 175 | #define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, _idx, _flags) \ |
182 | _flags) \ | ||
183 | { \ | 176 | { \ |
184 | .chip_label = _chip_label, \ | 177 | .chip_label = _chip_label, \ |
185 | .chip_hwnum = _chip_hwnum, \ | 178 | .chip_hwnum = _chip_hwnum, \ |
186 | .dev_id = _dev_id, \ | ||
187 | .con_id = _con_id, \ | 179 | .con_id = _con_id, \ |
188 | .idx = _idx, \ | 180 | .idx = _idx, \ |
189 | .flags = _flags, \ | 181 | .flags = _flags, \ |
190 | } | 182 | } |
191 | 183 | ||
192 | void gpiod_add_table(struct gpiod_lookup *table, size_t size); | 184 | void gpiod_add_lookup_table(struct gpiod_lookup_table *table); |
193 | 185 | ||
194 | #endif | 186 | #endif |