Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:05

0001 /*
0002  *  S3C2400 clock specific using the System Timer
0003  */
0004 
0005 /*
0006  *  The license and distribution terms for this file may be
0007  *  found in the file LICENSE in this distribution or at
0008  *  http://www.rtems.org/license/LICENSE.
0009  */
0010 
0011 #include <rtems.h>
0012 #include <bsp/irq.h>
0013 #include <bsp.h>
0014 #include <s3c24xx.h>
0015 
0016 void Clock_isr(rtems_irq_hdl_param arg);
0017 static void clock_isr_on(const rtems_irq_connect_data *unused);
0018 static void clock_isr_off(const rtems_irq_connect_data *unused);
0019 static int clock_isr_is_on(const rtems_irq_connect_data *irq);
0020 
0021 rtems_irq_connect_data clock_isr_data = {
0022   .name   = BSP_INT_TIMER4,
0023   .hdl    = Clock_isr,
0024   .handle = NULL,
0025   .on     = clock_isr_on,
0026   .off    = clock_isr_off,
0027   .isOn   = clock_isr_is_on,
0028 };
0029 
0030 /**
0031  * When we get the clock interrupt
0032  *    - clear the interrupt bit?
0033  *    - restart the timer?
0034  */
0035 #define Clock_driver_support_at_tick(arg)             \
0036   do {                                                \
0037         ClearPending(BIT_TIMER4);                     \
0038   } while(0)
0039 
0040 
0041 /**
0042  * Installs the clock ISR. You shouldn't need to change this.
0043  */
0044 #define Clock_driver_support_install_isr( _new ) \
0045   BSP_install_rtems_irq_handler(&clock_isr_data)
0046 
0047 
0048 /**
0049  * Initialize the hardware for the clock
0050  *   - Set the frequency
0051  *   - enable it
0052  *   - clear any pending interrupts
0053  *
0054  * Since you may want the clock always running, you can
0055  * enable interrupts here. If you do so, the clock_isr_on(),
0056  * clock_isr_off(), and clock_isr_is_on() functions can be
0057  * NOPs.
0058  */
0059 #define Clock_driver_support_initialize_hardware() \
0060   do { \
0061         uint32_t cr; \
0062         uint32_t freq; \
0063         /* set MUX for Timer4 to 1/16 */ \
0064         cr=rTCFG1 & 0xFFF0FFFF; \
0065         rTCFG1=(cr | (3<<16)); \
0066         freq = get_PCLK(); \
0067         /* set TIMER4 counter, input freq=PLCK/16/16Mhz*/ \
0068         freq = (freq /16)/16; \
0069         rTCNTB4 = ((freq / 1000) * rtems_configuration_get_microseconds_per_tick()) / 1000; \
0070         /*unmask TIMER4 irq*/ \
0071         rINTMSK&=~BIT_TIMER4; \
0072         /* start TIMER4 with autoreload */ \
0073         cr=rTCON & 0xFF8FFFFF; \
0074         rTCON=(cr|(0x6<<20)); \
0075         rTCON=(cr|(0x5<<20)); \
0076     } while (0)
0077 
0078 /**
0079  * Enables clock interrupt.
0080  *
0081  * If the interrupt is always on, this can be a NOP.
0082  */
0083 static void clock_isr_on(const rtems_irq_connect_data *unused)
0084 {
0085 }
0086 
0087 /**
0088  * Disables clock interrupts
0089  *
0090  * If the interrupt is always on, this can be a NOP.
0091  */
0092 static void clock_isr_off(const rtems_irq_connect_data *unused)
0093 {
0094     return;
0095 }
0096 
0097 /**
0098  * Tests to see if clock interrupt is enabled, and returns 1 if so.
0099  * If interrupt is not enabled, returns 0.
0100  *
0101  * If the interrupt is always on, this always returns 1.
0102  */
0103 static int clock_isr_is_on(const rtems_irq_connect_data *irq)
0104 {
0105   return 1;
0106 }
0107 
0108 #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
0109 
0110 /* Make sure to include this, and only at the end of the file */
0111 #include "../../../shared/dev/clock/clockimpl.h"