diff options
author | Dong Aisheng <aisheng.dong@nxp.com> | 2017-08-15 11:32:18 +0800 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:30:31 +0800 |
commit | 81a424f4a2649332fece51983fd6f3c4014d75f0 (patch) | |
tree | 170ba678721ba13e9b21fae86ce8bda23c2a7c09 | |
parent | 9373cd9ec933072bea759527edbf0a9bbbea053a (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 43b20760b0dc..047ceb498a69 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> @@ -258,6 +259,7 @@ static int vf610_gpio_probe(struct platform_device *pdev) &pdev->dev); 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; @@ -282,6 +284,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; |