source: rtems/c/src/lib/libcpu/arm/s3c2400/clock/clockdrv.c @ 479ac2d8

4.104.114.84.95
Last change on this file since 479ac2d8 was 479ac2d8, checked in by Jay Monkman <jtm@…>, on Mar 11, 2005 at 7:26:45 AM

2005-03-11 Philippe Simons <loki_666@…>

  • Makefile.am, configure.ac: Added gp32 BSP.
  • s3c2400/.cvsignore, s3c2400/Makefile.am, s3c2400/clock/clockdrv.c, s3c2400/include/s3c2400.h, s3c2400/irq/bsp_irq_asm.S, s3c2400/irq/bsp_irq_init.c, s3c2400/irq/irq.c, s3c2400/irq/irq.h, s3c2400/timer/timer.c: New files.
  • Property mode set to 100644
File size: 4.2 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.OARcorp.com/rtems/license.html.
11 *
12 *
13 *  $Id$
14*/
15#include <rtems.h>
16#include <irq.h>
17#include <bsp.h>
18#include <s3c2400.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      BSP_install_rtems_irq_handler(&clock_isr_data);                       \
58     } while(0)
59
60
61/**
62 * Initialize the hardware for the clock
63 *   - Set the frequency
64 *   - enable it
65 *   - clear any pending interrupts
66 *
67 * Since you may want the clock always running, you can
68 * enable interrupts here. If you do so, the clock_isr_on(),
69 * clock_isr_off(), and clock_isr_is_on() functions can be
70 * NOPs.
71 */
72#define Clock_driver_support_initialize_hardware() \
73  do { \
74        uint32_t cr; \
75        uint32_t freq,m,p,s; \
76        /* set MUX for Timer4 to 1/16 */ \
77        cr=rTCFG1 & 0xFFF0FFFF; \
78        rTCFG1=(cr | (3<<16)); \
79        /* compute MPLL freq */ \
80        m = M_MDIV + 8; \
81        p = M_PDIV + 2; \
82        s = M_SDIV; \
83        freq =(BSP_OSC_FREQ * m) / (p << s); \
84        /* PCLK = MPLL/4 */ \
85        freq = freq / 4; \
86        /* set TIMER4 counter, input freq=PLCK/16/16Mhz*/ \
87        freq = (freq /16)/16; \
88        rTCNTB4 = ((freq / 1000) * BSP_Configuration.microseconds_per_tick) / 1000; \
89        /*unmask TIMER4 irq*/ \
90        rINTMSK&=~BIT_TIMER4; \
91        /* start TIMER4 with autoreload */ \
92        cr=rTCON & 0xFF8FFFFF; \
93        rTCON=(cr|(0x6<<20)); \
94        rTCON=(cr|(0x5<<20)); \
95    } while (0)
96
97/**
98 * Do whatever you need to shut the clock down and remove the
99 * interrupt handler. Since this normally only gets called on
100 * RTEMS shutdown, you may not need to do anything other than
101 * remove the ISR.
102 */
103#define Clock_driver_support_shutdown_hardware()                        \
104  do {                                                                  \
105        /* Disable timer */ \
106        BSP_remove_rtems_irq_handler(&clock_isr_data);                  \
107     } while (0)
108
109/**
110 * Enables clock interrupt.
111 *
112 * If the interrupt is always on, this can be a NOP.
113 */
114static void clock_isr_on(const rtems_irq_connect_data *unused)
115{
116    return;
117}
118
119/**
120 * Disables clock interrupts
121 *
122 * If the interrupt is always on, this can be a NOP.
123 */
124static void clock_isr_off(const rtems_irq_connect_data *unused)
125{
126    return;
127}
128
129/**
130 * Tests to see if clock interrupt is enabled, and returns 1 if so.
131 * If interrupt is not enabled, returns 0.
132 *
133 * If the interrupt is always on, this always returns 1.
134 */
135static int clock_isr_is_on(const rtems_irq_connect_data *irq)
136{
137    return 1;
138}
139
140
141/* Make sure to include this, and only at the end of the file */
142#include "../../../../libbsp/shared/clockdrv_shell.c"
Note: See TracBrowser for help on using the repository browser.