Changeset 40716bf in rtems
- Timestamp:
- 10/12/14 18:59:50 (9 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 5105833c
- Parents:
- 48f8a98f
- git-author:
- Joel Sherrill <joel.sherrill@…> (10/12/14 18:59:50)
- git-committer:
- Joel Sherrill <joel.sherrill@…> (10/13/14 15:33:29)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libcpu/m68k/mcf5206/clock/ckinit.c
r48f8a98f r40716bf 4 4 * This driver initailizes timer1 on the MCF5206E as the 5 5 * main system clock 6 * 6 */ 7 8 /* 7 9 * Author: Victor V. Vengerov <vvv@oktet.ru> 8 10 * … … 30 32 volatile uint32_t Clock_driver_ticks; 31 33 32 33 /*34 * These are set by clock driver during its init35 */36 37 rtems_device_major_number rtems_clock_major = ~0;38 rtems_device_minor_number rtems_clock_minor;39 40 34 rtems_isr (*rtems_clock_hook)(rtems_vector_number) = NULL; 41 35 42 /* Clock_isr -- 43 * This handles the timer interrupt by clearing the timer's interrupt 44 * flag and announcing the clock tick to the system. 45 * 46 * PARAMETERS: 47 * vector - timer interrupt vector number 48 * 49 * RETURNS: 50 * none 51 */ 52 rtems_isr 36 static rtems_isr 53 37 Clock_isr (rtems_vector_number vector) 54 38 { … … 63 47 } 64 48 65 66 /* Clock_exit --67 * This shuts down the timer if it was enabled and removes it68 * from the MCF5206E interrupt mask.69 *70 * PARAMETERS:71 * none72 *73 * RETURNS:74 * none75 */76 49 void 77 50 Clock_exit(void) 78 51 { 79 if (rtems_configuration_get_ticks_per_timeslice()) 80 { 81 /* disable all timer1 interrupts */ 82 *MCF5206E_IMR(MBAR) |= MCF5206E_INTR_BIT(MCF5206E_INTR_TIMER_1); 52 /* disable all timer1 interrupts */ 53 *MCF5206E_IMR(MBAR) |= MCF5206E_INTR_BIT(MCF5206E_INTR_TIMER_1); 83 54 84 85 55 /* reset timer1 */ 56 *MCF5206E_TMR(MBAR,1) = MCF5206E_TMR_ICLK_STOP; 86 57 87 /* clear pending */ 88 *MCF5206E_TER(MBAR,1) = MCF5206E_TER_REF | MCF5206E_TER_CAP; 89 } 58 /* clear pending */ 59 *MCF5206E_TER(MBAR,1) = MCF5206E_TER_REF | MCF5206E_TER_CAP; 90 60 } 91 61 92 62 93 /* Install_clock --94 * This initialises timer1 with the BSP timeslice config value95 * as a reference and sets up the interrupt handler for clock ticks.96 *97 * PARAMETERS:98 * clock_isr - clock interrupt handler routine99 *100 * RETURNS:101 * none.102 */103 63 static void 104 64 Install_clock(rtems_isr_entry clock_isr) 105 65 { 106 Clock_driver_ticks = 0; 107 if (rtems_configuration_get_ticks_per_timeslice()) 108 { 109 /* Configure timer1 interrupts */ 110 *MCF5206E_ICR(MBAR,MCF5206E_INTR_TIMER_1) = 111 MCF5206E_ICR_AVEC | 112 ((BSP_INTLVL_TIMER1 << MCF5206E_ICR_IL_S) & MCF5206E_ICR_IL) | 113 ((BSP_INTPRIO_TIMER1 << MCF5206E_ICR_IP_S) & MCF5206E_ICR_IP); 66 Clock_driver_ticks = 0; 114 67 115 /* Register the interrupt handler */ 116 set_vector(clock_isr, BSP_INTVEC_TIMER1, 1); 68 /* Configure timer1 interrupts */ 69 *MCF5206E_ICR(MBAR,MCF5206E_INTR_TIMER_1) = 70 MCF5206E_ICR_AVEC | 71 ((BSP_INTLVL_TIMER1 << MCF5206E_ICR_IL_S) & MCF5206E_ICR_IL) | 72 ((BSP_INTPRIO_TIMER1 << MCF5206E_ICR_IP_S) & MCF5206E_ICR_IP); 117 73 118 /* Reset timer 1 */ 119 *MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_RST; 120 *MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_ICLK_STOP; 121 *MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_RST; 122 *MCF5206E_TCN(MBAR, 1) = 0; /* Reset counter */ 123 *MCF5206E_TER(MBAR, 1) = MCF5206E_TER_REF | MCF5206E_TER_CAP; 74 /* Register the interrupt handler */ 75 set_vector(clock_isr, BSP_INTVEC_TIMER1, 1); 124 76 125 /* Set Timer 1 prescaler so that it counts in microseconds*/126 *MCF5206E_TMR(MBAR, 1) =127 (((BSP_SYSTEM_FREQUENCY/1000000 - 1) << MCF5206E_TMR_PS_S) &128 MCF5206E_TMR_PS) |129 MCF5206E_TMR_CE_NONE | MCF5206E_TMR_ORI | MCF5206E_TMR_FRR |130 MCF5206E_TMR_RST;77 /* Reset timer 1 */ 78 *MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_RST; 79 *MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_ICLK_STOP; 80 *MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_RST; 81 *MCF5206E_TCN(MBAR, 1) = 0; /* Reset counter */ 82 *MCF5206E_TER(MBAR, 1) = MCF5206E_TER_REF | MCF5206E_TER_CAP; 131 83 132 /* Set the timer timeout value from the BSP config */ 133 *MCF5206E_TRR(MBAR, 1) = rtems_configuration_get_microseconds_per_tick() - 1; 84 /* Set Timer 1 prescaler so that it counts in microseconds */ 85 *MCF5206E_TMR(MBAR, 1) = 86 (((BSP_SYSTEM_FREQUENCY/1000000 - 1) << MCF5206E_TMR_PS_S) & 87 MCF5206E_TMR_PS) | 88 MCF5206E_TMR_CE_NONE | MCF5206E_TMR_ORI | MCF5206E_TMR_FRR | 89 MCF5206E_TMR_RST; 134 90 135 /* Feed system frequency to the timer*/136 *MCF5206E_TMR(MBAR, 1) |= MCF5206E_TMR_ICLK_MSCLK;91 /* Set the timer timeout value from the BSP config */ 92 *MCF5206E_TRR(MBAR, 1) = rtems_configuration_get_microseconds_per_tick() - 1; 137 93 138 /* Enable timer 1 interrupts*/139 *MCF5206E_IMR(MBAR) &= ~MCF5206E_INTR_BIT(MCF5206E_INTR_TIMER_1);94 /* Feed system frequency to the timer */ 95 *MCF5206E_TMR(MBAR, 1) |= MCF5206E_TMR_ICLK_MSCLK; 140 96 141 /* Register the driver exit procedure so we can shutdown */ 142 atexit(Clock_exit); 143 } 97 /* Enable timer 1 interrupts */ 98 *MCF5206E_IMR(MBAR) &= ~MCF5206E_INTR_BIT(MCF5206E_INTR_TIMER_1); 99 100 /* Register the driver exit procedure so we can shutdown */ 101 atexit(Clock_exit); 144 102 } 145 103 146 147 /* Clock_initialize --148 * This is called to setup the clock driver. It calls the hardware149 * setup function and make the driver major/minor values available150 * for other.151 *152 * PARAMETERS:153 * major - clock device major number154 * minor - clock device minor number155 * pargp - device driver initialization argument (not used)156 *157 * RETURNS:158 * RTEMS status code159 */160 104 rtems_device_driver 161 105 Clock_initialize(rtems_device_major_number major, … … 163 107 void *pargp) 164 108 { 165 109 Install_clock (Clock_isr); 166 110 167 /* Make major/minor avail to others such as shared memory driver */ 168 rtems_clock_major = major; 169 rtems_clock_minor = minor; 170 171 return RTEMS_SUCCESSFUL; 111 return RTEMS_SUCCESSFUL; 172 112 }
Note: See TracChangeset
for help on using the changeset viewer.