Changeset 5105833c in rtems
- Timestamp:
- 10/12/14 19:00:00 (9 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 5039d92
- Parents:
- 40716bf
- git-author:
- Joel Sherrill <joel.sherrill@…> (10/12/14 19:00:00)
- git-committer:
- Joel Sherrill <joel.sherrill@…> (10/13/14 15:33:29)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libcpu/m68k/mcf5272/clock/ckinit.c
r40716bf r5105833c 4 4 * This driver initailizes timer1 on the MCF5272 as the 5 5 * main system clock 6 * 6 */ 7 8 /* 7 9 * Copyright 2004 Cogent Computer Systems 8 10 * Author: Jay Monkman <jtm@lopingdog.com> … … 34 36 volatile uint32_t Clock_driver_ticks; 35 37 36 37 /*38 * These are set by clock driver during its init39 */40 41 rtems_device_major_number rtems_clock_major = ~0;42 rtems_device_minor_number rtems_clock_minor;43 44 38 rtems_isr (*rtems_clock_hook)(rtems_vector_number) = NULL; 45 39 46 /* Clock_isr -- 47 * This handles the timer interrupt by clearing the timer's interrupt 48 * flag and announcing the clock tick to the system. 49 * 50 * PARAMETERS: 51 * vector - timer interrupt vector number 52 53 * RETURNS: 54 * none 55 */ 56 rtems_isr 40 static rtems_isr 57 41 Clock_isr (rtems_vector_number vector) 58 42 { 59 60 43 /* Clear pending interrupt... */ 44 g_timer_regs->ter1 = MCF5272_TER_REF | MCF5272_TER_CAP; 61 45 62 63 64 65 66 67 46 /* Announce the clock tick */ 47 Clock_driver_ticks++; 48 rtems_clock_tick(); 49 if (rtems_clock_hook != NULL) { 50 rtems_clock_hook(vector); 51 } 68 52 } 69 53 70 71 /* Clock_exit --72 * This shuts down the timer if it was enabled and removes it73 * from the MCF5206E interrupt mask.74 *75 * PARAMETERS:76 * none77 *78 * RETURNS:79 * none80 */81 54 void 82 55 Clock_exit(void) 83 56 { 84 if (rtems_configuration_get_ticks_per_timeslice()) { 85 uint32_t icr; 86 /* disable all timer1 interrupts */ 87 icr = g_intctrl_regs->icr1; 88 icr = icr & ~(MCF5272_ICR1_TMR1_MASK | MCF5272_ICR1_TMR1_PI); 89 icr |= (MCF5272_ICR1_TMR1_IPL(0) | MCF5272_ICR1_TMR1_PI); 90 g_intctrl_regs->icr1 = icr; 57 uint32_t icr; 91 58 92 /* reset timer1 */ 93 g_timer_regs->tmr1 = MCF5272_TMR_CLK_STOP; 59 /* disable all timer1 interrupts */ 60 icr = g_intctrl_regs->icr1; 61 icr = icr & ~(MCF5272_ICR1_TMR1_MASK | MCF5272_ICR1_TMR1_PI); 62 icr |= (MCF5272_ICR1_TMR1_IPL(0) | MCF5272_ICR1_TMR1_PI); 63 g_intctrl_regs->icr1 = icr; 94 64 95 /* clear pending */ 96 g_timer_regs->ter1 = MCF5272_TER_REF | MCF5272_TER_CAP; 97 } 65 /* reset timer1 */ 66 g_timer_regs->tmr1 = MCF5272_TMR_CLK_STOP; 67 68 /* clear pending */ 69 g_timer_regs->ter1 = MCF5272_TER_REF | MCF5272_TER_CAP; 98 70 } 99 71 100 101 /* Install_clock --102 * This initialises timer1 with the BSP timeslice config value103 * as a reference and sets up the interrupt handler for clock ticks.104 *105 * PARAMETERS:106 * clock_isr - clock interrupt handler routine107 *108 * RETURNS:109 * none.110 */111 72 static void 112 73 Install_clock(rtems_isr_entry clock_isr) 113 74 { 114 75 uint32_t icr; 76 115 77 Clock_driver_ticks = 0; 116 if (rtems_configuration_get_ticks_per_timeslice()) {117 78 118 119 79 /* Register the interrupt handler */ 80 set_vector(clock_isr, BSP_INTVEC_TMR1, 1); 120 81 121 122 123 124 125 126 82 /* Reset timer 1 */ 83 g_timer_regs->tmr1 = MCF5272_TMR_RST; 84 g_timer_regs->tmr1 = MCF5272_TMR_CLK_STOP; 85 g_timer_regs->tmr1 = MCF5272_TMR_RST; 86 g_timer_regs->tcn1 = 0; /* reset counter */ 87 g_timer_regs->ter1 = MCF5272_TER_REF | MCF5272_TER_CAP; 127 88 128 129 130 131 132 133 134 135 89 /* Set Timer 1 prescaler so that it counts in microseconds */ 90 g_timer_regs->tmr1 = ( 91 ((((BSP_SYSTEM_FREQUENCY / 1000000) - 1) << MCF5272_TMR_PS_SHIFT) | 92 MCF5272_TMR_CE_DISABLE | 93 MCF5272_TMR_ORI | 94 MCF5272_TMR_FRR | 95 MCF5272_TMR_CLK_MSTR | 96 MCF5272_TMR_RST)); 136 97 137 138 98 /* Set the timer timeout value from the BSP config */ 99 g_timer_regs->trr1 = rtems_configuration_get_microseconds_per_tick() - 1; 139 100 140 141 101 /* Feed system frequency to the timer */ 102 g_timer_regs->tmr1 |= MCF5272_TMR_CLK_MSTR; 142 103 143 144 145 146 147 104 /* Configure timer1 interrupts */ 105 icr = g_intctrl_regs->icr1; 106 icr = icr & ~(MCF5272_ICR1_TMR1_MASK | MCF5272_ICR1_TMR1_PI); 107 icr |= (MCF5272_ICR1_TMR1_IPL(BSP_INTLVL_TMR1) | MCF5272_ICR1_TMR1_PI); 108 g_intctrl_regs->icr1 = icr; 148 109 149 /* Register the driver exit procedure so we can shutdown */ 150 atexit(Clock_exit); 151 } 110 /* Register the driver exit procedure so we can shutdown */ 111 atexit(Clock_exit); 152 112 } 153 113 114 rtems_device_driver 115 Clock_initialize( 116 rtems_device_major_number major, 117 rtems_device_minor_number minor, 118 void *pargp 119 ) 120 { 121 Install_clock (Clock_isr); 154 122 155 /* Clock_initialize -- 156 * This is called to setup the clock driver. It calls the hardware 157 * setup function and make the driver major/minor values available 158 * for other. 159 * 160 * PARAMETERS: 161 * major - clock device major number 162 * minor - clock device minor number 163 * pargp - device driver initialization argument (not used) 164 * 165 * RETURNS: 166 * RTEMS status code 167 */ 168 rtems_device_driver 169 Clock_initialize(rtems_device_major_number major, 170 rtems_device_minor_number minor, 171 void *pargp) 172 { 173 Install_clock (Clock_isr); 174 175 /* Make major/minor avail to others such as shared memory driver */ 176 rtems_clock_major = major; 177 rtems_clock_minor = minor; 178 179 return RTEMS_SUCCESSFUL; 123 return RTEMS_SUCCESSFUL; 180 124 }
Note: See TracChangeset
for help on using the changeset viewer.