Devicetree
 help / color / mirror / Atom feed
From: George Moussalem via B4 Relay <devnull+george.moussalem.outlook.com@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	Wesley Cheng <quic_wcheng@quicinc.com>,
	 Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	 Bjorn Andersson <andersson@kernel.org>,
	 Konrad Dybcio <konradybcio@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
	 devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>,
	 George Moussalem <george.moussalem@outlook.com>
Subject: [PATCH v3 02/10] usb: dwc3: qcom: Add support for selecting UTMI as reference clock
Date: Sun, 06 Sep 2026 08:46:41 +0400	[thread overview]
Message-ID: <20260906-ipq-flatten-usb-v3-2-13e4e0f63123@outlook.com> (raw)
In-Reply-To: <20260906-ipq-flatten-usb-v3-0-13e4e0f63123@outlook.com>

From: George Moussalem <george.moussalem@outlook.com>

On many Qualcomm chipsets, the UTMI clock is used as the reference clock
(ex. IPQ5018, IPQ6018, and IPQ9574 and more). Since moving to the new
flattened snps-dwc3 model, it is no longer possible to pass the
reference clock to the dwc3 core driver.

The clock rate is used by the dwc3 core to compute the reference clock
period and frame length adjustment. This is needed when the reference
clock rate used computes values that deviate from the hardware defaults.
Above mentioned SoCs require values different from the defaults and, as
such, the core initializes with the wrong values which leads to
non-functional USB operation.

In Qualcomm chipsets, if available, the UTMI clock is used as the
reference clock. Therefore, acquire the reference clock by name
('mock_utmi') and pass its clock rate to the core using the probe_data
structure.

Signed-off-by: George Moussalem <george.moussalem@outlook.com>
---
 drivers/usb/dwc3/dwc3-qcom.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index ac68b4218b56..8c1aca40c810 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -617,6 +617,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 	int			ret;
 	bool			ignore_pipe_clk;
 	bool			wakeup_source;
+	struct clk		*ref_clk;
 
 	qcom = devm_kzalloc(&pdev->dev, sizeof(*qcom), GFP_KERNEL);
 	if (!qcom)
@@ -698,6 +699,14 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 			qcom->current_role = USB_ROLE_DEVICE;
 	}
 
+	ref_clk = devm_clk_get_optional(dev, "mock_utmi");
+	if (IS_ERR(ref_clk)) {
+		ret = dev_err_probe(dev, PTR_ERR(ref_clk), "failed to get ref clock\n");
+		goto clk_disable;
+	} else if (ref_clk) {
+		probe_data.ref_clk_rate = clk_get_rate(ref_clk);
+	}
+
 	qcom->dwc.glue_ops = &dwc3_qcom_glue_ops;
 
 	qcom->dwc.dev = dev;

-- 
2.53.0



  parent reply	other threads:[~2026-09-06  4:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06  4:46 [PATCH v3 00/10] Flatten USB Controller Nodes on IPQ SoCs George Moussalem via B4 Relay
2026-09-06  4:46 ` [PATCH v3 01/10] usb: dwc3: core: Allow glue layer to pass reference clock rate George Moussalem via B4 Relay
2026-09-06  4:55   ` sashiko-bot
2026-09-07  5:05   ` Varadarajan Narayanan
2026-09-06  4:46 ` George Moussalem via B4 Relay [this message]
2026-09-07  4:06   ` [PATCH v3 02/10] usb: dwc3: qcom: Add support for selecting UTMI as reference clock Varadarajan Narayanan
2026-09-06  4:46 ` [PATCH v3 03/10] arm64: dts: qcom: ipq5018: Flatten usb controller node George Moussalem via B4 Relay
2026-09-06  4:46 ` [PATCH v3 04/10] arm64: dts: qcom: ipq5332: " George Moussalem via B4 Relay
2026-09-06  4:46 ` [PATCH v3 05/10] arm64: dts: qcom: ipq5424: Flatten usb controller nodes George Moussalem via B4 Relay
2026-09-06  4:58   ` sashiko-bot
2026-09-07 12:58   ` Konrad Dybcio
2026-09-06  4:46 ` [PATCH v3 06/10] arm64: dts: qcom: ipq6018: move DR mode to board DTS George Moussalem via B4 Relay
2026-09-07 12:57   ` Konrad Dybcio
2026-09-06  4:46 ` [PATCH v3 07/10] arm64: dts: qcom: ipq6018: Flatten usb controller nodes George Moussalem via B4 Relay
2026-09-07 12:58   ` Konrad Dybcio
2026-09-06  4:46 ` [PATCH v3 08/10] arm64: dts: qcom: ipq8074: move DR mode to board DTS George Moussalem via B4 Relay
2026-09-07 12:57   ` Konrad Dybcio
2026-09-06  4:46 ` [PATCH v3 09/10] arm64: dts: qcom: ipq8074: Flatten usb controller nodes George Moussalem via B4 Relay
2026-09-07 13:00   ` Konrad Dybcio
2026-09-06  4:46 ` [PATCH v3 10/10] arm64: dts: qcom: ipq9574: Flatten usb controller node George Moussalem via B4 Relay
2026-09-07 13:34   ` Abel Vesa
2026-09-09  9:09   ` Konrad Dybcio

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=20260906-ipq-flatten-usb-v3-2-13e4e0f63123@outlook.com \
    --to=devnull+george.moussalem.outlook.com@kernel.org \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=george.moussalem@outlook.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=quic_wcheng@quicinc.com \
    --cc=robh@kernel.org \
    --cc=varadarajan.narayanan@oss.qualcomm.com \
    /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