From: "A.s. Dong" <aisheng.dong@nxp.com>
To: "linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>,
"dongas86@gmail.com" <dongas86@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
Stefan Agner <stefan@agner.ch>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
dl-linux-imx <linux-imx@nxp.com>,
"kernel@pengutronix.de" <kernel@pengutronix.de>,
Fabio Estevam <fabio.estevam@nxp.com>,
"shawnguo@kernel.org" <shawnguo@kernel.org>
Subject: [PATCH V3 04/10] gpio: vf610: add optional clock support
Date: Wed, 31 Oct 2018 14:43:08 +0000 [thread overview]
Message-ID: <1540996688-23681-5-git-send-email-aisheng.dong@nxp.com> (raw)
In-Reply-To: <1540996688-23681-1-git-send-email-aisheng.dong@nxp.com>
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@linaro.org>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: linux-gpio@vger.kernel.org
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
v2->v3:
* error checking updated according to Russell's suggestion:
ptr == ERR_PTR(-EPROBE_DEFER)
* clock independently checking
v1->v2:
* new patch
---
drivers/gpio/gpio-vf610.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
index d4ad6d0..02fb7d8 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,28 @@ static int vf610_gpio_probe(struct platform_device *pdev)
if (port->irq < 0)
return port->irq;
+ clk_port = devm_clk_get(&pdev->dev, "port");
+ if (clk_port == ERR_PTR(-EPROBE_DEFER))
+ return -EPROBE_DEFER;
+
+ clk_gpio = devm_clk_get(&pdev->dev, "gpio");
+ if (clk_gpio == ERR_PTR(-EPROBE_DEFER))
+ return -EPROBE_DEFER;
+
+ if (!IS_ERR_OR_NULL(clk_port)) {
+ ret = clk_prepare_enable(clk_port);
+ if (ret)
+ return ret;
+ }
+
+ if (!IS_ERR_OR_NULL(clk_gpio)) {
+ 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;
--
2.7.4
next prev parent reply other threads:[~2018-10-31 14:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1540996688-23681-1-git-send-email-aisheng.dong@nxp.com>
2018-10-31 14:43 ` [PATCH V3 03/10] dt-bindings: gpio: vf610: add optional clocks property A.s. Dong
2018-11-02 9:26 ` Linus Walleij
2018-10-31 14:43 ` A.s. Dong [this message]
2018-11-02 9:32 ` [PATCH V3 04/10] gpio: vf610: add optional clock support Linus Walleij
2018-11-05 13:34 ` A.s. Dong
2018-10-31 14:43 ` [PATCH V3 05/10] dt-bindings: pinctrl: imx7ulp: back to imx legacy binding for consistency A.s. Dong
2018-10-31 14:43 ` [PATCH V3 06/10] pinctrl: fsl: imx7ulp: change to use imx legacy binding A.s. Dong
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=1540996688-23681-5-git-send-email-aisheng.dong@nxp.com \
--to=aisheng.dong@nxp.com \
--cc=dongas86@gmail.com \
--cc=fabio.estevam@nxp.com \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux@armlinux.org.uk \
--cc=robh+dt@kernel.org \
--cc=shawnguo@kernel.org \
--cc=stefan@agner.ch \
/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).