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

4.104.115
Last change on this file since d7a915da was d7a915da, checked in by Joel Sherrill <joel.sherrill@…>, on 06/04/09 at 16:33:31

2009-06-04 Xi Yang <hiyangxi@…>

  • Makefile.am, configure.ac, preinstall.am: New Gumstix BSP and PXA255 support.
  • pxa255/clock/clock.c, pxa255/ffuart/ffuart.c, pxa255/include/bits.h, pxa255/include/ffuart.h, pxa255/include/pxa255.h, pxa255/irq/bsp_irq_asm.S, pxa255/irq/bsp_irq_init.c, pxa255/irq/irq.c, pxa255/irq/irq.h, pxa255/pmc/pmc.c, pxa255/timer/timer.c: New files.
  • Property mode set to 100755
File size: 2.7 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 *  $Id$
13 */
14#include <rtems.h>
15#include <rtems/clockdrv.h>
16#include <rtems/libio.h>
17
18#include <stdlib.h>
19#include <bsp.h>
20#include <irq.h>
21#include <pxa255.h>
22
23
24
25static unsigned long period_num;
26
27
28
29
30
31/**
32 * Enables clock interrupt.
33 *
34 * If the interrupt is always on, this can be a NOP.
35 */
36static void clock_isr_on(const rtems_irq_connect_data *unused)
37{
38
39  /*Clear the interrupt bit */
40  XSCALE_OS_TIMER_TSR = 0x1;
41 
42   
43  /* enable timer interrupt */
44  XSCALE_OS_TIMER_IER |= 0x1;
45
46  period_num = TIMER_RATE*(Configuration.microseconds_per_tick/10000);
47
48  XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num;
49   
50}
51
52/**
53 * Disables clock interrupts
54 *
55 * If the interrupt is always on, this can be a NOP.
56 */
57static void clock_isr_off(const rtems_irq_connect_data *unused)
58{
59  /*Clear the interrupt bit */
60  XSCALE_OS_TIMER_TSR = 0x1;
61  /* disable timer interrupt*/
62  XSCALE_OS_TIMER_IER &= ~0x1;
63  return;
64}
65
66/**
67 * Tests to see if clock interrupt is enabled, and returns 1 if so.
68 * If interrupt is not enabled, returns 0.
69 *
70 * If the interrupt is always on, this always returns 1.
71 */
72static int clock_isr_is_on(const rtems_irq_connect_data *irq)
73{
74    /* check timer interrupt */
75  return XSCALE_OS_TIMER_IER & 0x1;
76}
77
78rtems_isr Clock_isr(rtems_vector_number vector);
79
80/* Replace the first value with the clock's interrupt name. */
81rtems_irq_connect_data clock_isr_data = {XSCALE_IRQ_OS_TIMER,   
82                                         (rtems_irq_hdl)Clock_isr,
83                                         clock_isr_on,
84                                         clock_isr_off,
85                                         clock_isr_is_on,
86                                         3,     /* unused for ARM cpus */
87                                         0 };   /* unused for ARM cpus */
88
89
90#define Clock_driver_support_install_isr( _new, _old ) \
91  BSP_install_rtems_irq_handler(&clock_isr_data)
92
93void Clock_driver_support_initialize_hardware(void)
94{
95 
96
97  period_num = TIMER_RATE*(Configuration.microseconds_per_tick/10000);
98 
99}
100
101
102#define CLOCK_VECTOR 0
103
104#define Clock_driver_support_at_tick() \
105  do { \
106    ;\                                                                 
107    XSCALE_OS_TIMER_TSR = 0x1;/* read the status to clear the int */    \
108    XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num;/*Add the match register*/ \   
109    ;\                                         
110  } while (0)
111
112void Clock_driver_support_shutdown_hardware( void )
113{
114    BSP_remove_rtems_irq_handler(&clock_isr_data);
115}
116
117#include "../../../../libbsp/shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.