mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: William Wu <william.wu@rock-chips.com>
To: kishon@ti.com
Cc: robh+dt@kernel.org, heiko@sntech.de,
	linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	frank.wang@rock-chips.com, huangtao@rock-chips.com,
	dianders@google.com, briannorris@google.com, groeck@google.com,
	daniel.meng@rock-chips.com, John.Youn@synopsys.com,
	william.wu@rock-chips.com, lin.huang@rock-chips.com
Subject: [PATCH 3/3] phy: rockchip-typec: reset USB3 controller before initializing PHY
Date: Fri, 12 Jan 2018 18:08:24 +0800	[thread overview]
Message-ID: <1515751704-13213-4-git-send-email-william.wu@rock-chips.com> (raw)
In-Reply-To: <1515751704-13213-1-git-send-email-william.wu@rock-chips.com>

According to the RK3399 TRM, for Type-C USB start-up sequence,
we need to hold the whole USB 3.0 OTG controller in reset state
to keep the PIPE power state in P2 while initializing PHY. This
is because when initialize the Type-C PHY for USB3, we need to
configure the PHY and PMA for the selected mode of operation,
and wait for the PMA and PIPE ready, if the USB3 OTG controller
isn't in P2 state, it may cause waiting timeout.

Without this patch, waiting for the PMA and PIPE ready timeout
issue easily happens when we shutdown the Logic on RK3399 and
do the suspend/resume stress test.

Signed-off-by: William Wu <william.wu@rock-chips.com>
---
 drivers/phy/rockchip/phy-rockchip-typec.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
index ee85fa0..68a5840 100644
--- a/drivers/phy/rockchip/phy-rockchip-typec.c
+++ b/drivers/phy/rockchip/phy-rockchip-typec.c
@@ -372,6 +372,7 @@ struct rockchip_typec_phy {
 	struct reset_control *uphy_rst;
 	struct reset_control *pipe_rst;
 	struct reset_control *tcphy_rst;
+	struct reset_control *otg_rst;
 	struct rockchip_usb3phy_port_cfg port_cfgs;
 	/* mutex to protect access to individual PHYs */
 	struct mutex lock;
@@ -841,10 +842,16 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
 	if (tcphy->mode == new_mode)
 		goto unlock_ret;
 
+	ret = reset_control_assert(tcphy->otg_rst);
+	if (ret < 0) {
+		dev_err(tcphy->dev, "failed to assert otg reset: %d\n", ret);
+		goto unlock_ret;
+	}
+
 	if (tcphy->mode == MODE_DISCONNECT) {
 		ret = tcphy_phy_init(tcphy, new_mode);
 		if (ret)
-			goto unlock_ret;
+			goto unlock_deassert;
 	}
 
 	/* wait TCPHY for pipe ready */
@@ -852,7 +859,7 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
 		regmap_read(tcphy->grf_regs, reg->offset, &val);
 		if (!(val & BIT(reg->enable_bit))) {
 			tcphy->mode |= new_mode & (MODE_DFP_USB | MODE_UFP_USB);
-			goto unlock_ret;
+			goto unlock_deassert;
 		}
 		usleep_range(10, 20);
 	}
@@ -862,6 +869,11 @@ static int rockchip_usb3_phy_power_on(struct phy *phy)
 
 	ret = -ETIMEDOUT;
 
+unlock_deassert:
+	ret = reset_control_deassert(tcphy->otg_rst);
+	if (ret < 0)
+		dev_err(tcphy->dev, "failed to deassert otg reset: %d\n", ret);
+
 unlock_ret:
 	mutex_unlock(&tcphy->lock);
 	return ret;
@@ -1066,6 +1078,12 @@ static int tcphy_parse_dt(struct rockchip_typec_phy *tcphy,
 		return PTR_ERR(tcphy->tcphy_rst);
 	}
 
+	tcphy->otg_rst = devm_reset_control_get(dev, "usb3-otg");
+	if (IS_ERR(tcphy->otg_rst)) {
+		dev_err(dev, "no otg_rst reset control found\n");
+		return PTR_ERR(tcphy->otg_rst);
+	}
+
 	return 0;
 }
 
-- 
2.0.0

  parent reply	other threads:[~2018-01-12 10:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 10:08 [PATCH 0/3] Reset USB3 controller before initializing Type-C PHY on rk3399 William Wu
2018-01-12 10:08 ` [PATCH 1/3] dt-bindings: phy: phy-rockchip-typec: add usb3 otg reset William Wu
2018-01-17 22:07   ` Brian Norris
2018-01-18 17:20     ` Enric Balletbo Serra
2018-01-18 17:47       ` Brian Norris
2018-01-19 21:49         ` Rob Herring
     [not found]           ` <d05fb977-cd6c-4875-25be-9212e75b7e39@rock-chips.com>
2018-02-10 19:55             ` Heiko Stuebner
2018-02-12 16:40               ` wlf
2018-01-12 10:08 ` [PATCH 2/3] arm64: dts: rockchip: add USB3 OTG reset for Type-C PHY on rk3399 William Wu
2018-01-18 17:21   ` Enric Balletbo Serra
2018-01-12 10:08 ` William Wu [this message]
2018-01-18 17:22   ` [PATCH 3/3] phy: rockchip-typec: reset USB3 controller before initializing PHY Enric Balletbo Serra

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=1515751704-13213-4-git-send-email-william.wu@rock-chips.com \
    --to=william.wu@rock-chips.com \
    --cc=John.Youn@synopsys.com \
    --cc=briannorris@google.com \
    --cc=daniel.meng@rock-chips.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@google.com \
    --cc=frank.wang@rock-chips.com \
    --cc=groeck@google.com \
    --cc=heiko@sntech.de \
    --cc=huangtao@rock-chips.com \
    --cc=kishon@ti.com \
    --cc=lin.huang@rock-chips.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=robh+dt@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 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®