libcpu/m68k/mcf5206/clock/ckinit.c: Fix warnings

This commit is contained in:
Joel Sherrill
2014-10-12 13:59:50 -05:00
parent 48f8a98f1c
commit 40716bf6fd

View File

@@ -3,7 +3,9 @@
* *
* This driver initailizes timer1 on the MCF5206E as the * This driver initailizes timer1 on the MCF5206E as the
* main system clock * main system clock
* */
/*
* Author: Victor V. Vengerov <vvv@oktet.ru> * Author: Victor V. Vengerov <vvv@oktet.ru>
* *
* Based on work: * Based on work:
@@ -29,27 +31,9 @@
*/ */
volatile uint32_t Clock_driver_ticks; volatile uint32_t Clock_driver_ticks;
/*
* These are set by clock driver during its init
*/
rtems_device_major_number rtems_clock_major = ~0;
rtems_device_minor_number rtems_clock_minor;
rtems_isr (*rtems_clock_hook)(rtems_vector_number) = NULL; rtems_isr (*rtems_clock_hook)(rtems_vector_number) = NULL;
/* Clock_isr -- static rtems_isr
* This handles the timer interrupt by clearing the timer's interrupt
* flag and announcing the clock tick to the system.
*
* PARAMETERS:
* vector - timer interrupt vector number
*
* RETURNS:
* none
*/
rtems_isr
Clock_isr (rtems_vector_number vector) Clock_isr (rtems_vector_number vector)
{ {
/* Clear pending interrupt... */ /* Clear pending interrupt... */
@@ -62,111 +46,67 @@ Clock_isr (rtems_vector_number vector)
rtems_clock_hook(vector); rtems_clock_hook(vector);
} }
/* Clock_exit --
* This shuts down the timer if it was enabled and removes it
* from the MCF5206E interrupt mask.
*
* PARAMETERS:
* none
*
* RETURNS:
* none
*/
void void
Clock_exit(void) Clock_exit(void)
{ {
if (rtems_configuration_get_ticks_per_timeslice()) /* disable all timer1 interrupts */
{ *MCF5206E_IMR(MBAR) |= MCF5206E_INTR_BIT(MCF5206E_INTR_TIMER_1);
/* disable all timer1 interrupts */
*MCF5206E_IMR(MBAR) |= MCF5206E_INTR_BIT(MCF5206E_INTR_TIMER_1);
/* reset timer1 */ /* reset timer1 */
*MCF5206E_TMR(MBAR,1) = MCF5206E_TMR_ICLK_STOP; *MCF5206E_TMR(MBAR,1) = MCF5206E_TMR_ICLK_STOP;
/* clear pending */ /* clear pending */
*MCF5206E_TER(MBAR,1) = MCF5206E_TER_REF | MCF5206E_TER_CAP; *MCF5206E_TER(MBAR,1) = MCF5206E_TER_REF | MCF5206E_TER_CAP;
}
} }
/* Install_clock --
* This initialises timer1 with the BSP timeslice config value
* as a reference and sets up the interrupt handler for clock ticks.
*
* PARAMETERS:
* clock_isr - clock interrupt handler routine
*
* RETURNS:
* none.
*/
static void static void
Install_clock(rtems_isr_entry clock_isr) Install_clock(rtems_isr_entry clock_isr)
{ {
Clock_driver_ticks = 0; Clock_driver_ticks = 0;
if (rtems_configuration_get_ticks_per_timeslice())
{
/* Configure timer1 interrupts */
*MCF5206E_ICR(MBAR,MCF5206E_INTR_TIMER_1) =
MCF5206E_ICR_AVEC |
((BSP_INTLVL_TIMER1 << MCF5206E_ICR_IL_S) & MCF5206E_ICR_IL) |
((BSP_INTPRIO_TIMER1 << MCF5206E_ICR_IP_S) & MCF5206E_ICR_IP);
/* Register the interrupt handler */ /* Configure timer1 interrupts */
set_vector(clock_isr, BSP_INTVEC_TIMER1, 1); *MCF5206E_ICR(MBAR,MCF5206E_INTR_TIMER_1) =
MCF5206E_ICR_AVEC |
((BSP_INTLVL_TIMER1 << MCF5206E_ICR_IL_S) & MCF5206E_ICR_IL) |
((BSP_INTPRIO_TIMER1 << MCF5206E_ICR_IP_S) & MCF5206E_ICR_IP);
/* Reset timer 1 */ /* Register the interrupt handler */
*MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_RST; set_vector(clock_isr, BSP_INTVEC_TIMER1, 1);
*MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_ICLK_STOP;
*MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_RST;
*MCF5206E_TCN(MBAR, 1) = 0; /* Reset counter */
*MCF5206E_TER(MBAR, 1) = MCF5206E_TER_REF | MCF5206E_TER_CAP;
/* Set Timer 1 prescaler so that it counts in microseconds */ /* Reset timer 1 */
*MCF5206E_TMR(MBAR, 1) = *MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_RST;
(((BSP_SYSTEM_FREQUENCY/1000000 - 1) << MCF5206E_TMR_PS_S) & *MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_ICLK_STOP;
MCF5206E_TMR_PS) | *MCF5206E_TMR(MBAR, 1) = MCF5206E_TMR_RST;
MCF5206E_TMR_CE_NONE | MCF5206E_TMR_ORI | MCF5206E_TMR_FRR | *MCF5206E_TCN(MBAR, 1) = 0; /* Reset counter */
MCF5206E_TMR_RST; *MCF5206E_TER(MBAR, 1) = MCF5206E_TER_REF | MCF5206E_TER_CAP;
/* Set the timer timeout value from the BSP config */ /* Set Timer 1 prescaler so that it counts in microseconds */
*MCF5206E_TRR(MBAR, 1) = rtems_configuration_get_microseconds_per_tick() - 1; *MCF5206E_TMR(MBAR, 1) =
(((BSP_SYSTEM_FREQUENCY/1000000 - 1) << MCF5206E_TMR_PS_S) &
MCF5206E_TMR_PS) |
MCF5206E_TMR_CE_NONE | MCF5206E_TMR_ORI | MCF5206E_TMR_FRR |
MCF5206E_TMR_RST;
/* Feed system frequency to the timer */ /* Set the timer timeout value from the BSP config */
*MCF5206E_TMR(MBAR, 1) |= MCF5206E_TMR_ICLK_MSCLK; *MCF5206E_TRR(MBAR, 1) = rtems_configuration_get_microseconds_per_tick() - 1;
/* Enable timer 1 interrupts */ /* Feed system frequency to the timer */
*MCF5206E_IMR(MBAR) &= ~MCF5206E_INTR_BIT(MCF5206E_INTR_TIMER_1); *MCF5206E_TMR(MBAR, 1) |= MCF5206E_TMR_ICLK_MSCLK;
/* Register the driver exit procedure so we can shutdown */ /* Enable timer 1 interrupts */
atexit(Clock_exit); *MCF5206E_IMR(MBAR) &= ~MCF5206E_INTR_BIT(MCF5206E_INTR_TIMER_1);
}
/* Register the driver exit procedure so we can shutdown */
atexit(Clock_exit);
} }
/* Clock_initialize --
* This is called to setup the clock driver. It calls the hardware
* setup function and make the driver major/minor values available
* for other.
*
* PARAMETERS:
* major - clock device major number
* minor - clock device minor number
* pargp - device driver initialization argument (not used)
*
* RETURNS:
* RTEMS status code
*/
rtems_device_driver rtems_device_driver
Clock_initialize(rtems_device_major_number major, Clock_initialize(rtems_device_major_number major,
rtems_device_minor_number minor, rtems_device_minor_number minor,
void *pargp) void *pargp)
{ {
Install_clock (Clock_isr); Install_clock (Clock_isr);
/* Make major/minor avail to others such as shared memory driver */ return RTEMS_SUCCESSFUL;
rtems_clock_major = major;
rtems_clock_minor = minor;
return RTEMS_SUCCESSFUL;
} }