18 #include <rtems/sysinit.h> 19 #include <rtems/score/sparcimpl.h> 21 static uint32_t leon3_counter_frequency = 1000000000;
23 uint32_t _CPU_Counter_frequency(
void)
25 return leon3_counter_frequency;
28 static void leon3_counter_initialize(
void)
34 irqmp_ts = &LEON3_IrqCtrl_Regs->timestamp[0];
35 gpt = LEON3_Timer_Regs;
36 counter = &_SPARC_Counter_mutable;
38 leon3_up_counter_enable();
40 if (leon3_up_counter_is_available()) {
42 counter->read_isr_disabled = _SPARC_Counter_read_asr23;
43 counter->read = _SPARC_Counter_read_asr23;
45 leon3_counter_frequency = leon3_up_counter_frequency();
46 }
else if (leon3_irqmp_has_timestamp(irqmp_ts)) {
48 counter->read_isr_disabled = _SPARC_Counter_read_up;
49 counter->read = _SPARC_Counter_read_up;
50 counter->counter_register = &LEON3_IrqCtrl_Regs->timestamp[0].counter;
53 irqmp_ts->control = 0x1;
55 leon3_counter_frequency = ambapp_freq_get(&ambapp_plb, LEON3_IrqCtrl_Adev);
56 }
else if (gpt != NULL) {
58 counter->read_isr_disabled = _SPARC_Counter_read_down;
59 counter->read = _SPARC_Counter_read_down;
60 counter->counter_register = &gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].value;
63 gpt->timer[LEON3_COUNTER_GPTIMER_INDEX].ctrl |= GPTIMER_TIMER_CTRL_EN;
65 leon3_counter_frequency = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev) /
66 (gpt->scaler_reload + 1);
71 leon3_counter_initialize,
72 RTEMS_SYSINIT_CPU_COUNTER,
73 RTEMS_SYSINIT_ORDER_FIRST
76 SPARC_COUNTER_DEFINITION;
LEON3 BSP data types and macros.
Free-Running Counter and Busy Wait Delay API.