Changeset 5105833c in rtems


Ignore:
Timestamp:
Oct 12, 2014, 7:00:00 PM (5 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, 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)
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/m68k/mcf5272/clock/ckinit.c

    r40716bf r5105833c  
    44 *  This driver initailizes timer1 on the MCF5272 as the
    55 *  main system clock
    6  *
     6 */
     7
     8/*
    79 *  Copyright 2004 Cogent Computer Systems
    810 *  Author: Jay Monkman <jtm@lopingdog.com>
     
    3436volatile uint32_t Clock_driver_ticks;
    3537
    36 
    37 /*
    38  * These are set by clock driver during its init
    39  */
    40 
    41 rtems_device_major_number rtems_clock_major = ~0;
    42 rtems_device_minor_number rtems_clock_minor;
    43 
    4438rtems_isr (*rtems_clock_hook)(rtems_vector_number) = NULL;
    4539
    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
     40static rtems_isr
    5741Clock_isr (rtems_vector_number vector)
    5842{
    59     /* Clear pending interrupt... */
    60     g_timer_regs->ter1 = MCF5272_TER_REF | MCF5272_TER_CAP;
     43  /* Clear pending interrupt... */
     44  g_timer_regs->ter1 = MCF5272_TER_REF | MCF5272_TER_CAP;
    6145
    62     /* Announce the clock tick */
    63     Clock_driver_ticks++;
    64     rtems_clock_tick();
    65     if (rtems_clock_hook != NULL) {
    66         rtems_clock_hook(vector);
    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  }
    6852}
    6953
    70 
    71 /* Clock_exit --
    72  *     This shuts down the timer if it was enabled and removes it
    73  *     from the MCF5206E interrupt mask.
    74  *
    75  * PARAMETERS:
    76  *     none
    77  *
    78  * RETURNS:
    79  *     none
    80  */
    8154void
    8255Clock_exit(void)
    8356{
    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;
    9158
    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;
    9464
    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;
    9870}
    9971
    100 
    101 /* Install_clock --
    102  *     This initialises timer1 with the BSP timeslice config value
    103  *     as a reference and sets up the interrupt handler for clock ticks.
    104  *
    105  * PARAMETERS:
    106  *     clock_isr - clock interrupt handler routine
    107  *
    108  * RETURNS:
    109  *     none.
    110  */
    11172static void
    11273Install_clock(rtems_isr_entry clock_isr)
    11374{
    11475  uint32_t icr;
     76
    11577  Clock_driver_ticks = 0;
    116   if (rtems_configuration_get_ticks_per_timeslice()) {
    11778
    118       /* Register the interrupt handler */
    119       set_vector(clock_isr, BSP_INTVEC_TMR1, 1);
     79  /* Register the interrupt handler */
     80  set_vector(clock_isr, BSP_INTVEC_TMR1, 1);
    12081
    121       /* Reset timer 1 */
    122       g_timer_regs->tmr1 = MCF5272_TMR_RST;
    123       g_timer_regs->tmr1 = MCF5272_TMR_CLK_STOP;
    124       g_timer_regs->tmr1 = MCF5272_TMR_RST;
    125       g_timer_regs->tcn1 = 0;  /* reset counter */
    126       g_timer_regs->ter1 = MCF5272_TER_REF | MCF5272_TER_CAP;
     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;
    12788
    128       /* Set Timer 1 prescaler so that it counts in microseconds */
    129       g_timer_regs->tmr1 = (
    130           ((((BSP_SYSTEM_FREQUENCY / 1000000) - 1) << MCF5272_TMR_PS_SHIFT) |
    131            MCF5272_TMR_CE_DISABLE                                      |
    132            MCF5272_TMR_ORI                                             |
    133            MCF5272_TMR_FRR                                             |
    134            MCF5272_TMR_CLK_MSTR                                        |
    135            MCF5272_TMR_RST));
     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));
    13697
    137       /* Set the timer timeout value from the BSP config */
    138       g_timer_regs->trr1 = rtems_configuration_get_microseconds_per_tick() - 1;
     98  /* Set the timer timeout value from the BSP config */
     99  g_timer_regs->trr1 = rtems_configuration_get_microseconds_per_tick() - 1;
    139100
    140       /* Feed system frequency to the timer */
    141       g_timer_regs->tmr1 |= MCF5272_TMR_CLK_MSTR;
     101  /* Feed system frequency to the timer */
     102  g_timer_regs->tmr1 |= MCF5272_TMR_CLK_MSTR;
    142103
    143       /* Configure timer1 interrupts */
    144       icr = g_intctrl_regs->icr1;
    145       icr = icr & ~(MCF5272_ICR1_TMR1_MASK | MCF5272_ICR1_TMR1_PI);
    146       icr |= (MCF5272_ICR1_TMR1_IPL(BSP_INTLVL_TMR1) | MCF5272_ICR1_TMR1_PI);
    147       g_intctrl_regs->icr1 = icr;
     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;
    148109
    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);
    152112}
    153113
     114rtems_device_driver
     115Clock_initialize(
     116  rtems_device_major_number major,
     117  rtems_device_minor_number minor,
     118  void *pargp
     119)
     120{
     121  Install_clock (Clock_isr);
    154122
    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;
    180124}
Note: See TracChangeset for help on using the changeset viewer.