diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2017-01-26 15:27:54 +0100 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-01-26 15:27:54 +0100 |
commit | 27a2873617415f7a5b9881a532008efd92334b05 (patch) | |
tree | 55e1d83ab16e2cfff45fe09cc12e1cd21cd78fda /drivers/pinctrl/core.c | |
parent | af81ba3cfdeefcb743e3f82cdbdbac8294ae6779 (diff) | |
parent | 2956b5d94a76b596fa5057c2b3ca915cb27d7652 (diff) | |
download | linux-27a2873617415f7a5b9881a532008efd92334b05.tar.bz2 |
Merge branch 'ib-pinctrl-genprops' into devel
Diffstat (limited to 'drivers/pinctrl/core.c')
-rw-r--r-- | drivers/pinctrl/core.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 2f853e03d28d..d69046537b75 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -862,6 +862,35 @@ int pinctrl_gpio_direction_output(unsigned gpio) } EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_output); +/** + * pinctrl_gpio_set_config() - Apply config to given GPIO pin + * @gpio: the GPIO pin number from the GPIO subsystem number space + * @config: the configuration to apply to the GPIO + * + * This function should *ONLY* be used from gpiolib-based GPIO drivers, if + * they need to call the underlying pin controller to change GPIO config + * (for example set debounce time). + */ +int pinctrl_gpio_set_config(unsigned gpio, unsigned long config) +{ + unsigned long configs[] = { config }; + struct pinctrl_gpio_range *range; + struct pinctrl_dev *pctldev; + int ret, pin; + + ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range); + if (ret) + return ret; + + mutex_lock(&pctldev->mutex); + pin = gpio_to_pin(range, gpio); + ret = pinconf_set_config(pctldev, pin, configs, ARRAY_SIZE(configs)); + mutex_unlock(&pctldev->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(pinctrl_gpio_set_config); + static struct pinctrl_state *find_state(struct pinctrl *p, const char *name) { |