Add MT7629 RTC clock selection
Subsystems (3)
v2 cover Add MT7629 RTC clock selection
The MT7629 RTC mux can select the 40 MHz crystal divided by 1024 or 1221. The integrated Wi-Fi needs the /1221 source, but the clock driver currently exposes only the /1024 source.
First move the clock counts used by clk-mt7629.c out of the DT binding header and into the driver. Then add clock IDs, the /1221 fixed-factor clock and the RTC mux to allow selection of the approximately 32.76 kHz source from device tree.
---
Changes in v2:
- Add a preparatory patch to move the TOP, INFRA, PERI and APMIXED
clock counts from the DT binding header into clk-mt7629.c.
- Update CLK_TOP_NR_CLK in the driver patch instead of the binding patch.
- Rebase onto next-20261119.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Chuanhong Guo (3):
clk: mediatek: mt7629: move clock counts out of DT bindings
dt-bindings: clock: mediatek: mt7629: add RTC clock IDs
clk: mediatek: mt7629: add RTC clock selection
drivers/clk/mediatek/clk-mt7629.c | 12 ++++++++++++ include/dt-bindings/clock/mt7629-clk.h | 6 ++---- 2 files changed, 14 insertions(+), 4 deletions(-)
---
base-commit: adcad7f4e6332cff3d6d7165f41584899f598534
change-id: 20260926-b4-mt7629-rtc-7488fa94b1ab
Best regards,
Signature · 1 line
Chuanhong Guo <[email protected]>
PATCH v2 1/3 clk: mediatek: mt7629: move clock counts out of DT bindings
The clock counts used by clk-mt7629.c size the clock provider arrays. They are driver implementation details rather than clock IDs used by device tree consumers.
Move CLK_TOP_NR_CLK, CLK_INFRA_NR_CLK, CLK_PERI_NR_CLK and CLK_APMIXED_NR_CLK into the driver. Keep their values and all clock IDs unchanged.
--- drivers/clk/mediatek/clk-mt7629.c | 5 +++++ include/dt-bindings/clock/mt7629-clk.h | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/clk/mediatek/clk-mt7629.c +5 -0
@@ -17,6 +17,11 @@#include <dt-bindings/clock/mt7629-clk.h> +#define CLK_TOP_NR_CLK 108 +#define CLK_INFRA_NR_CLK 6 +#define CLK_PERI_NR_CLK 22 +#define CLK_APMIXED_NR_CLK 7 +#define MT7629_PLL_FMAX (2500UL * MHZ)#define CON0_MT7629_RST_BAR BIT(24)
include/dt-bindings/clock/mt7629-clk.h +0 -4
@@ -115,7 +115,6 @@#define CLK_TOP_CRYPTO_SEL 105#define CLK_TOP_SGMII_REF_1_SEL 106#define CLK_TOP_10M_SEL 107 -#define CLK_TOP_NR_CLK 108/* INFRACFG */ #define CLK_INFRA_MUX1_SEL 0
@@ -124,7 +123,6 @@#define CLK_INFRA_DEVAPC_PD 3#define CLK_INFRA_APXGPT_PD 4#define CLK_INFRA_SEJ_PD 5 -#define CLK_INFRA_NR_CLK 6/* PERICFG */ #define CLK_PERIBUS_SEL 0
@@ -149,7 +147,6 @@#define CLK_PERI_NFI_PD 19#define CLK_PERI_NFIECC_PD 20#define CLK_PERI_FLASH_PD 21 -#define CLK_PERI_NR_CLK 22/* APMIXEDSYS */ #define CLK_APMIXED_ARMPLL 0
@@ -159,7 +156,6 @@#define CLK_APMIXED_ETH2PLL 4#define CLK_APMIXED_SGMIPLL 5#define CLK_APMIXED_MAIN_CORE_EN 6 -#define CLK_APMIXED_NR_CLK 7/* SSUSBSYS */ #define CLK_SSUSB_U2_PHY_1P_EN 0
Signature · 1 line
2.56.1
PATCH v2 2/3 dt-bindings: clock: mediatek: mt7629: add RTC clock IDs
In reply to Chuanhong GuoExpose the 40 MHz / 1221 RTC source and the RTC clock mux. Keep the existing CLK_TOP_RTC ID for the 40 MHz / 1024 source.
--- include/dt-bindings/clock/mt7629-clk.h | 2 ++ 1 file changed, 2 insertions(+)
include/dt-bindings/clock/mt7629-clk.h +2 -0
@@ -115,6 +115,8 @@#define CLK_TOP_CRYPTO_SEL 105#define CLK_TOP_SGMII_REF_1_SEL 106#define CLK_TOP_10M_SEL 107 +#define CLK_TOP_RTC_32K 108 +#define CLK_TOP_RTC_SEL 109/* INFRACFG */ #define CLK_INFRA_MUX1_SEL 0
Signature · 1 line
2.56.1
PATCH v2 3/3 clk: mediatek: mt7629: add RTC clock selection
In reply to Chuanhong GuoCLK_MODE bits 3:2 select the RTC clock source. Selector 0 uses the 40 MHz crystal divided by 1024, while selector 3 divides it by 1221 to provide approximately 32.76 kHz. The integrated Wi-Fi needs this /1221 source.
Add the /1221 fixed-factor clock and the RTC mux so device trees can select this source through assigned-clock-parents. Keep CLK_TOP_RTC for the existing /1024 source.
Selector 1 is reserved. Selector 2 is documented as an approximately 25 kHz PMU bandgap clock, but its source and control are not sufficiently described to model it here. Leave these entries unmodelled while preserving the hardware selector values.
--- drivers/clk/mediatek/clk-mt7629.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/clk/mediatek/clk-mt7629.c +8 -1
@@ -17,7 +17,7 @@#include <dt-bindings/clock/mt7629-clk.h> -#define CLK_TOP_NR_CLK 108 +#define CLK_TOP_NR_CLK 110#define CLK_INFRA_NR_CLK 6#define CLK_PERI_NR_CLK 22#define CLK_APMIXED_NR_CLK 7
@@ -290,6 +290,10 @@ static const char * const infra_mux1_parents[] = {"armpll" }; +static const char *const rtc_parents[] = { +"rtc" ,"clk_null" ,"clk_null" ,"rtc_32k" +}; +static const struct mtk_gate_regs apmixed_cg_regs = { .set_ofs =0x8 , .clr_ofs =0x8 ,
@@ -372,6 +376,7 @@ static const struct mtk_fixed_factor top_divs[] = {FACTOR (CLK_TOP_ETH_500M ,"eth_500m" ,"eth1pll" ,1 ,1 ),FACTOR (CLK_TOP_TXCLK_SRC_PRE ,"txclk_src_pre" ,"sgmiipll_d2" ,1 ,1 ),FACTOR (CLK_TOP_RTC ,"rtc" ,"clkxtal" ,1 ,1024 ), +FACTOR (CLK_TOP_RTC_32K ,"rtc_32k" ,"clkxtal" ,1 ,1221 ),FACTOR (CLK_TOP_PWM_QTR_26M ,"pwm_qtr_26m" ,"clkxtal" ,1 ,1 ),FACTOR (CLK_TOP_CPUM_TCK_IN ,"cpum_tck_in" ,"cpum_tck" ,1 ,1 ), FACTOR(CLK_TOP_TO_USB3_DA_TOP, "to_usb3_da_top", "clkxtal", 1, 1),
@@ -463,6 +468,8 @@ static struct mtk_composite infra_muxes[] = { };static struct mtk_composite top_muxes[] = { +/* CLK_MODE */ +MUX (CLK_TOP_RTC_SEL ,"rtc_sel" , rtc_parents,0x000 ,2 ,2 ),/* CLK_CFG_0 */ MUX_GATE (CLK_TOP_AXI_SEL ,"axi_sel" , axi_parents,0x040 ,0 ,3 ,7 ),
Signature · 1 line
2.56.1
AngeloGioacchino Del Regno
maintainerRe: [PATCH v2 1/3] clk: mediatek: mt7629: move clock counts out of DT bindings
In reply to Chuanhong GuoQuoted 9 lines · Chuanhong Guo
The clock counts used by
clk-mt7629.csize the clock provider arrays. They are driver implementation details rather than clock IDs used by device tree consumers.Move
CLK_TOP_NR_CLK,CLK_INFRA_NR_CLK,CLK_PERI_NR_CLKandCLK_APMIXED_NR_CLKinto the driver. Keep their values and all clock IDs unchanged.Signed-off-by Chuanhong Guo <[email protected]>
If you migrate clk-mt7629 to mtk_clk_simple_{probe,remove}, you will realize that the CLK_xxxx_NR_CLK definitions are completely useless, and you'll be able to remove those.
Check other MediaTek clock drivers about how to migrate.
In any case, NR_CLK is always the same as ARRAY_SIZE(that_clock_array)....
Cheers,
Angelo
Quoted 58 lines
--- drivers/clk/mediatek/clk-mt7629.c | 5 +++++ include/dt-bindings/clock/mt7629-clk.h | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-)drivers/clk/mediatek/clk-mt7629.c +5
-0@@ -17,6 +17,11 @@#include <dt-bindings/clock/mt7629-clk.h> +#define CLK_TOP_NR_CLK 108 +#define CLK_INFRA_NR_CLK 6 +#define CLK_PERI_NR_CLK 22 +#define CLK_APMIXED_NR_CLK 7 +#define MT7629_PLL_FMAX (2500UL * MHZ)#define CON0_MT7629_RST_BAR BIT(24)include/dt-bindings/clock/mt7629-clk.h +0
-4@@ -115,7 +115,6 @@#define CLK_TOP_CRYPTO_SEL 105#define CLK_TOP_SGMII_REF_1_SEL 106#define CLK_TOP_10M_SEL 107 -#define CLK_TOP_NR_CLK 108/* INFRACFG */ #define CLK_INFRA_MUX1_SEL 0@@ -124,7 +123,6 @@#define CLK_INFRA_DEVAPC_PD 3#define CLK_INFRA_APXGPT_PD 4#define CLK_INFRA_SEJ_PD 5 -#define CLK_INFRA_NR_CLK 6/* PERICFG */ #define CLK_PERIBUS_SEL 0@@ -149,7 +147,6 @@#define CLK_PERI_NFI_PD 19#define CLK_PERI_NFIECC_PD 20#define CLK_PERI_FLASH_PD 21 -#define CLK_PERI_NR_CLK 22/* APMIXEDSYS */ #define CLK_APMIXED_ARMPLL 0@@ -159,7 +156,6 @@#define CLK_APMIXED_ETH2PLL 4#define CLK_APMIXED_SGMIPLL 5#define CLK_APMIXED_MAIN_CORE_EN 6 -#define CLK_APMIXED_NR_CLK 7/* SSUSBSYS */ #define CLK_SSUSB_U2_PHY_1P_EN 0