Skip to contentSkip to conversation

clk: qcom: gcc-ipq5018: fix swapped MDIO clocks and resets

PATCH In review Davíð Steinn Geirsson 3 participants 5 messages Nov 12 – Nov 23

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: qcom: gcc-ipq5018: fix swapped MDIO clocks and resets

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")

---

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.

drivers/clk/qcom/gcc-ipq5018.c +19 -19
index 37ccdc44a8..bf1a4745d1 100644
@@ -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 },
Tested-by on v1 1/1
#1 lore raw
Quoted 21 lines · Davíð Steinn Geirsson

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.

Quoted 2 lines

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.

confirmed working on Linksys MX2000 and MR5500. Both devices don't have the internal GE PHY on mdio0 wired up. With mdio1 enabled and mdio0 disabled, ethernet comes up.

Adding Luo Jie: I think this patch can be reverted because not all boards use the internal GE PHY and its LDO needs not be enabled for ethernet functionality on externally connected PHYs or switches controlled by mdio1
-
https://lore.kernel.org/all/20260902-qcom_ipq5018_mdio_pinctrl-v3-2-629c7bb05c44@oss.qualcomm.com/

Quoted 75 lines
Fixes e3fdbef1bab8 ("clk: qcom: Add Global Clock controller (GCC) driver for IPQ5018")

---

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.

drivers/clk/qcom/gcc-ipq5018.c +19 -19
index 37ccdc44a8..bf1a4745d1 100644
@@ -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 },
#2 lore raw
Quoted 29 lines · George Moussalem
Quoted 21 lines · Davíð Steinn Geirsson

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.

Quoted 2 lines

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.

confirmed working on Linksys MX2000 and MR5500. Both devices don't have the internal GE PHY on mdio0 wired up. With mdio1 enabled and mdio0 disabled, ethernet comes up.

Quoted 9 lines

Adding Luo Jie: I think this patch can be reverted because not all boards use the internal GE PHY and its LDO needs not be enabled for ethernet functionality on externally connected PHYs or switches controlled by mdio1
-
https://lore.kernel.org/all/20260902-qcom_ipq5018_mdio_pinctrl-v3-2-629c7bb05c44@oss.qualcomm.com/

Thanks for testing on the MX2000 and MR5500.

All of the Qualcomm RDP boards have the internal GE PHY, so it makes sense to keep it enabled by default. A board that doesn't use the internal GE PHY can disable it in its own board DTS, as you already did for the MX2000 and MR5500:

	&mdio0 {
		status = "disabled";
	};
Quoted 67 lines
Quoted 67 lines
Fixes e3fdbef1bab8 ("clk: qcom: Add Global Clock controller (GCC) driver for IPQ5018")

---

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.

drivers/clk/qcom/gcc-ipq5018.c +17 -17
index 37ccdc44a8..bf1a4745d1 100644
@@ -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 },
Quoted 8 lines

drivers/clk/qcom/gcc-ipq5018.c line 3592

Quoted 8 lines
drivers/clk/qcom/gcc-ipq5018.c +2 -2
 	[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 },

The GCC driver is correct here. GCC_MDIO0_AHB_CLK (0x58004) and GCC_MDIO1_AHB_CLK (0x58014), along with the matching BCRs, follow the IPQ5018 hardware register definitions. What is wrong is the clock assignment in ipq5018.dtsi: the MDIO controller at 0x88000 is clocked by GCC_MDIO1_AHB_CLK, and the controller at 0x90000 is clocked by GCC_MDIO0_AHB_CLK.

Please drop this change and fix the DTS instead, for example:

