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

4.104.114.95
Last change on this file since 34ef6c7 was 34ef6c7, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 5, 2008 at 10:06:51 PM

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

  • clock/ckinit.c: The Shared Memory Driver no longer requires the special IOCTL in Clock_control. This was a hack which has existed since before the Classic API Timer Manager was implemented. All implementations of and references to Clock_control were removed.
  • Property mode set to 100644
File size: 3.6 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 <rtems/libio.h>
34#include <m68340.h>
35
36#define CLOCK_VECTOR    120             /* clock isr routine vector in the vbr */
37#define CLOCK_IRQ_LEVEL 6               /* clock isr level */
38
39/*
40 * Clock_driver_ticks is a monotonically increasing counter of the
41 * number of clock ticks since the driver was initialized.
42 */
43volatile uint32_t         Clock_driver_ticks;
44
45/*
46 * These are set by clock driver during its init
47 */
48rtems_device_major_number rtems_clock_major = ~0;
49rtems_device_minor_number rtems_clock_minor;
50
51/*
52 * Periodic interval timer interrupt handler
53 */
54
55/******************************************************
56  Name: Clock_isr
57  Input parameters: irq vector
58  Output parameters: none
59  Description: update # of clock ticks
60 *****************************************************/
61rtems_isr
62Clock_isr (rtems_vector_number vector)
63{
64        /*
65         * Announce the clock tick
66         */
67        Clock_driver_ticks++;
68        rtems_clock_tick();
69}
70
71/******************************************************
72  Name: clock_exit
73  Input parameters: -
74  Output parameters: -
75  Description: turn off periodic time at shutdown
76 *****************************************************/
77void
78Clock_exit (void)
79{
80        /*
81         * Turn off periodic interval timer
82         */
83        SIMPITR = 0;
84}
85
86/******************************************************
87  Name: Install_clock
88  Input parameters: the Clock Interrupt Subroutine
89  Output parameters: -
90  Description: initialize the periodic interval ticker
91               called by Clock_Initialize
92 *****************************************************/
93static void
94Install_clock (rtems_isr_entry clock_isr)
95{
96        uint32_t   pitr_tmp;
97        uint32_t   usecs_per_tick;
98
99        Clock_driver_ticks = 0;
100
101        set_vector (clock_isr, CLOCK_VECTOR, 1);
102
103        /* sets the Periodic Interrupt Control Register PICR */
104        /* voir a quoi correspond exactement le Clock Vector */
105
106        SIMPICR = ( CLOCK_IRQ_LEVEL << 8 ) | ( CLOCK_VECTOR );
107
108        /* sets the PITR count value */
109        /* this assumes a 32.765 kHz crystal */
110
111        usecs_per_tick = rtems_configuration_get_microseconds_per_tick();
112        /* find out whether prescaler should be enabled or not */
113        if ( usecs_per_tick <= 31128 ) {
114           pitr_tmp = ( usecs_per_tick * 8192 ) / 1000000 ;
115        } else {
116           pitr_tmp = ( usecs_per_tick / 1000000 ) * 16;
117           /* enable it */
118           pitr_tmp |= 0x100;
119        }
120
121        SIMPITR = (unsigned char) pitr_tmp;
122
123        atexit (Clock_exit);
124}
125
126/******************************************************
127  Name: Clock_initialize
128  Input parameters: major & minor numbers
129  Output parameters: -
130  Description: main entry for clock initialization
131               calls the bsp dependant routine
132 *****************************************************/
133rtems_device_driver
134Clock_initialize(
135        rtems_device_major_number major,
136        rtems_device_minor_number minor,
137        void *pargp
138)
139{
140        Install_clock (Clock_isr);
141
142        /*
143         * make major/minor avail to others such as shared memory driver
144         */
145        rtems_clock_major = major;
146        rtems_clock_minor = minor;
147
148        return RTEMS_SUCCESSFUL;
149}
Note: See TracBrowser for help on using the repository browser.