diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2012-11-20 08:25:07 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-11-21 02:55:12 -0500 |
commit | 9afbefb227792a3c195085d662050dcca748f521 (patch) | |
tree | 6ca22f39a4d97a73b2fb37472af596c159210ea7 | |
parent | 8f23ca1a73a096f21e6618d8e23df613daa5e532 (diff) |
pinctrl: add function to retrieve range from pin
This adds a function to the pinctrl core to retrieve the GPIO
range associated with a certain pin for a certain controller.
This is needed when a pinctrl driver want to look up the
corresponding struct gpio_chip for a certain pin. As the
GPIO drivers can now create these ranges themselves, the
pinctrl driver no longer knows about all its associated GPIO
chips.
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/pinctrl/core.c | 24 | ||||
-rw-r--r-- | include/linux/pinctrl/pinctrl.h | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 33af811a6a3c..5cdee8669ea3 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c | |||
@@ -364,6 +364,30 @@ struct pinctrl_dev *pinctrl_find_and_add_gpio_range(const char *devname, | |||
364 | EXPORT_SYMBOL_GPL(pinctrl_find_and_add_gpio_range); | 364 | EXPORT_SYMBOL_GPL(pinctrl_find_and_add_gpio_range); |
365 | 365 | ||
366 | /** | 366 | /** |
367 | * pinctrl_find_gpio_range_from_pin() - locate the GPIO range for a pin | ||
368 | * @pctldev: the pin controller device to look in | ||
369 | * @pin: a controller-local number to find the range for | ||
370 | */ | ||
371 | struct pinctrl_gpio_range * | ||
372 | pinctrl_find_gpio_range_from_pin(struct pinctrl_dev *pctldev, | ||
373 | unsigned int pin) | ||
374 | { | ||
375 | struct pinctrl_gpio_range *range = NULL; | ||
376 | |||
377 | /* Loop over the ranges */ | ||
378 | list_for_each_entry(range, &pctldev->gpio_ranges, node) { | ||
379 | /* Check if we're in the valid range */ | ||
380 | if (pin >= range->pin_base && | ||
381 | pin < range->pin_base + range->npins) { | ||
382 | return range; | ||
383 | } | ||
384 | } | ||
385 | |||
386 | return NULL; | ||
387 | } | ||
388 | EXPORT_SYMBOL_GPL(pinctrl_find_gpio_range_from_pin); | ||
389 | |||
390 | /** | ||
367 | * pinctrl_remove_gpio_range() - remove a range of GPIOs fro a pin controller | 391 | * pinctrl_remove_gpio_range() - remove a range of GPIOs fro a pin controller |
368 | * @pctldev: pin controller device to remove the range from | 392 | * @pctldev: pin controller device to remove the range from |
369 | * @range: the GPIO range to remove | 393 | * @range: the GPIO range to remove |
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h index 7dee9acbd271..04d6700d99af 100644 --- a/include/linux/pinctrl/pinctrl.h +++ b/include/linux/pinctrl/pinctrl.h | |||
@@ -139,6 +139,9 @@ extern void pinctrl_remove_gpio_range(struct pinctrl_dev *pctldev, | |||
139 | 139 | ||
140 | extern struct pinctrl_dev *pinctrl_find_and_add_gpio_range(const char *devname, | 140 | extern struct pinctrl_dev *pinctrl_find_and_add_gpio_range(const char *devname, |
141 | struct pinctrl_gpio_range *range); | 141 | struct pinctrl_gpio_range *range); |
142 | extern struct pinctrl_gpio_range * | ||
143 | pinctrl_find_gpio_range_from_pin(struct pinctrl_dev *pctldev, | ||
144 | unsigned int pin); | ||
142 | 145 | ||
143 | #ifdef CONFIG_OF | 146 | #ifdef CONFIG_OF |
144 | extern struct pinctrl_dev *of_pinctrl_get(struct device_node *np); | 147 | extern struct pinctrl_dev *of_pinctrl_get(struct device_node *np); |