aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/of_gpio.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/of_gpio.h')
-rw-r--r--include/linux/of_gpio.h51
1 files changed, 46 insertions, 5 deletions
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index 6598c04dab0..52280a2b5e6 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -46,8 +46,9 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
46 return container_of(gc, struct of_mm_gpio_chip, gc); 46 return container_of(gc, struct of_mm_gpio_chip, gc);
47} 47}
48 48
49extern int of_get_gpio_flags(struct device_node *np, int index, 49extern int of_get_named_gpio_flags(struct device_node *np,
50 enum of_gpio_flags *flags); 50 const char *list_name, int index, enum of_gpio_flags *flags);
51
51extern unsigned int of_gpio_count(struct device_node *np); 52extern unsigned int of_gpio_count(struct device_node *np);
52 53
53extern int of_mm_gpiochip_add(struct device_node *np, 54extern int of_mm_gpiochip_add(struct device_node *np,
@@ -56,12 +57,14 @@ extern int of_mm_gpiochip_add(struct device_node *np,
56extern void of_gpiochip_add(struct gpio_chip *gc); 57extern void of_gpiochip_add(struct gpio_chip *gc);
57extern void of_gpiochip_remove(struct gpio_chip *gc); 58extern void of_gpiochip_remove(struct gpio_chip *gc);
58extern struct gpio_chip *of_node_to_gpiochip(struct device_node *np); 59extern struct gpio_chip *of_node_to_gpiochip(struct device_node *np);
60extern int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np,
61 const void *gpio_spec, u32 *flags);
59 62
60#else /* CONFIG_OF_GPIO */ 63#else /* CONFIG_OF_GPIO */
61 64
62/* Drivers may not strictly depend on the GPIO support, so let them link. */ 65/* Drivers may not strictly depend on the GPIO support, so let them link. */
63static inline int of_get_gpio_flags(struct device_node *np, int index, 66static inline int of_get_named_gpio_flags(struct device_node *np,
64 enum of_gpio_flags *flags) 67 const char *list_name, int index, enum of_gpio_flags *flags)
65{ 68{
66 return -ENOSYS; 69 return -ENOSYS;
67} 70}
@@ -71,13 +74,51 @@ static inline unsigned int of_gpio_count(struct device_node *np)
71 return 0; 74 return 0;
72} 75}
73 76
77static inline int of_gpio_simple_xlate(struct gpio_chip *gc,
78 struct device_node *np,
79 const void *gpio_spec, u32 *flags)
80{
81 return -ENOSYS;
82}
83
74static inline void of_gpiochip_add(struct gpio_chip *gc) { } 84static inline void of_gpiochip_add(struct gpio_chip *gc) { }
75static inline void of_gpiochip_remove(struct gpio_chip *gc) { } 85static inline void of_gpiochip_remove(struct gpio_chip *gc) { }
76 86
77#endif /* CONFIG_OF_GPIO */ 87#endif /* CONFIG_OF_GPIO */
78 88
79/** 89/**
80 * of_get_gpio - Get a GPIO number to use with GPIO API 90 * of_get_gpio_flags() - Get a GPIO number and flags to use with GPIO API
91 * @np: device node to get GPIO from
92 * @index: index of the GPIO
93 * @flags: a flags pointer to fill in
94 *
95 * Returns GPIO number to use with Linux generic GPIO API, or one of the errno
96 * value on the error condition. If @flags is not NULL the function also fills
97 * in flags for the GPIO.
98 */
99static inline int of_get_gpio_flags(struct device_node *np, int index,
100 enum of_gpio_flags *flags)
101{
102 return of_get_named_gpio_flags(np, "gpios", index, flags);
103}
104
105/**
106 * of_get_named_gpio() - Get a GPIO number to use with GPIO API
107 * @np: device node to get GPIO from
108 * @propname: Name of property containing gpio specifier(s)
109 * @index: index of the GPIO
110 *
111 * Returns GPIO number to use with Linux generic GPIO API, or one of the errno
112 * value on the error condition.
113 */
114static inline int of_get_named_gpio(struct device_node *np,
115 const char *propname, int index)
116{
117 return of_get_named_gpio_flags(np, propname, index, NULL);
118}
119
120/**
121 * of_get_gpio() - Get a GPIO number to use with GPIO API
81 * @np: device node to get GPIO from 122 * @np: device node to get GPIO from
82 * @index: index of the GPIO 123 * @index: index of the GPIO
83 * 124 *