Skip to contentSkip to conversation

clk: socfpga: stratix10: use new parent data scheme

PATCH Superseded Dinh Nguyen 2 participants 4 messages Feb 28, 2020 – Mar 16, 2020

Subsystems (2)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Dinh Nguyen

author maintainer
#0 lore raw

PATCH 1/1 clk: socfpga: stratix10: use new parent data scheme

Convert, where possible, the stratix10 clock driver to the new parent data scheme by specifying the parent data for clocks that have multiple parents.

---
 drivers/clk/socfpga/clk-gate-s10.c   |   5 +-
 drivers/clk/socfpga/clk-periph-s10.c |  10 ++-
 drivers/clk/socfpga/clk-pll-s10.c    |   4 +-
 drivers/clk/socfpga/clk-s10.c        | 110 ++++++++++++++++++++-------
 drivers/clk/socfpga/stratix10-clk.h  |   8 +-
 5 files changed, 96 insertions(+), 41 deletions(-)
drivers/clk/socfpga/clk-gate-s10.c +3 -2
index 8be4722f6064..083b2ec21fdd 100644
@@ -70,7 +70,6 @@ struct clk *s10_register_gate(const struct stratix10_gate_clock *clks, void __io
 	struct clk *clk;
 	struct socfpga_gate_clk *socfpga_clk;
 	struct clk_init_data init;
-	const char * const *parent_names = clks->parent_names;
 	const char *parent_name = clks->parent_name;
 
 	socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
@@ -108,7 +107,9 @@ struct clk *s10_register_gate(const struct stratix10_gate_clock *clks, void __io
 	init.flags = clks->flags;
 
 	init.num_parents = clks->num_parents;
-	init.parent_names = parent_names ? parent_names : &parent_name;
+	init.parent_names = parent_name ? &parent_name : NULL;
+	if (init.parent_names == NULL)
+		init.parent_data = clks->parent_data;
 	socfpga_clk->hw.hw.init = &init;
 
 	clk = clk_register(NULL, &socfpga_clk->hw.hw);
drivers/clk/socfpga/clk-periph-s10.c +6 -4
index dd6d4056e9de..397b77b89b16 100644
@@ -81,7 +81,6 @@ struct clk *s10_register_periph(const struct stratix10_perip_c_clock *clks,
 	struct clk_init_data init;
 	const char *name = clks->name;
 	const char *parent_name = clks->parent_name;
-	const char * const *parent_names = clks->parent_names;
 
 	periph_clk = kzalloc(sizeof(*periph_clk), GFP_KERNEL);
 	if (WARN_ON(!periph_clk))
@@ -94,7 +93,9 @@ struct clk *s10_register_periph(const struct stratix10_perip_c_clock *clks,
 	init.flags = clks->flags;
 
 	init.num_parents = clks->num_parents;
-	init.parent_names = parent_names ? parent_names : &parent_name;
+	init.parent_names = parent_name ? &parent_name : NULL;
+	if (init.parent_names == NULL)
+		init.parent_data = clks->parent_data;
 
 	periph_clk->hw.hw.init = &init;
 
@@ -114,7 +115,6 @@ struct clk *s10_register_cnt_periph(const struct stratix10_perip_cnt_clock *clks
 	struct clk_init_data init;
 	const char *name = clks->name;
 	const char *parent_name = clks->parent_name;
-	const char * const *parent_names = clks->parent_names;
 
 	periph_clk = kzalloc(sizeof(*periph_clk), GFP_KERNEL);
 	if (WARN_ON(!periph_clk))
@@ -137,7 +137,9 @@ struct clk *s10_register_cnt_periph(const struct stratix10_perip_cnt_clock *clks
 	init.flags = clks->flags;
 
 	init.num_parents = clks->num_parents;
-	init.parent_names = parent_names ? parent_names : &parent_name;
+	init.parent_names = parent_name ? &parent_name : NULL;
+	if (init.parent_names == NULL)
+		init.parent_data = clks->parent_data;
 
 	periph_clk->hw.hw.init = &init;
 
drivers/clk/socfpga/clk-pll-s10.c +2 -2
index a301bb22f36c..bcd3f14e9145 100644
@@ -117,7 +117,6 @@ struct clk *s10_register_pll(const struct stratix10_pll_clock *clks,
 	struct socfpga_pll *pll_clk;
 	struct clk_init_data init;
 	const char *name = clks->name;
-	const char * const *parent_names = clks->parent_names;
 
 	pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL);
 	if (WARN_ON(!pll_clk))
@@ -134,7 +133,8 @@ struct clk *s10_register_pll(const struct stratix10_pll_clock *clks,
 	init.flags = clks->flags;
 
 	init.num_parents = clks->num_parents;
-	init.parent_names = parent_names;
+	init.parent_names = NULL;
+	init.parent_data = clks->parent_data;
 	pll_clk->hw.hw.init = &init;
 
 	pll_clk->hw.bit_idx = SOCFPGA_PLL_POWER;
drivers/clk/socfpga/clk-s10.c +81 -29

116 lines not on this page · raw message

drivers/clk/socfpga/stratix10-clk.h +4 -4
index fcabef42249c..ffbd1fb2c8ef 100644
@@ -14,7 +14,7 @@ struct stratix10_clock_data {
 struct stratix10_pll_clock {
 	unsigned int		id;
 	const char		*name;
-	const char		*const *parent_names;
+	const struct clk_parent_data	*parent_data;
 	u8			num_parents;
 	unsigned long		flags;
 	unsigned long		offset;
@@ -24,7 +24,7 @@ struct stratix10_perip_c_clock {
 	unsigned int		id;
 	const char		*name;
 	const char		*parent_name;
-	const char		*const *parent_names;
+	const struct clk_parent_data	*parent_data;
 	u8			num_parents;
 	unsigned long		flags;
 	unsigned long		offset;
@@ -34,7 +34,7 @@ struct stratix10_perip_cnt_clock {
 	unsigned int		id;
 	const char		*name;
 	const char		*parent_name;
-	const char		*const *parent_names;
+	const struct clk_parent_data	*parent_data;
 	u8			num_parents;
 	unsigned long		flags;
 	unsigned long		offset;
@@ -47,7 +47,7 @@ struct stratix10_gate_clock {
 	unsigned int		id;
 	const char		*name;
 	const char		*parent_name;
-	const char		*const *parent_names;
+	const struct clk_parent_data	*parent_data;
 	u8			num_parents;
 	unsigned long		flags;
 	unsigned long		gate_reg;
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Quoting Dinh Nguyen (2020-02-28 12:36:11)

drivers/clk/socfpga/clk-s10.c line 95

Quoted 8 lines
drivers/clk/socfpga/clk-s10.c +8 -0
+
+static const struct clk_parent_data mpu_free_mux[] = {
+       { .name = "main_mpu_base_clk", },
+       { .name = "peri_mpu_base_clk", },
+       { .name = "osc1", },
+       { .name = "cb-intosc-hs-div2-clk", },
+       { .name = "f2s-free-clk", },
+};

While this changes everything to use the new way it doesn't actually migrate anything over to using direct pointers or the .fw_name field. What's going on?

author maintainer
#2 lore raw
Quoted 14 lines · Stephen Boyd

Quoting Dinh Nguyen (2020-02-28 12:36:11)

drivers/clk/socfpga/clk-s10.c line 95

Quoted 8 lines
drivers/clk/socfpga/clk-s10.c +8 -0
+
+static const struct clk_parent_data mpu_free_mux[] = {
+       { .name = "main_mpu_base_clk", },
+       { .name = "peri_mpu_base_clk", },
+       { .name = "osc1", },
+       { .name = "cb-intosc-hs-div2-clk", },
+       { .name = "f2s-free-clk", },
+};

While this changes everything to use the new way it doesn't actually migrate anything over to using direct pointers or the .fw_name field. What's going on?

Sorry about that. I am using direct pointers to the new parent data here:

in drivers/clk/socfpga/clk-periph-s10.c

-       init.parent_names = parent_names;
+       init.parent_names = NULL;
+       init.parent_data = clks->parent_data;

The driver seems to work fine without having to add .fw_name.

Dinh

maintainer
#3 lore raw

Quoting Dinh Nguyen (2020-03-09 22:55:27)

Quoted 26 lines · Stephen Boyd
Quoted 14 lines

Quoting Dinh Nguyen (2020-02-28 12:36:11)

drivers/clk/socfpga/clk-s10.c line 95

Quoted 8 lines
drivers/clk/socfpga/clk-s10.c +8 -0
+
+static const struct clk_parent_data mpu_free_mux[] = {
+       { .name = "main_mpu_base_clk", },
+       { .name = "peri_mpu_base_clk", },
+       { .name = "osc1", },
+       { .name = "cb-intosc-hs-div2-clk", },
+       { .name = "f2s-free-clk", },
+};

While this changes everything to use the new way it doesn't actually migrate anything over to using direct pointers or the .fw_name field. What's going on?

Sorry about that. I am using direct pointers to the new parent data here:

in drivers/clk/socfpga/clk-periph-s10.c

drivers/clk/socfpga/clk-pll-s10.c +2 -1
-       init.parent_names = parent_names;
+       init.parent_names = NULL;
+       init.parent_data = clks->parent_data;
Quoted 2 lines

The driver seems to work fine without having to add .fw_name.

Yes, .fw_name would only be needed if the parent clks were external to the clk controller. Furthermore if they are only clk_hw pointers then we can use .parent_hws instead.