arch/arm64/boot/dts/qcom/ipq5018.dtsi +2 -2
@@ -220,7 +220,7 @@ mdio0: mdio@88000 {
                        #address-cells = <1>;
                        #size-cells = <0>;
 
-                       clocks = <&gcc GCC_MDIO0_AHB_CLK>;
+                       clocks = <&gcc GCC_MDIO1_AHB_CLK>;
                        clock-names = "gcc_mdio_ahb_clk";
                        clock-frequency = <6250000>;
 
@@ -243,7 +243,7 @@ mdio1: mdio@90000 {
                        pinctrl-0 = <&mdio_pins>;
                        pinctrl-names = "default";
 
-                       clocks = <&gcc GCC_MDIO1_AHB_CLK>;
+                       clocks = <&gcc GCC_MDIO0_AHB_CLK>;
                        clock-names = "gcc_mdio_ahb_clk";
 
                        status = "disabled";
#3 lore raw
Quoted 137 lines · Jie Luo
Quoted 29 lines · George Moussalem
Quoted 21 lines · Davíð Steinn Geirsson

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.

Quoted 2 lines

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.

confirmed working on Linksys MX2000 and MR5500. Both devices don't have the internal GE PHY on mdio0 wired up. With mdio1 enabled and mdio0 disabled, ethernet comes up.

Quoted 9 lines

Adding Luo Jie: I think this patch can be reverted because not all boards use the internal GE PHY and its LDO needs not be enabled for ethernet functionality on externally connected PHYs or switches controlled by mdio1
-
https://lore.kernel.org/all/20260902-qcom_ipq5018_mdio_pinctrl-v3-2-629c7bb05c44@oss.qualcomm.com/

Thanks for testing on the MX2000 and MR5500.

All of the Qualcomm RDP boards have the internal GE PHY, so it makes sense to keep it enabled by default. A board that doesn't use the internal GE PHY can disable it in its own board DTS, as you already did for the MX2000 and MR5500:

	&mdio0 {
		status = "disabled";
	};
Quoted 67 lines
Quoted 67 lines
Fixes e3fdbef1bab8 ("clk: qcom: Add Global Clock controller (GCC) driver for IPQ5018")

---

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.

drivers/clk/qcom/gcc-ipq5018.c +17 -17
index 37ccdc44a8..bf1a4745d1 100644
@@ -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 },
Quoted 8 lines

drivers/clk/qcom/gcc-ipq5018.c line 3592

Quoted 8 lines
drivers/clk/qcom/gcc-ipq5018.c +2 -2
 	[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 },

The GCC driver is correct here. GCC_MDIO0_AHB_CLK (0x58004) and GCC_MDIO1_AHB_CLK (0x58014), along with the matching BCRs, follow the IPQ5018 hardware register definitions. What is wrong is the clock assignment in ipq5018.dtsi: the MDIO controller at 0x88000 is clocked by GCC_MDIO1_AHB_CLK, and the controller at 0x90000 is clocked by GCC_MDIO0_AHB_CLK.

Quoted 1 line

Please drop this change and fix the DTS instead, for example:

Understood, will do. I'll be traveling for a conference the rest of the week, so I'll prepare and submit the v2 sometime next week. If George or someone else wants to submit before then, that's also fine by me. :)

Thanks,
Davíð

Quoted 22 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +2 -2
@@ -220,7 +220,7 @@ mdio0: mdio@88000 {
                        #address-cells = <1>;
                        #size-cells = <0>;
 
-                       clocks = <&gcc GCC_MDIO0_AHB_CLK>;
+                       clocks = <&gcc GCC_MDIO1_AHB_CLK>;
                        clock-names = "gcc_mdio_ahb_clk";
                        clock-frequency = <6250000>;
 
@@ -243,7 +243,7 @@ mdio1: mdio@90000 {
                        pinctrl-0 = <&mdio_pins>;
                        pinctrl-names = "default";
 
-                       clocks = <&gcc GCC_MDIO1_AHB_CLK>;
+                       clocks = <&gcc GCC_MDIO0_AHB_CLK>;
                        clock-names = "gcc_mdio_ahb_clk";
 
                        status = "disabled";
#4 lore raw
Quoted 143 lines · Davíð Steinn Geirsson
Quoted 137 lines · Jie Luo
Quoted 29 lines · George Moussalem
Quoted 21 lines · Davíð Steinn Geirsson

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.

Quoted 2 lines

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.

confirmed working on Linksys MX2000 and MR5500. Both devices don't have the internal GE PHY on mdio0 wired up. With mdio1 enabled and mdio0 disabled, ethernet comes up.

Quoted 9 lines

Adding Luo Jie: I think this patch can be reverted because not all boards use the internal GE PHY and its LDO needs not be enabled for ethernet functionality on externally connected PHYs or switches controlled by mdio1
-
https://lore.kernel.org/all/20260902-qcom_ipq5018_mdio_pinctrl-v3-2-629c7bb05c44@oss.qualcomm.com/

Thanks for testing on the MX2000 and MR5500.

All of the Qualcomm RDP boards have the internal GE PHY, so it makes sense to keep it enabled by default. A board that doesn't use the internal GE PHY can disable it in its own board DTS, as you already did for the MX2000 and MR5500:

	&mdio0 {
		status = "disabled";
	};
Quoted 67 lines
Quoted 67 lines
Fixes e3fdbef1bab8 ("clk: qcom: Add Global Clock controller (GCC) driver for IPQ5018")

---

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.

drivers/clk/qcom/gcc-ipq5018.c +17 -17
index 37ccdc44a8..bf1a4745d1 100644
@@ -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 },
Quoted 8 lines

drivers/clk/qcom/gcc-ipq5018.c line 3592

Quoted 8 lines
drivers/clk/qcom/gcc-ipq5018.c +2 -2
 	[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 },

The GCC driver is correct here. GCC_MDIO0_AHB_CLK (0x58004) and GCC_MDIO1_AHB_CLK (0x58014), along with the matching BCRs, follow the IPQ5018 hardware register definitions. What is wrong is the clock assignment in ipq5018.dtsi: the MDIO controller at 0x88000 is clocked by GCC_MDIO1_AHB_CLK, and the controller at 0x90000 is clocked by GCC_MDIO0_AHB_CLK.

Quoted 8 lines
Quoted 1 line

Please drop this change and fix the DTS instead, for example:

Understood, will do. I'll be traveling for a conference the rest of the week, so I'll prepare and submit the v2 sometime next week. If George or someone else wants to submit before then, that's also fine by me. :)

Thanks,
Davíð

should the labels of the controllers be swapped too to align them to the clock names? Else you would have &mdio0 with the GCC_MDIO1_AHB_CLK assigned. If yes, it will require changes to board files that reference these labels too.

BR,
George

Quoted 22 lines
Quoted 22 lines
arch/arm64/boot/dts/qcom/ipq5018.dtsi +2 -2
@@ -220,7 +220,7 @@ mdio0: mdio@88000 {
                        #address-cells = <1>;
                        #size-cells = <0>;
 
-                       clocks = <&gcc GCC_MDIO0_AHB_CLK>;
+                       clocks = <&gcc GCC_MDIO1_AHB_CLK>;
                        clock-names = "gcc_mdio_ahb_clk";
                        clock-frequency = <6250000>;
 
@@ -243,7 +243,7 @@ mdio1: mdio@90000 {
                        pinctrl-0 = <&mdio_pins>;
                        pinctrl-names = "default";
 
-                       clocks = <&gcc GCC_MDIO1_AHB_CLK>;
+                       clocks = <&gcc GCC_MDIO0_AHB_CLK>;
                        clock-names = "gcc_mdio_ahb_clk";
 
                        status = "disabled";