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

5
Last change on this file since e2bd1f6 was e2bd1f6, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 21, 2018 at 3:38:43 PM

bsp/bfin: Move libcpu content to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 1.7 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 <bsp.h>
19#include <rtems/clockdrv.h>
20
21
22#include <libcpu/cecRegs.h>
23#include <libcpu/coreTimerRegs.h>
24
25#if (BFIN_ON_SKYEYE)
26#define CLOCK_DRIVER_USE_FAST_IDLE 1
27#endif
28
29volatile uint32_t Clock_driver_ticks;
30
31void Clock_exit(void);
32
33static rtems_isr clockISR(rtems_vector_number vector) {
34
35  Clock_driver_ticks += 1;
36
37#if CLOCK_DRIVER_USE_FAST_IDLE
38  do {
39    rtems_clock_tick();
40  } while ( _Thread_Heir == _Thread_Executing && _Thread_Executing->is_idle );
41#else
42  rtems_clock_tick();
43#endif
44}
45
46/*
47 *  Clock_exit
48 *
49 *  This routine allows the clock driver to exit by masking the interrupt and
50 *  disabling the clock's counter.
51 */
52void Clock_exit(void)
53{
54  *(uint32_t volatile *) TCNTL = 0;
55}
56
57/*
58 *  Clock_initialize
59 *
60 *  This routine initializes the clock driver.
61 */
62rtems_device_driver Clock_initialize(
63  rtems_device_major_number major,
64  rtems_device_minor_number minor,
65  void *pargp
66)
67{
68  Clock_driver_ticks = 0;
69
70  set_vector(clockISR, CEC_CORE_TIMER_VECTOR, 1);
71
72  *(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD;
73  *(uint32_t volatile *) TSCALE = 0;
74  *(uint32_t volatile *) TPERIOD = CCLK / 1000000 *
75      rtems_configuration_get_microseconds_per_tick();
76  *(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD | TCNTL_TMREN;
77
78  atexit(Clock_exit);
79
80  return RTEMS_SUCCESSFUL;
81}
Note: See TracBrowser for help on using the repository browser.