diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-05-03 13:03:27 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-12-07 14:22:01 +0100 |
commit | 0a1f5df98e52b028bf8b4de3bf63e39702fa5f34 (patch) | |
tree | 7b3d8bfe7a9e760ee2bbb8916d3284f34edfec89 /bsps/sparc/leon3/start/cpucounter.c | |
parent | score: Avoid sbintime_t in API headers (diff) | |
download | rtems-0a1f5df98e52b028bf8b4de3bf63e39702fa5f34.tar.bz2 |
Simplify _CPU_Counter_difference()
In order to simplify the use of CPU counter values it is beneficial to
have monotonic increasing values within the range of the CPU counter
ticks data type, e.g. 32-bit unsigned integer. This eases the use of
CPU counter timestamps in external tools which do not know the details
of the CPU counter hardware. The CPU counter is the fastest way to get
a time on an RTEMS system.
Such a CPU counter may be also used as the timecounter. Use it on SPARC
for this purpose to simplify the clock drivers.
Update #3456.
Diffstat (limited to 'bsps/sparc/leon3/start/cpucounter.c')
-rw-r--r-- | bsps/sparc/leon3/start/cpucounter.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/bsps/sparc/leon3/start/cpucounter.c b/bsps/sparc/leon3/start/cpucounter.c index f583d9b0fb..007bb6d8ec 100644 --- a/bsps/sparc/leon3/start/cpucounter.c +++ b/bsps/sparc/leon3/start/cpucounter.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. + * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -29,46 +29,38 @@ static void leon3_counter_initialize(void) { volatile struct irqmp_timestamp_regs *irqmp_ts; volatile struct gptimer_regs *gpt; + SPARC_Counter *counter; irqmp_ts = &LEON3_IrqCtrl_Regs->timestamp[0]; gpt = LEON3_Timer_Regs; + counter = &_SPARC_Counter_mutable; leon3_up_counter_enable(); if (leon3_up_counter_is_available()) { /* Use the LEON4 up-counter if available */ - - _SPARC_Counter_initialize( - _SPARC_Counter_read_asr23, - _SPARC_Counter_difference_normal, - NULL - ); + counter->read_isr_disabled = _SPARC_Counter_read_asr23; + counter->read = _SPARC_Counter_read_asr23; leon3_counter_frequency = leon3_up_counter_frequency(); } else if (leon3_irqmp_has_timestamp(irqmp_ts)) { /* Use the interrupt controller timestamp counter if available */ + counter->read_isr_disabled = _SPARC_Counter_read_up; + counter->read = _SPARC_Counter_read_up; + counter->counter_register = &LEON3_IrqCtrl_Regs->timestamp[0].counter; /* Enable interrupt timestamping for an arbitrary interrupt line */ irqmp_ts->control = 0x1; - _SPARC_Counter_initialize( - _SPARC_Counter_read_address, - _SPARC_Counter_difference_normal, - (volatile const uint32_t *) &irqmp_ts->counter - ); - leon3_counter_frequency = ambapp_freq_get(&ambapp_plb, LEON3_IrqCtrl_Adev); } else if (gpt != NULL) { /* Fall back to the first GPTIMER if available */ + counter->read_isr_disabled = _SPARC_Counter_read_down; + counter->read = _SPARC_Counter_read_down; + counter->counter_register = &gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].value; /* Enable timer just in case no clock driver is configured */ - gpt->timer[LEON3_CLOCK_INDEX].ctrl |= GPTIMER_TIMER_CTRL_EN; - - _SPARC_Counter_initialize( - _SPARC_Counter_read_address, - _SPARC_Counter_difference_clock_period, - (volatile const uint32_t *) &gpt->timer[LEON3_CLOCK_INDEX].value - ); + gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].ctrl |= GPTIMER_TIMER_CTRL_EN; leon3_counter_frequency = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev) / (gpt->scaler_reload + 1); |