mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH V3] gpio: mxc: add clock operation
@ 2018-05-22  3:05 Anson Huang
  2018-05-22 11:23 ` Fabio Estevam
  2018-05-24  8:10 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Anson Huang @ 2018-05-22  3:05 UTC (permalink / raw)
  To: linus.walleij, linux-gpio, linux-kernel; +Cc: Linux-imx

Some i.MX SoCs have GPIO clock gates in CCM CCGR, such as
i.MX6SLL, need to enable clocks before accessing GPIO
registers, add optional clock operation for GPIO driver.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
changes since V2:
	remove the copyright change, since the change is already done by
	Fabio's patch [1/2] gpio: mxc: Switch to SPDX identifier, I redo
	the patch on top of it.
 drivers/gpio/gpio-mxc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 6a9dc61..2f28299 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -7,6 +7,7 @@
 // Authors: Daniel Mack, Juergen Beisert.
 // Copyright (C) 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
 
+#include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -47,6 +48,7 @@ struct mxc_gpio_hwdata {
 struct mxc_gpio_port {
 	struct list_head node;
 	void __iomem *base;
+	struct clk *clk;
 	int irq;
 	int irq_high;
 	struct irq_domain *domain;
@@ -421,6 +423,17 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 	if (port->irq < 0)
 		return port->irq;
 
+	/* the controller clock is optional */
+	port->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(port->clk))
+		port->clk = NULL;
+
+	err = clk_prepare_enable(port->clk);
+	if (err) {
+		dev_err(&pdev->dev, "Unable to enable clock.\n");
+		return err;
+	}
+
 	/* disable the interrupt and clear the status */
 	writel(0, port->base + GPIO_IMR);
 	writel(~0, port->base + GPIO_ISR);
@@ -489,6 +502,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 out_irqdomain_remove:
 	irq_domain_remove(port->domain);
 out_bgio:
+	clk_disable_unprepare(port->clk);
 	dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err);
 	return err;
 }
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V3] gpio: mxc: add clock operation
  2018-05-22  3:05 [PATCH V3] gpio: mxc: add clock operation Anson Huang
@ 2018-05-22 11:23 ` Fabio Estevam
  2018-05-24  8:10 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2018-05-22 11:23 UTC (permalink / raw)
  To: Anson Huang; +Cc: Linus Walleij, linux-gpio, linux-kernel, NXP Linux Team

On Tue, May 22, 2018 at 12:05 AM, Anson Huang <Anson.Huang@nxp.com> wrote:
> Some i.MX SoCs have GPIO clock gates in CCM CCGR, such as
> i.MX6SLL, need to enable clocks before accessing GPIO
> registers, add optional clock operation for GPIO driver.
>
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>

Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V3] gpio: mxc: add clock operation
  2018-05-22  3:05 [PATCH V3] gpio: mxc: add clock operation Anson Huang
  2018-05-22 11:23 ` Fabio Estevam
@ 2018-05-24  8:10 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2018-05-24  8:10 UTC (permalink / raw)
  To: Anson Huang; +Cc: open list:GPIO SUBSYSTEM, linux-kernel, NXP Linux Team

On Tue, May 22, 2018 at 5:05 AM, Anson Huang <Anson.Huang@nxp.com> wrote:

> Some i.MX SoCs have GPIO clock gates in CCM CCGR, such as
> i.MX6SLL, need to enable clocks before accessing GPIO
> registers, add optional clock operation for GPIO driver.
>
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
> changes since V2:

Patch applied with Fabio's review tag and using some
fuzzing, check the result in my git when you have time!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-24  8:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-22  3:05 [PATCH V3] gpio: mxc: add clock operation Anson Huang
2018-05-22 11:23 ` Fabio Estevam
2018-05-24  8:10 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®