diff options
Diffstat (limited to 'include/linux/of_gpio.h')
| -rw-r--r-- | include/linux/of_gpio.h | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index c454f5796747..a83dc6f5008e 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h | |||
| @@ -50,9 +50,6 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) | |||
| 50 | extern int of_get_named_gpio_flags(struct device_node *np, | 50 | extern 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 | ||
| 53 | extern unsigned int of_gpio_named_count(struct device_node *np, | ||
| 54 | const char* propname); | ||
| 55 | |||
| 56 | extern int of_mm_gpiochip_add(struct device_node *np, | 53 | extern int of_mm_gpiochip_add(struct device_node *np, |
| 57 | struct of_mm_gpio_chip *mm_gc); | 54 | struct of_mm_gpio_chip *mm_gc); |
| 58 | 55 | ||
| @@ -71,12 +68,6 @@ static inline int of_get_named_gpio_flags(struct device_node *np, | |||
| 71 | return -ENOSYS; | 68 | return -ENOSYS; |
| 72 | } | 69 | } |
| 73 | 70 | ||
| 74 | static inline unsigned int of_gpio_named_count(struct device_node *np, | ||
| 75 | const char* propname) | ||
| 76 | { | ||
| 77 | return 0; | ||
| 78 | } | ||
| 79 | |||
| 80 | static inline int of_gpio_simple_xlate(struct gpio_chip *gc, | 71 | static inline int of_gpio_simple_xlate(struct gpio_chip *gc, |
| 81 | const struct of_phandle_args *gpiospec, | 72 | const struct of_phandle_args *gpiospec, |
| 82 | u32 *flags) | 73 | u32 *flags) |
| @@ -90,22 +81,37 @@ static inline void of_gpiochip_remove(struct gpio_chip *gc) { } | |||
| 90 | #endif /* CONFIG_OF_GPIO */ | 81 | #endif /* CONFIG_OF_GPIO */ |
| 91 | 82 | ||
| 92 | /** | 83 | /** |
| 93 | * of_gpio_count - Count GPIOs for a device | 84 | * of_gpio_named_count() - Count GPIOs for a device |
| 94 | * @np: device node to count GPIOs for | 85 | * @np: device node to count GPIOs for |
| 86 | * @propname: property name containing gpio specifier(s) | ||
| 95 | * | 87 | * |
| 96 | * The function returns the count of GPIOs specified for a node. | 88 | * The function returns the count of GPIOs specified for a node. |
| 89 | * Note that the empty GPIO specifiers count too. Returns either | ||
| 90 | * Number of gpios defined in property, | ||
| 91 | * -EINVAL for an incorrectly formed gpios property, or | ||
| 92 | * -ENOENT for a missing gpios property | ||
| 97 | * | 93 | * |
| 98 | * Note that the empty GPIO specifiers counts too. For example, | 94 | * Example: |
| 99 | * | ||
| 100 | * gpios = <0 | 95 | * gpios = <0 |
| 101 | * &pio1 1 2 | 96 | * &gpio1 1 2 |
| 102 | * 0 | 97 | * 0 |
| 103 | * &pio2 3 4>; | 98 | * &gpio2 3 4>; |
| 99 | * | ||
| 100 | * The above example defines four GPIOs, two of which are not specified. | ||
| 101 | * This function will return '4' | ||
| 102 | */ | ||
| 103 | static inline int of_gpio_named_count(struct device_node *np, const char* propname) | ||
| 104 | { | ||
| 105 | return of_count_phandle_with_args(np, propname, "#gpio-cells"); | ||
| 106 | } | ||
| 107 | |||
| 108 | /** | ||
| 109 | * of_gpio_count() - Count GPIOs for a device | ||
| 110 | * @np: device node to count GPIOs for | ||
| 104 | * | 111 | * |
| 105 | * defines four GPIOs (so this function will return 4), two of which | 112 | * Same as of_gpio_named_count, but hard coded to use the 'gpios' property |
| 106 | * are not specified. | ||
| 107 | */ | 113 | */ |
| 108 | static inline unsigned int of_gpio_count(struct device_node *np) | 114 | static inline int of_gpio_count(struct device_node *np) |
| 109 | { | 115 | { |
| 110 | return of_gpio_named_count(np, "gpios"); | 116 | return of_gpio_named_count(np, "gpios"); |
| 111 | } | 117 | } |
