From: "Heiko Stübner" <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
To: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Cc: Daniel Lezcano
<daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Pawel Moll <Pawel.Moll-5wv7dgnIgG8@public.gmane.org>,
Ian Campbell
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
Matthias Brugger
<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH 2/2] clocksource: add rockchip-specific armv7-timer setup
Date: Fri, 20 Jun 2014 13:27:26 +0200 [thread overview]
Message-ID: <1653387.oFu7qPFqm3@diego> (raw)
In-Reply-To: <20140620105123.GH30188@leverpostej>
Am Freitag, 20. Juni 2014, 11:51:23 schrieb Mark Rutland:
> On Fri, Jun 20, 2014 at 11:44:49AM +0100, Heiko Stübner wrote:
> > The armv7-timer on Rockchip RK3288 SoCs needs an underlying timer to run.
> > Therefore the special rockchip,rk3288-armv7-timer does this setup and
> > then initializes the architected timer using the new locally exposed
> > arch_timer_init.
> >
> > Suggested-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
> > Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
> > ---
> >
> > .../bindings/arm/rockchip/armv7-timer.txt | 22 +++++++++
> > drivers/clocksource/Makefile | 1 +
> > drivers/clocksource/rockchip_timer.c | 57
> > ++++++++++++++++++++++ 3 files changed, 80 insertions(+)
> > create mode 100644
> > Documentation/devicetree/bindings/arm/rockchip/armv7-timer.txt create
> > mode 100644 drivers/clocksource/rockchip_timer.c
> >
> > diff --git
> > a/Documentation/devicetree/bindings/arm/rockchip/armv7-timer.txt
> > b/Documentation/devicetree/bindings/arm/rockchip/armv7-timer.txt new file
> > mode 100644
> > index 0000000..4c1950a
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/arm/rockchip/armv7-timer.txt
> > @@ -0,0 +1,22 @@
> > +Rockchip armv7-timer:
> > +---------------------
> > +
> > +The architected timer on rk3288 SoCs has special setup requirements, as
> > +the cpu-timer block needs to supply the architected timer.
> > +
> > +Required node properties:
> > +- compatible value : = "rockchip,rk3288-armv7-timer";
> > +- reg : physical base address and the size of the registers window
> > + of the supplying timer block
> > +- CP15 Timer node properties as described in bindings/arm/arch_timer.txt
> > +
> > +Example:
> > +
> > +architected-timer {
> > + compatible = "rockchip,rk3288-armv7-timer";
> > + reg = <0xff810020 0x20>;
> > + interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) |
> > IRQ_TYPE_LEVEL_HIGH)>,
> > + <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) |
IRQ_TYPE_LEVEL_HIGH)>,
> > + <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) |
IRQ_TYPE_LEVEL_HIGH)>;
> > + clock-frequency = <24000000>;
> > +};
> > diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> > index 800b130..cbad225 100644
> > --- a/drivers/clocksource/Makefile
> > +++ b/drivers/clocksource/Makefile
> > @@ -20,6 +20,7 @@ obj-$(CONFIG_ARCH_MARCO) += timer-marco.o
> >
> > obj-$(CONFIG_ARCH_MOXART) += moxart_timer.o
> > obj-$(CONFIG_ARCH_MXS) += mxs_timer.o
> > obj-$(CONFIG_ARCH_PRIMA2) += timer-prima2.o
> >
> > +obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip_timer.o
> >
> > obj-$(CONFIG_ARCH_U300) += timer-u300.o
> > obj-$(CONFIG_SUN4I_TIMER) += sun4i_timer.o
> > obj-$(CONFIG_SUN5I_HSTIMER) += timer-sun5i.o
> >
> > diff --git a/drivers/clocksource/rockchip_timer.c
> > b/drivers/clocksource/rockchip_timer.c new file mode 100644
> > index 0000000..46c2146
> > --- /dev/null
> > +++ b/drivers/clocksource/rockchip_timer.c
> > @@ -0,0 +1,57 @@
> > +/*
> > + * Copyright (c) 2014 MundoReader S.L.
> > + * Author: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation; either version 2 of the License, or
> > + * (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include <linux/init.h>
> > +#include <linux/of.h>
> > +#include <linux/of_address.h>
> > +#include <linux/clockchips.h>
> > +#include "arm_arch_timer.h"
> > +
> > +#define TIMER_LOAD_COUNT0 0x00
> > +#define TIMER_LOAD_COUNT1 0x04
> > +#define TIMER_CURRENT_VALUE0 0x08
> > +#define TIMER_CURRENT_VALUE1 0x0c
> > +#define TIMER_CONTROL_REG 0x10
> > +#define TIMER_INT_STATUS 0x18
> > +
> > +#define TIMER_DISABLE (0 << 0)
> > +#define TIMER_ENABLE (1 << 0)
> > +#define TIMER_MODE_FREE_RUNNING (0 << 1)
> > +#define TIMER_MODE_USER_DEFINED_COUNT (1 << 1)
> > +#define TIMER_INT_MASK (0 << 2)
> > +#define TIMER_INT_UNMASK (1 << 2)
> > +
> > +static __init void rk3288_arch_timer_init(struct device_node *np)
> > +{
> > + void __iomem *reg_base;
> > +
> > + reg_base = of_io_request_and_map(np, 0, "rk3288-armv7-timer");
> > + if (!reg_base) {
> > + pr_warn("%s: Can't get resource\n", __func__);
> > + return;
> > + }
> > +
> > + writel(TIMER_DISABLE, reg_base + TIMER_CONTROL_REG);
> > +
> > + writel(0xffffffff, reg_base + TIMER_LOAD_COUNT0);
> > + writel(0xffffffff, reg_base + TIMER_LOAD_COUNT1);
> > +
> > + writel(TIMER_ENABLE | TIMER_MODE_FREE_RUNNING,
> > + reg_base + TIMER_CONTROL_REG);
>
> Given that this is unconditionally set up in this way, could this not be
> done in the fimrware/bootloader?
>
> That way you could also setup CNTFREQ correctly, and virtualisation can
> just work out of the box.
It always comes back to this :-) . And as always the counter-argument would be
that I cannot influence the current bootloader, there are already devices
shipping in this constellation. And of course quite some more SoCs using this
pattern.
> This looks like a clock driver in disguise...
Yeah, that was my other idea - doing this as a clock. So would you be ok, with
the arch-timer getting the possibility to handle an optional clock?
Thanks
Heiko
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-06-20 11:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 10:43 [PATCH 0/2] clocksource: add rockchip rk3288 specific armv7-timer Heiko Stübner
2014-06-20 10:44 ` [PATCH 1/2] clocksource: arm_arch_timer: remove static from arch_timer_init Heiko Stübner
2014-06-20 10:52 ` Mark Rutland
2014-06-20 10:44 ` [PATCH 2/2] clocksource: add rockchip-specific armv7-timer setup Heiko Stübner
2014-06-20 10:51 ` Mark Rutland
2014-06-20 11:27 ` Heiko Stübner [this message]
2014-06-20 12:14 ` Mark Rutland
2014-06-23 10:54 ` Matthias Brugger
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=1653387.oFu7qPFqm3@diego \
--to=heiko-4mtyjxux2i+zqb+pc5nmwq@public.gmane.org \
--cc=Pawel.Moll-5wv7dgnIgG8@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.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).