aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 12:35:29 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 12:35:29 -0500
commit4c8c225abf972ce422c241579ce1d4d27eaeb166 (patch)
tree77bc67defdc53c494b20632e66b82ce9be3c06af /include/asm-generic
parent3eb05225ee8efb81fe50558f5f9d94e7477ade8f (diff)
parent9170100ee46402af6d318134525c728027318d67 (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/asm-generic')
-rw-r--r--include/asm-generic/gpio.h86
1 files changed, 42 insertions, 44 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;
47struct seq_file; 47struct seq_file;
48struct module; 48struct module;
49struct device_node; 49struct device_node;
50struct 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 {
152extern const char *gpiochip_is_requested(struct gpio_chip *chip, 157extern const char *gpiochip_is_requested(struct gpio_chip *chip,
153 unsigned offset); 158 unsigned offset);
154extern struct gpio_chip *gpio_to_chip(unsigned gpio); 159extern struct gpio_chip *gpio_to_chip(unsigned gpio);
155extern int __must_check gpiochip_reserve(int start, int ngpio);
156 160
157/* add/remove chips */ 161/* add/remove chips */
158extern int gpiochip_add(struct gpio_chip *chip); 162extern int gpiochip_add(struct gpio_chip *chip);
@@ -192,12 +196,6 @@ extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *labe
192extern int gpio_request_array(const struct gpio *array, size_t num); 196extern int gpio_request_array(const struct gpio *array, size_t num);
193extern void gpio_free_array(const struct gpio *array, size_t num); 197extern void gpio_free_array(const struct gpio *array, size_t num);
194 198
195/* bindings for managed devices that want to request gpios */
196int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
197int devm_gpio_request_one(struct device *dev, unsigned gpio,
198 unsigned long flags, const char *label);
199void 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
222struct gpio_pin_range {
223 struct list_head node;
224 struct pinctrl_dev *pctldev;
225 struct pinctrl_gpio_range range;
226};
227
228int 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);
231void gpiochip_remove_pin_ranges(struct gpio_chip *chip);
232
233#else
234
235static inline int
236gpiochip_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
243static inline void
244gpiochip_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
217static inline bool gpio_is_valid(int number) 252static 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
282struct gpio_pin_range {
283 struct list_head node;
284 struct pinctrl_dev *pctldev;
285 struct pinctrl_gpio_range range;
286};
287
288int 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);
291void gpiochip_remove_pin_ranges(struct gpio_chip *chip);
292
293#else
294
295static inline int
296gpiochip_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
303static inline void
304gpiochip_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 */