[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d19ef1ea19048a495350b375f1c477c9f4a8139f.1750182562.git.Ryan.Wanner@microchip.com>
Date: Tue, 24 Jun 2025 08:08:22 -0700
From: <Ryan.Wanner@...rochip.com>
To: <mturquette@...libre.com>, <sboyd@...nel.org>,
<nicolas.ferre@...rochip.com>, <alexandre.belloni@...tlin.com>,
<claudiu.beznea@...on.dev>
CC: <robh@...nel.org>, <linux-clk@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<varshini.rajendran@...rochip.com>
Subject: [PATCH v2 25/32] clk: at91: at91rm9200: switch to parent_hw and parent_data
From: Claudiu Beznea <claudiu.beznea@...on.dev>
Switch AT91RM9200 clocks to use parent_hw and parent_data. Having
parent_hw instead of parent names improves to clock registration
speed and re-parenting.
Signed-off-by: Claudiu Beznea <claudiu.beznea@...on.dev>
Signed-off-by: Ryan Wanner <Ryan.Wanner@...rochip.com>
---
drivers/clk/at91/at91rm9200.c | 95 ++++++++++++++++++-----------------
1 file changed, 49 insertions(+), 46 deletions(-)
diff --git a/drivers/clk/at91/at91rm9200.c b/drivers/clk/at91/at91rm9200.c
index e5a034f208d8..b834ca5ed092 100644
--- a/drivers/clk/at91/at91rm9200.c
+++ b/drivers/clk/at91/at91rm9200.c
@@ -11,7 +11,7 @@ static DEFINE_SPINLOCK(rm9200_mck_lock);
struct sck {
char *n;
- char *p;
+ struct clk_hw *parent_hw;
u8 id;
};
@@ -39,13 +39,13 @@ static const struct clk_pll_characteristics rm9200_pll_characteristics = {
.out = rm9200_pll_out,
};
-static const struct sck at91rm9200_systemck[] = {
- { .n = "udpck", .p = "usbck", .id = 1 },
- { .n = "uhpck", .p = "usbck", .id = 4 },
- { .n = "pck0", .p = "prog0", .id = 8 },
- { .n = "pck1", .p = "prog1", .id = 9 },
- { .n = "pck2", .p = "prog2", .id = 10 },
- { .n = "pck3", .p = "prog3", .id = 11 },
+static struct sck at91rm9200_systemck[] = {
+ { .n = "udpck", .id = 1 },
+ { .n = "uhpck", .id = 4 },
+ { .n = "pck0", .id = 8 },
+ { .n = "pck1", .id = 9 },
+ { .n = "pck2", .id = 10 },
+ { .n = "pck3", .id = 11 },
};
static const struct pck at91rm9200_periphck[] = {
@@ -76,25 +76,15 @@ static const struct pck at91rm9200_periphck[] = {
static void __init at91rm9200_pmc_setup(struct device_node *np)
{
- const char *slowxtal_name, *mainxtal_name;
+ const char *slow_clk_name = "slowck", *main_xtal_name = "main_xtal";
+ struct clk_hw *usbck_hw, *main_osc_hw, *hw;
+ u8 slow_clk_index = 0, main_xtal_index = 1;
+ struct clk_parent_data parent_data[6];
struct pmc_data *at91rm9200_pmc;
u32 usb_div[] = { 1, 2, 0, 0 };
- const char *parent_names[6];
struct regmap *regmap;
- struct clk_hw *hw;
- int i;
bool bypass;
-
- i = of_property_match_string(np, "clock-names", "slow_xtal");
- if (i < 0)
- return;
-
- slowxtal_name = of_clk_get_parent_name(np, i);
-
- i = of_property_match_string(np, "clock-names", "main_xtal");
- if (i < 0)
- return;
- mainxtal_name = of_clk_get_parent_name(np, i);
+ int i;
regmap = device_node_to_regmap(np);
if (IS_ERR(regmap))
@@ -108,18 +98,21 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
bypass = of_property_read_bool(np, "atmel,osc-bypass");
- hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL,
- bypass);
- if (IS_ERR(hw))
+ main_osc_hw = at91_clk_register_main_osc(regmap, "main_osc", NULL,
+ &AT91_CLK_PD_NAME(main_xtal_name, main_xtal_index),
+ bypass);
+ if (IS_ERR(main_osc_hw))
goto err_free;
- hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc", NULL);
+ hw = at91_clk_register_rm9200_main(regmap, "mainck", NULL,
+ &AT91_CLK_PD_HW(main_osc_hw));
if (IS_ERR(hw))
goto err_free;
at91rm9200_pmc->chws[PMC_MAIN] = hw;
- hw = at91_clk_register_pll(regmap, "pllack", "mainck", 0,
+ hw = at91_clk_register_pll(regmap, "pllack", NULL,
+ &AT91_CLK_PD_HW(at91rm9200_pmc->chws[PMC_MAIN]), 0,
&at91rm9200_pll_layout,
&rm9200_pll_characteristics);
if (IS_ERR(hw))
@@ -127,7 +120,8 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
at91rm9200_pmc->chws[PMC_PLLACK] = hw;
- hw = at91_clk_register_pll(regmap, "pllbck", "mainck", 1,
+ hw = at91_clk_register_pll(regmap, "pllbck", NULL,
+ &AT91_CLK_PD_HW(at91rm9200_pmc->chws[PMC_MAIN]), 1,
&at91rm9200_pll_layout,
&rm9200_pll_characteristics);
if (IS_ERR(hw))
@@ -135,20 +129,19 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
at91rm9200_pmc->chws[PMC_PLLBCK] = hw;
- parent_names[0] = slowxtal_name;
- parent_names[1] = "mainck";
- parent_names[2] = "pllack";
- parent_names[3] = "pllbck";
+ parent_data[0] = AT91_CLK_PD_NAME(slow_clk_name, slow_clk_index);
+ parent_data[1] = AT91_CLK_PD_HW(at91rm9200_pmc->chws[PMC_MAIN]);
+ parent_data[2] = AT91_CLK_PD_HW(at91rm9200_pmc->chws[PMC_PLLACK]);
+ parent_data[3] = AT91_CLK_PD_HW(at91rm9200_pmc->chws[PMC_PLLBCK]);
hw = at91_clk_register_master_pres(regmap, "masterck_pres", 4,
- parent_names, NULL,
+ NULL, parent_data,
&at91rm9200_master_layout,
&rm9200_mck_characteristics,
&rm9200_mck_lock);
if (IS_ERR(hw))
goto err_free;
- hw = at91_clk_register_master_div(regmap, "masterck_div",
- "masterck_pres", NULL,
+ hw = at91_clk_register_master_div(regmap, "masterck_div", NULL, &AT91_CLK_PD_HW(hw),
&at91rm9200_master_layout,
&rm9200_mck_characteristics,
&rm9200_mck_lock, CLK_SET_RATE_GATE, 0);
@@ -157,21 +150,23 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
at91rm9200_pmc->chws[PMC_MCK] = hw;
- hw = at91rm9200_clk_register_usb(regmap, "usbck", "pllbck", NULL, usb_div);
- if (IS_ERR(hw))
+ usbck_hw = at91rm9200_clk_register_usb(regmap, "usbck", NULL,
+ &AT91_CLK_PD_HW(at91rm9200_pmc->chws[PMC_PLLBCK]),
+ usb_div);
+ if (IS_ERR(usbck_hw))
goto err_free;
- parent_names[0] = slowxtal_name;
- parent_names[1] = "mainck";
- parent_names[2] = "pllack";
- parent_names[3] = "pllbck";
+ parent_data[0] = AT91_CLK_PD_NAME(slow_clk_name, slow_clk_index);
+ parent_data[1] = AT91_CLK_PD_HW(at91rm9200_pmc->chws[PMC_MAIN]);
+ parent_data[2] = AT91_CLK_PD_HW(at91rm9200_pmc->chws[PMC_PLLACK]);
+ parent_data[3] = AT91_CLK_PD_HW(at91rm9200_pmc->chws[PMC_PLLBCK]);
for (i = 0; i < 4; i++) {
char name[6];
snprintf(name, sizeof(name), "prog%d", i);
hw = at91_clk_register_programmable(regmap, name,
- parent_names, NULL, 4, i,
+ NULL, parent_data, 4, i,
&at91rm9200_programmable_layout,
NULL);
if (IS_ERR(hw))
@@ -180,9 +175,16 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
at91rm9200_pmc->pchws[i] = hw;
}
+ /* Set systemck parent hws. */
+ at91rm9200_systemck[0].parent_hw = usbck_hw;
+ at91rm9200_systemck[1].parent_hw = usbck_hw;
+ at91rm9200_systemck[2].parent_hw = at91rm9200_pmc->pchws[0];
+ at91rm9200_systemck[3].parent_hw = at91rm9200_pmc->pchws[1];
+ at91rm9200_systemck[4].parent_hw = at91rm9200_pmc->pchws[2];
+ at91rm9200_systemck[5].parent_hw = at91rm9200_pmc->pchws[3];
for (i = 0; i < ARRAY_SIZE(at91rm9200_systemck); i++) {
- hw = at91_clk_register_system(regmap, at91rm9200_systemck[i].n,
- at91rm9200_systemck[i].p, NULL,
+ hw = at91_clk_register_system(regmap, at91rm9200_systemck[i].n, NULL,
+ &AT91_CLK_PD_HW(at91rm9200_systemck[i].parent_hw),
at91rm9200_systemck[i].id, 0);
if (IS_ERR(hw))
goto err_free;
@@ -193,7 +195,8 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
for (i = 0; i < ARRAY_SIZE(at91rm9200_periphck); i++) {
hw = at91_clk_register_peripheral(regmap,
at91rm9200_periphck[i].n,
- "masterck_div", NULL,
+ NULL,
+ &AT91_CLK_PD_HW(at91rm9200_pmc->chws[PMC_MCK]),
at91rm9200_periphck[i].id);
if (IS_ERR(hw))
goto err_free;
--
2.43.0
Powered by blists - more mailing lists