diff options
author | Daniel Hellstrom <daniel@gaisler.com> | 2015-02-19 10:06:54 +0100 |
---|---|---|
committer | Daniel Hellstrom <daniel@gaisler.com> | 2015-04-17 01:10:15 +0200 |
commit | 5da315ffdce891a2bb45d5b7ed3e6ae6cebef220 (patch) | |
tree | 78813b5186faf0c0ff08af84f9a57f47d6f858bb /c/src/lib/libbsp/sparc/leon3/amba/amba.c | |
parent | leon3: always clear interrupt controller (diff) | |
download | rtems-5da315ffdce891a2bb45d5b7ed3e6ae6cebef220.tar.bz2 |
leon3: make timer initialization configurable
Its now possible to select which timer core will be used for
system clock timer and to control the timer prescaler that
affects all timer instances on that timer core.
The timer and interrupt controller AMBA devices are exported
to make it possible for other code to get detailed information.
For example the frequency of the timer and interrupt controller
is required by the cpucounter support.
Diffstat (limited to 'c/src/lib/libbsp/sparc/leon3/amba/amba.c')
-rw-r--r-- | c/src/lib/libbsp/sparc/leon3/amba/amba.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c b/c/src/lib/libbsp/sparc/leon3/amba/amba.c index 9706b25791..8655ee3bb5 100644 --- a/c/src/lib/libbsp/sparc/leon3/amba/amba.c +++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c @@ -16,6 +16,9 @@ #include <leon.h> #include <ambapp.h> +unsigned int leon3_timer_prescaler __attribute__((weak)) = 0; +int leon3_timer_core_index __attribute__((weak)) = 0; + /* AMBA Plug&Play information description. * * After software has scanned AMBA PnP it builds a tree to make @@ -28,6 +31,8 @@ rtems_interrupt_lock LEON3_IrqCtrl_Lock = /* Pointers to Interrupt Controller configuration registers */ volatile struct irqmp_regs *LEON3_IrqCtrl_Regs; +struct ambapp_dev *irqmp_dev; +struct ambapp_dev *timer_dev; /* * amba_initialize @@ -64,6 +69,7 @@ void amba_initialize(void) } LEON3_IrqCtrl_Regs = (volatile struct irqmp_regs *)DEV_TO_APB(adev)->start; + irqmp_dev = adev; if ((LEON3_IrqCtrl_Regs->ampctrl >> 28) > 0) { /* IRQ Controller has support for multiple IRQ Controllers, each * CPU can be routed to different Controllers, we find out which @@ -84,16 +90,24 @@ void amba_initialize(void) /* find GP Timer */ adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), VENDOR_GAISLER, GAISLER_GPTIMER, - ambapp_find_by_idx, NULL); + ambapp_find_by_idx, &leon3_timer_core_index); if (adev) { LEON3_Timer_Regs = (volatile struct gptimer_regs *)DEV_TO_APB(adev)->start; + timer_dev = adev; /* Register AMBA Bus Frequency */ ambapp_freq_init( &ambapp_plb, - adev, + timer_dev, (LEON3_Timer_Regs->scaler_reload + 1) * LEON3_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER ); + /* Set user prescaler configuration. Use this to increase accuracy of timer + * and accociated services like cpucounter. + * Note that minimum value is the number of timer instances present in + * GRTIMER/GPTIMER hardware. See HW manual. + */ + if (leon3_timer_prescaler) + LEON3_Timer_Regs->scaler_reload = leon3_timer_prescaler; } } |