source: rtems/c/src/lib/libcpu/arm/pxa255/clock/clock.c @ 358522d

4.115
Last change on this file since 358522d was 358522d, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 17:46:21

Libcpu misc files - Remove execute permission on source files.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 *  By Yang Xi <hiyangxi@gmail.com>
3 *  PXA255 clock specific using the System Timer
4 *
5 *  RTEMS uses IRQ 26 as Clock Source
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#include <rtems.h>
13#include <rtems/clockdrv.h>
14#include <rtems/libio.h>
15
16#include <stdlib.h>
17#include <bsp.h>
18#include <bspopts.h>
19#include <bsp/irq.h>
20#include <pxa255.h>
21
22#if ON_SKYEYE==1
23  #define CLOCK_DRIVER_USE_FAST_IDLE
24#endif
25
26static unsigned long period_num;
27
28/**
29 *  Return the nanoseconds since last tick
30 */
31uint32_t clock_driver_get_nanoseconds_since_last_tick(void)
32{
33  return 0;
34}
35
36#define Clock_driver_nanoseconds_since_last_tick \
37  clock_driver_get_nanoseconds_since_last_tick
38
39/**
40 * Enables clock interrupt.
41 *
42 * If the interrupt is always on, this can be a NOP.
43 */
44static void clock_isr_on(const rtems_irq_connect_data *unused)
45{
46  /*Clear the interrupt bit */
47  XSCALE_OS_TIMER_TSR = 0x1;
48
49  /* enable timer interrupt */
50  XSCALE_OS_TIMER_IER |= 0x1;
51
52#if ON_SKYEYE==1
53  period_num = (TIMER_RATE* Configuration.microseconds_per_tick)/100000;
54#else
55  period_num = (TIMER_RATE* Configuration.microseconds_per_tick)/10000;
56#endif
57
58  XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num;
59}
60
61/**
62 * Disables clock interrupts
63 *
64 * If the interrupt is always on, this can be a NOP.
65 */
66static void clock_isr_off(const rtems_irq_connect_data *unused)
67{
68  /*Clear the interrupt bit */
69  XSCALE_OS_TIMER_TSR = 0x1;
70  /* disable timer interrupt*/
71  XSCALE_OS_TIMER_IER &= ~0x1;
72}
73
74/**
75 * Tests to see if clock interrupt is enabled, and returns 1 if so.
76 * If interrupt is not enabled, returns 0.
77 *
78 * If the interrupt is always on, this always returns 1.
79 */
80static int clock_isr_is_on(const rtems_irq_connect_data *irq)
81{
82  /* check timer interrupt */
83  return XSCALE_OS_TIMER_IER & 0x1;
84}
85
86void Clock_isr(rtems_irq_hdl_param arg);
87
88rtems_irq_connect_data clock_isr_data = {
89  .name   = XSCALE_IRQ_OS_TIMER,
90  .hdl    = Clock_isr,
91  .handle = NULL,
92  .on     = clock_isr_on,
93  .off    = clock_isr_off,
94  .isOn   = clock_isr_is_on,
95};
96
97#define Clock_driver_support_install_isr( _new, _old ) \
98  do {                                                 \
99    _old = NULL;                                       \
100    BSP_install_rtems_irq_handler(&clock_isr_data);    \
101  } while (0)
102
103void Clock_driver_support_initialize_hardware(void)
104{
105#if ON_SKYEYE==1
106  period_num = (TIMER_RATE* Configuration.microseconds_per_tick)/100000;
107#else
108  period_num = (TIMER_RATE* Configuration.microseconds_per_tick)/10000;
109#endif
110}
111
112#define Clock_driver_support_at_tick() \
113  do { \
114    /* read the status to clear the int */ \
115    XSCALE_OS_TIMER_TSR = 0x1; \
116    \
117    /*Add the match register*/ \
118    XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num; \
119  } while (0)
120
121void Clock_driver_support_shutdown_hardware( void )
122{
123  BSP_remove_rtems_irq_handler(&clock_isr_data);
124}
125
126#include "../../../../libbsp/shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.