mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Davíð Steinn Geirsson" <david@dsg.is>
To: Bjorn Andersson <andersson@kernel.org>, Stephen Boyd <sboyd@kernel.org>
Cc: "Abel Vesa" <abelvesa@kernel.org>,
	"Konrad Dybcio" <konradybcio@kernel.org>,
	"Brian Masney" <bmasney+clk@redhat.com>,
	"Jerome Brunet" <jbrunet+clk@baylibre.com>,
	"Gokul Sriram Palanisamy" <quic_gokulsri@quicinc.com>,
	"Varadarajan Narayanan" <quic_varada@quicinc.com>,
	"Sricharan Ramabadhran" <quic_srichara@quicinc.com>,
	linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Davíð Steinn Geirsson" <david@dsg.is>
Subject: [PATCH] clk: qcom: gcc-ipq5018: fix swapped MDIO clocks and resets
Date: Thu, 12 Nov 2026 15:57:55 +0000	[thread overview]
Message-ID: <20261112155801.610730-1-david@dsg.is> (raw)

The GCC has a block reset (BCR) and an AHB clock branch for each of the
two MDIO controllers. The pair at 0x58000/0x58004 belongs to the
controller at 0x90000 (mdio1 in ipq5018.dtsi) and the pair at
0x58010/0x58014 belongs to the controller at 0x88000 (mdio0). The driver
maps the GCC_MDIO0_* IDs to the first pair and the GCC_MDIO1_* IDs to
the second, so each MDIO node gets the clock and reset of the other
controller.

ipq5018.dtsi enables mdio0 and leaves mdio1 disabled. On a board that
does not enable mdio1, clk_disable_unused() gates 0x58014 and the
controller at 0x88000 stops responding. Its registers then read back a
stale bus value, so MDIO reads return garbage instead of failing.

Observed on a Ubiquiti UniFi 6 Pro, which has the internal GE PHY on
mdio0 and nothing on mdio1:
- Gating 0x58004 leaves the 0x88000 controller working and every
  0x90000 register reads 0xffff. Gating 0x58014 does the reverse.
- Asserting the BCR at 0x58000 resets the 0x90000 controller and halts
  the 0x58004 branch. The BCR at 0x58010 resets the 0x88000 controller
  and halts the 0x58014 branch.

Swap the clock and reset offsets so that each ID controls the
controller it is named after. No in-tree DT uses the MDIO resets.

Fixes: e3fdbef1bab8 ("clk: qcom: Add Global Clock controller (GCC) driver for IPQ5018")
Signed-off-by: Davíð Steinn Geirsson <david@dsg.is>
---

Tested and confirmed working on the Ubiquiti U6 Pro with both
OpenWRT's v6.18.60 kernel and `qcom/clk-for-7.5`.

A comment in OpenWRT's `ipq5018-archer-ax55-v1.dts` indicates this
bug has bitten people before:
https://github.com/openwrt/openwrt/blob/main/target/linux/qualcommax/dts/ipq5018-archer-ax55-v1.dts#L273-L279
That workaround should become unnecessary with this patch, though I
do not have the right hardware to confirm that.

diff --git a/drivers/clk/qcom/gcc-ipq5018.c b/drivers/clk/qcom/gcc-ipq5018.c
index 37ccdc44a8..bf1a4745d1 100644
--- a/drivers/clk/qcom/gcc-ipq5018.c
+++ b/drivers/clk/qcom/gcc-ipq5018.c
@@ -1969,28 +1969,28 @@
 };
 
 static struct clk_branch gcc_mdio0_ahb_clk = {
+	.halt_reg = 0x58014,
+	.clkr = {
+		.enable_reg = 0x58014,
+		.enable_mask = BIT(0),
+		.hw.init = &(struct clk_init_data) {
+			.name = "gcc_mdioi0_ahb_clk",
+			.parent_hws = (const struct clk_hw *[]) {
+				&pcnoc_clk_src.hw,
+			},
+			.num_parents = 1,
+			.flags = CLK_SET_RATE_PARENT,
+			.ops = &clk_branch2_ops,
+		},
+	},
+};
+
+static struct clk_branch gcc_mdio1_ahb_clk = {
 	.halt_reg = 0x58004,
 	.clkr = {
 		.enable_reg = 0x58004,
 		.enable_mask = BIT(0),
 		.hw.init = &(struct clk_init_data) {
-			.name = "gcc_mdioi0_ahb_clk",
-			.parent_hws = (const struct clk_hw *[]) {
-				&pcnoc_clk_src.hw,
-			},
-			.num_parents = 1,
-			.flags = CLK_SET_RATE_PARENT,
-			.ops = &clk_branch2_ops,
-		},
-	},
-};
-
-static struct clk_branch gcc_mdio1_ahb_clk = {
-	.halt_reg = 0x58014,
-	.clkr = {
-		.enable_reg = 0x58014,
-		.enable_mask = BIT(0),
-		.hw.init = &(struct clk_init_data) {
 			.name = "gcc_mdio1_ahb_clk",
 			.parent_hws = (const struct clk_hw *[]) {
 				&pcnoc_clk_src.hw,
@@ -3585,8 +3585,8 @@
 	[GCC_GMAC1_SYS_ARES] = { 0x68438, 1 },
 	[GCC_IMEM_BCR] = { 0x0e000, 0 },
 	[GCC_LPASS_BCR] = { 0x2e000, 0 },
-	[GCC_MDIO0_BCR] = { 0x58000, 0 },
-	[GCC_MDIO1_BCR] = { 0x58010, 0 },
+	[GCC_MDIO0_BCR] = { 0x58010, 0 },
+	[GCC_MDIO1_BCR] = { 0x58000, 0 },
 	[GCC_MPM_BCR] = { 0x2c000, 0 },
 	[GCC_PCIE0_BCR] = { 0x75004, 0 },
 	[GCC_PCIE0_LINK_DOWN_BCR] = { 0x750a8, 0 },

                 reply	other threads:[~2026-11-12 15:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261112155801.610730-1-david@dsg.is \
    --to=david@dsg.is \
    --cc=abelvesa@kernel.org \
    --cc=andersson@kernel.org \
    --cc=bmasney+clk@redhat.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_gokulsri@quicinc.com \
    --cc=quic_srichara@quicinc.com \
    --cc=quic_varada@quicinc.com \
    --cc=sboyd@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

all inboxes | Powered by JetHome®