From: Krzysztof Kozlowski <krzk@kernel.org>
To: Joonhoe Kim <26rote@gmail.com>
Cc: gregkh@linuxfoundation.org, Thinh.Nguyen@synopsys.com,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
andersson@kernel.org, konradybcio@kernel.org,
heikki.krogerus@linux.intel.com, abel.vesa@oss.qualcomm.com,
abelvesa@kernel.org, wesley.cheng@oss.qualcomm.com,
krishna.kurapati@oss.qualcomm.com,
konrad.dybcio@oss.qualcomm.com,
dmitry.baryshkov@oss.qualcomm.com, neil.armstrong@linaro.org,
val@packett.cool, balaji.kalkonda@oss.qualcomm.com,
tvlad744@gmail.com, effeffe99@gmail.com,
prashanth.k@oss.qualcomm.com, yongxing.mou@oss.qualcomm.com,
linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] usb: dwc3: qcom: Use the UTMI clock as PIPE clock in DisplayPort-only modes
Date: Fri, 13 Nov 2026 09:16:10 +0100 [thread overview]
Message-ID: <20261113-artificial-quixotic-firefly-84baef@quoll> (raw)
In-Reply-To: <20261112113838.506-3-26rote@gmail.com>
On Thu, Nov 12, 2026 at 08:38:38PM +0900, Joonhoe Kim wrote:
> @@ -336,16 +346,19 @@ static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
> dwc3_qcom_enable_port_interrupts(&qcom->ports[i]);
> }
>
> -static void dwc3_qcom_select_utmi_clk(struct dwc3_qcom *qcom)
> +static void dwc3_qcom_select_utmi_clk(struct dwc3_qcom *qcom, bool utmi)
> {
> - /* Configure dwc3 to use UTMI clock as PIPE clock not present */
> dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG,
> PIPE_UTMI_CLK_DIS);
>
> usleep_range(100, 1000);
>
> - dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG,
> - PIPE_UTMI_CLK_SEL | PIPE3_PHYSTATUS_SW);
> + if (utmi)
> + dwc3_qcom_setbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG,
> + PIPE_UTMI_CLK_SEL | PIPE3_PHYSTATUS_SW);
> + else
> + dwc3_qcom_clrbits(qcom->qscratch_base, QSCRATCH_GENERAL_CFG,
> + PIPE_UTMI_CLK_SEL | PIPE3_PHYSTATUS_SW);
>
> usleep_range(100, 1000);
>
> @@ -353,6 +366,38 @@ static void dwc3_qcom_select_utmi_clk(struct dwc3_qcom *qcom)
> PIPE_UTMI_CLK_DIS);
> }
>
> +static bool dwc3_qcom_utmi_clk_selected(struct dwc3_qcom *qcom)
> +{
> + return readl(qcom->qscratch_base + QSCRATCH_GENERAL_CFG) &
> + PIPE_UTMI_CLK_SEL;
> +}
> +
> +static void dwc3_qcom_update_pipe_clk(struct dwc3_qcom *qcom)
> +{
> + lockdep_assert_held(&qcom->pipe_clk_lock);
> +
> + if (qcom->mode_switch && !qcom->utmi_as_pipe_clk &&
> + qcom->dp_only != dwc3_qcom_utmi_clk_selected(qcom))
> + dwc3_qcom_select_utmi_clk(qcom, qcom->dp_only);
> +}
> +
> +static void dwc3_qcom_defer_mux(struct dwc3_qcom *qcom)
> +{
> + guard(mutex)(&qcom->pipe_clk_lock);
Why aren't you using simple and most readable mutex lock/unlock? guard()
is not more readable.
> + qcom->mux_deferred = true;
> +}
> +
> +static void dwc3_qcom_undefer_mux(struct dwc3_qcom *qcom)
> +{
> + guard(mutex)(&qcom->pipe_clk_lock);
Here it makes sense, but other places, why?
> +
> + if (qcom->is_suspended)
> + return;
> +
> + qcom->mux_deferred = false;
> + dwc3_qcom_update_pipe_clk(qcom);
> +}
> +
> static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)
> {
> u32 val;
> @@ -413,7 +458,10 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup)
> * clock ("failed to enable ep0out").
> */
> if (qcom->utmi_as_pipe_clk)
> - dwc3_qcom_select_utmi_clk(qcom);
> + dwc3_qcom_select_utmi_clk(qcom, true);
> +
> + scoped_guard(mutex, &qcom->pipe_clk_lock)
> + dwc3_qcom_update_pipe_clk(qcom);
>
> /* Clear existing events from PHY related to L2 in/out */
> for (i = 0; i < qcom->num_ports; i++) {
> @@ -446,6 +494,52 @@ static irqreturn_t qcom_dwc3_resume_irq(int irq, void *data)
> return IRQ_HANDLED;
> }
>
> +static int dwc3_qcom_mux_set(struct typec_mux_dev *mux,
> + struct typec_mux_state *state)
> +{
> + struct dwc3_qcom *qcom = typec_mux_get_drvdata(mux);
> + bool dp = state->mode >= TYPEC_STATE_MODAL && state->alt &&
> + state->alt->svid == USB_TYPEC_DP_SID;
> +
> + guard(mutex)(&qcom->pipe_clk_lock);
> +
> + if (state->mode == TYPEC_STATE_SAFE) {
> + qcom->dp_active = false;
> + } else if (dp) {
> + if (state->mode == TYPEC_DP_STATE_C ||
> + state->mode == TYPEC_DP_STATE_E)
> + qcom->dp_only = true;
> + else if (!qcom->dp_active)
> + qcom->dp_only = false;
> + qcom->dp_active = true;
> + } else if (!qcom->dp_active) {
> + qcom->dp_only = false;
> + }
> +
> + if (!qcom->mux_deferred)
> + dwc3_qcom_update_pipe_clk(qcom);
> +
> + return 0;
> +}
> +
> +static int dwc3_qcom_mux_register(struct dwc3_qcom *qcom)
> +{
> + struct typec_mux_desc desc = {};
> +
> + if (!IS_ENABLED(CONFIG_TYPEC) ||
> + !device_property_present(qcom->dev, "mode-switch"))
> + return 0;
> +
> + desc.drvdata = qcom;
> + desc.fwnode = dev_fwnode(qcom->dev);
> + desc.set = dwc3_qcom_mux_set;
> +
> + qcom->mode_switch = true;
> + qcom->mux = typec_mux_register(qcom->dev, &desc);
> +
> + return PTR_ERR_OR_ZERO(qcom->mux);
> +}
> +
> static int dwc3_qcom_request_irq(struct dwc3_qcom *qcom, int irq,
> const char *name)
> {
> @@ -625,7 +719,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> struct resource res;
> struct resource *r;
> int ret;
> - bool ignore_pipe_clk;
> bool wakeup_source;
>
> qcom = devm_kzalloc(&pdev->dev, sizeof(*qcom), GFP_KERNEL);
> @@ -688,11 +781,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> * Disable pipe_clk requirement if specified. Used when dwc3
> * operates without SSPHY and only HS/FS/LS modes are supported.
> */
> - ignore_pipe_clk = device_property_read_bool(dev,
> - "qcom,select-utmi-as-pipe-clk");
> - qcom->utmi_as_pipe_clk = ignore_pipe_clk;
> - if (ignore_pipe_clk)
> - dwc3_qcom_select_utmi_clk(qcom);
> + qcom->utmi_as_pipe_clk =
You use some odd formatting, making this unreadable. That's one line,
eventually wrapped.
I don't get why you are changing these lines in the first place. Mixing
style changes and actual code changes make it difficult to spot the
differenec, but the code looks the same, no?
> + device_property_read_bool(dev, "qcom,select-utmi-as-pipe-clk");
> + if (qcom->utmi_as_pipe_clk)
> + dwc3_qcom_select_utmi_clk(qcom, true);
>
> qcom->mode = usb_get_dr_mode(dev);
Best regards,
Krzysztof
prev parent reply other threads:[~2026-11-13 8:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 11:38 [PATCH v3 0/2] usb: dwc3: qcom: Keep USB 2.0 working " Joonhoe Kim
2026-11-12 11:38 ` [PATCH v3 1/2] dt-bindings: usb: qcom,snps-dwc3: Add mode-switch Joonhoe Kim
2026-11-13 8:16 ` Krzysztof Kozlowski
2026-11-12 11:38 ` [PATCH v3 2/2] usb: dwc3: qcom: Use the UTMI clock as PIPE clock in DisplayPort-only modes Joonhoe Kim
2026-11-13 8:16 ` Krzysztof Kozlowski [this message]
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=20261113-artificial-quixotic-firefly-84baef@quoll \
--to=krzk@kernel.org \
--cc=26rote@gmail.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=abel.vesa@oss.qualcomm.com \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=balaji.kalkonda@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=effeffe99@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krishna.kurapati@oss.qualcomm.com \
--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=neil.armstrong@linaro.org \
--cc=prashanth.k@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=tvlad744@gmail.com \
--cc=val@packett.cool \
--cc=wesley.cheng@oss.qualcomm.com \
--cc=yongxing.mou@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
all inboxes | Powered by JetHome®