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 v2 01/10] usb: dwc3: core: Allow glue layer to pass reference clock rate
Date: Sun, 06 Sep 2026 07:52:40 +0400 [thread overview]
Message-ID: <20260906-ipq-flatten-usb-v2-1-dab83120b10a@outlook.com> (raw)
In-Reply-To: <20260906-ipq-flatten-usb-v2-0-dab83120b10a@outlook.com>
From: George Moussalem <george.moussalem@outlook.com>
Add ability to pass the reference clock rate from the glue layer to the
DWC3 core driver. The core calculates the reference clock period and
frame length adjustment based on the reference clock rate.
In the flattened snsp-dwc3 model, it is currently not possible to pass a
reference clock that differs from the default since:
commit 613a2e655d4d ("usb: dwc3: core: Expose core driver as library")
The new glue layers (incl. Qualcomm's) set the ignore_clocks_and_resets
flag in dwc3_probe_data to true, which disables the core driver's clock
management, thus it also doesn't acquire the reference clock from the
devicetree needed in dwc3_ref_clk_period.
There's an existing DT property 'snps,ref-clock-period-ns', but that's
been deprecated. In addition, basing the rate from the period is often
not accurate enough to derive the frame length adjustment value.
This prevents moving chipsets such as IPQ5018, IPQ6018, IPQ5332, IPQ5424
and IPQ9574 with a reference clock rate that computes values for the
period and frame length adjustment different from the hardware default
from moving to the flattened model.
So, add ability to set the reference clock rate in dwc3_probe_data, then
have the core obtain the clock rate and use that to calculate the
required period and frame length adjustment.
Signed-off-by: George Moussalem <george.moussalem@outlook.com>
---
drivers/usb/dwc3/core.c | 6 ++++++
drivers/usb/dwc3/core.h | 2 ++
drivers/usb/dwc3/glue.h | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index fd5c2cd36c59..6ff0e4822b49 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -420,6 +420,9 @@ static void dwc3_ref_clk_period(struct dwc3 *dwc)
} else if (dwc->ref_clk_per) {
period = dwc->ref_clk_per;
rate = NSEC_PER_SEC / period;
+ } else if (dwc->ref_clk_rate) {
+ rate = dwc->ref_clk_rate;
+ period = NSEC_PER_SEC / rate;
} else {
return;
}
@@ -2334,6 +2337,9 @@ int dwc3_core_probe(const struct dwc3_probe_data *data)
goto err_put_psy;
}
+ if (data->ref_clk_rate > 0)
+ dwc->ref_clk_rate = data->ref_clk_rate;
+
ret = reset_control_deassert(dwc->reset);
if (ret)
goto err_put_psy;
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 608daeb7ef10..4181d57a6cd3 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1032,6 +1032,7 @@ struct dwc3_glue_ops {
* @regs_size: address space size
* @fladj: frame length adjustment
* @ref_clk_per: reference clock period configuration
+ * @ref_clk_rate: reference clock rate provided by glue layer
* @irq_gadget: peripheral controller's IRQ number
* @otg_irq: IRQ number for OTG IRQs
* @current_otg_role: current role of operation while using the OTG block
@@ -1261,6 +1262,7 @@ struct dwc3 {
u32 fladj;
u32 ref_clk_per;
+ unsigned long ref_clk_rate;
u32 irq_gadget;
u32 otg_irq;
u32 current_otg_role;
diff --git a/drivers/usb/dwc3/glue.h b/drivers/usb/dwc3/glue.h
index d738e1739ae0..ed96b10d8cd8 100644
--- a/drivers/usb/dwc3/glue.h
+++ b/drivers/usb/dwc3/glue.h
@@ -33,6 +33,9 @@ struct dwc3_properties {
* @skip_core_init_mode: Skip the finial initialization of the target mode, as
* it must be managed by the glue
* @properties: dwc3 software manage properties
+ * @ref_clk_rate: optional reference clock rate for the DWC3 core to compute the
+ * period and frame length adjustment required if these values
+ * differ from the hardware default.
*/
struct dwc3_probe_data {
struct dwc3 *dwc;
@@ -40,6 +43,7 @@ struct dwc3_probe_data {
bool ignore_clocks_and_resets;
bool skip_core_init_mode;
struct dwc3_properties properties;
+ unsigned long ref_clk_rate;
};
/**
--
2.53.0
next prev parent reply other threads:[~2026-09-06 3:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 3:52 [PATCH v2 00/10] Flatten USB Controller Nodes on IPQ SoCs George Moussalem via B4 Relay
2026-09-06 3:52 ` George Moussalem via B4 Relay [this message]
2026-09-07 4:02 ` [PATCH v2 01/10] usb: dwc3: core: Allow glue layer to pass reference clock rate Varadarajan Narayanan
2026-09-06 3:52 ` [PATCH v2 02/10] usb: dwc3: qcom: Add support for selecting UTMI as reference clock George Moussalem via B4 Relay
2026-09-07 4:03 ` Varadarajan Narayanan
2026-09-06 3:52 ` [PATCH v2 03/10] arm64: dts: qcom: ipq5018: Flatten usb controller node George Moussalem via B4 Relay
2026-09-06 3:52 ` [PATCH v2 04/10] arm64: dts: qcom: ipq5332: " George Moussalem via B4 Relay
2026-09-06 3:52 ` [PATCH v2 05/10] arm64: dts: qcom: ipq5424: Flatten usb controller nodes George Moussalem via B4 Relay
2026-09-06 3:52 ` [PATCH v2 06/10] arm64: dts: qcom: ipq6018: move DR mode to board DTS George Moussalem via B4 Relay
2026-09-06 3:52 ` [PATCH v2 07/10] arm64: dts: qcom: ipq6018: Flatten usb controller nodes George Moussalem via B4 Relay
2026-09-06 4:01 ` sashiko-bot
2026-09-06 3:52 ` [PATCH v2 08/10] arm64: dts: qcom: ipq8074: move DR mode to board DTS George Moussalem via B4 Relay
2026-09-06 3:52 ` [PATCH v2 09/10] arm64: dts: qcom: ipq8074: Flatten usb controller nodes George Moussalem via B4 Relay
2026-09-06 3:52 ` [PATCH v2 10/10] arm64: dts: qcom: ipq9574: Flatten usb controller node George Moussalem via B4 Relay
2026-09-06 4:08 ` sashiko-bot
2026-09-06 4:30 ` [PATCH v2 00/10] Flatten USB Controller Nodes on IPQ SoCs George Moussalem
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-v2-1-dab83120b10a@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