diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-26 12:35:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-26 12:35:29 -0500 |
commit | 4c8c225abf972ce422c241579ce1d4d27eaeb166 (patch) | |
tree | 77bc67defdc53c494b20632e66b82ce9be3c06af /include | |
parent | 3eb05225ee8efb81fe50558f5f9d94e7477ade8f (diff) | |
parent | 9170100ee46402af6d318134525c728027318d67 (diff) |
Merge tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux
Pull GPIO changes from Grant Likely:
"This branch contains the usual set of individual driver improvements
and bug fixes, as well as updates to the core code. The more notable
changes include:
- Internally add new API for referencing GPIOs by gpio_desc instead
of number. Eventually this will become a public API
- ACPI GPIO binding support"
* tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux: (33 commits)
arm64: select ARCH_WANT_OPTIONAL_GPIOLIB
gpio: em: Use irq_domain_add_simple() to fix runtime error
gpio: using common order: let 'static const' instead of 'const static'
gpio/vt8500: memory cleanup missing
gpiolib: Fix locking on gpio debugfs files
gpiolib: let gpio_chip reference its descriptors
gpiolib: use descriptors internally
gpiolib: use gpio_chips list in gpiochip_find_base
gpiolib: use gpio_chips list in sysfs ops
gpiolib: use gpio_chips list in gpiochip_find
gpiolib: use gpio_chips list in gpiolib_sysfs_init
gpiolib: link all gpio_chips using a list
gpio/langwell: cleanup driver
gpio/langwell: Add Cloverview ids to pci device table
gpio/lynxpoint: add chipset gpio driver.
gpiolib: add missing braces in gpio_direction_show
gpiolib-acpi: Fix error checks in interrupt requesting
gpio: mpc8xxx: don't set IRQ_TYPE_NONE when creating irq mapping
gpiolib: remove gpiochip_reserve()
arm: pxa: tosa: do not use gpiochip_reserve()
...
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/gpio.h | 86 | ||||
-rw-r--r-- | include/linux/acpi_gpio.h | 4 | ||||
-rw-r--r-- | include/linux/gpio.h | 28 |
3 files changed, 54 insertions, 64 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 20ca7663975f..bde646995d10 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h | |||
@@ -47,12 +47,14 @@ struct gpio; | |||
47 | struct seq_file; | 47 | struct seq_file; |
48 | struct module; | 48 | struct module; |
49 | struct device_node; | 49 | struct device_node; |
50 | struct gpio_desc; | ||
50 | 51 | ||
51 | /** | 52 | /** |
52 | * struct gpio_chip - abstract a GPIO controller | 53 | * struct gpio_chip - abstract a GPIO controller |
53 | * @label: for diagnostics | 54 | * @label: for diagnostics |
54 | * @dev: optional device providing the GPIOs | 55 | * @dev: optional device providing the GPIOs |
55 | * @owner: helps prevent removal of modules exporting active GPIOs | 56 | * @owner: helps prevent removal of modules exporting active GPIOs |
57 | * @list: links gpio_chips together for traversal | ||
56 | * @request: optional hook for chip-specific activation, such as | 58 | * @request: optional hook for chip-specific activation, such as |
57 | * enabling module power and clock; may sleep | 59 | * enabling module power and clock; may sleep |
58 | * @free: optional hook for chip-specific deactivation, such as | 60 | * @free: optional hook for chip-specific deactivation, such as |
@@ -75,6 +77,7 @@ struct device_node; | |||
75 | * negative during registration, requests dynamic ID allocation. | 77 | * negative during registration, requests dynamic ID allocation. |
76 | * @ngpio: the number of GPIOs handled by this controller; the last GPIO | 78 | * @ngpio: the number of GPIOs handled by this controller; the last GPIO |
77 | * handled is (base + ngpio - 1). | 79 | * handled is (base + ngpio - 1). |
80 | * @desc: array of ngpio descriptors. Private. | ||
78 | * @can_sleep: flag must be set iff get()/set() methods sleep, as they | 81 | * @can_sleep: flag must be set iff get()/set() methods sleep, as they |
79 | * must while accessing GPIO expander chips over I2C or SPI | 82 | * must while accessing GPIO expander chips over I2C or SPI |
80 | * @names: if set, must be an array of strings to use as alternative | 83 | * @names: if set, must be an array of strings to use as alternative |
@@ -98,6 +101,7 @@ struct gpio_chip { | |||
98 | const char *label; | 101 | const char *label; |
99 | struct device *dev; | 102 | struct device *dev; |
100 | struct module *owner; | 103 | struct module *owner; |
104 | struct list_head list; | ||
101 | 105 | ||
102 | int (*request)(struct gpio_chip *chip, | 106 | int (*request)(struct gpio_chip *chip, |
103 | unsigned offset); | 107 | unsigned offset); |
@@ -124,6 +128,7 @@ struct gpio_chip { | |||
124 | struct gpio_chip *chip); | 128 | struct gpio_chip *chip); |
125 | int base; | 129 | int base; |
126 | u16 ngpio; | 130 | u16 ngpio; |
131 | struct gpio_desc *desc; | ||
127 | const char *const *names; | 132 | const char *const *names; |
128 | unsigned can_sleep:1; | 133 | unsigned can_sleep:1; |
129 | unsigned exported:1; | 134 | unsigned exported:1; |
@@ -152,7 +157,6 @@ struct gpio_chip { | |||
152 | extern const char *gpiochip_is_requested(struct gpio_chip *chip, | 157 | extern const char *gpiochip_is_requested(struct gpio_chip *chip, |
153 | unsigned offset); | 158 | unsigned offset); |
154 | extern struct gpio_chip *gpio_to_chip(unsigned gpio); | 159 | extern struct gpio_chip *gpio_to_chip(unsigned gpio); |
155 | extern int __must_check gpiochip_reserve(int start, int ngpio); | ||
156 | 160 | ||
157 | /* add/remove chips */ | 161 | /* add/remove chips */ |
158 | extern int gpiochip_add(struct gpio_chip *chip); | 162 | extern int gpiochip_add(struct gpio_chip *chip); |
@@ -192,12 +196,6 @@ extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *labe | |||
192 | extern int gpio_request_array(const struct gpio *array, size_t num); | 196 | extern int gpio_request_array(const struct gpio *array, size_t num); |
193 | extern void gpio_free_array(const struct gpio *array, size_t num); | 197 | extern void gpio_free_array(const struct gpio *array, size_t num); |
194 | 198 | ||
195 | /* bindings for managed devices that want to request gpios */ | ||
196 | int devm_gpio_request(struct device *dev, unsigned gpio, const char *label); | ||
197 | int devm_gpio_request_one(struct device *dev, unsigned gpio, | ||
198 | unsigned long flags, const char *label); | ||
199 | void devm_gpio_free(struct device *dev, unsigned int gpio); | ||
200 | |||
201 | #ifdef CONFIG_GPIO_SYSFS | 199 | #ifdef CONFIG_GPIO_SYSFS |
202 | 200 | ||
203 | /* | 201 | /* |
@@ -212,6 +210,43 @@ extern void gpio_unexport(unsigned gpio); | |||
212 | 210 | ||
213 | #endif /* CONFIG_GPIO_SYSFS */ | 211 | #endif /* CONFIG_GPIO_SYSFS */ |
214 | 212 | ||
213 | #ifdef CONFIG_PINCTRL | ||
214 | |||
215 | /** | ||
216 | * struct gpio_pin_range - pin range controlled by a gpio chip | ||
217 | * @head: list for maintaining set of pin ranges, used internally | ||
218 | * @pctldev: pinctrl device which handles corresponding pins | ||
219 | * @range: actual range of pins controlled by a gpio controller | ||
220 | */ | ||
221 | |||
222 | struct gpio_pin_range { | ||
223 | struct list_head node; | ||
224 | struct pinctrl_dev *pctldev; | ||
225 | struct pinctrl_gpio_range range; | ||
226 | }; | ||
227 | |||
228 | int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, | ||
229 | unsigned int gpio_offset, unsigned int pin_offset, | ||
230 | unsigned int npins); | ||
231 | void gpiochip_remove_pin_ranges(struct gpio_chip *chip); | ||
232 | |||
233 | #else | ||
234 | |||
235 | static inline int | ||
236 | gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, | ||
237 | unsigned int gpio_offset, unsigned int pin_offset, | ||
238 | unsigned int npins) | ||
239 | { | ||
240 | return 0; | ||
241 | } | ||
242 | |||
243 | static inline void | ||
244 | gpiochip_remove_pin_ranges(struct gpio_chip *chip) | ||
245 | { | ||
246 | } | ||
247 | |||
248 | #endif /* CONFIG_PINCTRL */ | ||
249 | |||
215 | #else /* !CONFIG_GPIOLIB */ | 250 | #else /* !CONFIG_GPIOLIB */ |
216 | 251 | ||
217 | static inline bool gpio_is_valid(int number) | 252 | static inline bool gpio_is_valid(int number) |
@@ -270,41 +305,4 @@ static inline void gpio_unexport(unsigned gpio) | |||
270 | } | 305 | } |
271 | #endif /* CONFIG_GPIO_SYSFS */ | 306 | #endif /* CONFIG_GPIO_SYSFS */ |
272 | 307 | ||
273 | #ifdef CONFIG_PINCTRL | ||
274 | |||
275 | /** | ||
276 | * struct gpio_pin_range - pin range controlled by a gpio chip | ||
277 | * @head: list for maintaining set of pin ranges, used internally | ||
278 | * @pctldev: pinctrl device which handles corresponding pins | ||
279 | * @range: actual range of pins controlled by a gpio controller | ||
280 | */ | ||
281 | |||
282 | struct gpio_pin_range { | ||
283 | struct list_head node; | ||
284 | struct pinctrl_dev *pctldev; | ||
285 | struct pinctrl_gpio_range range; | ||
286 | }; | ||
287 | |||
288 | int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, | ||
289 | unsigned int gpio_offset, unsigned int pin_offset, | ||
290 | unsigned int npins); | ||
291 | void gpiochip_remove_pin_ranges(struct gpio_chip *chip); | ||
292 | |||
293 | #else | ||
294 | |||
295 | static inline int | ||
296 | gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, | ||
297 | unsigned int gpio_offset, unsigned int pin_offset, | ||
298 | unsigned int npins) | ||
299 | { | ||
300 | return 0; | ||
301 | } | ||
302 | |||
303 | static inline void | ||
304 | gpiochip_remove_pin_ranges(struct gpio_chip *chip) | ||
305 | { | ||
306 | } | ||
307 | |||
308 | #endif /* CONFIG_PINCTRL */ | ||
309 | |||
310 | #endif /* _ASM_GENERIC_GPIO_H */ | 308 | #endif /* _ASM_GENERIC_GPIO_H */ |
diff --git a/include/linux/acpi_gpio.h b/include/linux/acpi_gpio.h index 91615a389b65..b76ebd08ff8e 100644 --- a/include/linux/acpi_gpio.h +++ b/include/linux/acpi_gpio.h | |||
@@ -2,10 +2,12 @@ | |||
2 | #define _LINUX_ACPI_GPIO_H_ | 2 | #define _LINUX_ACPI_GPIO_H_ |
3 | 3 | ||
4 | #include <linux/errno.h> | 4 | #include <linux/errno.h> |
5 | #include <linux/gpio.h> | ||
5 | 6 | ||
6 | #ifdef CONFIG_GPIO_ACPI | 7 | #ifdef CONFIG_GPIO_ACPI |
7 | 8 | ||
8 | int acpi_get_gpio(char *path, int pin); | 9 | int acpi_get_gpio(char *path, int pin); |
10 | void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); | ||
9 | 11 | ||
10 | #else /* CONFIG_GPIO_ACPI */ | 12 | #else /* CONFIG_GPIO_ACPI */ |
11 | 13 | ||
@@ -14,6 +16,8 @@ static inline int acpi_get_gpio(char *path, int pin) | |||
14 | return -ENODEV; | 16 | return -ENODEV; |
15 | } | 17 | } |
16 | 18 | ||
19 | static inline void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { } | ||
20 | |||
17 | #endif /* CONFIG_GPIO_ACPI */ | 21 | #endif /* CONFIG_GPIO_ACPI */ |
18 | 22 | ||
19 | #endif /* _LINUX_ACPI_GPIO_H_ */ | 23 | #endif /* _LINUX_ACPI_GPIO_H_ */ |
diff --git a/include/linux/gpio.h b/include/linux/gpio.h index bfe665621536..f6c7ae3e223b 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h | |||
@@ -94,24 +94,12 @@ static inline int gpio_request(unsigned gpio, const char *label) | |||
94 | return -ENOSYS; | 94 | return -ENOSYS; |
95 | } | 95 | } |
96 | 96 | ||
97 | static inline int devm_gpio_request(struct device *dev, unsigned gpio, | ||
98 | const char *label) | ||
99 | { | ||
100 | return -ENOSYS; | ||
101 | } | ||
102 | |||
103 | static inline int gpio_request_one(unsigned gpio, | 97 | static inline int gpio_request_one(unsigned gpio, |
104 | unsigned long flags, const char *label) | 98 | unsigned long flags, const char *label) |
105 | { | 99 | { |
106 | return -ENOSYS; | 100 | return -ENOSYS; |
107 | } | 101 | } |
108 | 102 | ||
109 | static inline int devm_gpio_request_one(struct device *dev, unsigned gpio, | ||
110 | unsigned long flags, const char *label) | ||
111 | { | ||
112 | return -ENOSYS; | ||
113 | } | ||
114 | |||
115 | static inline int gpio_request_array(const struct gpio *array, size_t num) | 103 | static inline int gpio_request_array(const struct gpio *array, size_t num) |
116 | { | 104 | { |
117 | return -ENOSYS; | 105 | return -ENOSYS; |
@@ -125,14 +113,6 @@ static inline void gpio_free(unsigned gpio) | |||
125 | WARN_ON(1); | 113 | WARN_ON(1); |
126 | } | 114 | } |
127 | 115 | ||
128 | static inline void devm_gpio_free(struct device *dev, unsigned gpio) | ||
129 | { | ||
130 | might_sleep(); | ||
131 | |||
132 | /* GPIO can never have been requested */ | ||
133 | WARN_ON(1); | ||
134 | } | ||
135 | |||
136 | static inline void gpio_free_array(const struct gpio *array, size_t num) | 116 | static inline void gpio_free_array(const struct gpio *array, size_t num) |
137 | { | 117 | { |
138 | might_sleep(); | 118 | might_sleep(); |
@@ -248,4 +228,12 @@ gpiochip_remove_pin_ranges(struct gpio_chip *chip) | |||
248 | 228 | ||
249 | #endif /* ! CONFIG_GENERIC_GPIO */ | 229 | #endif /* ! CONFIG_GENERIC_GPIO */ |
250 | 230 | ||
231 | struct device; | ||
232 | |||
233 | /* bindings for managed devices that want to request gpios */ | ||
234 | int devm_gpio_request(struct device *dev, unsigned gpio, const char *label); | ||
235 | int devm_gpio_request_one(struct device *dev, unsigned gpio, | ||
236 | unsigned long flags, const char *label); | ||
237 | void devm_gpio_free(struct device *dev, unsigned int gpio); | ||
238 | |||
251 | #endif /* __LINUX_GPIO_H */ | 239 | #endif /* __LINUX_GPIO_H */ |