diff options
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/gpio.h | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index a9432fc6b8ba..20ca7663975f 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <linux/errno.h> | 6 | #include <linux/errno.h> |
7 | #include <linux/of.h> | 7 | #include <linux/of.h> |
8 | #include <linux/pinctrl/pinctrl.h> | ||
8 | 9 | ||
9 | #ifdef CONFIG_GPIOLIB | 10 | #ifdef CONFIG_GPIOLIB |
10 | 11 | ||
@@ -56,6 +57,8 @@ struct device_node; | |||
56 | * enabling module power and clock; may sleep | 57 | * enabling module power and clock; may sleep |
57 | * @free: optional hook for chip-specific deactivation, such as | 58 | * @free: optional hook for chip-specific deactivation, such as |
58 | * disabling module power and clock; may sleep | 59 | * disabling module power and clock; may sleep |
60 | * @get_direction: returns direction for signal "offset", 0=out, 1=in, | ||
61 | * (same as GPIOF_DIR_XXX), or negative error | ||
59 | * @direction_input: configures signal "offset" as input, or returns error | 62 | * @direction_input: configures signal "offset" as input, or returns error |
60 | * @get: returns value for signal "offset"; for output signals this | 63 | * @get: returns value for signal "offset"; for output signals this |
61 | * returns either the value actually sensed, or zero | 64 | * returns either the value actually sensed, or zero |
@@ -100,7 +103,8 @@ struct gpio_chip { | |||
100 | unsigned offset); | 103 | unsigned offset); |
101 | void (*free)(struct gpio_chip *chip, | 104 | void (*free)(struct gpio_chip *chip, |
102 | unsigned offset); | 105 | unsigned offset); |
103 | 106 | int (*get_direction)(struct gpio_chip *chip, | |
107 | unsigned offset); | ||
104 | int (*direction_input)(struct gpio_chip *chip, | 108 | int (*direction_input)(struct gpio_chip *chip, |
105 | unsigned offset); | 109 | unsigned offset); |
106 | int (*get)(struct gpio_chip *chip, | 110 | int (*get)(struct gpio_chip *chip, |
@@ -134,6 +138,15 @@ struct gpio_chip { | |||
134 | int (*of_xlate)(struct gpio_chip *gc, | 138 | int (*of_xlate)(struct gpio_chip *gc, |
135 | const struct of_phandle_args *gpiospec, u32 *flags); | 139 | const struct of_phandle_args *gpiospec, u32 *flags); |
136 | #endif | 140 | #endif |
141 | #ifdef CONFIG_PINCTRL | ||
142 | /* | ||
143 | * If CONFIG_PINCTRL is enabled, then gpio controllers can optionally | ||
144 | * describe the actual pin range which they serve in an SoC. This | ||
145 | * information would be used by pinctrl subsystem to configure | ||
146 | * corresponding pins for gpio usage. | ||
147 | */ | ||
148 | struct list_head pin_ranges; | ||
149 | #endif | ||
137 | }; | 150 | }; |
138 | 151 | ||
139 | extern const char *gpiochip_is_requested(struct gpio_chip *chip, | 152 | extern const char *gpiochip_is_requested(struct gpio_chip *chip, |
@@ -257,4 +270,41 @@ static inline void gpio_unexport(unsigned gpio) | |||
257 | } | 270 | } |
258 | #endif /* CONFIG_GPIO_SYSFS */ | 271 | #endif /* CONFIG_GPIO_SYSFS */ |
259 | 272 | ||
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 | |||
260 | #endif /* _ASM_GENERIC_GPIO_H */ | 310 | #endif /* _ASM_GENERIC_GPIO_H */ |