devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: Paul Walmsley <paul@pwsan.com>
Cc: devicetree@vger.kernel.org, Tony Lindgren <tony@atomide.com>,
	mturquette@linaro.org, linux-omap@vger.kernel.org, nm@ti.com,
	khilman@linaro.org, pdeschrijver@nvidia.com, rnayak@ti.com,
	bcousson@baylibre.com, linux-arm-kernel@lists.infradead.org,
	swarren@nvidia.com, mark.rutland@arm.com
Subject: Re: [PATCHv7 00/36] ARM: OMAP: clock data conversion to DT
Date: Mon, 14 Oct 2013 17:57:00 +0300	[thread overview]
Message-ID: <525C063C.9080908@ti.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1310132023240.27397@utopia.booyaka.com>

Hi Paul,

I've been looking at this stuff today, and this will cause pretty huge 
changes to the set. This probably means a few weeks delay in 
implementation at least.

Some comments on the technical perspectives below.

On 10/14/2013 02:45 AM, Paul Walmsley wrote:
>
> Here you go:
>
> 1. Create DT nodes for the IP blocks that contain the clock control
> registers, underneath the appropriate bus node.  So for example OMAP4
> would have:
>
> /ocp {
>
>      prm@4a306000 {
> 	compatible = xxx;
> 	regs = <0x4a306000 xxxx>;
>      };
>
>      cm1@4a004000 {
> 	compatible = xxx;
> 	regs = <0x4a004000 xxxx>;
>      };
>
>      cm2@4a008000 {
> 	compatible = xxx;
> 	regs = <0x4a008000 xxxx>;
>      };
>
> };
>
> This is pure OS-independent hardware description (with the unfortunate
> exception of the "ocp" part).
>
>
> 2. Create the clock data underneath the corresponding PRCM/CM/PRM device
> nodes that their control registers exist in.  So for example, dpll_per_ck
> would belong to the "cm1" device, since that's where its control registers
> are located.  Something like this:
>
>      cm1@4a004000 {
>          ...
>          clocks {
>              dpll_per_ck@.... {
> 		<clock data goes here>
>              };
>          };
>      };
>
>
> The DT data is intended to portray addressable devices from the
> perspective of the CPUs that are booted with that data, organized by bus
> structure.  From this point of view, clocks that are controlled via a
> particular IP block should have their data associated with that block.
>
>
> 3. Place clock register accesses in the low-level PRCM/CM/PRM device
> driver.  If other kernel code needs some resource that's provided by the
> IP block, it should either come from common Linux framework routines (like
> the clock code), or use functions exported from the low-level driver that
> don't expose register addresses.
>
> Otherwise, if MMIO accesses to that device are allowed from all over the
> codebase, it creates an undebuggable mess:
>
> A. It could result in IP blocks being partially programmed before they are
> probed by their drivers.  If their drivers (or the integration code) reset
> the IP blocks, the non-driver code has no way of knowing that it needs to
> reprogram the underlying IP block.
>
> B. If any preparation is needed before the clock registers can be
> accessed, like runtime PM calls or device_enable()-type calls, this should
> be coordinated by the low-level IP block itself.  We don't expect this to
> be the case for PRCM/CM/PRM, but we do expect it to be the case for UART,
> DSS, some audio clocks, etc.
>
> C. The low-level IP block drivers may want to implement some caching layer
> like regmap.  If some register writes bypass the low-level driver, then
> someone is likely to get a big unpleasant surprise.
>
> D. It impairs the common debugging technique of adding code to the IP
> block MMIO read/write functions to log register accesses.
>
>
>
> 4. Use relative register offsets from the top of the containing IP block's
> base address, rather than absolute addresses.
>
>     cm1@4a004000 {
>          ...
>          clocks {
>              dpll_per_ck@4140 {
>                  <clock data goes here>
>              };
>          };
>      };
>
> This makes it possible to reuse the same DT clock data in cases where the
> same IP block is used, but at a different base address.  This is probably
> not a big issue with the system integration IP blocks, but quite possible
> with the non-SoC-integration IP blocks.  It also makes it obvious if
> someone tries to sneak clocks into the IP block data that aren't
> controlled by that IP block.

