From: laurent.pinchart@ideasonboard.com (Laurent Pinchart)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 23/27] clocksource: sh_cmt: Add DT support
Date: Fri, 14 Feb 2014 16:53:08 +0100 [thread overview]
Message-ID: <107109887.afEv2P92gg@avalon> (raw)
In-Reply-To: <20140214105822.GE9907@e106331-lin.cambridge.arm.com>
Hi Mark,
Thank you for the review.
On Friday 14 February 2014 10:58:22 Mark Rutland wrote:
> On Fri, Feb 14, 2014 at 01:00:01AM +0000, Laurent Pinchart wrote:
> > Cc: devicetree at vger.kernel.org
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> >
> > .../devicetree/bindings/timer/renesas,cmt.txt | 75 +++++++++++++++
> > drivers/clocksource/sh_cmt.c | 104 +++++++++++++---
> > 2 files changed, 160 insertions(+), 19 deletions(-)
> > create mode 100644
> > Documentation/devicetree/bindings/timer/renesas,cmt.txt
> >
> > diff --git a/Documentation/devicetree/bindings/timer/renesas,cmt.txt
> > b/Documentation/devicetree/bindings/timer/renesas,cmt.txt new file mode
> > 100644
> > index 0000000..28d4ab5
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/timer/renesas,cmt.txt
> > @@ -0,0 +1,75 @@
> > +* Renesas R-Car Compare Match Timer (CMT)
> > +
> > +The CMT is a multi-channel 16/32/48-bit timer/counter with configurable
> > clock
> > +inputs and programmable compare match.
> > +
> > +Channels share hadware resources but their counter and compare match
> > value are
> > +independent. A particular CMT instance can implement only a subset of the
> > +channels supported by the CMT model. Channels indices start from 0 and
> > are
> > +consecutive.
> > +
> > +Required Properties:
> > +
> > + - compatible: must contain one of the following.
> > + - "renesas,cmt-32" for the 32-bit CMT
> > + (CMT0 on sh7372, sh73a0 and r8a7740)
> > + - "renesas,cmt-32-fast" for the 32-bit CMT with fast clock support
> > + (CMT[234] on sh7372, sh73a0 and r8a7740)
> > + - "renasas,cmt-48" for the 48-bit CMT
> > + (CMT1 on sh7372, sh73a0 and r8a7740)
> > + - "renesas,cmt-48-gen2" for the second generation 48-bit CMT
> > + (CMT[01] on r8a73a4, r8a7790 and r8a7791)
> > +
> > + - reg: base address and length of the registers block for the timer
> > module.
> > + - interrupt-parent, interrupts: interrupt-specifier for the timer, one
> > per
> > + channel.
>
> It might make more sense to describe the interrupt on the channel
> subnode. It makes it far clearer which channel has which interrupt.
That's a good point. I'm relying on platform_get_irq() which won't support
that usage, but I can switch to of_irq_to_resource() instead.
> > + - clocks: phandle and clock-specifier pair for the functional clock.
> > + - clock-names: must be "fck".
>
> It would be nice to define the list once:
>
> - clocks: A list of phandle + clock-specifier pairs, one for each entry
> in clock-names.
> - clock-names: Should contain "fck" for the functional clock.
OK.
> > +
> > + - #address-cells: must be 1
> > + - #size-cells: must be 0
> > +
> > + - renesas,channels-mask: integer bitmask of the channels implemented by
> > the
> > + timer instance.
>
> This is implied by the presence of a subnode. Either remove this or the
> subnodes.
>
> > +
> > +
> > +Each channel is described by a sub-node named "channel@<idx>", where
> > <idx> is +the channel index.
> > +
> > +Channels Required Properties:
> > +
> > + - reg: the channel index.
> > +
> > +Channels Optional Properties:
> > +
> > + - clock-source-rating: rating of the timer as a clock source device.
> > + - clock-event-rating: rating of the timer as a clock event device.
>
> This feels like a leak of Linux internals. Why do you need this?
You're right, it is. The clock source and clock event ratings are currently
configured through platform data, I'll need to find a way to compute them in
the driver instead.
There's still one piece of Linux-specific data I need though, as I need to
specify for each channel whether to use it as a clock source device, a clock
event device, both of them or none. That's configuration information that
needs to be provided somehow.
> > +
> > +
> > +Example: R8A7790 (R-Car H2) CMT0 node
> > +
> > + CMT0 on R8A7790 implements hardware channels 5 and 6 only and names
> > + them channels 0 and 1 in the documentation.
> > +
> > + cmt0: timer at ffca0000 {
> > + compatible = "renesas,cmt-48-gen2";
> > + reg = <0 0xffca0000 0 0x1004>;
> > + interrupt-parent = <&gic>;
> > + interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
> > + <0 142 IRQ_TYPE_LEVEL_HIGH>;
> > + clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
> > +
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + renesas,channels-mask = <0x60>;
> > +
> > + channel at 0 {
> > + reg = <0>;
> > + clock-event-rating = <80>;
> > + };
> > + channel at 0 {
> > + reg = <0>;
> > + clock-source-rating = <80>;
> > + };
>
> Aaargh. Use the _real_ channel IDs for the reg proeprties and get rid of
> the mask. It's pointlessly confusing.
There's two real channel IDs. One of them is the value used in the hardware
implementation (5 and 6 in this case, used to compute the channel registers
block address) and the other one is the value used throughout the datasheet, 0
and 1 in this case.
The later is used by the driver to reference the correct interrupt, which
won't be needed anymore when referencing interrupts in the channel subnodes
directly. It's also used to print messages to the kernel log and match the
channel numbers specified in the datasheets. I could use the hardware channel
number instead, but that might become confusing.
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2014-02-14 15:53 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-14 0:59 [PATCH 00/27] Renesas CMT (Compare Match Timer) DT bindings Laurent Pinchart
2014-02-14 0:59 ` [PATCH 01/27] clocksource: sh_cmt: Split channel fields from sh_cmt_priv Laurent Pinchart
2014-02-14 0:59 ` [PATCH 02/27] clocksource: sh_cmt: Rename struct sh_cmt_priv to sh_cmt_device Laurent Pinchart
2014-02-14 0:59 ` [PATCH 03/27] clocksource: sh_cmt: Split channel setup to separate function Laurent Pinchart
2014-02-14 0:59 ` [PATCH 04/27] clocksource: sh_cmt: Rename mapbase/mapbase_str to mapbase_ch/mapbase Laurent Pinchart
2014-02-14 0:59 ` [PATCH 05/27] clocksource: sh_cmt: Add memory base to sh_cmt_channel structure Laurent Pinchart
2014-02-14 0:59 ` [PATCH 06/27] clocksource: sh_cmt: Add index to struct sh_cmt_channel Laurent Pinchart
2014-02-14 0:59 ` [PATCH 07/27] clocksource: sh_cmt: Replace kmalloc + memset with kzalloc Laurent Pinchart
2014-02-14 0:59 ` [PATCH 08/27] clocksource: sh_cmt: Allocate channels dynamically Laurent Pinchart
2014-02-14 0:59 ` [PATCH 09/27] clocksource: sh_cmt: Split static information from sh_cmt_device Laurent Pinchart
2014-02-14 0:59 ` [PATCH 10/27] clocksource: sh_cmt: Replace hardcoded register values with macros Laurent Pinchart
2014-02-14 0:59 ` [PATCH 11/27] clocksource: sh_cmt: Add support for multiple channels per device Laurent Pinchart
2014-02-15 12:46 ` Thomas Gleixner
2014-02-16 18:18 ` Laurent Pinchart
2014-02-17 1:41 ` Magnus Damm
2014-02-17 1:48 ` Laurent Pinchart
2014-02-17 2:07 ` Magnus Damm
2014-02-17 9:58 ` Laurent Pinchart
2014-02-14 0:59 ` [PATCH 12/27] clocksource: sh_cmt: Acquire default clock in the non-legacy case Laurent Pinchart
2014-02-14 0:59 ` [PATCH 13/27] clocksource: sh_cmt: Remove FSF mail address from GPL notice Laurent Pinchart
2014-02-14 0:59 ` [PATCH 14/27] clocksource: sh_cmt: Sort headers alphabetically Laurent Pinchart
2014-02-14 0:59 ` [PATCH 15/27] sh: Switch to new style CMT device Laurent Pinchart
2014-02-14 0:59 ` [PATCH 16/27] ARM: shmobile: sh7372: " Laurent Pinchart
2014-02-14 0:59 ` [PATCH 17/27] ARM: shmobile: sh73a0: " Laurent Pinchart
2014-02-14 0:59 ` [PATCH 18/27] ARM: shmobile: r8a73a4: " Laurent Pinchart
2014-02-14 0:59 ` [PATCH 19/27] ARM: shmobile: r8a7740: " Laurent Pinchart
2014-02-14 0:59 ` [PATCH 20/27] ARM: shmobile: r8a7790: " Laurent Pinchart
2014-02-14 0:59 ` [PATCH 21/27] ARM: shmobile: r8a7791: " Laurent Pinchart
2014-02-14 1:00 ` [PATCH 22/27] clocksource: sh_cmt: Drop support for legacy platform data Laurent Pinchart
2014-02-14 1:00 ` [PATCH 23/27] clocksource: sh_cmt: Add DT support Laurent Pinchart
2014-02-14 9:18 ` Geert Uytterhoeven
2014-02-14 14:35 ` Laurent Pinchart
2014-02-14 10:58 ` Mark Rutland
2014-02-14 15:53 ` Laurent Pinchart [this message]
2014-02-14 15:59 ` Josh Cartwright
2014-02-14 16:15 ` Laurent Pinchart
2014-02-14 16:01 ` Magnus Damm
2014-02-14 16:12 ` Laurent Pinchart
2014-02-14 17:22 ` Magnus Damm
2014-02-17 1:45 ` Laurent Pinchart
2014-02-17 1:48 ` Magnus Damm
2014-02-17 21:43 ` Laurent Pinchart
2014-02-18 0:51 ` Magnus Damm
2014-02-18 11:45 ` Laurent Pinchart
2014-02-14 1:00 ` [PATCH 24/27] ARM: shmobile: r8a7790: Add CMT devices to DT Laurent Pinchart
2014-02-14 1:00 ` [PATCH 25/27] ARM: shmobile: r8a7791: " Laurent Pinchart
2014-02-14 1:00 ` [PATCH 26/27] ARM: shmobile: lager-reference: Enable CMT0 in device tree Laurent Pinchart
2014-02-14 13:45 ` Sergei Shtylyov
2014-02-14 13:48 ` Laurent Pinchart
2014-02-14 14:13 ` Sergei Shtylyov
2014-02-14 14:22 ` Laurent Pinchart
2014-02-14 14:36 ` Sergei Shtylyov
2014-02-14 16:26 ` Laurent Pinchart
2014-02-14 19:56 ` Sergei Shtylyov
2014-02-14 1:00 ` [PATCH 27/27] ARM: shmobile: koelsch-reference: " Laurent Pinchart
2014-02-14 13:47 ` Sergei Shtylyov
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=107109887.afEv2P92gg@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).