Re: [PATCH 1/4] clk: meson: mpll: add init callback and regs
From: Stephen Boyd
Date: Fri Mar 29 2019 - 18:14:41 EST
Quoting Jerome Brunet (2019-03-26 00:53:15)
> On Mon, 2019-03-25 at 10:10 -0700, Stephen Boyd wrote:
> > Quoting Jerome Brunet (2019-03-25 04:11:57)
> > > @@ -138,6 +129,27 @@ static int mpll_set_rate(struct clk_hw *hw,
> > > return 0;
> > > }
> > >
> > > +static void mpll_init(struct clk_hw *hw)
> > > +{
> > > + struct clk_regmap *clk = to_clk_regmap(hw);
> > > + struct meson_clk_mpll_data *mpll = meson_clk_mpll_data(clk);
> > > +
> > > + if (mpll->init_count)
> > > + regmap_multi_reg_write(clk->map, mpll->init_regs,
> > > + mpll->init_count);
> > > +
> > > + /* Enable the fractional part */
> > > + meson_parm_write(clk->map, &mpll->sdm_en, 1);
> > > +
> > > + /* Set additional fractional part enable if required */
> > > + if (MESON_PARM_APPLICABLE(&mpll->ssen))
> > > + meson_parm_write(clk->map, &mpll->ssen, 1);
> > > +
> > > + /* Set the magic misc bit if required */
> > > + if (MESON_PARM_APPLICABLE(&mpll->misc))
> > > + meson_parm_write(clk->map, &mpll->misc, 1);
> > > +}
> > > +
> > > const struct clk_ops meson_clk_mpll_ro_ops = {
> > > .recalc_rate = mpll_recalc_rate,
> > > .round_rate = mpll_round_rate,
> > > @@ -148,6 +160,7 @@ const struct clk_ops meson_clk_mpll_ops = {
> > > .recalc_rate = mpll_recalc_rate,
> > > .round_rate = mpll_round_rate,
> > > .set_rate = mpll_set_rate,
> > > + .init = mpll_init,
> >
> > We actively discourage using init callbacks. Can you do this some other
> > way?
>
> Yes I'm aware of that but init it the right place to do this.
> To be clear, this is not initializing the clock to some particular rate, the
> rate is preserved.
>
> It just applies the necessary settings that needs to be done only once to make
> sure the clock is in working order and that the rate calculated is actually
> accurate.
Ok, but can you do that in your driver's probe routine instead of
attaching to the init callback? We want to get rid of "init" at some
point so throwing the init sequence stuff into the driver probe around
registration is a solution. Or we should think about not discouraging
the init callback.