source: rtems/c/src/lib/libcpu/arm/s3c24xx/clock/clockdrv.c @ dbdb0255

4.104.114.95
Last change on this file since dbdb0255 was dbdb0255, checked in by Joel Sherrill <joel.sherrill@…>, on May 6, 2008 at 8:58:05 PM

2008-05-06 Ray Xu <rayx.cn@…>

  • Makefile.am, configure.ac, preinstall.am, s3c2400/include/s3c2400.h: Add CPU type s3c2410. Add a new s3c24xx common file shared between s3c2400 and s3c2410. Most content is moved from s3c2400 now. Some were changed to include <s3c24xx.h> instead of <s3c2400.h>.
  • s3c2410/include/s3c2410.h, s3c2410/irq/bsp_irq_asm.S, s3c2410/irq/irq.h, s3c24xx/clock/clockdrv.c, s3c24xx/clock/support.c, s3c24xx/include/s3c24xx.h, s3c24xx/irq/bsp_irq_init.c, s3c24xx/irq/irq.c, s3c24xx/irq/irq.h, s3c24xx/timer/timer.c: New files.
  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 *  S3C2400 clock specific using the System Timer
3 *
4 *  This is hardware specific part of the clock driver. At the end of this
5 *  file, the generic part of the driver is #included.
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *
13 *  $Id$
14*/
15#include <rtems.h>
16#include <irq.h>
17#include <bsp.h>
18#include <s3c24xx.h>
19
20/* this is defined in ../../../shared/clockdrv_shell.c */
21rtems_isr Clock_isr(rtems_vector_number vector);
22static void clock_isr_on(const rtems_irq_connect_data *unused);
23static void clock_isr_off(const rtems_irq_connect_data *unused);
24static int clock_isr_is_on(const rtems_irq_connect_data *irq);
25
26/* Replace the first value with the clock's interrupt name. */
27rtems_irq_connect_data clock_isr_data = {BSP_INT_TIMER4,
28                                         (rtems_irq_hdl)Clock_isr,
29                                         clock_isr_on,
30                                         clock_isr_off,
31                                         clock_isr_is_on,
32                                         3,     /* unused for ARM cpus */
33                                         0 };   /* unused for ARM cpus */
34
35/* If you follow the code, this is never used, so any value
36 * should work
37 */
38#define CLOCK_VECTOR 0
39
40
41/**
42 * When we get the clock interrupt
43 *    - clear the interrupt bit?
44 *    - restart the timer?
45 */
46#define Clock_driver_support_at_tick()                \
47  do {                                                \
48        ClearPending(BIT_TIMER4);                                 \
49  } while(0)
50
51
52/**
53 * Installs the clock ISR. You shouldn't need to change this.
54 */
55#define Clock_driver_support_install_isr( _new, _old ) \
56  do {                                                 \
57    _old = NULL;                                       \
58    BSP_install_rtems_irq_handler(&clock_isr_data);    \
59  } while(0)
60
61
62/**
63 * Initialize the hardware for the clock
64 *   - Set the frequency
65 *   - enable it
66 *   - clear any pending interrupts
67 *
68 * Since you may want the clock always running, you can
69 * enable interrupts here. If you do so, the clock_isr_on(),
70 * clock_isr_off(), and clock_isr_is_on() functions can be
71 * NOPs.
72 */
73#define Clock_driver_support_initialize_hardware() \
74  do { \
75        uint32_t cr; \
76        uint32_t freq,m,p,s; \
77        /* set MUX for Timer4 to 1/16 */ \
78        cr=rTCFG1 & 0xFFF0FFFF; \
79        rTCFG1=(cr | (3<<16)); \
80        freq = get_PCLK(); \
81        /* set TIMER4 counter, input freq=PLCK/16/16Mhz*/ \
82        freq = (freq /16)/16; \
83        rTCNTB4 = ((freq / 1000) * BSP_Configuration.microseconds_per_tick) / 1000; \
84        /*unmask TIMER4 irq*/ \
85        rINTMSK&=~BIT_TIMER4; \
86        /* start TIMER4 with autoreload */ \
87        cr=rTCON & 0xFF8FFFFF; \
88        rTCON=(cr|(0x6<<20)); \
89        rTCON=(cr|(0x5<<20)); \
90    } while (0)
91
92/**
93 * Do whatever you need to shut the clock down and remove the
94 * interrupt handler. Since this normally only gets called on
95 * RTEMS shutdown, you may not need to do anything other than
96 * remove the ISR.
97 */
98#define Clock_driver_support_shutdown_hardware()                        \
99  do {                                                                  \
100        /* Disable timer */ \
101        BSP_remove_rtems_irq_handler(&clock_isr_data);                  \
102     } while (0)
103
104/**
105 * Enables clock interrupt.
106 *
107 * If the interrupt is always on, this can be a NOP.
108 */
109static void clock_isr_on(const rtems_irq_connect_data *unused)
110{
111    return;
112}
113
114/**
115 * Disables clock interrupts
116 *
117 * If the interrupt is always on, this can be a NOP.
118 */
119static void clock_isr_off(const rtems_irq_connect_data *unused)
120{
121    return;
122}
123
124/**
125 * Tests to see if clock interrupt is enabled, and returns 1 if so.
126 * If interrupt is not enabled, returns 0.
127 *
128 * If the interrupt is always on, this always returns 1.
129 */
130static int clock_isr_is_on(const rtems_irq_connect_data *irq)
131{
132    return 1;
133}
134
135
136/* Make sure to include this, and only at the end of the file */
137#include "../../../../libbsp/shared/clockdrv_shell.c"
Note: See TracBrowser for help on using the repository browser.