diff options
author | Yunlei He <heyunlei@huawei.com> | 2014-12-02 12:32:59 +0800 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-12-03 14:44:23 +0100 |
commit | 27f9fec5cf248692b373c31905c65326952a8e63 (patch) | |
tree | 509e1d01c482249fb9fe7844a5e587490519daef /drivers/gpio | |
parent | a4e635544f65021c346f2097daa0c8dd63dd6221 (diff) |
gpio: pl061: hook request if gpio-ranges avaiable
Gpio-ranges property is useful to represent which GPIOs correspond
to which pins on which pin controllers. But there may be some gpios
without pinctrl operation. So check whether gpio-ranges property
exists in device node first.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Xinwei Kong <kong.kongxinwei@hisilicon.com>
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-pl061.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 84b49cfb81a..04756130437 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c @@ -52,28 +52,34 @@ struct pl061_gpio { void __iomem *base; struct gpio_chip gc; + bool uses_pinctrl; #ifdef CONFIG_PM struct pl061_context_save_regs csave_regs; #endif }; -static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset) +static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset) { /* * Map back to global GPIO space and request muxing, the direction * parameter does not matter for this controller. */ - int gpio = chip->base + offset; + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + int gpio = gc->base + offset; - return pinctrl_request_gpio(gpio); + if (chip->uses_pinctrl) + return pinctrl_request_gpio(gpio); + return 0; } -static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset) +static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset) { - int gpio = chip->base + offset; + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + int gpio = gc->base + offset; - pinctrl_free_gpio(gpio); + if (chip->uses_pinctrl) + pinctrl_free_gpio(gpio); } static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) @@ -263,6 +269,8 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) return PTR_ERR(chip->base); spin_lock_init(&chip->lock); + if (of_property_read_bool(dev->of_node, "gpio-ranges")) + chip->uses_pinctrl = true; chip->gc.request = pl061_gpio_request; chip->gc.free = pl061_gpio_free; |