Relative addressing basically means I need to copy paste the code for 
clk_divider + clk_mux from drivers/clk to drivers/clk/ti. Or 
alternatively add a way to provide register read/write ops to the basic 
clock.

> 5. Register the clocks from the low-level IP block drivers, rather than
> from external code.  That way there's no need to export low-level register
> manipulation functions off to other kernel code.  This registration can be
> done when the PRCM/CM/PRM driver probes.
>
>
> 6. Move the OMAP clockdomain data underneath the DT node for the low-level
> IP block that contains them:
>
>
>     cm1@4a004000 {
>          ...
>          clocks {
> 	       ...
>          };
>
>          clockdomains {
>                 l3_init_clkdm: l3_init_clkdm@... {
>                     ...
>                 };
>          };
>      };

I think clocks + clockdomains grouping nodes are unnecessary in this 
case. Same can be accomplished with simply using the compatible string 
for mapping to corresponding types. (This is probably valid for current 
code also.)

> For non-OMAP folks reading this thread, OMAP clockdomains have control
> registers associated with them, located in the PRCM/CM/PRM IP block
> address space, so that's where they belong.
>
>
> 7. drivers/clk/ti is probably the wrong place for most of the low-level
> drivers for IP blocks like the PRM/PRCM/CM.  Most of these IP blocks do
> more than just control clocks: they also control other system entities
> like reset lines, OMAP powerdomains, AVS, or OMAP "clockdomains" (which in
> some cases may have nothing to do with clocks).
>
> drivers/clk/ti is almost defensible for CM, if it weren't for the OMAP
> "clockdomain" registers that are there.  However, for the other OMAP
> integration IP blocks, drivers/clk/ti definitely seems out of place.  And
> since some OMAP chips like OMAP2420 or AM43XX don't have separate CM and
> PRM blocks -- they combine them both into a single PRCM module -- it seems
> best to place CM, PRM, and other related code into a single common
> directory, so they can easily share code across chips.
>
> I'd suggest putting them in drivers/sysctrl/omap/.  This would be intended
> for low-level SoC IP block drivers that control system integration.
> Otherwise drivers/clk/XXX is going to turn into another drivers/mfd.

I think initially I would place this stuff under mach-omap2. Much better 
than to try to introduce multiple new drivers with a single set.

> 8. A few random comments about the individual clock binding data formats
> themselves, based on a quick look:
>
> A. It seems pretty odd and unnecessarily obscure to do something like
> this:
>
> dpll_usb_ck: dpll_usb_ck@... {
>         ...
>         reg = <0x4a008180 0x4>, <0x4a008184 0x4>, <0x4a008188 0x4>, <0x4a00818c 0x4>;
>         ...
> };
 >
> It's at least self-documenting to do something like this:
>
> dpll_usb_ck: dpll_usb_ck@... {
>         ...
>         control-reg = < ... >;
>         idlest-reg = < ... >;
>         .. etc. ..
> };

Some earlier version had something along these lines, but it was turned 
down. I had also reg-names as documentation purposes along, but this was 
unnecessary and was dropped also.

> Which itself might not even be needed, depending on how the DPLL control
> code is implemented.  For example, if the relative offsets are always the
> same for all OMAP4-family devices, maybe there's not even a need to
> explicitly encode that into the DT data.

If I want to get rid of these, I need to add extra compatible strings 
for the dpll types. There are several weird register offsets for 
omap3/am3 devices. omap4/5/dra7/am4 behave more sanely.

> B. Seems like you can remove the "ti," prefix on the properties, since
> they have no pretentions at genericity: they are specific to the
> PRCM/CM/PRM IP block data, and registered by those drivers.

Can or should? It seems existing bindings use "ti," prefix even on 
non-generic bindings, meaning if I look at any other data in DT.

