diff options
author | Dong Aisheng <aisheng.dong@nxp.com> | 2017-08-15 11:32:18 +0800 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | 7d9ecc041d64b627c91422e09f212b2f1fdd40be (patch) | |
tree | 17eea29acb76b8305fe4a81710a2bda338b8e5f6 | |
parent | 245c4a85cc836e47cfb20181d7e220374b75541d (diff) |
MLK-17491-14 gpio-vf610: add getting necessary clocks support
On MX7ULP, GPIO controller needs two necessary clocks:
Port module clock and GPIO module clock.
Add them as optional clocks to use.
Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
-rw-r--r-- | Documentation/devicetree/bindings/gpio/gpio-vf610.txt | 6 | ||||
-rw-r--r-- | drivers/gpio/gpio-vf610.c | 19 |
2 files changed, 25 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio-vf610.txt b/Documentation/devicetree/bindings/gpio/gpio-vf610.txt index 0ccbae44019c..42130d9a2ef2 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-vf610.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-vf610.txt @@ -27,6 +27,12 @@ Required properties for GPIO node: Note: Each GPIO port should have an alias correctly numbered in "aliases" node. +Optional properties: +- clocks : phandle + clock specifier pairs, one for each entry in + clock-names. +- clock-names : should contain: "port" - the Port module clock and + "gpio" - the GPIO module clock. + Examples: aliases { diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c index ffc077204db3..0e3771f89040 100644 --- a/drivers/gpio/gpio-vf610.c +++ b/drivers/gpio/gpio-vf610.c @@ -16,6 +16,7 @@ */ #include <linux/bitops.h> +#include <linux/clk.h> #include <linux/err.h> #include <linux/gpio.h> #include <linux/init.h> @@ -239,6 +240,7 @@ static int vf610_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; + struct clk *clk_port, *clk_gpio; struct vf610_gpio_port *port; struct resource *iores; struct gpio_chip *gc; @@ -262,6 +264,23 @@ static int vf610_gpio_probe(struct platform_device *pdev) if (port->irq < 0) return port->irq; + clk_port = devm_clk_get(&pdev->dev, "port"); + clk_gpio = devm_clk_get(&pdev->dev, "gpio"); + if (PTR_ERR(clk_port) == -EPROBE_DEFER || + PTR_ERR(clk_gpio) == -EPROBE_DEFER) + return -EPROBE_DEFER; + + if (!IS_ERR(clk_port) && !IS_ERR(clk_gpio)) { + ret = clk_prepare_enable(clk_port); + if (ret) + return ret; + ret = clk_prepare_enable(clk_gpio); + if (ret) { + clk_disable_unprepare(clk_port); + return ret; + } + } + gc = &port->gc; gc->of_node = np; gc->parent = dev; |