All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: masonccyang@mxic.com.tw, Mark Brown <broonie@kernel.org>,
	Trent Piepho <tpiepho@impinj.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-spi <linux-spi@vger.kernel.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	Simon Horman <horms@verge.net.au>,
	juliensu@mxic.com.tw,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	zhengxunli@mxic.com.tw
Subject: Re: [PATCH 1/2] spi: Add Renesas R-Car RPC SPI controller driver
Date: Tue, 20 Nov 2018 09:10:52 +0100	[thread overview]
Message-ID: <20181120091052.096ab7e3@bbrezillon> (raw)
In-Reply-To: <CAMuHMdVjqkHsqEjEgBWg0eGtE-9ND+a=OeHwu=r39LrfkQq=Yw@mail.gmail.com>

On Tue, 20 Nov 2018 09:01:29 +0100
Geert Uytterhoeven <geert@linux-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.

  reply	other threads:[~2018-11-20 18:38 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-19 10:01 [PATCH 0/2] spi: Add Renesas R-Car D3 RPC SPI driver Mason Yang
2018-11-19 10:01 ` [PATCH 1/2] spi: Add Renesas R-Car RPC SPI controller driver Mason Yang
2018-11-19 14:12   ` Marek Vasut
2018-11-19 15:27     ` Mark Brown
2018-11-19 22:10       ` Marek Vasut
2018-11-20 13:26         ` Mark Brown
2018-11-20 13:33           ` Marek Vasut
2018-11-20  7:23     ` masonccyang
2018-11-20 13:09       ` Marek Vasut
2018-11-20 13:32         ` Boris Brezillon
2018-11-20 13:35           ` Marek Vasut
2018-11-23  0:45     ` masonccyang
2018-11-23 13:34       ` Marek Vasut
2018-11-23 13:34         ` Marek Vasut
2018-11-20  2:04   ` kbuild test robot
2018-11-20  5:49   ` kbuild test robot
2018-11-20  8:01   ` Geert Uytterhoeven
2018-11-20  8:10     ` Boris Brezillon [this message]
2018-11-20  9:27       ` masonccyang
2018-11-20  9:23     ` masonccyang
2018-11-19 10:01 ` [PATCH 2/2] dt-binding: spi: Document Renesas R-Car RPC controller bindings Mason Yang
2018-11-19 13:49   ` Marek Vasut
2018-11-19 14:10     ` Boris Brezillon
2018-11-19 14:14       ` Marek Vasut
2018-11-19 14:43         ` Boris Brezillon
2018-11-19 15:12           ` Marek Vasut
2018-11-19 15:21             ` Boris Brezillon
2018-11-19 22:11               ` Marek Vasut
2018-11-19 22:19                 ` Boris Brezillon
2018-11-19 22:22                   ` Marek Vasut
2018-11-19 22:25                     ` Boris Brezillon
2018-11-19 22:29                       ` Marek Vasut
2018-11-19 22:31                         ` Boris Brezillon
2018-11-20  5:42     ` masonccyang
2018-11-20 12:57       ` Marek Vasut
2018-11-21  0:53         ` masonccyang
2018-11-21  1:51           ` Marek Vasut
2018-11-20  8:07   ` Geert Uytterhoeven
2018-11-20 13:56   ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181120091052.096ab7e3@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=horms@verge.net.au \
    --cc=juliensu@mxic.com.tw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=masonccyang@mxic.com.tw \
    --cc=tpiepho@impinj.com \
    --cc=zhengxunli@mxic.com.tw \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.