Skip to content

Commit f5290d8

Browse files
lumagbebarino
authored andcommitted
clk: asm9260: use parent index to link the reference clock
Rewrite clk-asm9260 to use parent index to use the reference clock. During this rework two helpers are added: - clk_hw_register_mux_table_parent_data() to supplement clk_hw_register_mux_table() but using parent_data instead of parent_names - clk_hw_register_fixed_rate_parent_accuracy() to be used instead of directly calling __clk_hw_register_fixed_rate(). The later function is an internal API, which is better not to be called directly. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20220916061740.87167-2-dmitry.baryshkov@linaro.org Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 568035b commit f5290d8

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

drivers/clk/clk-asm9260.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct asm9260_mux_clock {
8080
u8 mask;
8181
u32 *table;
8282
const char *name;
83-
const char **parent_names;
83+
const struct clk_parent_data *parent_data;
8484
u8 num_parents;
8585
unsigned long offset;
8686
unsigned long flags;
@@ -232,10 +232,10 @@ static const struct asm9260_gate_data asm9260_ahb_gates[] __initconst = {
232232
HW_AHBCLKCTRL1, 16 },
233233
};
234234

235-
static const char __initdata *main_mux_p[] = { NULL, NULL };
236-
static const char __initdata *i2s0_mux_p[] = { NULL, NULL, "i2s0m_div"};
237-
static const char __initdata *i2s1_mux_p[] = { NULL, NULL, "i2s1m_div"};
238-
static const char __initdata *clkout_mux_p[] = { NULL, NULL, "rtc"};
235+
static struct clk_parent_data __initdata main_mux_p[] = { { .index = 0, }, { .name = "pll" } };
236+
static struct clk_parent_data __initdata i2s0_mux_p[] = { { .index = 0, }, { .name = "pll" }, { .name = "i2s0m_div"} };
237+
static struct clk_parent_data __initdata i2s1_mux_p[] = { { .index = 0, }, { .name = "pll" }, { .name = "i2s1m_div"} };
238+
static struct clk_parent_data __initdata clkout_mux_p[] = { { .index = 0, }, { .name = "pll" }, { .name = "rtc"} };
239239
static u32 three_mux_table[] = {0, 1, 3};
240240

241241
static struct asm9260_mux_clock asm9260_mux_clks[] __initdata = {
@@ -255,9 +255,10 @@ static struct asm9260_mux_clock asm9260_mux_clks[] __initdata = {
255255

256256
static void __init asm9260_acc_init(struct device_node *np)
257257
{
258-
struct clk_hw *hw;
258+
struct clk_hw *hw, *pll_hw;
259259
struct clk_hw **hws;
260-
const char *ref_clk, *pll_clk = "pll";
260+
const char *pll_clk = "pll";
261+
struct clk_parent_data pll_parent_data = { .index = 0 };
261262
u32 rate;
262263
int n;
263264

@@ -274,21 +275,15 @@ static void __init asm9260_acc_init(struct device_node *np)
274275
/* register pll */
275276
rate = (ioread32(base + HW_SYSPLLCTRL) & 0xffff) * 1000000;
276277

277-
/* TODO: Convert to DT parent scheme */
278-
ref_clk = of_clk_get_parent_name(np, 0);
279-
hw = __clk_hw_register_fixed_rate(NULL, NULL, pll_clk,
280-
ref_clk, NULL, NULL, 0, rate, 0,
281-
CLK_FIXED_RATE_PARENT_ACCURACY);
282-
283-
if (IS_ERR(hw))
278+
pll_hw = clk_hw_register_fixed_rate_parent_accuracy(NULL, pll_clk, &pll_parent_data,
279+
0, rate);
280+
if (IS_ERR(pll_hw))
284281
panic("%pOFn: can't register REFCLK. Check DT!", np);
285282

286283
for (n = 0; n < ARRAY_SIZE(asm9260_mux_clks); n++) {
287284
const struct asm9260_mux_clock *mc = &asm9260_mux_clks[n];
288285

289-
mc->parent_names[0] = ref_clk;
290-
mc->parent_names[1] = pll_clk;
291-
hw = clk_hw_register_mux_table(NULL, mc->name, mc->parent_names,
286+
hw = clk_hw_register_mux_table_parent_data(NULL, mc->name, mc->parent_data,
292287
mc->num_parents, mc->flags, base + mc->offset,
293288
0, mc->mask, 0, mc->table, &asm9260_clk_lock);
294289
}

include/linux/clk-provider.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,20 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
439439
__clk_hw_register_fixed_rate((dev), NULL, (name), NULL, NULL, \
440440
(parent_data), NULL, (flags), \
441441
(fixed_rate), (fixed_accuracy), 0)
442+
/**
443+
* clk_hw_register_fixed_rate_parent_accuracy - register fixed-rate clock with
444+
* the clock framework
445+
* @dev: device that is registering this clock
446+
* @name: name of this clock
447+
* @parent_name: name of clock's parent
448+
* @flags: framework-specific flags
449+
* @fixed_rate: non-adjustable clock rate
450+
*/
451+
#define clk_hw_register_fixed_rate_parent_accuracy(dev, name, parent_data, \
452+
flags, fixed_rate) \
453+
__clk_hw_register_fixed_rate((dev), NULL, (name), NULL, NULL, \
454+
(parent_data), (flags), (fixed_rate), 0, \
455+
CLK_FIXED_RATE_PARENT_ACCURACY)
442456

443457
void clk_unregister_fixed_rate(struct clk *clk);
444458
void clk_hw_unregister_fixed_rate(struct clk_hw *hw);
@@ -957,6 +971,13 @@ struct clk *clk_register_mux_table(struct device *dev, const char *name,
957971
(parent_names), NULL, NULL, (flags), (reg), \
958972
(shift), (mask), (clk_mux_flags), (table), \
959973
(lock))
974+
#define clk_hw_register_mux_table_parent_data(dev, name, parent_data, \
975+
num_parents, flags, reg, shift, mask, \
976+
clk_mux_flags, table, lock) \
977+
__clk_hw_register_mux((dev), NULL, (name), (num_parents), \
978+
NULL, NULL, (parent_data), (flags), (reg), \
979+
(shift), (mask), (clk_mux_flags), (table), \
980+
(lock))
960981
#define clk_hw_register_mux(dev, name, parent_names, num_parents, flags, reg, \
961982
shift, width, clk_mux_flags, lock) \
962983
__clk_hw_register_mux((dev), NULL, (name), (num_parents), \

0 commit comments

Comments
 (0)