source: rtems/c/src/lib/libbsp/m68k/gen68340/clock/ckinit.c @ c6fb8ed4

4.104.115
Last change on this file since c6fb8ed4 was c6fb8ed4, checked in by Joel Sherrill <joel.sherrill@…>, on 09/16/08 at 19:03:44

2008-09-16 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, configure.ac, clock/ckinit.c, startup/linkcmds: Add use of bsp_get_work_area() in its own file and rely on BSP Framework to perform more initialization. Remove unnecessary includes of rtems/libio.h and rtems/libcsupport.h.
  • startup/bspstart.c: Removed.
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * This routine initializes the MC68340/349 Periodic Interval Timer
3 *
4 * Based on the `gen68360' board support package, and covered by the
5 * original distribution terms.
6 *
7 * Geoffroy Montel
8 * France Telecom - CNET/DSM/TAM/CAT
9 * 4, rue du Clos Courtel
10 * 35512 CESSON-SEVIGNE
11 * FRANCE
12 *
13 * e-mail: g_montel@yahoo.com
14 *
15 *  $Id$
16 */
17
18/*
19 * Input parameters:    NONE
20 *
21 * Output parameters:   NONE
22 *
23 * COPYRIGHT (c) 1989-1999.
24 * On-Line Applications Research Corporation (OAR).
25 *
26 * The license and distribution terms for this file may be
27 * found in the file LICENSE in this distribution or at
28 * http://www.rtems.com/license/LICENSE.
29 */
30
31#include <stdlib.h>                     /* for atexit() */
32#include <bsp.h>
33#include <m68340.h>
34
35#define CLOCK_VECTOR    120             /* clock isr routine vector in the vbr */
36#define CLOCK_IRQ_LEVEL 6               /* clock isr level */
37
38/*
39 * Clock_driver_ticks is a monotonically increasing counter of the
40 * number of clock ticks since the driver was initialized.
41 */
42volatile uint32_t         Clock_driver_ticks;
43
44/*
45 * These are set by clock driver during its init
46 */
47rtems_device_major_number rtems_clock_major = ~0;
48rtems_device_minor_number rtems_clock_minor;
49
50/*
51 * Periodic interval timer interrupt handler
52 */
53
54/******************************************************
55  Name: Clock_isr
56  Input parameters: irq vector
57  Output parameters: none
58  Description: update # of clock ticks
59 *****************************************************/
60rtems_isr
61Clock_isr (rtems_vector_number vector)
62{
63        /*
64         * Announce the clock tick
65         */
66        Clock_driver_ticks++;
67        rtems_clock_tick();
68}
69
70/******************************************************
71  Name: clock_exit
72  Input parameters: -
73  Output parameters: -
74  Description: turn off periodic time at shutdown
75 *****************************************************/
76void
77Clock_exit (void)
78{
79        /*
80         * Turn off periodic interval timer
81         */
82        SIMPITR = 0;
83}
84
85/******************************************************
86  Name: Install_clock
87  Input parameters: the Clock Interrupt Subroutine
88  Output parameters: -
89  Description: initialize the periodic interval ticker
90               called by Clock_Initialize
91 *****************************************************/
92static void
93Install_clock (rtems_isr_entry clock_isr)
94{
95        uint32_t   pitr_tmp;
96        uint32_t   usecs_per_tick;
97
98        Clock_driver_ticks = 0;
99
100        set_vector (clock_isr, CLOCK_VECTOR, 1);
101
102        /* sets the Periodic Interrupt Control Register PICR */
103        /* voir a quoi correspond exactement le Clock Vector */
104
105        SIMPICR = ( CLOCK_IRQ_LEVEL << 8 ) | ( CLOCK_VECTOR );
106
107        /* sets the PITR count value */
108        /* this assumes a 32.765 kHz crystal */
109
110        usecs_per_tick = rtems_configuration_get_microseconds_per_tick();
111        /* find out whether prescaler should be enabled or not */
112        if ( usecs_per_tick <= 31128 ) {
113           pitr_tmp = ( usecs_per_tick * 8192 ) / 1000000 ;
114        } else {
115           pitr_tmp = ( usecs_per_tick / 1000000 ) * 16;
116           /* enable it */
117           pitr_tmp |= 0x100;
118        }
119
120        SIMPITR = (unsigned char) pitr_tmp;
121
122        atexit (Clock_exit);
123}
124
125/******************************************************
126  Name: Clock_initialize
127  Input parameters: major & minor numbers
128  Output parameters: -
129  Description: main entry for clock initialization
130               calls the bsp dependant routine
131 *****************************************************/
132rtems_device_driver
133Clock_initialize(
134        rtems_device_major_number major,
135        rtems_device_minor_number minor,
136        void *pargp
137)
138{
139        Install_clock (Clock_isr);
140
141        /*
142         * make major/minor avail to others such as shared memory driver
143         */
144        rtems_clock_major = major;
145        rtems_clock_minor = minor;
146
147        return RTEMS_SUCCESSFUL;
148}
Note: See TracBrowser for help on using the repository browser.