[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ff968ce4-9490-4e19-981b-7a5e9a842b68@tuxon.dev>
Date: Mon, 20 Oct 2025 22:39:48 +0300
From: Claudiu Beznea <claudiu.beznea@...on.dev>
To: Ryan.Wanner@...rochip.com, mturquette@...libre.com, sboyd@...nel.org,
alexandre.belloni@...tlin.com, nicolas.ferre@...rochip.com
Cc: linux-clk@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, varshini.rajendran@...rochip.com
Subject: Re: [PATCH v4 10/31] clk: at91: clk-generated: use clk_parent_data
Hi, Ryan,
On 9/19/25 00:15, Ryan.Wanner@...rochip.com wrote:
> From: Claudiu Beznea <claudiu.beznea@...on.dev>
>
> Use struct clk_parent_data instead of struct parent_hw as this leads
> to less usage of __clk_get_hw() in SoC specific clock drivers and simpler
> conversion of existing SoC specific clock drivers from parent_names to
> modern clk_parent_data structures.
>
> Remove the last of the usage of __clk_get_hw().
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea@...on.dev>
> [ryan.wanner@...rochip.com: Added SAMA7D65 and SAM9X75 SoCs to the
> clk-generated changes. Adjust clk name variable order.]
> Signed-off-by: Ryan Wanner <Ryan.Wanner@...rochip.com>
> ---
> drivers/clk/at91/clk-generated.c | 8 +++----
> drivers/clk/at91/pmc.h | 2 +-
> drivers/clk/at91/sam9x7.c | 38 ++++++++++++++---------------
> drivers/clk/at91/sama7d65.c | 41 +++++++++++++++++---------------
> drivers/clk/at91/sama7g5.c | 39 ++++++++++++++++--------------
> 5 files changed, 67 insertions(+), 61 deletions(-)
>
[...]
> static void __init sama7d65_pmc_setup(struct device_node *np)
> {
> - const char *main_xtal_name;
> + const char *main_xtal_name, *md_slck_name, *td_slck_name;
> struct pmc_data *sama7d65_pmc;
> const char *parent_names[11];
> void **alloc_mem = NULL;
> int alloc_mem_size = 0;
> struct regmap *regmap;
> struct clk_hw *hw, *main_rc_hw, *main_osc_hw, *main_xtal_hw;
> - struct clk_hw *td_slck_hw, *md_slck_hw;
> struct clk_parent_data parent_data[10];
> - struct clk_hw *parent_hws[10];
> bool bypass;
> int i, j;
>
> - td_slck_hw = __clk_get_hw(of_clk_get_by_name(np, "td_slck"));
> - md_slck_hw = __clk_get_hw(of_clk_get_by_name(np, "md_slck"));
> + i = of_property_match_string(np, "clock-names", "td_slck");
> + if (i < 0)
> + return;
> + td_slck_name = of_clk_get_parent_name(np, i);
> +
> + i = of_property_match_string(np, "clock-names", "md_slck");
> + if (i < 0)
> + return;
> + md_slck_name = of_clk_get_parent_name(np, i);
> +
> i = of_property_match_string(np, "clock-names", "main_xtal");
>
Please drop the resulting empty line here.
> - if (!td_slck_hw || !md_slck_hw || !i)
> + if (i < 0)
> return;
> main_xtal_name = of_clk_get_parent_name(np, i);
>
> @@ -1218,8 +1224,8 @@ static void __init sama7d65_pmc_setup(struct device_node *np)
> sama7d65_pmc->chws[PMC_MCK] = hw;
> sama7d65_mckx[PCK_PARENT_HW_MCK0].hw = hw;
>
> - parent_data[0] = AT91_CLK_PD_NAME("md_slck");
> - parent_data[1] = AT91_CLK_PD_NAME("td_slck");
> + parent_data[0] = AT91_CLK_PD_NAME(md_slck_name);
> + parent_data[1] = AT91_CLK_PD_NAME(td_slck_name);
> parent_data[2] = AT91_CLK_PD_HW(sama7d65_pmc->chws[PMC_MAIN]);
> for (i = PCK_PARENT_HW_MCK1; i < ARRAY_SIZE(sama7d65_mckx); i++) {
> u8 num_parents = 3 + sama7d65_mckx[i].ep_count;
> @@ -1264,8 +1270,8 @@ static void __init sama7d65_pmc_setup(struct device_node *np)
> if (IS_ERR(hw))
> goto err_free;
>
> - parent_data[0] = AT91_CLK_PD_NAME("md_slck");
> - parent_data[1] = AT91_CLK_PD_NAME("td_slck");
> + parent_data[0] = AT91_CLK_PD_NAME(md_slck_name);
> + parent_data[1] = AT91_CLK_PD_NAME(td_slck_name);
> parent_data[2] = AT91_CLK_PD_HW(sama7d65_pmc->chws[PMC_MAIN]);
> parent_data[3] = AT91_CLK_PD_HW(sama7d65_plls[PLL_ID_SYS][PLL_COMPID_DIV0].hw);
> parent_data[4] = AT91_CLK_PD_HW(sama7d65_plls[PLL_ID_DDR][PLL_COMPID_DIV0].hw);
> @@ -1315,13 +1321,12 @@ static void __init sama7d65_pmc_setup(struct device_node *np)
> sama7d65_pmc->phws[sama7d65_periphck[i].id] = hw;
> }
>
> - parent_hws[0] = md_slck_hw;
> - parent_hws[1] = td_slck_hw;
> - parent_hws[2] = sama7d65_pmc->chws[PMC_MAIN];
> - parent_hws[3] = sama7d65_pmc->chws[PMC_MCK1];
> + parent_data[0] = AT91_CLK_PD_NAME(md_slck_name);
> + parent_data[1] = AT91_CLK_PD_NAME(td_slck_name);
> + parent_data[2] = AT91_CLK_PD_HW(sama7d65_pmc->chws[PMC_MAIN]);
> + parent_data[3] = AT91_CLK_PD_HW(sama7d65_pmc->chws[PMC_MCK1]);
> for (i = 0; i < ARRAY_SIZE(sama7d65_gck); i++) {
> u8 num_parents = 4 + sama7d65_gck[i].pp_count;
> - struct clk_hw *tmp_parent_hws[8];
> u32 *mux_table;
>
> mux_table = kmalloc_array(num_parents, sizeof(*mux_table),
> @@ -1338,15 +1343,13 @@ static void __init sama7d65_pmc_setup(struct device_node *np)
> u8 pll_id = sama7d65_gck[i].pp[j].pll_id;
> u8 pll_compid = sama7d65_gck[i].pp[j].pll_compid;
>
> - tmp_parent_hws[j] = sama7d65_plls[pll_id][pll_compid].hw;
> + parent_data[4 + j] = AT91_CLK_PD_HW(sama7d65_plls[pll_id][pll_compid].hw);
> }
> - PMC_FILL_TABLE(&parent_hws[4], tmp_parent_hws,
> - sama7d65_gck[i].pp_count);
>
> hw = at91_clk_register_generated(regmap, &pmc_pcr_lock,
> &sama7d65_pcr_layout,
> sama7d65_gck[i].n, NULL,
> - parent_hws, mux_table,
> + parent_data, mux_table,
> num_parents,
> sama7d65_gck[i].id,
> &sama7d65_gck[i].r,
> diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c
> index ddd5ad318990..ddbf69beb495 100644
> --- a/drivers/clk/at91/sama7g5.c
> +++ b/drivers/clk/at91/sama7g5.c
> @@ -971,24 +971,30 @@ static const struct clk_pcr_layout sama7g5_pcr_layout = {
>
> static void __init sama7g5_pmc_setup(struct device_node *np)
> {
> - const char *main_xtal_name;
> + const char *main_xtal_name, *md_slck_name, *td_slck_name;
> struct pmc_data *sama7g5_pmc;
> void **alloc_mem = NULL;
> int alloc_mem_size = 0;
> struct regmap *regmap;
> struct clk_hw *hw, *main_rc_hw, *main_osc_hw;
> - struct clk_hw *td_slck_hw, *md_slck_hw;
> struct clk_parent_data parent_data[10];
> - struct clk_hw *parent_hws[10];
> struct clk *main_xtal;
> bool bypass;
> int i, j;
>
> - td_slck_hw = __clk_get_hw(of_clk_get_by_name(np, "td_slck"));
> - md_slck_hw = __clk_get_hw(of_clk_get_by_name(np, "md_slck"));
> + i = of_property_match_string(np, "clock-names", "td_slck");
> + if (i < 0)
> + return;
> + td_slck_name = of_clk_get_parent_name(np, i);
> +
> + i = of_property_match_string(np, "clock-names", "md_slck");
> + if (i < 0)
> + return;
> + md_slck_name = of_clk_get_parent_name(np, i);
> +
> i = of_property_match_string(np, "clock-names", "main_xtal");
>
Please drop the resulting empty line here.
Powered by blists - more mailing lists