Skip to content

Commit 30d8b7d

Browse files
Elaine Zhangmmind
authored andcommitted
clk: rockchip: Add MUXTBL variant
Add a clock branch consisting of a mux with non-standard select values. The parent in Mux table is sorted by priority. Use clk_register_mux_table() to register such a mux-clock. Cc: [email protected] Cc: Michael Turquette <[email protected]> Cc: Stephen Boyd <[email protected]> Signed-off-by: Elaine Zhang <[email protected]> Signed-off-by: Jagan Teki <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Heiko Stuebner <[email protected]>
1 parent 1c23f9e commit 30d8b7d

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

drivers/clk/rockchip/clk.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static struct clk *rockchip_clk_register_branch(const char *name,
4040
const char *const *parent_names, u8 num_parents,
4141
void __iomem *base,
4242
int muxdiv_offset, u8 mux_shift, u8 mux_width, u8 mux_flags,
43+
u32 *mux_table,
4344
int div_offset, u8 div_shift, u8 div_width, u8 div_flags,
4445
struct clk_div_table *div_table, int gate_offset,
4546
u8 gate_shift, u8 gate_flags, unsigned long flags,
@@ -62,6 +63,7 @@ static struct clk *rockchip_clk_register_branch(const char *name,
6263
mux->shift = mux_shift;
6364
mux->mask = BIT(mux_width) - 1;
6465
mux->flags = mux_flags;
66+
mux->table = mux_table;
6567
mux->lock = lock;
6668
mux_ops = (mux_flags & CLK_MUX_READ_ONLY) ? &clk_mux_ro_ops
6769
: &clk_mux_ops;
@@ -270,6 +272,8 @@ static struct clk *rockchip_clk_register_frac_branch(
270272
frac_mux->shift = child->mux_shift;
271273
frac_mux->mask = BIT(child->mux_width) - 1;
272274
frac_mux->flags = child->mux_flags;
275+
if (child->mux_table)
276+
frac_mux->table = child->mux_table;
273277
frac_mux->lock = lock;
274278
frac_mux->hw.init = &init;
275279

@@ -444,11 +448,21 @@ void rockchip_clk_register_branches(struct rockchip_clk_provider *ctx,
444448
/* catch simple muxes */
445449
switch (list->branch_type) {
446450
case branch_mux:
447-
clk = clk_register_mux(NULL, list->name,
448-
list->parent_names, list->num_parents,
449-
flags, ctx->reg_base + list->muxdiv_offset,
450-
list->mux_shift, list->mux_width,
451-
list->mux_flags, &ctx->lock);
451+
if (list->mux_table)
452+
clk = clk_register_mux_table(NULL, list->name,
453+
list->parent_names, list->num_parents,
454+
flags,
455+
ctx->reg_base + list->muxdiv_offset,
456+
list->mux_shift, list->mux_width,
457+
list->mux_flags, list->mux_table,
458+
&ctx->lock);
459+
else
460+
clk = clk_register_mux(NULL, list->name,
461+
list->parent_names, list->num_parents,
462+
flags,
463+
ctx->reg_base + list->muxdiv_offset,
464+
list->mux_shift, list->mux_width,
465+
list->mux_flags, &ctx->lock);
452466
break;
453467
case branch_muxgrf:
454468
clk = rockchip_clk_register_muxgrf(list->name,
@@ -506,7 +520,8 @@ void rockchip_clk_register_branches(struct rockchip_clk_provider *ctx,
506520
ctx->reg_base, list->muxdiv_offset,
507521
list->mux_shift,
508522
list->mux_width, list->mux_flags,
509-
list->div_offset, list->div_shift, list->div_width,
523+
list->mux_table, list->div_offset,
524+
list->div_shift, list->div_width,
510525
list->div_flags, list->div_table,
511526
list->gate_offset, list->gate_shift,
512527
list->gate_flags, flags, &ctx->lock);

drivers/clk/rockchip/clk.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ struct rockchip_clk_branch {
448448
u8 mux_shift;
449449
u8 mux_width;
450450
u8 mux_flags;
451+
u32 *mux_table;
451452
int div_offset;
452453
u8 div_shift;
453454
u8 div_width;
@@ -680,6 +681,22 @@ struct rockchip_clk_branch {
680681
.gate_offset = -1, \
681682
}
682683

684+
#define MUXTBL(_id, cname, pnames, f, o, s, w, mf, mt) \
685+
{ \
686+
.id = _id, \
687+
.branch_type = branch_mux, \
688+
.name = cname, \
689+
.parent_names = pnames, \
690+
.num_parents = ARRAY_SIZE(pnames), \
691+
.flags = f, \
692+
.muxdiv_offset = o, \
693+
.mux_shift = s, \
694+
.mux_width = w, \
695+
.mux_flags = mf, \
696+
.gate_offset = -1, \
697+
.mux_table = mt, \
698+
}
699+
683700
#define MUXGRF(_id, cname, pnames, f, o, s, w, mf) \
684701
{ \
685702
.id = _id, \

0 commit comments

Comments
 (0)