Linux clock framework development
 help / color / mirror / Atom feed
* [PATCH 0/2] clk: mediatek: mt8196: Add clocks needed for Ethernet
@ 2026-12-03 14:49 Arnaud Ferraris
  2026-12-03 14:49 ` [PATCH 1/2] dt-bindings: clock: Add IDs for MediaTek MT8196 Ethernet clocks Arnaud Ferraris
  2026-12-03 14:49 ` [PATCH 2/2] clk: mediatek: mt8196: Add clocks needed for Ethernet Arnaud Ferraris
  0 siblings, 2 replies; 4+ messages in thread
From: Arnaud Ferraris @ 2026-12-03 14:49 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, Stephen Boyd, Brian Masney,
	Jerome Brunet, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, Richard Cochran
  Cc: linux-clk, linux-mediatek, devicetree, linux-kernel,
	linux-arm-kernel, netdev, kernel, Arnaud Ferraris

Add support for the Ethernet-related clocks of the MT8196 SoC, used by
the Ethernet MAC as well as both HSGMII PHYs.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
---
Arnaud Ferraris (2):
      dt-bindings: clock: Add IDs for MediaTek MT8196 Ethernet clocks
      clk: mediatek: mt8196: Add clocks needed for Ethernet

 drivers/clk/mediatek/clk-mt8196-topckgen.c        | 102 ++++++++++++++++++++++
 drivers/clk/mediatek/clk-mt8196-vlpckgen.c        |   2 +
 include/dt-bindings/clock/mediatek,mt8196-clock.h |  14 +++
 3 files changed, 118 insertions(+)
---
base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
change-id: 20261203-mt8196-net-clocks-9e5fcbc3292c

Best regards,
--  
Arnaud Ferraris <arnaud.ferraris@collabora.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] dt-bindings: clock: Add IDs for MediaTek MT8196 Ethernet clocks
  2026-12-03 14:49 [PATCH 0/2] clk: mediatek: mt8196: Add clocks needed for Ethernet Arnaud Ferraris
@ 2026-12-03 14:49 ` Arnaud Ferraris
  2026-12-03 14:49 ` [PATCH 2/2] clk: mediatek: mt8196: Add clocks needed for Ethernet Arnaud Ferraris
  1 sibling, 0 replies; 4+ messages in thread
From: Arnaud Ferraris @ 2026-12-03 14:49 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, Stephen Boyd, Brian Masney,
	Jerome Brunet, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, Richard Cochran
  Cc: linux-clk, linux-mediatek, devicetree, linux-kernel,
	linux-arm-kernel, netdev, kernel, Arnaud Ferraris

Add the Ethernet-related clocks found in the MT8196 SoC, as well as the
missing fixed factor dividers those depend on.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
---
 include/dt-bindings/clock/mediatek,mt8196-clock.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/dt-bindings/clock/mediatek,mt8196-clock.h b/include/dt-bindings/clock/mediatek,mt8196-clock.h
index ae0946ab7621b..498de4d43b5dd 100644
--- a/include/dt-bindings/clock/mediatek,mt8196-clock.h
+++ b/include/dt-bindings/clock/mediatek,mt8196-clock.h
@@ -140,6 +140,18 @@
 #define CLK_TOP_OSC_D32					127
 #define CLK_TOP_OSC_D40					128
 #define CLK_TOP_SFLASH					129
+#define CLK_TOP_NET1PLL_D4				130
+#define CLK_TOP_NET1PLL_D5				131
+#define CLK_TOP_NET1PLL_D5_D5				132
+#define CLK_TOP_UNIVPLL_D5_D8				133
+#define CLK_TOP_SGMII0_REF_325M				134
+#define CLK_TOP_SGMII0_REG				135
+#define CLK_TOP_SGMII1_REF_325M				136
+#define CLK_TOP_SGMII1_REG				137
+#define CLK_TOP_GMAC_312P5M				138
+#define CLK_TOP_GMAC_125M				139
+#define CLK_TOP_GMAC_RMII				140
+#define CLK_TOP_GMAC_62P4M_PTP				141
 
 /* APMIXEDSYS */
 #define CLK_APMIXED_MAINPLL				0