> C. Looks like the patches use the property "autoidle-low" to indicate that
> the autoidle bit should be inverted.  "Low" seems like the wrong
> expression here - it invokes the actual voltage logic level of a hardware
> signal, and we have no idea whether the hardware signal is using a low
> voltage or a high voltage to express this condition.  Would suggest
> something like 'invert-autoidle-bit' instead.
 >
> D. Regarding "ti,index-starts-at-one", it seems best to explicitly state
> which index starts at one.  The code mentions a "mux index" so please
> consider renaming this something like "mux-index-starts-at-one" or
> "one-based-mux-index"

The index is explicitly defined by the clock node where this is present. 
If it is a mux-clock, then it is for mux-index. If for divider clock, it 
is index for the divider.

-Tero


  reply	other threads:[~2013-10-14 14:57 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-25  8:48 [PATCHv7 00/36] ARM: OMAP: clock data conversion to DT Tero Kristo
2013-09-25  8:48 ` [PATCHv7 01/36] CLK: TI: Add DPLL clock support Tero Kristo
2013-09-25  8:48 ` [PATCHv7 04/36] CLK: ti: add support for ti divider-clock Tero Kristo
2013-09-25  8:48 ` [PATCHv7 07/36] CLK: TI: add support for clockdomain binding Tero Kristo
2013-09-25  8:48 ` [PATCHv7 08/36] ARM: dts: omap4 clock data Tero Kristo
2013-09-25  8:48 ` [PATCHv7 10/36] clk: ti: add support for basic mux clock Tero Kristo
2013-09-25  8:48 ` [PATCHv7 11/36] CLK: TI: add omap4 clock init file Tero Kristo
2013-09-25  8:48 ` [PATCHv7 12/36] ARM: OMAP4: remove old clock data and link in new clock init code Tero Kristo
2013-09-25  8:48 ` [PATCHv7 13/36] ARM: dts: omap5 clock data Tero Kristo
2013-09-25  8:48 ` [PATCHv7 15/36] CLK: TI: omap5: Initialize USB_DPLL at boot Tero Kristo
2013-09-25  8:48 ` [PATCHv7 18/36] ARM: dts: DRA7: Change apll_pcie_m2_ck to fixed factor clock Tero Kristo
2013-09-25  8:48 ` [PATCHv7 19/36] ARM: dts: DRA7: Add PCIe related clock nodes Tero Kristo
2013-09-25  8:48 ` [PATCHv7 23/36] ARM: dts: DRA7: link in clock DT data Tero Kristo
2013-09-25  8:48 ` [PATCHv7 24/36] ARM: dts: am33xx clock data Tero Kristo
2013-09-25  8:48 ` [PATCHv7 32/36] ARM: dts: AM35xx: use DT " Tero Kristo
2013-09-25  8:48 ` [PATCHv7 33/36] ARM: OMAP3: use DT clock init if DT data is available Tero Kristo
2013-09-25  8:48 ` [PATCHv7 35/36] ARM: dts: AM43xx: link in clock DT data Tero Kristo
     [not found] ` <1380098922-30340-1-git-send-email-t-kristo-l0cyMroinI0@public.gmane.org>
2013-09-25  8:48   ` [PATCHv7 02/36] CLK: TI: add DT alias clock registration mechanism Tero Kristo
2013-09-25  8:48   ` [PATCHv7 03/36] CLK: TI: add autoidle support Tero Kristo
2013-09-25  8:48   ` [PATCHv7 05/36] clk: ti: add support for TI fixed factor clock Tero Kristo
2013-09-25  8:48   ` [PATCHv7 06/36] CLK: TI: add support for OMAP gate clock Tero Kristo
2013-09-25  8:48   ` [PATCHv7 09/36] clk: ti: add mux-gate clock support Tero Kristo
2013-09-25  8:48   ` [PATCHv7 14/36] CLK: TI: add omap5 clock init file Tero Kristo
2013-09-25  8:48   ` [PATCHv7 16/36] ARM: dts: dra7 clock data Tero Kristo
2013-09-25  8:48   ` [PATCHv7 17/36] ARM: dts: clk: Add apll related clocks Tero Kristo
2013-09-25  8:48   ` [PATCHv7 20/36] CLK: TI: DRA7: Add APLL support Tero Kristo
2013-10-08  5:16     ` Mike Turquette
2013-09-25  8:48   ` [PATCHv7 21/36] CLK: TI: add dra7 clock init file Tero Kristo
2013-09-25  8:48   ` [PATCHv7 22/36] ARM: OMAP: DRA7: Enable clock init Tero Kristo
2013-09-25  8:48   ` [PATCHv7 25/36] CLK: TI: add am33xx clock init file Tero Kristo
2013-09-25  8:48   ` [PATCHv7 26/36] ARM: AM33xx: remove old clock data and link in new clock init code Tero Kristo
2013-09-25  8:48   ` [PATCHv7 27/36] CLK: TI: add interface clock support for OMAP3 Tero Kristo
2013-09-25  8:48   ` [PATCHv7 28/36] ARM: OMAP: hwmod: fix an incorrect clk type cast with _get_clkdm Tero Kristo
2013-09-25  8:48   ` [PATCHv7 29/36] ARM: OMAP3: hwmod: initialize clkdm from clkdm_name Tero Kristo
2013-09-25  8:48   ` [PATCHv7 30/36] ARM: dts: omap3 clock data Tero Kristo
2013-09-26 16:06     ` Nishanth Menon
2013-09-26 16:23       ` Nishanth Menon
2013-09-25  8:48   ` [PATCHv7 31/36] CLK: TI: add omap3 clock init file Tero Kristo
2013-09-25  8:48   ` [PATCHv7 34/36] ARM: dts: am43xx clock data Tero Kristo
2013-09-25  8:48   ` [PATCHv7 36/36] CLK: TI: add am43xx clock init file Tero Kristo
2013-09-26 15:21   ` [PATCHv7 00/36] ARM: OMAP: clock data conversion to DT Nishanth Menon
2013-09-26 15:29     ` Nishanth Menon
2013-10-04 15:34   ` Tero Kristo
2013-10-07  2:15     ` Tony Lindgren
2013-10-07  6:35       ` Tero Kristo
2013-10-07 15:41         ` Tony Lindgren
2013-10-07 16:13           ` Nishanth Menon
2013-10-07 19:03           ` Tony Lindgren
     [not found]             ` <20131007190322.GY8949-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2013-10-09 18:55               ` Paul Walmsley
2013-10-09 18:59                 ` Paul Walmsley
2013-10-09 19:24                   ` Tony Lindgren
2013-10-10  7:18                   ` Tero Kristo
2013-10-11 17:54                     ` Paul Walmsley
2013-10-11 18:23                       ` Tero Kristo
2013-10-11 22:26                         ` Paul Walmsley
2013-10-11 18:46                       ` Tero Kristo
2013-10-11 22:37                         ` Paul Walmsley
2013-10-12 10:25                           ` Tero Kristo
2013-10-13 23:45                             ` Paul Walmsley
2013-10-14 14:57                               ` Tero Kristo [this message]
2013-10-14 18:27                                 ` Paul Walmsley
2013-10-14 18:34                                   ` Tero Kristo
2013-10-09 19:22                 ` Tony Lindgren
2013-10-10  8:17                 ` Tero Kristo
2013-10-11 22:53                   ` Tony Lindgren
2013-10-08  5:40 ` Mike Turquette
2013-10-08  8:17   ` Tero Kristo
2013-10-08 16:47     ` Tony Lindgren

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=525C063C.9080908@ti.com \
    --to=t-kristo@ti.com \
    --cc=bcousson@baylibre.com \
    --cc=devicetree@vger.kernel.org \
    --cc=khilman@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@linaro.org \
    --cc=nm@ti.com \
    --cc=paul@pwsan.com \
    --cc=pdeschrijver@nvidia.com \
    --cc=rnayak@ti.com \
    --cc=swarren@nvidia.com \
    --cc=tony@atomide.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).