From: Daniel Tang <dt.tangr@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
John Stultz <john.stultz@linaro.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
Arnd Bergmann <arnd@arndb.de>,
"fabian@ritter-vogt.de Vogt" <fabian@ritter-vogt.de>,
Lionel Debroux <lionel_debroux@yahoo.fr>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCHv3 4/6] clocksource: Add TI-Nspire timer drivers
Date: Tue, 14 May 2013 21:51:10 +1000 [thread overview]
Message-ID: <26FBB324-AAA9-4C10-8978-C2EC1C26672E@gmail.com> (raw)
In-Reply-To: <CACRpkdZBFbOnQ9rCehO0yKDN7fH9VR3VYCa_NkOGJz7KN+02FQ@mail.gmail.com>
On 14/05/2013, at 6:03 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
>> +
>> + timer->interrupt_regs = of_iomap(node, 1);
>
> Check for errors.
>
>> + timer->irqnr = irq_of_parse_and_map(node, 0);
>
> Check for errors.
>> + if (timer->interrupt_regs && timer->irqnr) {
>>
The idea with this is to make these properties optional. Each timer has two sub-timers but only one can generate interrupts. One will be added as a clockevent device and the other as a clocksource. If an IRQ number or interrupt acknowledge address is not passed through the DT, then the clockevents device is not added but the clocksource still is.
Should I comment it in the code to make it apparent what's happening or is there a better way to express this?
>
>> + writel(0x3F, timer->interrupt_regs + IO_INTR_ACK);
>
> Hm magic number, I guess it's clearing all IRQ lines…
It's a bitmask of bits 0-5.
>
>> +
>> + /* Interrupt to occur when timer value matches 0 */
>> + writel(0, timer->base + IO_MATCH1);
>> +
>> + timer->clkevt_irq.name = timer->clockevent_name;
>> + timer->clkevt_irq.handler = nspire_timer_interrupt;
>> + timer->clkevt_irq.dev_id = timer;
>> + timer->clkevt_irq.flags =
>> + IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL;
>> +
>> + setup_irq(timer->irqnr, &timer->clkevt_irq);
>> +
>> + clockevents_config_and_register(&timer->clkevt,
>> + clk_get_rate(timer->clk), 0x0001, 0xfffe);
>> + pr_info("Added %s as clockevent\n", timer->clockevent_name);
>> + }
>> +
>> + writel(CNTL_RUN_TIMER | CNTL_FOREVER | CNTL_INC,
>> + timer->timer2 + IO_CONTROL);
>> +
>> + clocksource_mmio_init(timer->timer2 + IO_CURRENT_VAL,
>> + timer->clocksource_name,
>> + clk_get_rate(timer->clk),
>> + 200, 16,
>> + clocksource_mmio_readw_up);
>
> If this timer is really just 16 bits, it's a *pretty* good idea to use
> the prescaler (I guess this is what IO_DIVIDER is) beacuse else you
> will get short sleep times with CONFIG_NO_HZ_IDLE on this system,
> and wake up unnecessarily often.
>
> The same goes for the clock event.
The clock frequency is 32768Hz. Should I be scaling it down at that frequency?
>
> See how we calculate the prescaler in arch/arm/mach-integrator/integrator_ap.c
> for example.
>
> Yours,
> Linus Walleij
Cheers,
Daniel Tang
next prev parent reply other threads:[~2013-05-14 11:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-12 4:22 [RFC PATCHv3 0/6] arm: Initial TI-Nspire support Daniel Tang
2013-05-12 4:22 ` [RFC PATCHv3 1/6] " Daniel Tang
2013-05-12 9:06 ` Russell King - ARM Linux
2013-05-12 9:22 ` Daniel Tang
2013-05-12 4:22 ` [RFC PATCHv3 2/6] arm: Add device trees for TI-Nspire Daniel Tang
2013-05-15 14:10 ` Arnd Bergmann
2013-05-12 4:22 ` [RFC PATCHv3 3/6] clk: Add TI-Nspire clock drivers Daniel Tang
2013-05-15 14:07 ` Arnd Bergmann
2013-05-16 8:31 ` Daniel Tang
2013-05-16 12:17 ` Arnd Bergmann
2013-05-19 11:09 ` Daniel Tang
2013-05-19 19:48 ` Arnd Bergmann
2013-05-20 11:19 ` Daniel Tang
2013-05-20 12:26 ` Arnd Bergmann
2013-05-12 4:22 ` [RFC PATCHv3 4/6] clocksource: Add TI-Nspire timer drivers Daniel Tang
2013-05-14 8:03 ` Linus Walleij
2013-05-14 11:51 ` Daniel Tang [this message]
2013-05-17 13:17 ` Linus Walleij
2013-05-18 6:40 ` Daniel Tang
2013-05-20 12:49 ` Linus Walleij
2013-05-12 4:23 ` [RFC PATCHv3 5/6] input: Add TI-Nspire keypad driver Daniel Tang
2013-05-12 4:23 ` [RFC PATCHv3 6/6] irqchip: Add TI-Nspire irqchip Daniel Tang
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=26FBB324-AAA9-4C10-8978-C2EC1C26672E@gmail.com \
--to=dt.tangr@gmail.com \
--cc=arnd@arndb.de \
--cc=fabian@ritter-vogt.de \
--cc=john.stultz@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=lionel_debroux@yahoo.fr \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®