@@ -379,6 +391,8 @@
 #define CLK_VLP_APLL1_D8				46
 #define CLK_VLP_APLL2_D4				47
 #define CLK_VLP_APLL2_D8				48
+#define CLK_VLP_APLL1_D3				49
+#define CLK_VLP_APLL2_D3				50
 
 /* DISPSYS_CONFIG */
 #define CLK_MM_CONFIG					0

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] clk: mediatek: mt8196: Add clocks needed for Ethernet
  2026-12-03 14:49 [PATCH 0/2] clk: mediatek: mt8196: Add clocks needed for Ethernet Arnaud Ferraris
  2026-12-03 14:49 ` [PATCH 1/2] dt-bindings: clock: Add IDs for MediaTek MT8196 Ethernet clocks Arnaud Ferraris
@ 2026-12-03 14:49 ` Arnaud Ferraris
  2026-12-04 14:52   ` sashiko-bot
  1 sibling, 1 reply; 4+ messages in thread
From: Arnaud Ferraris @ 2026-12-03 14:49 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, Stephen Boyd, Brian Masney,
	Jerome Brunet, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, Richard Cochran
  Cc: linux-clk, linux-mediatek, devicetree, linux-kernel,
	linux-arm-kernel, netdev, kernel, Arnaud Ferraris

Add support for the Ethernet-related clocks of the MT8196 SoC, used by
the Ethernet MAC as well as both HSGMII PHYs.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
---
 drivers/clk/mediatek/clk-mt8196-topckgen.c | 102 +++++++++++++++++++++++++++++
 drivers/clk/mediatek/clk-mt8196-vlpckgen.c |   2 +
 2 files changed, 104 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mt8196-topckgen.c b/drivers/clk/mediatek/clk-mt8196-topckgen.c
index 6ace11ef6b694..90d03bdd426b7 100644
--- a/drivers/clk/mediatek/clk-mt8196-topckgen.c
+++ b/drivers/clk/mediatek/clk-mt8196-topckgen.c
@@ -81,6 +81,12 @@
 #define CLK_CFG_19		0x0140
 #define CLK_CFG_19_SET		0x0144
 #define CLK_CFG_19_CLR		0x0148
+#define CLK_CFG_20		0x0150
+#define CLK_CFG_20_SET		0x0154
+#define CLK_CFG_20_CLR		0x0158
+#define CLK_CFG_21		0x0160
+#define CLK_CFG_21_SET		0x0164
+#define CLK_CFG_21_CLR		0x0168
 #define CLK_AUDDIV_0		0x020c
 #define CLK_FENC_STATUS_MON_0	0x0270
 #define CLK_FENC_STATUS_MON_1	0x0274
@@ -154,6 +160,14 @@
 #define TOP_MUX_SPU0_SHIFT			12
 #define TOP_MUX_SPU1_SHIFT			13
 #define TOP_MUX_DXCC_SHIFT			14
+#define TOP_MUX_SGMII0_REF_325M_SHIFT		17
+#define TOP_MUX_SGMII0_REG_SHIFT		18
+#define TOP_MUX_SGMII1_REF_325M_SHIFT		19
+#define TOP_MUX_SGMII1_REG_SHIFT		20
+#define TOP_MUX_GMAC_312P5M_SHIFT		21
+#define TOP_MUX_GMAC_125M_SHIFT			22
+#define TOP_MUX_GMAC_RMII_SHIFT			23
+#define TOP_MUX_GMAC_62P4M_PTP_SHIFT		24
 
 /* CKSTA REG */
 #define CKSTA_REG	0x01c8
@@ -219,6 +233,7 @@ static const struct mtk_fixed_factor top_divs[] = {
 	FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll", 1, 5),
 	FACTOR(CLK_TOP_UNIVPLL_D5_D2, "univpll_d5_d2", "univpll", 1, 10),
 	FACTOR(CLK_TOP_UNIVPLL_D5_D4, "univpll_d5_d4", "univpll", 1, 20),
+	FACTOR(CLK_TOP_UNIVPLL_D5_D8, "univpll_d5_d8", "univpll", 1, 40),
 	FACTOR(CLK_TOP_UNIVPLL_D6, "univpll_d6", "univpll", 1, 6),
 	FACTOR(CLK_TOP_UNIVPLL_D6_D2, "univpll_d6_d2", "univpll", 1, 12),
 	FACTOR(CLK_TOP_UNIVPLL_D6_D4, "univpll_d6_d4", "univpll", 1, 24),
@@ -232,6 +247,9 @@ static const struct mtk_fixed_factor top_divs[] = {
 	FACTOR(CLK_TOP_UNIVPLL_192M_D10, "univpll_192m_d10", "univpll", 1, 130),
 	FACTOR(CLK_TOP_TVDPLL1_D2, "tvdpll1_d2", "tvdpll1", 1, 2),
 	FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll", 1, 2),
+	FACTOR(CLK_TOP_NET1PLL_D4, "net1pll_d4", "net1pll", 1, 4),
+	FACTOR(CLK_TOP_NET1PLL_D5, "net1pll_d5", "net1pll", 1, 5),
+	FACTOR(CLK_TOP_NET1PLL_D5_D5, "net1pll_d5_d5", "net1pll", 1, 25),
 	FACTOR(CLK_TOP_OSC_D2, "osc_d2", "ulposc", 1, 2),
 	FACTOR(CLK_TOP_OSC_D3, "osc_d3", "ulposc", 1, 3),
 	FACTOR(CLK_TOP_OSC_D4, "osc_d4", "ulposc", 1, 4),
@@ -612,6 +630,48 @@ static const char * const sflash_parents[] = {
 	"univpll_d6_d8"
 };
 
+static const char * const sgmii0_ref_325m_parents[] = {
+	"clk26m",
+	"sgmiipll"
+};
+
+static const char * const sgmii0_reg_parents[] = {
+	"clk26m",
+	"mainpll_d7_d4"
+};
+
+static const char * const sgmii1_ref_325m_parents[] = {
+	"clk26m",
+	"sgmiipll"
+};
+
+static const char * const sgmii1_reg_parents[] = {
+	"clk26m",
+	"mainpll_d7_d4"
+};
+
+static const char * const gmac_312p5m_parents[] = {
+	"clk26m",
+	"net1pll_d4"
+};
+
+static const char * const gmac_125m_parents[] = {
+	"clk26m",
+	"net1pll_d5"
+};
+
+static const char * const gmac_rmii_parents[] = {
+	"clk26m",
+	"net1pll_d5_d5"
+};
+
+static const char * const gmac_62p4m_ptp_parents[] = {
+	"clk26m",
+	"apll1_d3",
+	"univpll_d5_d8",
+	"apll2_d3"
+};
+
 static const struct mtk_mux top_muxes[] = {
 	/* CLK_CFG_0 */
 	MUX_CLR_SET_UPD(CLK_TOP_AXI, "axi",
@@ -913,6 +973,48 @@ static const struct mtk_mux top_muxes[] = {
 		dxcc_parents, CLK_CFG_19, CLK_CFG_19_SET,
 		CLK_CFG_19_CLR, 0, 2,
 		CLK_CFG_UPDATE2, TOP_MUX_DXCC_SHIFT),
+	MUX_GATE_FENC_CLR_SET_UPD(CLK_TOP_SGMII0_REF_325M, "sgmii0_ref_325m",
+		sgmii0_ref_325m_parents, CLK_CFG_19, CLK_CFG_19_SET,
+		CLK_CFG_19_CLR, 24, 1, 31,
+		CLK_CFG_UPDATE2, TOP_MUX_SGMII0_REF_325M_SHIFT,
+		CLK_FENC_STATUS_MON_2, 16),
+	/* CLK_CFG_20 */
+	MUX_GATE_FENC_CLR_SET_UPD(CLK_TOP_SGMII0_REG, "sgmii0_reg",
+		sgmii0_reg_parents, CLK_CFG_20, CLK_CFG_20_SET,
+		CLK_CFG_20_CLR, 0, 1, 7,
+		CLK_CFG_UPDATE2, TOP_MUX_SGMII0_REG_SHIFT,
+		CLK_FENC_STATUS_MON_2, 15),
+	MUX_GATE_FENC_CLR_SET_UPD(CLK_TOP_SGMII1_REF_325M, "sgmii1_ref_325m",
+		sgmii1_ref_325m_parents, CLK_CFG_20, CLK_CFG_20_SET,
+		CLK_CFG_20_CLR, 8, 1, 15,
+		CLK_CFG_UPDATE2, TOP_MUX_SGMII1_REF_325M_SHIFT,
+		CLK_FENC_STATUS_MON_2, 14),
+	MUX_GATE_FENC_CLR_SET_UPD(CLK_TOP_SGMII1_REG, "sgmii1_reg",
+		sgmii1_reg_parents, CLK_CFG_20, CLK_CFG_20_SET,
+		CLK_CFG_20_CLR, 16, 1, 23,
+		CLK_CFG_UPDATE2, TOP_MUX_SGMII1_REG_SHIFT,
+		CLK_FENC_STATUS_MON_2, 13),
+	MUX_GATE_FENC_CLR_SET_UPD(CLK_TOP_GMAC_312P5M, "gmac_312p5m",
+		gmac_312p5m_parents, CLK_CFG_20, CLK_CFG_20_SET,
+		CLK_CFG_20_CLR, 24, 1, 31,
+		CLK_CFG_UPDATE2, TOP_MUX_GMAC_312P5M_SHIFT,
+		CLK_FENC_STATUS_MON_2, 12),
+	/* CLK_CFG_21 */
+	MUX_GATE_FENC_CLR_SET_UPD(CLK_TOP_GMAC_125M, "gmac_125m",
+		gmac_125m_parents, CLK_CFG_21, CLK_CFG_21_SET,
+		CLK_CFG_21_CLR, 0, 1, 7,
+		CLK_CFG_UPDATE2, TOP_MUX_GMAC_125M_SHIFT,
+		CLK_FENC_STATUS_MON_2, 11),
+	MUX_GATE_FENC_CLR_SET_UPD(CLK_TOP_GMAC_RMII, "gmac_rmii",
+		gmac_rmii_parents, CLK_CFG_21, CLK_CFG_21_SET,
+		CLK_CFG_21_CLR, 8, 1, 15,
+		CLK_CFG_UPDATE2, TOP_MUX_GMAC_RMII_SHIFT,
+		CLK_FENC_STATUS_MON_2, 10),
+	MUX_GATE_FENC_CLR_SET_UPD(CLK_TOP_GMAC_62P4M_PTP, "gmac_62p4m_ptp",
+		gmac_62p4m_ptp_parents, CLK_CFG_21, CLK_CFG_21_SET,
+		CLK_CFG_21_CLR, 16, 2, 23,
+		CLK_CFG_UPDATE2, TOP_MUX_GMAC_62P4M_PTP_SHIFT,
+		CLK_FENC_STATUS_MON_2, 9),
 };
 
 static const struct mtk_composite top_aud_divs[] = {
diff --git a/drivers/clk/mediatek/clk-mt8196-vlpckgen.c b/drivers/clk/mediatek/clk-mt8196-vlpckgen.c
index ee88dc4a231af..95d65d4e52045 100644
--- a/drivers/clk/mediatek/clk-mt8196-vlpckgen.c
+++ b/drivers/clk/mediatek/clk-mt8196-vlpckgen.c
@@ -169,8 +169,10 @@ static DEFINE_SPINLOCK(mt8196_clk_vlp_lock);
 
 static const struct mtk_fixed_factor vlp_divs[] = {
 	FACTOR(CLK_VLP_CLK26M, "vlp_clk26m", "clk26m", 1, 1),
+	FACTOR(CLK_VLP_APLL1_D3, "apll1_d3", "vlp_apll1", 1, 3),
 	FACTOR(CLK_VLP_APLL1_D4, "apll1_d4", "vlp_apll1", 1, 4),
 	FACTOR(CLK_VLP_APLL1_D8, "apll1_d8", "vlp_apll1", 1, 8),
+	FACTOR(CLK_VLP_APLL2_D3, "apll2_d3", "vlp_apll2", 1, 3),
 	FACTOR(CLK_VLP_APLL2_D4, "apll2_d4", "vlp_apll2", 1, 4),
 	FACTOR(CLK_VLP_APLL2_D8, "apll2_d8", "vlp_apll2", 1, 8),
 };

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] clk: mediatek: mt8196: Add clocks needed for Ethernet
  2026-12-03 14:49 ` [PATCH 2/2] clk: mediatek: mt8196: Add clocks needed for Ethernet Arnaud Ferraris
