Changeset dc95663e in rtems for c/src/lib/libbsp/arm/tms570


Ignore:
Timestamp:
Mar 9, 2017, 1:14:42 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
b437a360
Parents:
5ca634e9
git-author:
Sebastian Huber <sebastian.huber@…> (03/09/17 13:14:42)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/09/17 13:17:52)
Message:

bsp/tms570: Fix CPU counter frequency

The CPU counter runs with the processor frequency. Use
RTEMS_SYSINIT_ITEM() to initialize the CPU counter.

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

Legend:

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

    r5ca634e9 rdc95663e  
    3030#include <bsp/irq.h>
    3131#include <bsp/tms570-rti.h>
    32 #include <rtems/counter.h>
    3332#include <rtems/timecounter.h>
    3433
     
    6867  microsec_per_tick = rtems_configuration_get_microseconds_per_tick();
    6968  tc_frequency = TMS570_PREFERRED_TC_FREQUENCY;
    70 
    71   rtems_counter_initialize_converter(BSP_PLL_OUT_CLOCK);
    7269
    7370  tc_prescaler = (BSP_PLL_OUT_CLOCK + tc_frequency) / (tc_frequency * 2);
  • c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c

    r5ca634e9 rdc95663e  
    2727 */
    2828
    29 #include <stdlib.h>
     29#include <rtems/counter.h>
     30#include <rtems/sysinit.h>
    3031
    31 #include <rtems.h>
    3232#include <bsp.h>
    33 
    34 static int cpu_counter_initialized;
    35 
    3633
    3734/**
     
    4441 * @retval Void
    4542 */
    46 static inline void _CPU_Counter_init_perfcounters(
     43static inline void tms570_init_perfcounters(
    4744    int32_t do_reset,
    4845    int32_t enable_divider
     
    8279 *
    8380 */
    84 static void _CPU_Counter_initialize(void)
     81static void tms570_cpu_counter_initialize(void)
    8582{
    86   rtems_interrupt_level level;
    87 
    88   rtems_interrupt_disable(level);
    89 
    90   if ( cpu_counter_initialized ) {
    91     rtems_interrupt_enable(level);
    92     return;
    93   }
    94 
    9583  /* enable user-mode access to the performance counter */
    9684  asm volatile ("mcr p15, 0, %0, c9, c14, 0\n\t" :: "r"(1));
     
    9987  asm volatile ("mcr p15, 0, %0, c9, c14, 2\n\t" :: "r"(0x8000000f));
    10088
    101   _CPU_Counter_init_perfcounters(false, false);
    102 
    103   cpu_counter_initialized = 1;
    104 
    105   rtems_interrupt_enable(level);
     89  tms570_init_perfcounters(false, false);
     90  rtems_counter_initialize_converter(2 * BSP_PLL_OUT_CLOCK);
    10691}
    10792
     
    117102{
    118103  uint32_t ticks;
    119   if ( !cpu_counter_initialized ) {
    120     _CPU_Counter_initialize();
    121   }
    122104  asm volatile ("mrc p15, 0, %0, c9, c13, 0\n": "=r" (ticks));
    123105  return ticks;
    124106}
     107
     108RTEMS_SYSINIT_ITEM(
     109  tms570_cpu_counter_initialize,
     110  RTEMS_SYSINIT_BSP_START,
     111  RTEMS_SYSINIT_ORDER_FIRST
     112);
Note: See TracChangeset for help on using the changeset viewer.