Changeset e51eb80 in rtems


Ignore:
Timestamp:
Feb 19, 2015, 8:25:09 AM (5 years ago)
Author:
Daniel Hellstrom <daniel@…>
Branches:
4.11, master
Children:
a31845f7
Parents:
5da315f
git-author:
Daniel Hellstrom <daniel@…> (02/19/15 08:25:09)
git-committer:
Daniel Hellstrom <daniel@…> (04/16/15 23:10:15)
Message:

leon3,ngmp: simplify cpucounter initialization

Remove support for using the second timer for time stamping.
Instead the user can configure the system clock timer to a higher
base clock frequency (lower the prescaler). This change does not
affect the GR712RC or LEON4-N2X. The GR712RC does not have two
GPTIMERs and the N2X uses the Interrupt Controller for time
stamping.

Bow that the AMBA initialization code exports the AMBA device,
the frequency can be obtained without an additional AMBA PnP
scanning.

File:
1 edited

Legend:

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

    r5da315f re51eb80  
    1717#include <rtems/counter.h>
    1818
    19 static volatile struct gptimer_regs *adev_to_gpt(struct ambapp_dev *adev)
    20 {
    21   return (volatile struct gptimer_regs *) DEV_TO_APB(adev)->start;
    22 }
    23 
    2419static CPU_Counter_ticks timestamp_counter_difference(
    2520  CPU_Counter_ticks second,
     
    2823{
    2924  return second - first;
    30 }
    31 
    32 static CPU_Counter_ticks free_counter_difference(
    33   CPU_Counter_ticks second,
    34   CPU_Counter_ticks first
    35 )
    36 {
    37   return first - second;
    3825}
    3926
     
    6754  volatile struct irqmp_timestamp_regs *irqmp_ts =
    6855    &LEON3_IrqCtrl_Regs->timestamp[0];
    69   struct ambapp_dev *adev;
    70   int idx = 1;
     56  unsigned int freq;
    7157
    7258  if (leon3_irqmp_has_timestamp(irqmp_ts)) {
     
    8268
    8369    /* Get and set the frequency */
    84     adev = (void *) ambapp_for_each(
    85       &ambapp_plb,
    86       OPTIONS_ALL | OPTIONS_APB_SLVS,
    87       VENDOR_GAISLER,
    88       GAISLER_IRQMP,
    89       ambapp_find_by_idx,
    90       NULL
    91     );
    92     rtems_counter_initialize_converter(ambapp_freq_get(&ambapp_plb, adev));
    93   } else {
    94     adev = (void *) ambapp_for_each(
    95       &ambapp_plb,
    96       OPTIONS_ALL | OPTIONS_APB_SLVS,
    97       VENDOR_GAISLER,
    98       GAISLER_GPTIMER,
    99       ambapp_find_by_idx,
    100       &idx
    101     );
    102     if (adev != NULL) {
    103       /* Use the second GPTIMER if available */
    104       volatile struct gptimer_regs *gpt = adev_to_gpt(adev);
    105       uint32_t max_frequency = ambapp_freq_get(&ambapp_plb, adev);
    106       unsigned min_prescaler = 8;
    107       uint32_t frequency = max_frequency / min_prescaler;
     70    rtems_counter_initialize_converter(ambapp_freq_get(&ambapp_plb, irqmp_dev));
     71  } else if (LEON3_Timer_Regs != NULL) {
     72      /* Fall back to the first GPTIMER if available */
     73      freq = ambapp_freq_get(&ambapp_plb, timer_dev);
    10874
    109       gpt->scaler_reload = min_prescaler - 1;
    110       gpt->timer[0].reload = 0xffffffff;
    111       gpt->timer[0].ctrl = GPTIMER_TIMER_CTRL_EN | GPTIMER_TIMER_CTRL_RS
    112         | GPTIMER_TIMER_CTRL_LD;
    113 
    114       gpt_counter_initialize(gpt, 0, frequency, free_counter_difference);
    115     } else if (LEON3_Timer_Regs != NULL) {
    116       /* Fall back to the first GPTIMER if available */
    11775      gpt_counter_initialize(
    11876        LEON3_Timer_Regs,
    11977        LEON3_CLOCK_INDEX,
    120         LEON3_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER,
     78        freq / (LEON3_Timer_Regs->scaler_reload - 1),
    12179        clock_counter_difference
    12280      );
    123     }
    12481  }
    12582}
Note: See TracChangeset for help on using the changeset viewer.