linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Neeli <srinivas.neeli@xilinx.com>
To: <linus.walleij@linaro.org>, <bgolaszewski@baylibre.com>,
	<michal.simek@xilinx.com>, <shubhrajyoti.datta@xilinx.com>,
	<sgoud@xilinx.com>, <hancock@sedsystems.ca>
Cc: linux-gpio@vger.kernel.org,
	Srinivas Neeli <srinivas.neeli@xilinx.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, git@xilinx.com
Subject: [LINUX PATCH V3 3/9] gpio: gpio-xilinx: Add clock support
Date: Thu, 12 Nov 2020 22:42:22 +0530	[thread overview]
Message-ID: <1605201148-4508-4-git-send-email-srinivas.neeli@xilinx.com> (raw)
In-Reply-To: <1605201148-4508-1-git-send-email-srinivas.neeli@xilinx.com>

Adds clock support to the Xilinx GPIO driver.

Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
---
Chnages in V3:
-Created separate patch for Clock changes.
---
 drivers/gpio/gpio-xilinx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index 17a8a8f90d84..99d603bfb6f0 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -6,6 +6,7 @@
  */
 
 #include <linux/bitops.h>
+#include <linux/clk.h>
 #include <linux/errno.h>
 #include <linux/gpio/driver.h>
 #include <linux/init.h>
@@ -38,6 +39,7 @@
  * @gpio_state: GPIO state shadow register
  * @gpio_dir: GPIO direction shadow register
  * @gpio_lock: Lock used for synchronization
+ * @clk: clock resource for this driver
  */
 struct xgpio_instance {
 	struct gpio_chip gc;
@@ -46,6 +48,7 @@ struct xgpio_instance {
 	u32 gpio_state[2];
 	u32 gpio_dir[2];
 	spinlock_t gpio_lock[2];
+	struct clk *clk;
 };
 
 static inline int xgpio_index(struct xgpio_instance *chip, int gpio)
@@ -333,11 +336,25 @@ static int xgpio_probe(struct platform_device *pdev)
 		return PTR_ERR(chip->regs);
 	}
 
+	chip->clk = devm_clk_get_optional(&pdev->dev, NULL);
+	if (IS_ERR(chip->clk)) {
+		if (PTR_ERR(chip->clk) != -EPROBE_DEFER)
+			dev_dbg(&pdev->dev, "Input clock not found\n");
+		return PTR_ERR(chip->clk);
+	}
+
+	status = clk_prepare_enable(chip->clk);
+	if (status < 0) {
+		dev_err(&pdev->dev, "Failed to prepare clk\n");
+		return status;
+	}
+
 	xgpio_save_regs(chip);
 
 	status = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
 	if (status) {
 		dev_err(&pdev->dev, "failed to add GPIO chip\n");
+		clk_disable_unprepare(chip->clk);
 		return status;
 	}
 
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-11-12 17:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 17:12 [LINUX PATCH V3 0/9] gpio-xilinx: Update on xilinx gpio driver Srinivas Neeli
2020-11-12 17:12 ` [LINUX PATCH V3 1/9] gpio: gpio-xilinx: Arrange headers in sorting order Srinivas Neeli
2020-11-17 23:57   ` Linus Walleij
2020-11-12 17:12 ` [LINUX PATCH V3 2/9] dt-bindings: gpio: gpio-xilinx: Add clk support to xilinx soft gpio IP Srinivas Neeli
2020-11-17 23:59   ` Linus Walleij
2020-11-12 17:12 ` Srinivas Neeli [this message]
2020-11-17 23:53   ` [LINUX PATCH V3 3/9] gpio: gpio-xilinx: Add clock support Linus Walleij
2020-11-18  0:00     ` Linus Walleij
2020-11-12 17:12 ` [LINUX PATCH V3 4/9] gpio: gpio-xilinx: Reduce spinlock array to single Srinivas Neeli
2020-11-18  0:02   ` Linus Walleij
2020-11-12 17:12 ` [LINUX PATCH V3 5/9] gpio: gpio-xilinx: Add interrupt support Srinivas Neeli
2020-11-16 16:44   ` Robert Hancock
2020-11-18  0:15   ` Linus Walleij
2020-11-12 17:12 ` [LINUX PATCH V3 6/9] gpio: gpio-xilinx: Add remove function Srinivas Neeli
2020-11-18  0:17   ` Linus Walleij
2020-11-12 17:12 ` [LINUX PATCH V3 7/9] gpio: gpio-xilinx: Add support for suspend and resume Srinivas Neeli
2020-11-18  0:38   ` Linus Walleij
2020-11-12 17:12 ` [LINUX PATCH V3 8/9] gpio: gpio-xilinx: Check return value of of_property_read_u32 Srinivas Neeli
2020-11-18  0:39   ` Linus Walleij
2020-11-12 17:12 ` [LINUX PATCH V3 9/9] MAINTAINERS: add fragment for xilinx GPIO drivers Srinivas Neeli
2020-11-18  0:40   ` Linus Walleij
2020-11-13  7:44 ` [LINUX PATCH V3 0/9] gpio-xilinx: Update on xilinx gpio driver Michal Simek
2020-11-18  0:42 ` Linus Walleij
2020-11-19  5:29   ` Srinivas Neeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1605201148-4508-4-git-send-email-srinivas.neeli@xilinx.com \
    --to=srinivas.neeli@xilinx.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=git@xilinx.com \
    --cc=hancock@sedsystems.ca \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=sgoud@xilinx.com \
    --cc=shubhrajyoti.datta@xilinx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).