Some StarFive clocks only advertise the divider and invert capabilities (via STARFIVE_CLK_INVERT, without ENABLE). Add the STARFIVE_IDIV() macro to declare such clocks, and starfive_clk_idiv_ops, which combines the divider rate operations with get_phase/set_phase.
Signed-off-by: Changhuang Liang <[email protected]> --- drivers/clk/starfive/clk-starfive-common.c | 12 ++++++++++++ drivers/clk/starfive/clk-starfive-common.h | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/clk/starfive/clk-starfive-common.c b/drivers/clk/starfive/clk-starfive-common.c index 9678616d293d..523e2f816036 100644 --- a/drivers/clk/starfive/clk-starfive-common.c +++ b/drivers/clk/starfive/clk-starfive-common.c @@ -300,6 +300,15 @@ static const struct clk_ops starfive_clk_inv_ops = { .debug_init = starfive_clk_debug_init, }; +static const struct clk_ops starfive_clk_idiv_ops = { + .get_phase = starfive_clk_get_phase, + .set_phase = starfive_clk_set_phase, + .recalc_rate = starfive_clk_recalc_rate, + .determine_rate = starfive_clk_determine_rate, + .set_rate = starfive_clk_set_rate, + .debug_init = starfive_clk_debug_init, +}; + const struct clk_ops *starfive_clk_ops(u32 max) { if (max & STARFIVE_CLK_DIV_MASK) { @@ -310,6 +319,9 @@ const struct clk_ops *starfive_clk_ops(u32 max) } if (max & STARFIVE_CLK_ENABLE) return &starfive_clk_gdiv_ops; + else if (max & STARFIVE_CLK_INVERT) + return &starfive_clk_idiv_ops; + if (max == STARFIVE_CLK_FRAC_MAX) return &starfive_clk_fdiv_ops; return &starfive_clk_div_ops; diff --git a/drivers/clk/starfive/clk-starfive-common.h b/drivers/clk/starfive/clk-starfive-common.h index 4cd4357f8366..fd9d13735896 100644 --- a/drivers/clk/starfive/clk-starfive-common.h +++ b/drivers/clk/starfive/clk-starfive-common.h @@ -104,6 +104,14 @@ struct starfive_clk_data { .parents = { [0] = _parent }, \ } +#define STARFIVE_IDIV(_idx, _name, _flags, _max, _parent) \ +[_idx] = { \ + .name = _name, \ + .flags = _flags, \ + .max = STARFIVE_CLK_INVERT | (_max), \ + .parents = { [0] = _parent }, \ +} + struct starfive_clk { struct clk_hw hw; unsigned int idx; -- 2.25.1

