* [PATCH] clk: qcom: regmap-phy-mux: Rework the implementation
@ 2026-04-09 11:57 Konrad Dybcio
2026-06-08 15:09 ` Bjorn Andersson
0 siblings, 1 reply; 7+ messages in thread
From: Konrad Dybcio @ 2026-04-09 11:57 UTC (permalink / raw)
To: Bjorn Andersson, Michael Turquette, Stephen Boyd, Taniya Das,
Dmitry Baryshkov, Jagadeesh Kona
Cc: usb4-upstream, linux-arm-msm, linux-clk, linux-kernel, Konrad Dybcio
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
The sole reason this hw exists is to let the branch clock downstream of
it keep running, with the PHY disengaged. This is not possible with the
current implementation, as the enabled status is hijacked to mean
"enabled" = "use fast/PHY source" and "disabled" = "use XO source".
This is an issue, since the mux enable state follows that of the child
branch, making the desired "child enabled, MUX @ XO" combination
impossible.
Solve that by implementing ratesetting. Because PHY clock rates may
change at runtime and aren't really deterministic from Linux, assume
ULONG_MAX as "fast clock" and 19.2 MHz as XO. All the branches in
question already set CLK_SET_RATE_PARENT, so everything works out.
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
drivers/clk/qcom/clk-regmap-phy-mux.c | 58 +++++++++++++++++++++++------------
1 file changed, 38 insertions(+), 20 deletions(-)
diff --git a/drivers/clk/qcom/clk-regmap-phy-mux.c b/drivers/clk/qcom/clk-regmap-phy-mux.c
index 7b7243b7107d..b7d1c69d62f7 100644
--- a/drivers/clk/qcom/clk-regmap-phy-mux.c
+++ b/drivers/clk/qcom/clk-regmap-phy-mux.c
@@ -15,48 +15,66 @@
#define PHY_MUX_PHY_SRC 0
#define PHY_MUX_REF_SRC 2
+#define XO_RATE 19200000UL
+
static inline struct clk_regmap_phy_mux *to_clk_regmap_phy_mux(struct clk_regmap *clkr)
{
return container_of(clkr, struct clk_regmap_phy_mux, clkr);
}
-static int phy_mux_is_enabled(struct clk_hw *hw)
+static unsigned long phy_mux_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
{
struct clk_regmap *clkr = to_clk_regmap(hw);
struct clk_regmap_phy_mux *phy_mux = to_clk_regmap_phy_mux(clkr);
- unsigned int val;
+ u32 val;
regmap_read(clkr->regmap, phy_mux->reg, &val);
- val = FIELD_GET(PHY_MUX_MASK, val);
- WARN_ON(val != PHY_MUX_PHY_SRC && val != PHY_MUX_REF_SRC);
-
- return val == PHY_MUX_PHY_SRC;
+ switch (FIELD_GET(PHY_MUX_MASK, val)) {
+ case PHY_MUX_PHY_SRC:
+ return ULONG_MAX;
+ case PHY_MUX_REF_SRC:
+ return XO_RATE;
+ default:
+ return 0;
+ }
}
-static int phy_mux_enable(struct clk_hw *hw)
+static int phy_mux_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
+{
+ if (req->rate == XO_RATE || req->rate == ULONG_MAX)
+ return 0;
+
+ return -EINVAL;
+}
+
+static int phy_mux_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate)
{
struct clk_regmap *clkr = to_clk_regmap(hw);
struct clk_regmap_phy_mux *phy_mux = to_clk_regmap_phy_mux(clkr);
+ u32 val;
- return regmap_update_bits(clkr->regmap, phy_mux->reg,
- PHY_MUX_MASK,
- FIELD_PREP(PHY_MUX_MASK, PHY_MUX_PHY_SRC));
-}
-
-static void phy_mux_disable(struct clk_hw *hw)
-{
- struct clk_regmap *clkr = to_clk_regmap(hw);
- struct clk_regmap_phy_mux *phy_mux = to_clk_regmap_phy_mux(clkr);
+ switch (rate) {
+ case XO_RATE:
+ val = PHY_MUX_REF_SRC;
+ break;
+ case ULONG_MAX:
+ val = PHY_MUX_PHY_SRC;
+ break;
+ default:
+ return -EINVAL;
+ }
regmap_update_bits(clkr->regmap, phy_mux->reg,
PHY_MUX_MASK,
- FIELD_PREP(PHY_MUX_MASK, PHY_MUX_REF_SRC));
+ FIELD_PREP(PHY_MUX_MASK, val));
+
+ return 0;
}
const struct clk_ops clk_regmap_phy_mux_ops = {
- .enable = phy_mux_enable,
- .disable = phy_mux_disable,
- .is_enabled = phy_mux_is_enabled,
+ .recalc_rate = phy_mux_recalc_rate,
+ .determine_rate = phy_mux_determine_rate,
+ .set_rate = phy_mux_set_rate,
};
EXPORT_SYMBOL_GPL(clk_regmap_phy_mux_ops);
---
base-commit: db7efce4ae23ad5e42f5f55428f529ff62b86fab
change-id: 20260409-topic-phy_fastclk-9258a40b75ed
Best regards,
--
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] clk: qcom: regmap-phy-mux: Rework the implementation
2026-04-09 11:57 [PATCH] clk: qcom: regmap-phy-mux: Rework the implementation Konrad Dybcio
@ 2026-06-08 15:09 ` Bjorn Andersson
2026-06-11 19:38 ` Dmitry Baryshkov
0 siblings, 1 reply; 7+ messages in thread
From: Bjorn Andersson @ 2026-06-08 15:09 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd, Taniya Das, Dmitry Baryshkov,
Jagadeesh Kona, Konrad Dybcio
Cc: usb4-upstream, linux-arm-msm, linux-clk, linux-kernel, Konrad Dybcio
On Thu, 09 Apr 2026 13:57:45 +0200, Konrad Dybcio wrote:
> The sole reason this hw exists is to let the branch clock downstream of
> it keep running, with the PHY disengaged. This is not possible with the
> current implementation, as the enabled status is hijacked to mean
> "enabled" = "use fast/PHY source" and "disabled" = "use XO source".
>
> This is an issue, since the mux enable state follows that of the child
> branch, making the desired "child enabled, MUX @ XO" combination
> impossible.
>
> [...]
Applied, thanks!
[1/1] clk: qcom: regmap-phy-mux: Rework the implementation
commit: e108373c54fbc844b7f541c6fd7ecb31772afd3c
Best regards,
--
Bjorn Andersson <andersson@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] clk: qcom: regmap-phy-mux: Rework the implementation
2026-06-08 15:09 ` Bjorn Andersson
@ 2026-06-11 19:38 ` Dmitry Baryshkov
2026-06-16 14:12 ` Konrad Dybcio
[not found] ` <CGME20260626094632eucas1p2a0bd78e844ebe4e0205a0b900f8e3289@eucas1p2.samsung.com>
0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Baryshkov @ 2026-06-11 19:38 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Michael Turquette, Stephen Boyd, Taniya Das, Jagadeesh Kona,
Konrad Dybcio, usb4-upstream, linux-arm-msm, linux-clk,
linux-kernel, Konrad Dybcio
On Mon, Jun 08, 2026 at 10:09:55AM -0500, Bjorn Andersson wrote:
>
> On Thu, 09 Apr 2026 13:57:45 +0200, Konrad Dybcio wrote:
> > The sole reason this hw exists is to let the branch clock downstream of
> > it keep running, with the PHY disengaged. This is not possible with the
> > current implementation, as the enabled status is hijacked to mean
> > "enabled" = "use fast/PHY source" and "disabled" = "use XO source".
> >
> > This is an issue, since the mux enable state follows that of the child
> > branch, making the desired "child enabled, MUX @ XO" combination
> > impossible.
> >
> > [...]
>
> Applied, thanks!
>
> [1/1] clk: qcom: regmap-phy-mux: Rework the implementation
> commit: e108373c54fbc844b7f541c6fd7ecb31772afd3c
This breaks at PCIe at least on SM8350. The attached WiFi card is
not detected anymore. Rewerting the patch makes it work again.
>
> Best regards,
> --
> Bjorn Andersson <andersson@kernel.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] clk: qcom: regmap-phy-mux: Rework the implementation
2026-06-11 19:38 ` Dmitry Baryshkov
@ 2026-06-16 14:12 ` Konrad Dybcio
[not found] ` <CGME20260626094632eucas1p2a0bd78e844ebe4e0205a0b900f8e3289@eucas1p2.samsung.com>
1 sibling, 0 replies; 7+ messages in thread
From: Konrad Dybcio @ 2026-06-16 14:12 UTC (permalink / raw)
To: Dmitry Baryshkov, Bjorn Andersson
Cc: Michael Turquette, Stephen Boyd, Taniya Das, Jagadeesh Kona,
Konrad Dybcio, usb4-upstream, linux-arm-msm, linux-clk,
linux-kernel
On 6/11/26 9:38 PM, Dmitry Baryshkov wrote:
> On Mon, Jun 08, 2026 at 10:09:55AM -0500, Bjorn Andersson wrote:
>>
>> On Thu, 09 Apr 2026 13:57:45 +0200, Konrad Dybcio wrote:
>>> The sole reason this hw exists is to let the branch clock downstream of
>>> it keep running, with the PHY disengaged. This is not possible with the
>>> current implementation, as the enabled status is hijacked to mean
>>> "enabled" = "use fast/PHY source" and "disabled" = "use XO source".
>>>
>>> This is an issue, since the mux enable state follows that of the child
>>> branch, making the desired "child enabled, MUX @ XO" combination
>>> impossible.
>>>
>>> [...]
>>
>> Applied, thanks!
>>
>> [1/1] clk: qcom: regmap-phy-mux: Rework the implementation
>> commit: e108373c54fbc844b7f541c6fd7ecb31772afd3c
>
> This breaks at PCIe at least on SM8350. The attached WiFi card is
> not detected anymore. Rewerting the patch makes it work again.
Hm, that's anticlimactic. Can you please dump:
gcc_pcie_0_pipe_clk_src: gcc+0x6b054
gcc_pcie_0_pipe_clk: gcc+0x52008
gcc_pcie_1_pipe_clk_src: gcc+0x8d054
gcc_pcie_1_pipe_clk: gcc+0x52000
Konrad
^ permalink raw reply [flat|nested] 7+ messages in thread[parent not found: <CGME20260626094632eucas1p2a0bd78e844ebe4e0205a0b900f8e3289@eucas1p2.samsung.com>]
* Re: [PATCH] clk: qcom: regmap-phy-mux: Rework the implementation
[not found] ` <CGME20260626094632eucas1p2a0bd78e844ebe4e0205a0b900f8e3289@eucas1p2.samsung.com>
@ 2026-06-26 9:46 ` Marek Szyprowski
[not found] ` <CGME20260626111504eucas1p1f9f7ffbd3655c400c6d7bd35e11fccb8@eucas1p1.samsung.com>
0 siblings, 1 reply; 7+ messages in thread
From: Marek Szyprowski @ 2026-06-26 9:46 UTC (permalink / raw)
To: Dmitry Baryshkov, Bjorn Andersson
Cc: Michael Turquette, Stephen Boyd, Taniya Das, Jagadeesh Kona,
Konrad Dybcio, usb4-upstream, linux-arm-msm, linux-clk,
linux-kernel, Konrad Dybcio
On 11.06.2026 21:38, Dmitry Baryshkov wrote:
> On Mon, Jun 08, 2026 at 10:09:55AM -0500, Bjorn Andersson wrote:
>> On Thu, 09 Apr 2026 13:57:45 +0200, Konrad Dybcio wrote:
>>> The sole reason this hw exists is to let the branch clock downstream of
>>> it keep running, with the PHY disengaged. This is not possible with the
>>> current implementation, as the enabled status is hijacked to mean
>>> "enabled" = "use fast/PHY source" and "disabled" = "use XO source".
>>>
>>> This is an issue, since the mux enable state follows that of the child
>>> branch, making the desired "child enabled, MUX @ XO" combination
>>> impossible.
>>>
>>> [...]
>> Applied, thanks!
>>
>> [1/1] clk: qcom: regmap-phy-mux: Rework the implementation
>> commit: e108373c54fbc844b7f541c6fd7ecb31772afd3c
> This breaks at PCIe at least on SM8350. The attached WiFi card is
> not detected anymore. Rewerting the patch makes it work again.
Same on QCS6490-based RubikPi3, after this patch the XHCI USB host controller PCI
devive is no longer detected.
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-06-26 11:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-09 11:57 [PATCH] clk: qcom: regmap-phy-mux: Rework the implementation Konrad Dybcio
2026-06-08 15:09 ` Bjorn Andersson
2026-06-11 19:38 ` Dmitry Baryshkov
2026-06-16 14:12 ` Konrad Dybcio
[not found] ` <CGME20260626094632eucas1p2a0bd78e844ebe4e0205a0b900f8e3289@eucas1p2.samsung.com>
2026-06-26 9:46 ` Marek Szyprowski
[not found] ` <CGME20260626111504eucas1p1f9f7ffbd3655c400c6d7bd35e11fccb8@eucas1p1.samsung.com>
2026-06-26 11:15 ` Marek Szyprowski
2026-06-26 11:16 ` Konrad Dybcio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome