diff options
author | Yunlei He <heyunlei@huawei.com> | 2014-12-01 23:32:59 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-12-03 08:44:23 -0500 |
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 84b49cfb81a8..04756130437f 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c | |||
@@ -52,28 +52,34 @@ struct pl061_gpio { | |||
52 | 52 | ||
53 | void __iomem *base; | 53 | void __iomem *base; |
54 | struct gpio_chip gc; | 54 | struct gpio_chip gc; |
55 | bool uses_pinctrl; | ||
55 | 56 | ||
56 | #ifdef CONFIG_PM | 57 | #ifdef CONFIG_PM |
57 | struct pl061_context_save_regs csave_regs; | 58 | struct pl061_context_save_regs csave_regs; |
58 | #endif | 59 | #endif |
59 | }; | 60 | }; |
60 | 61 | ||
61 | static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset) | 62 | static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset) |
62 | { | 63 | { |
63 | /* | 64 | /* |
64 | * Map back to global GPIO space and request muxing, the direction | 65 | * Map back to global GPIO space and request muxing, the direction |
65 | * parameter does not matter for this controller. | 66 | * parameter does not matter for this controller. |
66 | */ | 67 | */ |
67 | int gpio = chip->base + offset; | 68 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); |
69 | int gpio = gc->base + offset; | ||
68 | 70 | ||
69 | return pinctrl_request_gpio(gpio); | 71 | if (chip->uses_pinctrl) |
72 | return pinctrl_request_gpio(gpio); | ||
73 | return 0; | ||
70 | } | 74 | } |
71 | 75 | ||
72 | static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset) | 76 | static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset) |
73 | { | 77 | { |
74 | int gpio = chip->base + offset; | 78 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); |
79 | int gpio = gc->base + offset; | ||
75 | 80 | ||
76 | pinctrl_free_gpio(gpio); | 81 | if (chip->uses_pinctrl) |
82 | pinctrl_free_gpio(gpio); | ||
77 | } | 83 | } |
78 | 84 | ||
79 | static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) | 85 | 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) | |||
263 | return PTR_ERR(chip->base); | 269 | return PTR_ERR(chip->base); |
264 | 270 | ||
265 | spin_lock_init(&chip->lock); | 271 | spin_lock_init(&chip->lock); |
272 | if (of_property_read_bool(dev->of_node, "gpio-ranges")) | ||
273 | chip->uses_pinctrl = true; | ||
266 | 274 | ||
267 | chip->gc.request = pl061_gpio_request; | 275 | chip->gc.request = pl061_gpio_request; |
268 | chip->gc.free = pl061_gpio_free; | 276 | chip->gc.free = pl061_gpio_free; |