linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/11] ARM: timer-sp: convert to use CLKSRC_OF init
Date: Thu, 21 Mar 2013 21:31:01 -0500	[thread overview]
Message-ID: <514BC265.7080204@gmail.com> (raw)
In-Reply-To: <20130321193549.GS4977@n2100.arm.linux.org.uk>

On 03/21/2013 02:35 PM, Russell King - ARM Linux wrote:
> On Wed, Mar 20, 2013 at 05:54:03PM -0500, Rob Herring wrote:
>> +	clk0 = of_clk_get(np, 0);
>> +	if (IS_ERR(clk0))
>> +		clk0 = NULL;
>> +
>> +	/* Get the 2nd clock if the timer has 2 timer clocks */
>> +	if (of_count_phandle_with_args(np, "clocks", "#clock-cells") == 3) {
>> +		clk1 = of_clk_get(np, 1);
>> +		if (IS_ERR(clk1)) {
>> +			pr_err("sp804: %s clock not found: %d\n", np->name,
>> +				(int)PTR_ERR(clk1));
>> +			return;
>> +		}
>> +	} else
>> +		clk1 = clk0;
>> +
>> +	irq = irq_of_parse_and_map(np, 0);
>> +	if (irq <= 0)
>> +		return;
>> +
>> +	of_property_read_u32(np, "arm,sp804-has-irq", &irq_num);
>> +	if (irq_num == 2)
>> +		tmr2_evt = true;
>> +
>> +	__sp804_clockevents_init(base + (tmr2_evt ? TIMER_2_BASE : 0),
>> +				 irq, tmr2_evt ? clk1 : clk0, name);
>> +	__sp804_clocksource_and_sched_clock_init(base + (tmr2_evt ? 0 : TIMER_2_BASE),
>> +						 name, tmr2_evt ? clk0 : clk1, 1);
> 
> This just looks totally screwed to me.
> 
> A SP804 cell has two timers, and has one clock input and two clock
> enable inputs.  The clock input is common to both timers.  The timers
> only count on the rising edge of the clock input when the enable
> input is high.  (the APB PCLK also matters too...)
> 
> Now, the clock enable inputs are controlled by the SP810 system
> controller to achieve different clock rates for each.  So, we *can*
> view an SP804 as having two clock inputs.

Exactly. Effectively, the TIMCLKENx are just dividers of the clock input.

> However, the two clock inputs do not depend on whether one or the
> other has an IRQ or not.  Timer 1 is always clocked by TIMCLK &
> TIMCLKEN1.  Timer 2 is always clocked by TIMCLK & TIMCLKEN2.
> 
> Using the logic above, the clocks depend on how the IRQs are wired
> up... really?  Can you see from my description above why that is
> screwed?  What bearing does the IRQ have on the wiring of the
> clock inputs?

No. I'm simply swapping which timer is used for clksrc vs. clkevt based
on the irq connection DT describes. If only timer 2's irq being hooked
up, then timer 2 is the clkevt. Otherwise I always use timer 1 for the
clkevt because I either have a combined interrupt or timer 1 interrupt
hooked up.

Perhaps re-writing it like this would be more clear:

if (irq_num == 2){
	__sp804_clockevents_init(base + TIMER_2_BASE, irq, clk1, name);
	__sp804_clocksource_and_sched_clock_init(base, name, clk0, 1);
} else {
	__sp804_clockevents_init(base, irq, clk0, name);
	__sp804_clocksource_and_sched_clock_init(base + TIMER_2_BASE,
						name, clk1, 1);
}


Rob

  reply	other threads:[~2013-03-22  2:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20 22:54 [PATCH 00/11] sp804 and integrator timer CLKSRC_OF support Rob Herring
2013-03-20 22:54 ` [PATCH 01/11] OF: add empty of_device_is_available for !OF Rob Herring
2013-03-21 14:18   ` Mark Rutland
2013-03-21 14:26     ` Rob Herring
2013-03-20 22:54 ` [PATCH 02/11] ARM: remove extra timer-sp control register clearing Rob Herring
2013-03-21 17:58   ` Linus Walleij
2013-03-21 18:03     ` Rob Herring
2013-03-21 19:23   ` Russell King - ARM Linux
2013-03-22  2:36     ` Rob Herring
2013-03-20 22:54 ` [PATCH 03/11] ARM: timer-sp: convert to use CLKSRC_OF init Rob Herring
2013-03-21 18:02   ` Linus Walleij
2013-03-21 19:35   ` Russell King - ARM Linux
2013-03-22  2:31     ` Rob Herring [this message]
2013-03-22 11:49       ` Russell King - ARM Linux
2013-03-20 22:54 ` [PATCH 04/11] ARM: highbank: use OF init for sp804 timer Rob Herring
2013-03-20 22:54 ` [PATCH 05/11] ARM: vexpress: remove sp804 OF init Rob Herring
2013-03-20 22:54 ` [PATCH 06/11] ARM: dts: vexpress: disable CA9 core tile sp804 timer Rob Herring
2013-03-20 22:54 ` [PATCH 07/11] ARM: versatile: add versatile dtbs to dtbs target Rob Herring
2013-03-20 22:54 ` [PATCH 08/11] ARM: versatile: use OF init for sp804 timer Rob Herring
2013-03-20 22:54 ` [PATCH 09/11] ARM: integrator-cp: convert use CLKSRC_OF for timer init Rob Herring
2013-03-21 18:07   ` Linus Walleij
2013-03-20 22:54 ` [PATCH 10/11] ARM: move sp804 and integrator timers to drivers/clocksource Rob Herring
2013-03-21 18:15   ` Linus Walleij
2013-03-20 22:54 ` [PATCH 11/11] devtree: add binding documentation for sp804 Rob Herring
2013-03-21 19:36   ` Russell King - ARM Linux
2013-03-21 13:24 ` [PATCH 00/11] sp804 and integrator timer CLKSRC_OF support Arnd Bergmann
2013-03-21 14:06   ` Rob Herring

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=514BC265.7080204@gmail.com \
    --to=robherring2@gmail.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).