Changeset 5a0b27ed in rtems


Ignore:
Timestamp:
Mar 15, 2016, 1:29:15 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
78c9fe8
Parents:
057154e
git-author:
Sebastian Huber <sebastian.huber@…> (03/15/16 13:29:15)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/15/16 13:32:16)
Message:

bsp/leon3: Clock driver workaround for GR712RC

File:
1 edited

Legend:

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

    r057154e r5a0b27ed  
    4242static int clkirq;
    4343
    44 static bool leon3_tc_use_irqmp;
     44static void (*leon3_tc_tick)(void);
    4545
    4646static rtems_timecounter_simple leon3_tc;
    4747
     48#ifndef RTEMS_SMP
    4849static uint32_t leon3_tc_get(rtems_timecounter_simple *tc)
    4950{
     
    5455{
    5556  return LEON_Is_interrupt_pending(clkirq);
     57}
     58
     59static void leon3_tc_at_tick( rtems_timecounter_simple *tc )
     60{
     61  /* Nothing to do */
    5662}
    5763
     
    6571}
    6672
     73static void leon3_tc_tick_simple(void)
     74{
     75  rtems_timecounter_simple_downcounter_tick(
     76    &leon3_tc,
     77    leon3_tc_get,
     78    leon3_tc_at_tick
     79  );
     80}
     81#endif
     82
    6783static uint32_t leon3_tc_get_timecount_irqmp(struct timecounter *tc)
    6884{
     
    7086}
    7187
    72 static void leon3_clock_profiling_interrupt_delay(void)
     88#ifdef RTEMS_SMP
     89static uint32_t leon3_tc_get_timecount_second_timer(struct timecounter *tc)
     90{
     91  return 0xffffffff - LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX + 1].value;
     92}
     93#endif
     94
     95static void leon3_tc_tick_irqmp_timestamp(void)
    7396{
    7497#ifdef RTEMS_PROFILING
     
    91114
    92115    _Profiling_Update_max_interrupt_delay(_Per_CPU_Get(), second - first);
    93   } else if (state == 1 && leon3_irqmp_has_timestamp(irqmp_ts)) {
     116  } else if (state == 1) {
    94117    unsigned int ks = 1U << 5;
    95118
     
    101124  }
    102125#endif
    103 }
    104 
    105 static void leon3_tc_at_tick( rtems_timecounter_simple *tc )
    106 {
    107   leon3_clock_profiling_interrupt_delay();
    108 }
    109 
    110 static void leon3_tc_tick(void)
    111 {
    112   if (leon3_tc_use_irqmp) {
    113     leon3_clock_profiling_interrupt_delay();
    114     rtems_timecounter_tick();
    115   } else {
    116     rtems_timecounter_simple_downcounter_tick(
    117       &leon3_tc,
    118       leon3_tc_get,
    119       leon3_tc_at_tick
    120     );
    121   }
     126
     127  rtems_timecounter_tick();
     128}
     129
     130#ifdef RTEMS_SMP
     131static void leon3_tc_tick_second_timer(void)
     132{
     133  rtems_timecounter_tick();
     134}
     135#endif
     136
     137static void leon3_tc_do_tick(void)
     138{
     139  (*leon3_tc_tick)();
    122140}
    123141
     
    184202    leon3_tc.tc.tc_frequency = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev);
    185203    leon3_tc.tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
    186     leon3_tc_use_irqmp = true;
     204    leon3_tc_tick = leon3_tc_tick_irqmp_timestamp;
    187205    rtems_timecounter_install(&leon3_tc.tc);
    188206  } else {
     207#ifdef RTEMS_SMP
     208    /*
     209     * The GR712RC for example has no timestamp unit in the interrupt
     210     * controller.  At least on SMP configurations we must use a second timer
     211     * in free running mode for the timecounter.
     212     */
     213    LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX + 1].ctrl =
     214      GPTIMER_TIMER_CTRL_EN | GPTIMER_TIMER_CTRL_IE;
     215    leon3_tc.tc.tc_get_timecount = leon3_tc_get_timecount_second_timer;
     216    leon3_tc.tc.tc_counter_mask = 0xffffffff;
     217    leon3_tc.tc.tc_frequency = LEON3_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER;
     218    leon3_tc.tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
     219    leon3_tc_tick = leon3_tc_tick_second_timer;
     220    rtems_timecounter_install(&leon3_tc.tc);
     221#else
     222    leon3_tc_tick = leon3_tc_tick_simple;
    189223    rtems_timecounter_simple_install(
    190224      &leon3_tc,
     
    193227      leon3_tc_get_timecount
    194228    );
     229#endif
    195230  }
    196231}
     
    205240  } while (0)
    206241
    207 #define Clock_driver_timecounter_tick() leon3_tc_tick()
     242#define Clock_driver_timecounter_tick() leon3_tc_do_tick()
    208243
    209244#include "../../../shared/clockdrv_shell.h"
Note: See TracChangeset for help on using the changeset viewer.