source: rtems/c/src/lib/libbsp/m68k/mvme136/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.3 KB
Line 
1/*  Clock_init()
2 *
3 *  This routine initializes the Z80386 1 on the MVME136 board.
4 *  The tick frequency is 1 millisecond.
5 *
6 *  Input parameters:  NONE
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include <stdlib.h>
21
22#include <bsp.h>
23#include <rtems/libio.h>
24#include <rtems/zilog/z8036.h>
25
26#define MICRVAL     0xe2            /* disable lower chain, no vec */
27                                    /*  set right justified addr */
28                                    /*  and master int enable */
29#define MCCRVAL     0xc4            /* enable T1 and port B */
30                                    /*   timers independent */
31#define MS_COUNT    0x07d0          /* T1's countdown constant (1 ms) */
32#define T1MSRVAL    0x80            /* T1 cont. cycle/pulse output */
33#define T1CSRVAL    0xc6            /* enable interrupt, allow and */
34                                    /*   and trigger countdown */
35
36#define TIMER        0xfffb0000
37#define RELOAD       0x24            /* clr IP & IUS,allow countdown */
38
39#define CLOCK_VECTOR 66
40
41uint32_t         Clock_isrs;        /* ISRs until next tick */
42
43volatile uint32_t         Clock_driver_ticks; /* ticks since initialization */
44
45rtems_isr_entry  Old_ticker;
46
47void Clock_exit( void );
48
49/*
50 * These are set by clock driver during its init
51 */
52
53rtems_device_major_number rtems_clock_major = ~0;
54rtems_device_minor_number rtems_clock_minor;
55
56/*
57 *  ISR Handler
58 */
59
60rtems_isr Clock_isr(
61  rtems_vector_number vector
62)
63{
64  Clock_driver_ticks += 1;
65  ((volatile struct z8036_map *) TIMER)->CT1_CMD_STATUS = RELOAD;
66
67  if ( Clock_isrs == 1 ) {
68    rtems_clock_tick();
69    Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
70  }
71  else
72    Clock_isrs -= 1;
73}
74
75void Install_clock(
76  rtems_isr_entry clock_isr
77)
78{
79  volatile struct z8036_map *timer;
80
81  Clock_driver_ticks = 0;
82  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
83
84  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
85  timer = (struct z8036_map *) 0xfffb0000;
86  timer->MASTER_INTR        = MICRVAL;
87  timer->CT1_MODE_SPEC      = T1MSRVAL;
88
89  *((uint16_t*)0xfffb0016) = MS_COUNT;  /* write countdown value */
90
91  /*
92   *  timer->CT1_TIME_CONST_MSB = (MS_COUNT >> 8);
93   *  timer->CT1_TIME_CONST_LSB = (MS_COUNT &  0xff);
94   */
95
96  timer->MASTER_CFG         = MCCRVAL;
97  timer->CT1_CMD_STATUS     = T1CSRVAL;
98
99  /*
100   * Enable interrupt via VME interrupt mask register
101   */
102  (*(uint8_t*)0xfffb0038) &= 0xfd;
103
104  atexit( Clock_exit );
105}
106
107void Clock_exit( void )
108{
109  volatile struct z8036_map *timer;
110
111  timer = (struct z8036_map *) 0xfffb0000;
112  timer->MASTER_INTR        = 0x62;
113  timer->CT1_MODE_SPEC      = 0x00;
114  timer->MASTER_CFG         = 0xf4;
115  timer->CT1_CMD_STATUS     = 0x00;
116  /* do not restore old vector */
117}
118
119rtems_device_driver Clock_initialize(
120  rtems_device_major_number major,
121  rtems_device_minor_number minor,
122  void *pargp
123)
124{
125  Install_clock( Clock_isr );
126
127  /*
128   * make major/minor avail to others such as shared memory driver
129   */
130
131  rtems_clock_major = major;
132  rtems_clock_minor = minor;
133
134  return RTEMS_SUCCESSFUL;
135}
Note: See TracBrowser for help on using the repository browser.