2013-12-02 14:07:35 -06:00
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup sparc_leon2
|
|
|
|
|
* @brief Clock Tick Device Driver
|
2006-01-09 10:36:06 +00:00
|
|
|
*
|
|
|
|
|
* This routine initializes LEON timer 1 which used for the clock tick.
|
|
|
|
|
*
|
|
|
|
|
* The tick frequency is directly programmed to the configured number of
|
|
|
|
|
* microseconds per tick.
|
2014-04-03 15:14:47 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
2008-05-07 17:40:52 +00:00
|
|
|
* COPYRIGHT (c) 1989-2008.
|
2006-01-09 10:36:06 +00:00
|
|
|
* On-Line Applications Research Corporation (OAR).
|
|
|
|
|
*
|
2006-11-16 16:31:34 +00:00
|
|
|
* Modified for LEON BSP
|
|
|
|
|
* COPYRIGHT (c) 2004.
|
|
|
|
|
* Gaisler Research.
|
|
|
|
|
*
|
2006-01-09 10:36:06 +00:00
|
|
|
* The license and distribution terms for this file may be
|
|
|
|
|
* found in the file LICENSE in this distribution or at
|
2014-03-21 08:10:47 +11:00
|
|
|
* http://www.rtems.org/license/LICENSE.
|
2006-01-09 10:36:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <bsp.h>
|
2006-11-16 16:31:34 +00:00
|
|
|
#include <bspopts.h>
|
2015-04-01 15:33:25 +02:00
|
|
|
#include <rtems/timecounter.h>
|
2016-06-22 13:45:02 +02:00
|
|
|
#include <rtems/score/sparcimpl.h>
|
2006-01-09 10:36:06 +00:00
|
|
|
|
2015-04-01 15:33:25 +02:00
|
|
|
static rtems_timecounter_simple leon2_tc;
|
|
|
|
|
|
|
|
|
|
static uint32_t leon2_tc_get( rtems_timecounter_simple *tc )
|
|
|
|
|
{
|
|
|
|
|
return LEON_REG.Timer_Counter_1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool leon2_tc_is_pending( rtems_timecounter_simple *tc )
|
|
|
|
|
{
|
|
|
|
|
return LEON_Is_interrupt_pending( LEON_INTERRUPT_TIMER1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static uint32_t leon2_tc_get_timecount( struct timecounter *tc )
|
|
|
|
|
{
|
|
|
|
|
return rtems_timecounter_simple_downcounter_get(
|
|
|
|
|
tc,
|
|
|
|
|
leon2_tc_get,
|
|
|
|
|
leon2_tc_is_pending
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-23 07:29:47 +01:00
|
|
|
static void leon2_tc_at_tick( rtems_timecounter_simple *tc )
|
|
|
|
|
{
|
|
|
|
|
/* Nothing to do */
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-01 15:33:25 +02:00
|
|
|
static void leon2_tc_tick( void )
|
|
|
|
|
{
|
2015-12-23 07:29:47 +01:00
|
|
|
rtems_timecounter_simple_downcounter_tick(
|
|
|
|
|
&leon2_tc,
|
|
|
|
|
leon2_tc_get,
|
|
|
|
|
leon2_tc_at_tick
|
|
|
|
|
);
|
2015-04-01 15:33:25 +02:00
|
|
|
}
|
|
|
|
|
|
2006-01-09 10:36:06 +00:00
|
|
|
/*
|
2006-11-16 16:31:34 +00:00
|
|
|
* The Real Time Clock Counter Timer uses this trap type.
|
2006-01-09 10:36:06 +00:00
|
|
|
*/
|
|
|
|
|
|
2006-11-16 16:31:34 +00:00
|
|
|
#define CLOCK_VECTOR LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 )
|
2006-01-09 10:36:06 +00:00
|
|
|
|
2017-09-18 08:22:38 +02:00
|
|
|
#define Clock_driver_support_install_isr( _new ) \
|
|
|
|
|
set_vector( _new, CLOCK_VECTOR, 1 )
|
2006-11-16 16:31:34 +00:00
|
|
|
|
|
|
|
|
extern int CLOCK_SPEED;
|
|
|
|
|
|
|
|
|
|
#define Clock_driver_support_initialize_hardware() \
|
|
|
|
|
do { \
|
2014-05-08 15:42:12 +02:00
|
|
|
LEON_REG.Timer_Reload_1 = \
|
2014-05-08 17:08:04 +02:00
|
|
|
rtems_configuration_get_microseconds_per_tick() - 1; \
|
2006-11-16 16:31:34 +00:00
|
|
|
\
|
|
|
|
|
LEON_REG.Timer_Control_1 = ( \
|
|
|
|
|
LEON_REG_TIMER_COUNTER_ENABLE_COUNTING | \
|
|
|
|
|
LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO | \
|
|
|
|
|
LEON_REG_TIMER_COUNTER_LOAD_COUNTER \
|
|
|
|
|
); \
|
2015-04-01 15:33:25 +02:00
|
|
|
rtems_timecounter_simple_install( \
|
|
|
|
|
&leon2_tc, \
|
|
|
|
|
1000000, \
|
|
|
|
|
rtems_configuration_get_microseconds_per_tick(), \
|
|
|
|
|
leon2_tc_get_timecount \
|
|
|
|
|
); \
|
2006-11-16 16:31:34 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
2015-04-01 15:33:25 +02:00
|
|
|
#define Clock_driver_timecounter_tick() leon2_tc_tick()
|
2008-05-07 17:40:52 +00:00
|
|
|
|
2018-04-19 06:35:52 +02:00
|
|
|
#include "../../../shared/dev/clock/clockimpl.h"
|
2016-06-20 10:08:39 +02:00
|
|
|
|
2016-06-22 13:45:02 +02:00
|
|
|
SPARC_COUNTER_DEFINITION;
|