From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: agross@kernel.org, andersson@kernel.org, vkoul@kernel.org,
kishon@kernel.org, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org
Cc: konrad.dybcio@linaro.org, linux-arm-msm@vger.kernel.org,
linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
bryan.odonoghue@linaro.org
Subject: [PATCH v2 2/2] phy: qcom-usb-hs: Add qcom,dp-manual-pullup logic
Date: Thu, 29 Dec 2022 18:34:10 +0000 [thread overview]
Message-ID: <20221229183410.683584-3-bryan.odonoghue@linaro.org> (raw)
In-Reply-To: <20221229183410.683584-1-bryan.odonoghue@linaro.org>
Downstream has a flag called qcom,dp-manual-pullup which informs the
downstream driver if it should toggle ULPI_MISC_A_VBUSVLDEXTSEL and
ULPI_MISC_A_VBUSVLDEXT.
Downstream states:
"qcom,dp-manual-pullup: If present, vbus is not routed to USB
controller/phy and controller driver therefore enables pull-up
explicitly before starting controller using usbcmd run/stop bit."
Working with a system that has both an external Type-C port controller and
an internal USB Hub results in a situation where VBUS is not connected to
the SoC.
In this case we still need to set the DP pullup.
This patch enables and disables the DP pullup on PHY power_on and power_off
respectively if the DT has declared the bool "qcom,enable-vbus-pullup"
effectively replicating the downstream logic to the same effect.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
drivers/phy/qualcomm/phy-qcom-usb-hs.c | 36 ++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/phy/qualcomm/phy-qcom-usb-hs.c b/drivers/phy/qualcomm/phy-qcom-usb-hs.c
index 53e46c220a3aa..45c94f6722c66 100644
--- a/drivers/phy/qualcomm/phy-qcom-usb-hs.c
+++ b/drivers/phy/qualcomm/phy-qcom-usb-hs.c
@@ -37,6 +37,7 @@ struct qcom_usb_hs_phy {
struct ulpi_seq *init_seq;
struct extcon_dev *vbus_edev;
struct notifier_block vbus_notify;
+ u8 enable_dp_pullup:1;
};
static int qcom_usb_hs_phy_set_mode(struct phy *phy,
@@ -105,6 +106,23 @@ qcom_usb_hs_phy_vbus_notifier(struct notifier_block *nb, unsigned long event,
return ulpi_write(uphy->ulpi, addr, ULPI_MISC_A_VBUSVLDEXT);
}
+static int qcom_usb_hs_phy_enable_dp_pullup(struct ulpi *ulpi, bool enable)
+{
+ u8 addr;
+ int ret;
+
+ if (enable)
+ addr = ULPI_SET(ULPI_MISC_A);
+ else
+ addr = ULPI_CLR(ULPI_MISC_A);
+
+ ret = ulpi_write(ulpi, addr, ULPI_MISC_A_VBUSVLDEXTSEL);
+ if (ret)
+ return ret;
+
+ return ulpi_write(ulpi, addr, ULPI_MISC_A_VBUSVLDEXT);
+}
+
static int qcom_usb_hs_phy_power_on(struct phy *phy)
{
struct qcom_usb_hs_phy *uphy = phy_get_drvdata(phy);
@@ -154,6 +172,12 @@ static int qcom_usb_hs_phy_power_on(struct phy *phy)
goto err_ulpi;
}
+ if (uphy->enable_dp_pullup) {
+ ret = qcom_usb_hs_phy_enable_dp_pullup(ulpi, true);
+ if (ret)
+ goto err_ulpi;
+ }
+
if (uphy->vbus_edev) {
state = extcon_get_state(uphy->vbus_edev, EXTCON_USB);
/* setup initial state */
@@ -180,10 +204,19 @@ static int qcom_usb_hs_phy_power_on(struct phy *phy)
static int qcom_usb_hs_phy_power_off(struct phy *phy)
{
struct qcom_usb_hs_phy *uphy = phy_get_drvdata(phy);
+ struct ulpi *ulpi = uphy->ulpi;
+ int ret;
if (uphy->vbus_edev)
extcon_unregister_notifier(uphy->vbus_edev, EXTCON_USB,
&uphy->vbus_notify);
+
+ if (uphy->enable_dp_pullup) {
+ ret = qcom_usb_hs_phy_enable_dp_pullup(ulpi, false);
+ if (ret)
+ return ret;
+ }
+
regulator_disable(uphy->v3p3);
regulator_disable(uphy->v1p8);
clk_disable_unprepare(uphy->sleep_clk);
@@ -229,6 +262,9 @@ static int qcom_usb_hs_phy_probe(struct ulpi *ulpi)
/* NUL terminate */
uphy->init_seq[size / 2].addr = uphy->init_seq[size / 2].val = 0;
+ if (of_property_read_bool(ulpi->dev.of_node, "qcom,dp-manual-pullup"))
+ uphy->enable_dp_pullup = 1;
+
uphy->ref_clk = clk = devm_clk_get(&ulpi->dev, "ref");
if (IS_ERR(clk))
return PTR_ERR(clk);
--
2.34.1
next prev parent reply other threads:[~2022-12-29 18:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-29 18:34 [PATCH v2 0/2] qcom: Add a method to manually toggle the DP pullup on HS USB PHY Bryan O'Donoghue
2022-12-29 18:34 ` [PATCH v2 1/2] dt-bindings: phy: Add qcom,dp-manual-pullup description Bryan O'Donoghue
2022-12-29 18:57 ` Stephan Gerhold
2022-12-29 19:48 ` Bryan O'Donoghue
2022-12-29 20:43 ` Stephan Gerhold
2022-12-30 8:21 ` Krzysztof Kozlowski
2022-12-29 18:34 ` Bryan O'Donoghue [this message]
2022-12-29 19:45 ` [PATCH v2 2/2] phy: qcom-usb-hs: Add qcom,dp-manual-pullup logic Stephan Gerhold
2022-12-29 19:55 ` Bryan O'Donoghue
2022-12-29 21:02 ` Stephan Gerhold
2022-12-29 21:05 ` Bryan O'Donoghue
2022-12-29 21:11 ` Stephan Gerhold
2022-12-29 21:20 ` Bryan O'Donoghue
2022-12-29 21:41 ` Stephan Gerhold
2022-12-29 23:38 ` Bryan O'Donoghue
2022-12-30 12:05 ` Stephan Gerhold
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=20221229183410.683584-3-bryan.odonoghue@linaro.org \
--to=bryan.odonoghue@linaro.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kishon@kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=vkoul@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