aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/of_gpio.h
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-02-02 10:20:01 -0500
committerGrant Likely <grant.likely@secretlab.ca>2012-02-06 01:08:30 -0500
commitff64abefb6680dfc2aca7ecaa5e695949e7335c9 (patch)
tree8e580bc26cb65edf3135b25e29ddf8f77d776569 /include/linux/of_gpio.h
parent9467d298e92455e6fd411d7ef1f367ced940587c (diff)
of_gpio: add support of of_gpio_named_count to be able to count named gpio
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Cc: devicetree-discuss@lists.ozlabs.org Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'include/linux/of_gpio.h')
-rw-r--r--include/linux/of_gpio.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index b254052a49d7..81733d12cbea 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -50,7 +50,8 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
50extern int of_get_named_gpio_flags(struct device_node *np, 50extern int of_get_named_gpio_flags(struct device_node *np,
51 const char *list_name, int index, enum of_gpio_flags *flags); 51 const char *list_name, int index, enum of_gpio_flags *flags);
52 52
53extern unsigned int of_gpio_count(struct device_node *np); 53extern unsigned int of_gpio_named_count(struct device_node *np,
54 const char* propname);
54 55
55extern int of_mm_gpiochip_add(struct device_node *np, 56extern int of_mm_gpiochip_add(struct device_node *np,
56 struct of_mm_gpio_chip *mm_gc); 57 struct of_mm_gpio_chip *mm_gc);
@@ -71,7 +72,8 @@ static inline int of_get_named_gpio_flags(struct device_node *np,
71 return -ENOSYS; 72 return -ENOSYS;
72} 73}
73 74
74static inline unsigned int of_gpio_count(struct device_node *np) 75static inline unsigned int of_gpio_named_count(struct device_node *np,
76 const char* propname)
75{ 77{
76 return 0; 78 return 0;
77} 79}
@@ -89,6 +91,27 @@ static inline void of_gpiochip_remove(struct gpio_chip *gc) { }
89#endif /* CONFIG_OF_GPIO */ 91#endif /* CONFIG_OF_GPIO */
90 92
91/** 93/**
94 * of_gpio_count - Count GPIOs for a device
95 * @np: device node to count GPIOs for
96 *
97 * The function returns the count of GPIOs specified for a node.
98 *
99 * Note that the empty GPIO specifiers counts too. For example,
100 *
101 * gpios = <0
102 * &pio1 1 2
103 * 0
104 * &pio2 3 4>;
105 *
106 * defines four GPIOs (so this function will return 4), two of which
107 * are not specified.
108 */
109static inline unsigned int of_gpio_count(struct device_node *np)
110{
111 return of_gpio_named_count(np, "gpios");
112}
113
114/**
92 * of_get_gpio_flags() - Get a GPIO number and flags to use with GPIO API 115 * of_get_gpio_flags() - Get a GPIO number and flags to use with GPIO API
93 * @np: device node to get GPIO from 116 * @np: device node to get GPIO from
94 * @index: index of the GPIO 117 * @index: index of the GPIO