[PATCH V2 4/8] gpio: vf610: add optional clock support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some SoCs need the gpio clock to be enabled before accessing
HW registers. This patch add the optional clock handling.

Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
Cc: Stefan Agner <stefan@xxxxxxxx>
Cc: Shawn Guo <shawnguo@xxxxxxxxxx>
Cc: linux-gpio@xxxxxxxxxxxxxxx
Signed-off-by: Dong Aisheng <aisheng.dong@xxxxxxx>
---
v1->v2:
 * new patch
---
 drivers/gpio/gpio-vf610.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
index d4ad6d0..cbc4f44 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>
@@ -256,6 +257,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_gpio, *clk_port;
 	struct vf610_gpio_port *port;
 	struct resource *iores;
 	struct gpio_chip *gc;
@@ -280,6 +282,24 @@ static int vf610_gpio_probe(struct platform_device *pdev)
 	if (port->irq < 0)
 		return port->irq;
 
+	clk_gpio = devm_clk_get(&pdev->dev, "gpio");
+	clk_port = devm_clk_get(&pdev->dev, "port");
+	if ((PTR_ERR(clk_gpio) == -EPROBE_DEFER) ||
+	    (PTR_ERR(clk_port) == -EPROBE_DEFER)) {
+		return -EPROBE_DEFER;
+	} else if (!IS_ERR_OR_NULL(clk_gpio) &&
+		   !IS_ERR_OR_NULL(clk_port)) {
+		ret = clk_prepare_enable(clk_gpio);
+		if (ret)
+			return ret;
+
+		ret = clk_prepare_enable(clk_port);
+		if (ret) {
+			clk_disable_unprepare(clk_gpio);
+			return ret;
+		}
+	}
+
 	gc = &port->gc;
 	gc->of_node = np;
 	gc->parent = dev;
-- 
2.7.4





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux