linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Turquette <mturquette@linaro.org>
To: Arnd Bergmann <arnd@arndb.de>, linux-arm-kernel@lists.infradead.org
Cc: "Maxime Ripard" <maxime.ripard@free-electrons.com>,
	devicetree@vger.kernel.org, andriy.shevchenko@intel.com,
	"Emilio Lopez" <emilio@elopez.com.ar>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	zhuzhenhua@allwinnertech.com, "Vinod Koul" <vinod.koul@intel.com>,
	linux-sunxi@googlegroups.com, kevin.z.m.zh@gmail.com,
	sunny@allwinnertech.com, shuge@allwinnertech.com,
	"Dan Williams" <dan.j.williams@intel.com>
Subject: Re: [PATCH v6 3/8] ARM: sunxi: Move the clock protection to machine hooks
Date: Mon, 12 May 2014 18:30:24 -0700	[thread overview]
Message-ID: <20140513013024.5943.89772@quantum> (raw)
In-Reply-To: <4987444.Zp0Prbn0Y8@wuerfel>

Quoting Arnd Bergmann (2014-04-23 06:31:06)
> On Wednesday 23 April 2014 15:17:20 Maxime Ripard wrote:
> > > > +#include <linux/clk.h>
> > > >  #include <linux/init.h>
> > > >  #include <linux/of_platform.h>
> > > >  
> > > > @@ -19,9 +20,17 @@
> > > >  
> > > >  static void __init sun4i_dt_init(void)
> > > >  {
> > > > +       struct clk *clk;
> > > > +
> > > >         sunxi_setup_restart();
> > > >  
> > > >         of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> > > > +
> > > > +       /* Make sure the clocks we absolutely need are enabled */
> > > > +       /* DDR clock */
> > > > +       clk = clk_get(NULL, "pll5_ddr");
> > > > +       if (!IS_ERR(clk))
> > > > +               clk_prepare_enable(clk);
> > > >  }
> > > 
> > > Isn't there already DT syntax to do the same? If not, should there be?
> > 
> > I don't think there is, and I gave some thought about it too. But
> > something a la regulator-always-on wouldn't work with clocks with
> > multiple outputs (like pll5), because you might need to leave only one
> > of the output enabled, but not the others, and I couldn't think of a
> > nice way to do so.
> > 
> > If you have one, I'd be happy to implement it.
> 
> We had a discussion a while ago about encoding default settings for clock
> providers in the clock provider nodes. I don't remember the details
> unfortunately.
> 
> Mike, can you explain how this should be done?

The default clock settings are still in discussion. My perspective is
that the default settings are best used by the consuming device. E.g. an
MMC controller that consumes a clock signal should specify in DT the
clock that it consumes (already does this) and the preferred rate that
it wants that clock, as well as the preferred parent if that clock is a
mux.

Of course clock providers themselves are devices and could specify such
defaults for the clocks that they create. This approach is a minor
bastardization of the default clock settings since the clock provider
device isn't really consuming the clock, but it is helpful when no such
driver or DT node exists to do the same.

It is worth pointing out that the above approach amounts to the exact
same hard coding of clk_enable requirements as is done in Maxime's
patch, but with the added problem that the default are hidden away in DT
somewhere which is a debugging nightmare for someone trying to figure
out why a clock is set at a certain rate.

Finally, to answer the question more directly, I completely oppose
having something analogous to a regulator-always-on for a clock that can
gate. Please always use the clk.h API for this in Linux kernel driver C
code:

clk_get()
clk_prepare()
clk_enable()

In Maxime's case he is doing the right thing (using the clk.h API) but
he has no memory driver to do it, so he is putting that stuff in the clk
provider driver. I'm fine with that solution, until the day that he does
have a memory driver and then it needs to migrate out to that code.

Regards,
Mike

> 
>         Arnd

  reply	other threads:[~2014-05-13  1:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-17  8:46 [PATCH v6 0/8] Add support for the Allwinner A31 DMA Controller Maxime Ripard
2014-04-17  8:46 ` [PATCH v6 1/8] clk: sunxi: Remove calls to clk_put Maxime Ripard
2014-04-17  8:46 ` [PATCH v6 2/8] ARM: sunxi: Split out the various machines into separate files Maxime Ripard
2014-04-23 12:33   ` Arnd Bergmann
2014-04-23 13:28     ` Maxime Ripard
2014-04-23 13:33       ` Arnd Bergmann
2014-04-17  8:46 ` [PATCH v6 3/8] ARM: sunxi: Move the clock protection to machine hooks Maxime Ripard
2014-04-23 12:39   ` Arnd Bergmann
2014-04-23 13:17     ` Maxime Ripard
2014-04-23 13:31       ` Arnd Bergmann
2014-05-13  1:30         ` Mike Turquette [this message]
2014-04-17  8:46 ` [PATCH v6 4/8] ARM: sun6i: Protect CPU clock Maxime Ripard
2014-04-17  8:46 ` [PATCH v6 5/8] ARM: sun6i: Protect SDRAM gating bit Maxime Ripard
2014-04-17  8:46 ` [PATCH v6 6/8] ARM: sun6i: Sort the NMI node by physical address Maxime Ripard
2014-04-23 12:39   ` Arnd Bergmann
2014-04-23 13:11     ` Maxime Ripard
2014-04-17  8:46 ` [PATCH v6 7/8] DMA: sun6i: Add driver for the Allwinner A31 DMA controller Maxime Ripard
2014-04-17  8:46 ` [PATCH v6 8/8] ARM: sun6i: dt: Add A31 DMA controller to DTSI Maxime Ripard

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=20140513013024.5943.89772@quantum \
    --to=mturquette@linaro.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=arnd@arndb.de \
    --cc=dan.j.williams@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=emilio@elopez.com.ar \
    --cc=kevin.z.m.zh@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=shuge@allwinnertech.com \
    --cc=sunny@allwinnertech.com \
    --cc=vinod.koul@intel.com \
    --cc=zhuzhenhua@allwinnertech.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).