source: rtems/bsps/bfin/shared/dev/clock.c @ bb99cd0d

5
Last change on this file since bb99cd0d was bb99cd0d, checked in by Sebastian Huber <sebastian.huber@…>, on 12/05/19 at 18:22:33

clock: Simplify driver initialization

Use a system initialization handler instead of a legacy IO driver.

Update #3834.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*  RTEMS Clock Tick Driver for Blackfin.  Uses Blackfin Core Timer.
2 */
3
4/*
5 *  Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA
6 *             written by Allan Hessenflow <allanh@kallisti.com>
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.org/license/LICENSE.
11 */
12
13
14#include <rtems.h>
15#include <stdlib.h>
16#include <rtems/libio.h>
17#include <rtems/score/percpu.h>
18#include <rtems/score/thread.h>
19#include <bsp.h>
20#include <rtems/clockdrv.h>
21
22
23#include <libcpu/cecRegs.h>
24#include <libcpu/coreTimerRegs.h>
25
26#if (BFIN_ON_SKYEYE)
27#define CLOCK_DRIVER_USE_FAST_IDLE 1
28#endif
29
30volatile uint32_t Clock_driver_ticks;
31
32static rtems_isr clockISR(rtems_vector_number vector) {
33
34  Clock_driver_ticks += 1;
35
36#if CLOCK_DRIVER_USE_FAST_IDLE
37  do {
38    rtems_clock_tick();
39  } while ( _Thread_Heir == _Thread_Executing && _Thread_Executing->is_idle );
40#else
41  rtems_clock_tick();
42#endif
43}
44
45/*
46 *  Clock_exit
47 *
48 *  This routine allows the clock driver to exit by masking the interrupt and
49 *  disabling the clock's counter.
50 */
51static void Clock_exit(void)
52{
53  *(uint32_t volatile *) TCNTL = 0;
54}
55
56void _Clock_Initialize( void )
57{
58  Clock_driver_ticks = 0;
59
60  set_vector(clockISR, CEC_CORE_TIMER_VECTOR, 1);
61
62  *(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD;
63  *(uint32_t volatile *) TSCALE = 0;
64  *(uint32_t volatile *) TPERIOD = CCLK / 1000000 *
65      rtems_configuration_get_microseconds_per_tick();
66  *(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD | TCNTL_TMREN;
67
68  atexit(Clock_exit);
69}
Note: See TracBrowser for help on using the repository browser.