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

4.115
Last change on this file since 75acd9e was 75acd9e, checked in by Alexander Krutwig <alexander.krutwig@…>, on 04/01/15 at 13:33:25

bsps: Convert clock drivers to use a timecounter

Update #2271.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 *  S3C2400 clock specific using the System Timer
3 */
4
5/*
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.rtems.org/license/LICENSE.
9 */
10
11#include <rtems.h>
12#include <bsp/irq.h>
13#include <bsp.h>
14#include <s3c24xx.h>
15
16void Clock_isr(rtems_irq_hdl_param arg);
17static void clock_isr_on(const rtems_irq_connect_data *unused);
18static void clock_isr_off(const rtems_irq_connect_data *unused);
19static int clock_isr_is_on(const rtems_irq_connect_data *irq);
20
21rtems_irq_connect_data clock_isr_data = {
22  .name   = BSP_INT_TIMER4,
23  .hdl    = Clock_isr,
24  .handle = NULL,
25  .on     = clock_isr_on,
26  .off    = clock_isr_off,
27  .isOn   = clock_isr_is_on,
28};
29
30/**
31 * When we get the clock interrupt
32 *    - clear the interrupt bit?
33 *    - restart the timer?
34 */
35#define Clock_driver_support_at_tick()                \
36  do {                                                \
37        ClearPending(BIT_TIMER4);                     \
38  } while(0)
39
40
41/**
42 * Installs the clock ISR. You shouldn't need to change this.
43 */
44#define Clock_driver_support_install_isr( _new, _old ) \
45  do {                                                 \
46    _old = NULL;                                       \
47    BSP_install_rtems_irq_handler(&clock_isr_data);    \
48  } while(0)
49
50
51/**
52 * Initialize the hardware for the clock
53 *   - Set the frequency
54 *   - enable it
55 *   - clear any pending interrupts
56 *
57 * Since you may want the clock always running, you can
58 * enable interrupts here. If you do so, the clock_isr_on(),
59 * clock_isr_off(), and clock_isr_is_on() functions can be
60 * NOPs.
61 */
62#define Clock_driver_support_initialize_hardware() \
63  do { \
64        uint32_t cr; \
65        uint32_t freq; \
66        uint32_t mask; \
67        /* set MUX for Timer4 to 1/16 */ \
68        cr=rTCFG1 & 0xFFF0FFFF; \
69        rTCFG1=(cr | (3<<16)); \
70        freq = get_PCLK(); \
71        /* set TIMER4 counter, input freq=PLCK/16/16Mhz*/ \
72        freq = (freq /16)/16; \
73        rTCNTB4 = ((freq / 1000) * rtems_configuration_get_microseconds_per_tick()) / 1000; \
74        /*unmask TIMER4 irq*/ \
75        rINTMSK&=~BIT_TIMER4; \
76        /* start TIMER4 with autoreload */ \
77        cr=rTCON & 0xFF8FFFFF; \
78        rTCON=(cr|(0x6<<20)); \
79        rTCON=(cr|(0x5<<20)); \
80    } while (0)
81
82/**
83 * Do whatever you need to shut the clock down and remove the
84 * interrupt handler. Since this normally only gets called on
85 * RTEMS shutdown, you may not need to do anything other than
86 * remove the ISR.
87 */
88#define Clock_driver_support_shutdown_hardware()                        \
89  do {                                                                  \
90        /* Disable timer */ \
91        BSP_remove_rtems_irq_handler(&clock_isr_data);                  \
92     } while (0)
93
94/**
95 * Enables clock interrupt.
96 *
97 * If the interrupt is always on, this can be a NOP.
98 */
99static void clock_isr_on(const rtems_irq_connect_data *unused)
100{
101}
102
103/**
104 * Disables clock interrupts
105 *
106 * If the interrupt is always on, this can be a NOP.
107 */
108static void clock_isr_off(const rtems_irq_connect_data *unused)
109{
110    return;
111}
112
113/**
114 * Tests to see if clock interrupt is enabled, and returns 1 if so.
115 * If interrupt is not enabled, returns 0.
116 *
117 * If the interrupt is always on, this always returns 1.
118 */
119static int clock_isr_is_on(const rtems_irq_connect_data *irq)
120{
121  return 1;
122}
123
124#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
125
126/* Make sure to include this, and only at the end of the file */
127#include "../../../../libbsp/shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.