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 03/21/18 at 15:38:43

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
RevLine 
[30abd24]1/*  RTEMS Clock Tick Driver for Blackfin.  Uses Blackfin Core Timer.
[e827199]2 */
3
4/*
[30abd24]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
[c499856]10 *  http://www.rtems.org/license/LICENSE.
[30abd24]11 */
[359e537]12
[30abd24]13
14#include <rtems.h>
15#include <stdlib.h>
16#include <rtems/libio.h>
[48fed9a]17#include <rtems/score/percpu.h>
[30abd24]18#include <bsp.h>
[6b597c39]19#include <rtems/clockdrv.h>
20
[30abd24]21
22#include <libcpu/cecRegs.h>
23#include <libcpu/coreTimerRegs.h>
24
[44237e3c]25#if (BFIN_ON_SKYEYE)
[d473dc0]26#define CLOCK_DRIVER_USE_FAST_IDLE 1
[44237e3c]27#endif
[30abd24]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
[d473dc0]37#if CLOCK_DRIVER_USE_FAST_IDLE
[30abd24]38  do {
39    rtems_clock_tick();
[1f5bee3]40  } while ( _Thread_Heir == _Thread_Executing && _Thread_Executing->is_idle );
[30abd24]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 */
[e827199]52void Clock_exit(void)
53{
[30abd24]54  *(uint32_t volatile *) TCNTL = 0;
55}
56
57/*
58 *  Clock_initialize
59 *
60 *  This routine initializes the clock driver.
61 */
[e827199]62rtems_device_driver Clock_initialize(
63  rtems_device_major_number major,
64  rtems_device_minor_number minor,
65  void *pargp
66)
67{
[30abd24]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.