Re: [PATCH RFC RFT v3 12/13] clk: meson: t7: Model the PLL pre-divider as a divider clock
From: Jerome Brunet
Date: Thu Dec 03 2026 - 10:31:42 EST
> The pre-divider is currently described by a dedicated n parameter,
> although it is a plain divider between the input clock and the DCO.
>
> Model it as a regular divider clock and make it the parent of the DCO.
>
> Signed-off-by: Jian Hu <jian.hu@xxxxxxxxxxx>
> ---
> drivers/clk/meson/t7-pll.c | 192 +++++++++++++++++++++++++++++++++++----------
> 1 file changed, 150 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/clk/meson/t7-pll.c b/drivers/clk/meson/t7-pll.c
> index 0a622f45fa36..fb20e9e5f991 100644
> --- a/drivers/clk/meson/t7-pll.c
> +++ b/drivers/clk/meson/t7-pll.c
> @@ -71,6 +71,34 @@
> #define MCLK_PLL_CNTL4 0x10
> #define MCLK_PLL_STS 0x14
>
> +/* Force the pre-divider at 1 to minimize PLL jitter */
> +static const struct clk_div_table t7_pll_prediv_div_table[] = {
> + { .val = 1, .div = 1 },
> + { /* sentinel */ }
> +};
> +
> +static struct clk_regmap t7_gp0_prediv = {
> + .data = &(struct clk_regmap_div_data){
> + .offset = GP0PLL_CTRL0,
> + .shift = 10,
> + .width = 5,
> + .table = t7_pll_prediv_div_table,
> + /*
> + * CLK_DIVIDER_INVALID_ZERO to report 0 Hz during registration.
> + * The same applies below.
> + */
> + .flags = CLK_DIVIDER_INVALID_ZERO,
> + },
> + .hw.init = &(struct clk_init_data) {
> + .name = "gp0_prediv",
> + .ops = &clk_regmap_divider_ops,
> + .parent_data = &(const struct clk_parent_data) {
> + .fw_name = "in0",
> + },
> + .num_parents = 1,
> + },
> +};
> +
> static const struct pll_mult_range t7_media_pll_mult_range = {
> .min = 125,
> .max = 250,
> @@ -97,11 +125,6 @@ static struct clk_regmap t7_gp0_pll_dco = {
> .shift = 0,
> .width = 8,
> },
> - .n = {
> - .reg_off = GP0PLL_CTRL0,
> - .shift = 10,
> - .width = 5,
> - },
> .l = {
> .reg_off = GP0PLL_STS,
> .shift = 31,
> @@ -119,10 +142,11 @@ static struct clk_regmap t7_gp0_pll_dco = {
> .hw.init = &(struct clk_init_data){
> .name = "gp0_pll_dco",
> .ops = &meson_clk_pll_ops,
> - .parent_data = &(const struct clk_parent_data) {
> - .fw_name = "in0",
> + .parent_hws = (const struct clk_hw *[]) {
> + &t7_gp0_prediv.hw
> },
> .num_parents = 1,
> + .flags = CLK_SET_RATE_PARENT,
> },
> };
>
> @@ -144,6 +168,24 @@ static struct clk_regmap t7_gp0_pll = {
> },
> };
>
> +static struct clk_regmap t7_gp1_prediv = {
> + .data = &(struct clk_regmap_div_data){
> + .offset = GP1PLL_CTRL0,
> + .shift = 16,
> + .width = 5,
> + .table = t7_pll_prediv_div_table,
> + .flags = CLK_DIVIDER_INVALID_ZERO,
> + },
> + .hw.init = &(struct clk_init_data) {
> + .name = "gp1_prediv",
> + .ops = &clk_regmap_divider_ops,
> + .parent_data = &(const struct clk_parent_data) {
> + .fw_name = "in0",
> + },
> + .num_parents = 1,
> + },
> +};
> +
> /*
> * Compared with GP0 PLL, GP1 PLL is a newly designed PLL with
> * a DCO range of 1.6GHz to 3.2GHz.
> @@ -171,11 +213,6 @@ static struct clk_regmap t7_gp1_pll_dco = {
> .shift = 0,
> .width = 8,
> },
> - .n = {
> - .reg_off = GP1PLL_CTRL0,
> - .shift = 16,
> - .width = 5,
> - },
> .l = {
> .reg_off = GP1PLL_STS,
> .shift = 31,
> @@ -193,10 +230,11 @@ static struct clk_regmap t7_gp1_pll_dco = {
> .hw.init = &(struct clk_init_data){
> .name = "gp1_pll_dco",
> .ops = &meson_clk_pll_ops,
> - .parent_data = &(const struct clk_parent_data) {
> - .fw_name = "in0",
> + .parent_hws = (const struct clk_hw *[]) {
> + &t7_gp1_prediv.hw
> },
> .num_parents = 1,
> + .flags = CLK_SET_RATE_PARENT,
> },
> };
>
> @@ -218,6 +256,24 @@ static struct clk_regmap t7_gp1_pll = {
> },
> };
>
> +static struct clk_regmap t7_hifi_prediv = {
> + .data = &(struct clk_regmap_div_data){
> + .offset = HIFIPLL_CTRL0,
> + .shift = 10,
> + .width = 5,
> + .table = t7_pll_prediv_div_table,
> + .flags = CLK_DIVIDER_INVALID_ZERO,
> + },
> + .hw.init = &(struct clk_init_data) {
> + .name = "hifi_prediv",
> + .ops = &clk_regmap_divider_ops,
> + .parent_data = &(const struct clk_parent_data) {
> + .fw_name = "in0",
> + },
> + .num_parents = 1,
> + },
> +};
> +
> static const struct reg_sequence t7_hifi_init_regs[] = {
> { .reg = HIFIPLL_CTRL1, .def = 0x00000000 },
> { .reg = HIFIPLL_CTRL2, .def = 0x00000000 },
> @@ -239,11 +295,6 @@ static struct clk_regmap t7_hifi_pll_dco = {
> .shift = 0,
> .width = 8,
> },
> - .n = {
> - .reg_off = HIFIPLL_CTRL0,
> - .shift = 10,
> - .width = 5,
> - },
> .frac = {
> .reg_off = HIFIPLL_CTRL1,
> .shift = 0,
> @@ -267,10 +318,11 @@ static struct clk_regmap t7_hifi_pll_dco = {
> .hw.init = &(struct clk_init_data){
> .name = "hifi_pll_dco",
> .ops = &meson_clk_pll_ops,
> - .parent_data = &(const struct clk_parent_data) {
> - .fw_name = "in0",
> + .parent_hws = (const struct clk_hw *[]) {
> + &t7_hifi_prediv.hw
> },
> .num_parents = 1,
> + .flags = CLK_SET_RATE_PARENT,
> },
> };
>
> @@ -292,6 +344,32 @@ static struct clk_regmap t7_hifi_pll = {
> },
> };
>
> +static struct clk_regmap t7_pcie_prediv = {
> + .data = &(struct clk_regmap_div_data){
> + .offset = PCIEPLL_CTRL0,
> + .shift = 10,
> + .width = 5,
> + .table = t7_pll_prediv_div_table,
> + .flags = CLK_DIVIDER_INVALID_ZERO,
So it means the valid value being, it divides by 2 at least ?
> + },
> + .hw.init = &(struct clk_init_data) {
> + .name = "pcie_prediv",
> + .ops = &clk_regmap_divider_ops,
> + .parent_data = &(const struct clk_parent_data) {
> + .fw_name = "in0",
> + },
> + .num_parents = 1,
> + /*
> + * The PCIe prediv register reads zero on power-on.
> + * CLK_DIVIDER_INVALID_ZERO makes the first rate return 0 Hz,
> + * which gets cached by CCF. The PCIe PLL enable callback
> + * later writes a valid non-zero divider value. Use
> + * CLK_GET_RATE_NOCACHE to avoid stale cached rate.
> + */
> + .flags = CLK_GET_RATE_NOCACHE,
DCO registers first so the no cache is not necessary and would not have
been a correct solution anyway
--
Jerome