source: rtems/c/src/lib/libbsp/sparc/leon2/clock/ckinit.c @ de7b174e

Last change on this file since de7b174e was de7b174e, checked in by Joel Sherrill <joel@…>, on Nov 15, 2016 at 6:19:39 PM

Remove sparc/sis BSP.

closes #2810.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/**
2 * @file
3 * @ingroup sparc_leon2
4 * @brief Clock Tick Device Driver
5 *
6 *  This routine initializes LEON timer 1 which used for the clock tick.
7 *
8 *  The tick frequency is directly programmed to the configured number of
9 *  microseconds per tick.
10 */
11
12/*
13 *  COPYRIGHT (c) 1989-2008.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  Modified for LEON BSP
17 *  COPYRIGHT (c) 2004.
18 *  Gaisler Research.
19 *
20 *  The license and distribution terms for this file may be
21 *  found in the file LICENSE in this distribution or at
22 *  http://www.rtems.org/license/LICENSE.
23 */
24
25#include <bsp.h>
26#include <bspopts.h>
27#include <rtems/timecounter.h>
28#include <rtems/score/sparcimpl.h>
29
30static rtems_timecounter_simple leon2_tc;
31
32static uint32_t leon2_tc_get( rtems_timecounter_simple *tc )
33{
34  return LEON_REG.Timer_Counter_1;
35}
36
37static bool leon2_tc_is_pending( rtems_timecounter_simple *tc )
38{
39  return LEON_Is_interrupt_pending( LEON_INTERRUPT_TIMER1 );
40}
41
42static uint32_t leon2_tc_get_timecount( struct timecounter *tc )
43{
44  return rtems_timecounter_simple_downcounter_get(
45    tc,
46    leon2_tc_get,
47    leon2_tc_is_pending
48  );
49}
50
51static void leon2_tc_at_tick( rtems_timecounter_simple *tc )
52{
53  /* Nothing to do */
54}
55
56static void leon2_tc_tick( void )
57{
58  rtems_timecounter_simple_downcounter_tick(
59    &leon2_tc,
60    leon2_tc_get,
61    leon2_tc_at_tick
62  );
63}
64
65/*
66 *  The Real Time Clock Counter Timer uses this trap type.
67 */
68
69#define CLOCK_VECTOR LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 )
70
71#define Clock_driver_support_install_isr( _new, _old ) \
72  do { \
73    _old = set_vector( _new, CLOCK_VECTOR, 1 ); \
74  } while(0)
75
76extern int CLOCK_SPEED;
77
78#define Clock_driver_support_initialize_hardware() \
79  do { \
80    LEON_REG.Timer_Reload_1 = \
81        rtems_configuration_get_microseconds_per_tick() - 1; \
82    \
83    LEON_REG.Timer_Control_1 = ( \
84      LEON_REG_TIMER_COUNTER_ENABLE_COUNTING |  \
85        LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO | \
86        LEON_REG_TIMER_COUNTER_LOAD_COUNTER  \
87    ); \
88    rtems_timecounter_simple_install( \
89      &leon2_tc, \
90      1000000, \
91      rtems_configuration_get_microseconds_per_tick(), \
92      leon2_tc_get_timecount \
93    ); \
94  } while (0)
95
96#define Clock_driver_support_shutdown_hardware() \
97  do { \
98    LEON_Mask_interrupt( LEON_INTERRUPT_TIMER1 ); \
99    LEON_REG.Timer_Control_1 = 0; \
100  } while (0)
101
102#define Clock_driver_timecounter_tick() leon2_tc_tick()
103
104#include "../../../shared/clockdrv_shell.h"
105
106SPARC_COUNTER_DEFINITION;
Note: See TracBrowser for help on using the repository browser.