@ 2026-12-04 14:52   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-12-04 14:52 UTC (permalink / raw)
  To: Arnaud Ferraris; +Cc: linux-clk, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] clk: mediatek: mt8196 gmac_125m uses 1/5 divider net1pll_d5
  instead of 1/10
- [Low] clk: mediatek: duplicate SGMII parent arrays in
  clk-mt8196-topckgen.c
--

commit a6333bb8a54b98bb2785eda186ab22038a6646f2
Author: Arnaud Ferraris <arnaud.ferraris@collabora.com>

clk: mediatek: mt8196: Add clocks needed for Ethernet

This commit adds the fixed-factor dividers and topckgen/vlpckgen muxes
needed for the MT8196 Ethernet MAC and HSGMII PHYs.

> diff --git a/drivers/clk/mediatek/clk-mt8196-topckgen.c b/drivers/clk/mediatek/clk-mt8196-topckgen.c
> index 6ace11ef6b694..90d03bdd426b7 100644
> --- a/drivers/clk/mediatek/clk-mt8196-topckgen.c
> +++ b/drivers/clk/mediatek/clk-mt8196-topckgen.c

[ ... ]

> @@ -612,6 +630,48 @@ static const char * const sflash_parents[] = {
>  	"univpll_d6_d8"
>  };
>  
> +static const char * const sgmii0_ref_325m_parents[] = {
> +	"clk26m",
> +	"sgmiipll"
> +};
> +
> +static const char * const sgmii0_reg_parents[] = {
> +	"clk26m",
> +	"mainpll_d7_d4"
> +};
> +
> +static const char * const sgmii1_ref_325m_parents[] = {
> +	"clk26m",
> +	"sgmiipll"
> +};
> +
> +static const char * const sgmii1_reg_parents[] = {
> +	"clk26m",
> +	"mainpll_d7_d4"
> +};

