All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
To: mturquette@baylibre.com, sboyd@kernel.org, robh+dt@kernel.org,
	mark.rutland@arm.com, geert+renesas@glider.be
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Subject: [PATCH 3/3] clk: renesas: rcar-usb2-clock-sel: Add reset_control
Date: Thu, 24 Oct 2019 20:17:01 +0900	[thread overview]
Message-ID: <1571915821-1620-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> (raw)
In-Reply-To: <1571915821-1620-1-git-send-email-yoshihiro.shimoda.uh@renesas.com>

This hardware needs to deassert resets of both host and peripheral.
So, this patch adds reset control.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/clk/renesas/rcar-usb2-clock-sel.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/clk/renesas/rcar-usb2-clock-sel.c b/drivers/clk/renesas/rcar-usb2-clock-sel.c
index 570fbd0..dfe5510 100644
--- a/drivers/clk/renesas/rcar-usb2-clock-sel.c
+++ b/drivers/clk/renesas/rcar-usb2-clock-sel.c
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
+#include <linux/reset.h>
 #include <linux/slab.h>
 
 #define USB20_CLKSET0		0x00
@@ -36,6 +37,7 @@ struct usb2_clock_sel_priv {
 	void __iomem *base;
 	struct clk_hw hw;
 	struct clk *clks[CLK_NUM];
+	struct reset_control *rsts;
 	bool extal;
 	bool xtal;
 };
@@ -63,11 +65,16 @@ static int usb2_clock_sel_enable(struct clk_hw *hw)
 	struct usb2_clock_sel_priv *priv = to_priv(hw);
 	int i, ret;
 
+	ret = reset_control_deassert(priv->rsts);
+	if (ret)
+		return ret;
+
 	for (i = 0; i < CLK_NUM; i++) {
 		ret = clk_prepare_enable(priv->clks[i]);
 		if (ret) {
 			while (--i >= 0)
 				clk_disable_unprepare(priv->clks[i]);
+			reset_control_assert(priv->rsts);
 			return ret;
 		}
 	}
@@ -86,6 +93,7 @@ static void usb2_clock_sel_disable(struct clk_hw *hw)
 
 	for (i = 0; i < CLK_NUM; i++)
 		clk_disable_unprepare(priv->clks[i]);
+	reset_control_assert(priv->rsts);
 }
 
 /*
@@ -164,6 +172,10 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->clks[CLK_INDEX_HS_USB]))
 		return PTR_ERR(priv->clks[CLK_INDEX_HS_USB]);
 
+	priv->rsts = devm_reset_control_array_get_optional_shared(&pdev->dev);
+	if (IS_ERR(priv->rsts))
+		return PTR_ERR(priv->rsts);
+
 	clk = devm_clk_get(dev, "usb_extal");
 	if (!IS_ERR(clk) && !clk_prepare_enable(clk)) {
 		priv->extal = !!clk_get_rate(clk);
-- 
2.7.4


  parent reply	other threads:[~2019-10-24 11:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 11:16 [PATCH 0/3] clk: renesas: rcar-usb2-clock-sel: Fix clks/resets handling Yoshihiro Shimoda
2019-10-24 11:16 ` [PATCH 1/3] dt-bindings: clock: renesas: rcar-usb2-clock-sel: Fix clock[-name]s properties Yoshihiro Shimoda
2019-10-24 11:45   ` Geert Uytterhoeven
2019-10-25  1:29     ` Yoshihiro Shimoda
2019-10-25  7:45       ` Geert Uytterhoeven
2019-10-24 11:17 ` [PATCH 2/3] clk: renesas: rcar-usb2-clock-sel: Add multiple clocks management Yoshihiro Shimoda
2019-10-24 11:34   ` Geert Uytterhoeven
2019-10-25  1:36     ` Yoshihiro Shimoda
2019-10-25  7:47       ` Geert Uytterhoeven
2019-10-25  8:44         ` Yoshihiro Shimoda
2019-10-25  8:57           ` Geert Uytterhoeven
2019-10-24 11:17 ` Yoshihiro Shimoda [this message]
2019-10-24 11:26   ` [PATCH 3/3] clk: renesas: rcar-usb2-clock-sel: Add reset_control Geert Uytterhoeven
2019-10-25  1:42     ` Yoshihiro Shimoda
2019-10-25  7:54       ` Geert Uytterhoeven
2019-10-25  8:44         ` Yoshihiro Shimoda

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=1571915821-1620-4-git-send-email-yoshihiro.shimoda.uh@renesas.com \
    --to=yoshihiro.shimoda.uh@renesas.com \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.