Changeset 75acd9e in rtems for c/src/lib/libbsp/arm/beagle


Ignore:
Timestamp:
Apr 1, 2015, 1:33:25 PM (6 years ago)
Author:
Alexander Krutwig <alexander.krutwig@…>
Branches:
4.11, 5, master
Children:
a9c4f15d
Parents:
7cd2484
git-author:
Alexander Krutwig <alexander.krutwig@…> (04/01/15 13:33:25)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/20/15 06:40:34)
Message:

bsps: Convert clock drivers to use a timecounter

Update #2271.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/beagle/clock.c

    r7cd2484 r75acd9e  
    1616
    1717#include <rtems.h>
     18#include <rtems/timecounter.h>
    1819#include <bsp.h>
    1920
    2021#include <libcpu/omap_timer.h>
    2122
    22 #ifdef ARM_MULTILIB_ARCH_V4
     23static struct timecounter beagle_clock_tc;
    2324
    2425static omap_timer_registers_t regs_v1 = {
     
    116117#endif
    117118
    118 static int done = 0;
    119 
    120119#if IS_AM335X
    121120#define FRCLOCK_HZ (16*1500000)
     
    182181  mmio_set(fr_timer->base + fr_timer->regs->TCLR,
    183182      OMAP3_TCLR_OVF_TRG | OMAP3_TCLR_AR | OMAP3_TCLR_ST);
    184   done = 1;
    185 }
    186 
    187 static inline uint32_t
    188 read_frc(void)
    189 {
    190   if (done == 0) {
    191     return 0;
    192   }
     183}
     184
     185static uint32_t
     186beagle_clock_get_timecount(struct timecounter *tc)
     187{
    193188  return mmio_read(fr_timer->base + fr_timer->regs->TCRR);
    194189}
    195 
    196 static uint32_t last_tick_nanoseconds;
    197190
    198191static void
     
    263256#endif
    264257
     258  /* Install timecounter */ \
     259  beagle_clock_tc.tc_get_timecount = beagle_clock_get_timecount;
     260  beagle_clock_tc.tc_counter_mask = 0xffffffff;
     261  beagle_clock_tc.tc_frequency = FRCLOCK_HZ;
     262  beagle_clock_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
     263  rtems_timecounter_install(&beagle_clock_tc);
    265264}
    266265
    267266static void beagle_clock_at_tick(void)
    268267{
    269   last_tick_nanoseconds = read_frc();
    270 
    271268  mmio_write(timer->base + timer->regs->TISR,
    272269    OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG |
     
    316313}
    317314
    318 static inline uint32_t beagle_clock_nanoseconds_since_last_tick(void)
    319 {
    320   /* this arithmetic also works if read_frc() wraps around, as long
    321    * as the subtraction wraps around too
    322    */
    323   return (read_frc() - (uint64_t) last_tick_nanoseconds) * 1000000000 / FRCLOCK_HZ;
    324 }
    325 
    326315#define Clock_driver_support_at_tick() beagle_clock_at_tick()
    327316#define Clock_driver_support_initialize_hardware() beagle_clock_initialize()
     
    333322
    334323#define Clock_driver_support_shutdown_hardware() beagle_clock_cleanup()
    335 #define Clock_driver_nanoseconds_since_last_tick \
    336   beagle_clock_nanoseconds_since_last_tick
    337324
    338325/* Include shared source clock driver code */
    339326#include "../../shared/clockdrv_shell.h"
    340 
    341 #endif /* ARM_MULTILIB_ARCH_V4 */
Note: See TracChangeset for help on using the changeset viewer.