[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181120091052.096ab7e3@bbrezillon>
Date: Tue, 20 Nov 2018 09:10:52 +0100
From: Boris Brezillon <boris.brezillon@...tlin.com>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: masonccyang@...c.com.tw, Mark Brown <broonie@...nel.org>,
Trent Piepho <tpiepho@...inj.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-spi <linux-spi@...r.kernel.org>,
Linux-Renesas <linux-renesas-soc@...r.kernel.org>,
Simon Horman <horms@...ge.net.au>, juliensu@...c.com.tw,
Geert Uytterhoeven <geert+renesas@...der.be>,
zhengxunli@...c.com.tw
Subject: Re: [PATCH 1/2] spi: Add Renesas R-Car RPC SPI controller driver
On Tue, 20 Nov 2018 09:01:29 +0100
Geert Uytterhoeven <geert@...ux-m68k.org> wrote:
> > --- /dev/null
> > +++ b/drivers/spi/spi-renesas-rpc.c
> > @@ -0,0 +1,750 @@
>
> > +static int rpc_spi_set_freq(struct rpc_spi *rpc, unsigned long freq)
> > +{
> > + int ret;
> > +
> > + if (rpc->cur_speed_hz == freq)
> > + return 0;
> > +
> > + clk_disable_unprepare(rpc->clk_rpc);
> > + ret = clk_set_rate(rpc->clk_rpc, freq);
> > + if (ret)
> > + return ret;
> > +
> > + ret = clk_prepare_enable(rpc->clk_rpc);
> > + if (ret)
> > + return ret;
>
> The clk_{disable_unprepare,prepare_enable}() may be needed on the Macronix
> controller you based this driver on, but will be futile on Renesas SoCs.
>
> As the RPC is part of the CPG/MSSR clock domain, its clock will be controlled
> by the Runtime PM. As you've already called pm_runtime_get_sync() from your
> .probe() calback, Runtime PM will have enabled the clock.
> If you disable it manually, you create an imbalance between automatic and
> manual clock control.
>
> So please don't control the clock explicitly, but always use
> pm_runtime_*() calls.
More about that. The reason we did that on MXIC is that the clk rate
can't be changed when the clk is enabled. So we have to
1/ explicitly disable the clk that has been enabled by runtime PM
2/ set the new rate
3/ re-enable the clk
So the clk enable/disable are not unbalanced, but it's also true that
this disable/set_rate/enable dance might be unneeded on your platform.
Powered by blists - more mailing lists