Changeset 5da315f in rtems


Ignore:
Timestamp:
Feb 19, 2015, 9:06:54 AM (5 years ago)
Author:
Daniel Hellstrom <daniel@…>
Branches:
4.11, master
Children:
e51eb80
Parents:
ead16ae1
git-author:
Daniel Hellstrom <daniel@…> (02/19/15 09:06:54)
git-committer:
Daniel Hellstrom <daniel@…> (04/16/15 23:10:15)
Message:

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.

Location:
c/src/lib/libbsp/sparc/leon3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/leon3/amba/amba.c

    read16ae1 r5da315f  
    1717#include <ambapp.h>
    1818
     19unsigned int leon3_timer_prescaler __attribute__((weak)) = 0;
     20int leon3_timer_core_index __attribute__((weak)) = 0;
     21
    1922/* AMBA Plug&Play information description.
    2023 *
     
    2932/* Pointers to Interrupt Controller configuration registers */
    3033volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
     34struct ambapp_dev *irqmp_dev;
     35struct ambapp_dev *timer_dev;
    3136
    3237/*
     
    6570
    6671  LEON3_IrqCtrl_Regs = (volatile struct irqmp_regs *)DEV_TO_APB(adev)->start;
     72  irqmp_dev = adev;
    6773  if ((LEON3_IrqCtrl_Regs->ampctrl >> 28) > 0) {
    6874    /* IRQ Controller has support for multiple IRQ Controllers, each
     
    8591  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
    8692                                 VENDOR_GAISLER, GAISLER_GPTIMER,
    87                                  ambapp_find_by_idx, NULL);
     93                                 ambapp_find_by_idx, &leon3_timer_core_index);
    8894  if (adev) {
    8995    LEON3_Timer_Regs = (volatile struct gptimer_regs *)DEV_TO_APB(adev)->start;
     96    timer_dev = adev;
    9097
    9198    /* Register AMBA Bus Frequency */
    9299    ambapp_freq_init(
    93100      &ambapp_plb,
    94       adev,
     101      timer_dev,
    95102      (LEON3_Timer_Regs->scaler_reload + 1)
    96103        * LEON3_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER
    97104    );
     105    /* Set user prescaler configuration. Use this to increase accuracy of timer
     106     * and accociated services like cpucounter.
     107     * Note that minimum value is the number of timer instances present in
     108     * GRTIMER/GPTIMER hardware. See HW manual.
     109     */
     110    if (leon3_timer_prescaler)
     111      LEON3_Timer_Regs->scaler_reload = leon3_timer_prescaler;
    98112  }
    99113}
  • c/src/lib/libbsp/sparc/leon3/include/leon.h

    read16ae1 r5da315f  
    9595/* LEON3 Interrupt Controller */
    9696extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
     97extern struct ambapp_dev *irqmp_dev;
     98
    9799/* LEON3 GP Timer */
    98100extern volatile struct gptimer_regs *LEON3_Timer_Regs;
     101extern struct ambapp_dev *timer_dev;
    99102
    100103/* LEON3 CPU Index of boot CPU */
     
    309312extern int debug_uart_index;
    310313
     314/* Let user override which on-chip TIMER core will be used for system clock
     315 * timer. This controls which timer core will be accociated with
     316 * LEON3_Timer_Regs registers base address. This value will by destroyed during
     317 * initialization.
     318 *  0 = Default configuration. GPTIMER[0]
     319 *  1 = GPTIMER[1]
     320 *  2 = GPTIMER[2]
     321 *  ...
     322 */
     323extern int leon3_timer_core_index;
     324
     325/* Let user override system clock timer prescaler. This affects all timer
     326 * instances on the system clock timer core determined by
     327 * leon3_timer_core_index.
     328 *  0 = Default configuration. Use bootloader configured value.
     329 *  N = Prescaler is set to N. N must not be less that number of timers.
     330 *  8 = Prescaler is set to 8 (the fastest prescaler possible on all HW)
     331 *  ...
     332 */
     333extern unsigned int leon3_timer_prescaler;
     334
    311335void leon3_cpu_counter_initialize(void);
    312336
Note: See TracChangeset for help on using the changeset viewer.