Changeset a4ff2a2 in rtems


Ignore:
Timestamp:
Jun 21, 2016, 8:24:13 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
bc884f6
Parents:
291945f1
git-author:
Sebastian Huber <sebastian.huber@…> (06/21/16 08:24:13)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/21/16 13:54:18)
Message:

bsp/leon3: Add up counter timecounter

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

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/shared/include/fatal.h

    r291945f1 ra4ff2a2  
    11/*
    2  * Copyright (c) 2012-2015 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2012, 2016 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    5656  LEON3_FATAL_INVALID_CACHE_CONFIG_MAIN_PROCESSOR,
    5757  LEON3_FATAL_INVALID_CACHE_CONFIG_SECONDARY_PROCESSOR,
     58  LEON3_FATAL_CLOCK_NO_IRQMP_TIMESTAMP_SUPPORT,
    5859
    5960  /* LPC24XX fatal codes */
  • c/src/lib/libbsp/sparc/leon3/clock/ckinit.c

    r291945f1 ra4ff2a2  
    1313 *  COPYRIGHT (c) 2004.
    1414 *  Gaisler Research.
     15 *
     16 *  Copyright (c) 2014, 2016 embedded brains GmbH
    1517 *
    1618 *  The license and distribution terms for this file may be
     
    8082}
    8183#endif
     84
     85static uint32_t leon3_tc_get_timecount_up_counter(struct timecounter *tc)
     86{
     87  return leon3_up_counter_low();
     88}
    8289
    8390static uint32_t leon3_tc_get_timecount_irqmp(struct timecounter *tc)
     
    203210static void leon3_clock_initialize(void)
    204211{
    205   volatile struct irqmp_timestamp_regs *irqmp_ts =
    206     &LEON3_IrqCtrl_Regs->timestamp[0];
    207 
    208   LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload =
     212  volatile struct irqmp_timestamp_regs *irqmp_ts;
     213  volatile struct gptimer_regs *gpt;
     214
     215  irqmp_ts = &LEON3_IrqCtrl_Regs->timestamp[0];
     216  gpt = LEON3_Timer_Regs;
     217
     218  gpt->timer[LEON3_CLOCK_INDEX].reload =
    209219    rtems_configuration_get_microseconds_per_tick() - 1;
    210   LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].ctrl =
     220  gpt->timer[LEON3_CLOCK_INDEX].ctrl =
    211221    GPTIMER_TIMER_CTRL_EN | GPTIMER_TIMER_CTRL_RS |
    212222      GPTIMER_TIMER_CTRL_LD | GPTIMER_TIMER_CTRL_IE;
    213223
    214   if (leon3_irqmp_has_timestamp(irqmp_ts)) {
     224  leon3_up_counter_enable();
     225
     226  if (leon3_up_counter_is_available()) {
     227    /* Use the LEON4 up-counter if available */
     228    leon3_tc.tc.tc_get_timecount = leon3_tc_get_timecount_up_counter;
     229    leon3_tc.tc.tc_counter_mask = 0xffffffff;
     230    leon3_tc.tc.tc_frequency = leon3_up_counter_frequency();
     231    leon3_tc.tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
     232
     233#ifdef RTEMS_PROFILING
     234    if (!leon3_irqmp_has_timestamp(irqmp_ts)) {
     235      bsp_fatal(LEON3_FATAL_CLOCK_NO_IRQMP_TIMESTAMP_SUPPORT);
     236    }
     237#endif
     238
     239    leon3_tc_tick = leon3_tc_tick_irqmp_timestamp_init;
     240    rtems_timecounter_install(&leon3_tc.tc);
     241  } else if (leon3_irqmp_has_timestamp(irqmp_ts)) {
     242    /* Use the interrupt controller timestamp counter if available */
    215243    leon3_tc.tc.tc_get_timecount = leon3_tc_get_timecount_irqmp;
    216244    leon3_tc.tc.tc_counter_mask = 0xffffffff;
     
    226254     * in free running mode for the timecounter.
    227255     */
    228     LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX + 1].ctrl =
     256    gpt->timer[LEON3_CLOCK_INDEX + 1].ctrl =
    229257      GPTIMER_TIMER_CTRL_EN | GPTIMER_TIMER_CTRL_IE;
    230258    leon3_tc.tc.tc_get_timecount = leon3_tc_get_timecount_second_timer;
Note: See TracChangeset for help on using the changeset viewer.