Changeset c19342a7 in rtems for c/src/lib/libbsp


Ignore:
Timestamp:
Jun 5, 2014, 2:19:21 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
dc44de7
Parents:
1468d70
git-author:
Sebastian Huber <sebastian.huber@…> (06/05/14 14:19:21)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/06/14 06:02:10)
Message:

bsps/arm: Fix Cortex-A9 MPCore clock driver

The nanoseconds extension returned wrong values on secondary processors
since some of the global timer registeres are banked. Use global
variables instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/shared/arm-a9mpcore-clock-config.c

    r1468d70 rc19342a7  
    2525static uint64_t a9mpcore_clock_last_tick_k;
    2626
     27static uint32_t a9mpcore_clock_last_tick_cmpvallower;
     28
     29static uint32_t a9mpcore_clock_autoinc;
     30
    2731/* This is defined in clockdrv_shell.h */
    2832void Clock_isr(rtems_irq_hdl_param arg);
     
    3741{
    3842  volatile a9mpcore_gt *gt = A9MPCORE_GT;
     43
     44  /*
     45   * FIXME: Now the _TOD_Get_with_nanoseconds() yields wrong values until
     46   * _TOD_Tickle_ticks() managed to update the uptime.  See also PR2180.
     47   */
     48  a9mpcore_clock_last_tick_cmpvallower =
     49    gt->cmpvallower - a9mpcore_clock_autoinc;
    3950
    4051  gt->irqst = A9MPCORE_GT_IRQST_EFLG;
     
    8091  uint64_t cmpval;
    8192
    82   a9mpcore_clock_last_tick_k = (UINT64_C(1000000000) << 32) / periphclk;
    83 
    8493  gt->ctrl &= A9MPCORE_GT_CTRL_TMR_EN;
    8594  gt->irqst = A9MPCORE_GT_IRQST_EFLG;
     
    91100  gt->cmpvalupper = (uint32_t) (cmpval >> 32);
    92101  gt->autoinc = interval;
     102
     103  a9mpcore_clock_last_tick_k = (UINT64_C(1000000000) << 32) / periphclk;
     104  a9mpcore_clock_last_tick_cmpvallower = (uint32_t) cmpval - interval;
     105  a9mpcore_clock_autoinc = interval;
     106
    93107  gt->ctrl = A9MPCORE_GT_CTRL_AUTOINC_EN
    94108    | A9MPCORE_GT_CTRL_IRQ_EN
     
    142156  volatile a9mpcore_gt *gt = A9MPCORE_GT;
    143157  uint64_t k = a9mpcore_clock_last_tick_k;
     158  uint32_t n = a9mpcore_clock_last_tick_cmpvallower;
    144159  uint32_t c = gt->cntrlower;
    145   uint32_t n = gt->cmpvallower;
    146   uint32_t i = gt->autoinc;
    147160
    148   if ((gt->irqst & A9MPCORE_GT_IRQST_EFLG) != 0) {
    149     n = gt->cmpvallower - i;
    150   }
    151 
    152   return (uint32_t) (((c - n + i) * k) >> 32);
     161  return (uint32_t) (((c - n) * k) >> 32);
    153162}
    154163
Note: See TracChangeset for help on using the changeset viewer.