On 02/24/2014 04:58 PM, Sebastian Huber wrote:
On 2014-02-24 16:45, Daniel Hellstrom wrote:
On 02/24/2014 04:16 PM, Sebastian Huber wrote:
On 2014-02-24 15:20, Daniel Hellstrom wrote:
Sebastian, I think it's a good solution to rely on the GPTIMER[0].timer0 as a
fallback.
Looks good to me, and should work on the TSIM/GRSIM and LEON3 hardware.
Assuming that the frequency has been initialized to 1MHz for secondary GPTIMER
may be wrong when invoked from a boot loader, however this can be fixed later
if determined a problem.
Thanks for the quick review. I checked in a slightly different version that
uses now only the first GPTIMER to determine the frequency:
http://git.rtems.org/rtems/commit/?id=a4bc90af4ee55e72b18de4b64da6338634490760
Ok. that is much better I think. But it is not 100% correct, you can not be
sure that the timers are clocked at the same frequency. To your help is the
function call:
freq_hz = ambapp_freq_get(&ambapp_plb, adev_gptimer1);
That will return the frequency of any APB or AHB device in the system, the call
can be made after the frequency of the AMBA bus have been initialized in
amba_initialize() calling ambapp_freq_init().
Ok, I used the clock driver as a reference:
#define Clock_driver_support_initialize_hardware() \
do { \
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = \
rtems_configuration_get_microseconds_per_tick() - 1; \
\
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].ctrl = \
LEON3_GPTIMER_EN | LEON3_GPTIMER_RL | \
LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN; \
} while (0)
It simply assumes that the frequency is 1MHz. Is it possible to use
ambapp_freq_get() here also?
No. Or Yes after amba_initialize(), however it is pointless since it defines the system frequency. It is from the GPTIMER[0].prescaler we get the frequency of the timer. By knowing where the timer's
frequency, we know the bus frequency, and from the PnP information we get the frequency of all AMBA devices by the relation between buses frequency.
Has the ambapp_freq_get() any dependencies to the boot loader?
Yes. A bootloader must have initialized GPTIMER[0].prescaler to 1MHz according to the "system frequency" or in some cases the "APB bus frequency" where the GPTIMER[0] is located. The timer is clocked
by the bus it is situated on. In some systems the CPU bus runs at 200MHz but the I/O bus in 50MHz for example, the relation in AMBA plug & play is a factor four in that case.
Basically we don't have to use AMBA PnP to search for GPTIMER[0], since we
assume that initialization has been performed by the system clock driver we
could might as well assume that the LEON3_Timer_Regs variable is initialized
too? The problem is that the CPU cycle counter is initialized before the timer
driver, but is that working for all other platform also or are we really sure
no other platform depend upon the system clock initialisation to complete?
The CPU counter should work before drivers are initialized.
Why is that? Is it useful during driver initilization or during system
initialization?
Daniel
_______________________________________________
rtems-devel mailing list
rtems-devel@rtems.org
http://www.rtems.org/mailman/listinfo/rtems-devel