[dbdb0255] | 1 | /* |
---|
| 2 | * S3C2400 clock specific using the System Timer |
---|
[da71123] | 3 | */ |
---|
| 4 | |
---|
| 5 | /* |
---|
[dbdb0255] | 6 | * The license and distribution terms for this file may be |
---|
| 7 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 8 | * http://www.rtems.org/license/LICENSE. |
---|
[1a3cbfba] | 9 | */ |
---|
| 10 | |
---|
[dbdb0255] | 11 | #include <rtems.h> |
---|
[f4dc319a] | 12 | #include <bsp/irq.h> |
---|
[dbdb0255] | 13 | #include <bsp.h> |
---|
| 14 | #include <s3c24xx.h> |
---|
| 15 | |
---|
[1a3cbfba] | 16 | void Clock_isr(rtems_irq_hdl_param arg); |
---|
[dbdb0255] | 17 | static void clock_isr_on(const rtems_irq_connect_data *unused); |
---|
| 18 | static void clock_isr_off(const rtems_irq_connect_data *unused); |
---|
| 19 | static int clock_isr_is_on(const rtems_irq_connect_data *irq); |
---|
| 20 | |
---|
[1a3cbfba] | 21 | rtems_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, |
---|
[c193baad] | 28 | }; |
---|
[dbdb0255] | 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 { \ |
---|
[1a3cbfba] | 37 | ClearPending(BIT_TIMER4); \ |
---|
[dbdb0255] | 38 | } while(0) |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | /** |
---|
| 42 | * Installs the clock ISR. You shouldn't need to change this. |
---|
| 43 | */ |
---|
[f3b29236] | 44 | #define Clock_driver_support_install_isr( _new ) \ |
---|
| 45 | BSP_install_rtems_irq_handler(&clock_isr_data) |
---|
[dbdb0255] | 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; \ |
---|
[7ca51e3] | 62 | uint32_t freq; \ |
---|
[dbdb0255] | 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; \ |
---|
[e6a4446] | 69 | rTCNTB4 = ((freq / 1000) * rtems_configuration_get_microseconds_per_tick()) / 1000; \ |
---|
[dbdb0255] | 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 | */ |
---|
| 95 | static 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 | */ |
---|
| 104 | static 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 | */ |
---|
| 115 | static int clock_isr_is_on(const rtems_irq_connect_data *irq) |
---|
| 116 | { |
---|
[da71123] | 117 | return 1; |
---|
[dbdb0255] | 118 | } |
---|
| 119 | |
---|
[75acd9e] | 120 | #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER |
---|
| 121 | |
---|
[dbdb0255] | 122 | /* Make sure to include this, and only at the end of the file */ |
---|
[7632906] | 123 | #include "../../../shared/dev/clock/clockimpl.h" |
---|