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

Last change on this file since f3b29236 was f3b29236, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 18, 2017 at 6:22:38 AM

bsps: Clock_driver_support_install_isr()

Remove old ISR parameter since is not used by the clock driver shell.
Make an implementation optional.

Update #3139.

  • Property mode set to 100644
File size: 3.3 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 ) \
45  BSP_install_rtems_irq_handler(&clock_isr_data)
46
47
48/**
49 * Initialize the hardware for the clock
50 *   - Set the frequency
51 *   - enable it
52 *   - clear any pending interrupts
53 *
54 * Since you may want the clock always running, you can
55 * enable interrupts here. If you do so, the clock_isr_on(),
56 * clock_isr_off(), and clock_isr_is_on() functions can be
57 * NOPs.
58 */
59#define Clock_driver_support_initialize_hardware() \
60  do { \
61        uint32_t cr; \
62        uint32_t freq; \
63        /* set MUX for Timer4 to 1/16 */ \
64        cr=rTCFG1 & 0xFFF0FFFF; \
65        rTCFG1=(cr | (3<<16)); \
66        freq = get_PCLK(); \
67        /* set TIMER4 counter, input freq=PLCK/16/16Mhz*/ \
68        freq = (freq /16)/16; \
69        rTCNTB4 = ((freq / 1000) * rtems_configuration_get_microseconds_per_tick()) / 1000; \
70        /*unmask TIMER4 irq*/ \
71        rINTMSK&=~BIT_TIMER4; \
72        /* start TIMER4 with autoreload */ \
73        cr=rTCON & 0xFF8FFFFF; \
74        rTCON=(cr|(0x6<<20)); \
75        rTCON=(cr|(0x5<<20)); \
76    } while (0)
77
78/**
79 * Do whatever you need to shut the clock down and remove the
80 * interrupt handler. Since this normally only gets called on
81 * RTEMS shutdown, you may not need to do anything other than
82 * remove the ISR.
83 */
84#define Clock_driver_support_shutdown_hardware()                        \
85  do {                                                                  \
86        /* Disable timer */ \
87        BSP_remove_rtems_irq_handler(&clock_isr_data);                  \
88     } while (0)
89
90/**
91 * Enables clock interrupt.
92 *
93 * If the interrupt is always on, this can be a NOP.
94 */
95static void clock_isr_on(const rtems_irq_connect_data *unused)
96{
97}
98
99/**
100 * Disables clock interrupts
101 *
102 * If the interrupt is always on, this can be a NOP.
103 */
104static void clock_isr_off(const rtems_irq_connect_data *unused)
105{
106    return;
107}
108
109/**
110 * Tests to see if clock interrupt is enabled, and returns 1 if so.
111 * If interrupt is not enabled, returns 0.
112 *
113 * If the interrupt is always on, this always returns 1.
114 */
115static int clock_isr_is_on(const rtems_irq_connect_data *irq)
116{
117  return 1;
118}
119
120#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
121
122/* Make sure to include this, and only at the end of the file */
123#include "../../../../libbsp/shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.