[Severity: Low]
This isn't a bug, but sgmii1_ref_325m_parents and sgmii1_reg_parents
duplicate the sgmii0 arrays verbatim.  Could these share
sgmii_ref_325m_parents and sgmii_reg_parents to match spu_parents and
tl_parents in this driver?

> +
> +static const char * const gmac_312p5m_parents[] = {
> +	"clk26m",
> +	"net1pll_d4"
> +};
> +
> +static const char * const gmac_125m_parents[] = {
> +	"clk26m",
> +	"net1pll_d5"
> +};
> +
> +static const char * const gmac_rmii_parents[] = {
> +	"clk26m",
> +	"net1pll_d5_d5"
> +};

[Severity: Medium]
Should gmac_125m use a 1/10 divider (such as net1pll_d5_d2) instead of
net1pll_d5?

gmac_312p5m uses net1pll_d4 (1/4) and gmac_rmii uses net1pll_d5_d5
(1/25), which both require net1pll to run at 1250 MHz.  At 1250 MHz,
net1pll_d5 (1/5) produces 250 MHz rather than 125 MHz.

Because CLK_TOP_GMAC_125M uses mtk_clk_mux_determine_rate(), which calls
clk_mux_determine_rate_flags() with flags = 0, only parents at or below
the requested rate are considered.  A 125 MHz clk_set_rate() call on
gmac_125m will therefore reject net1pll_d5 and fall back to clk26m.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-mt8196-net-clocks-v1-0-c23567b55dff@collabora.com?part=2

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-04 14:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 14:49 [PATCH 0/2] clk: mediatek: mt8196: Add clocks needed for Ethernet Arnaud Ferraris
2026-12-03 14:49 ` [PATCH 1/2] dt-bindings: clock: Add IDs for MediaTek MT8196 Ethernet clocks Arnaud Ferraris
2026-12-03 14:49 ` [PATCH 2/2] clk: mediatek: mt8196: Add clocks needed for Ethernet Arnaud Ferraris
2026-12-04 14:52   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox