1 | /* Defines for routines to implement a low-overhead timer for drivers */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * This program is free software; you can redistribute it and/or
|
---|
5 | * modify it under the terms of the GNU General Public License as
|
---|
6 | * published by the Free Software Foundation; either version 2, or (at
|
---|
7 | * your option) any later version.
|
---|
8 | */
|
---|
9 |
|
---|
10 | /*
|
---|
11 | * Oracle GPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
12 | * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
|
---|
13 | * the General Public License version 2 (GPLv2) at this time for any software where
|
---|
14 | * a choice of GPL license versions is made available with the language indicating
|
---|
15 | * that GPLv2 or any later version may be used, or where a choice of which version
|
---|
16 | * of the GPL is applied is otherwise unspecified.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef TIMER_H
|
---|
20 | #define TIMER_H
|
---|
21 |
|
---|
22 | /* Ports for the 8254 timer chip */
|
---|
23 | #define TIMER2_PORT 0x42
|
---|
24 | #define TIMER_MODE_PORT 0x43
|
---|
25 |
|
---|
26 | /* Meaning of the mode bits */
|
---|
27 | #define TIMER0_SEL 0x00
|
---|
28 | #define TIMER1_SEL 0x40
|
---|
29 | #define TIMER2_SEL 0x80
|
---|
30 | #define READBACK_SEL 0xC0
|
---|
31 |
|
---|
32 | #define LATCH_COUNT 0x00
|
---|
33 | #define LOBYTE_ACCESS 0x10
|
---|
34 | #define HIBYTE_ACCESS 0x20
|
---|
35 | #define WORD_ACCESS 0x30
|
---|
36 |
|
---|
37 | #define MODE0 0x00
|
---|
38 | #define MODE1 0x02
|
---|
39 | #define MODE2 0x04
|
---|
40 | #define MODE3 0x06
|
---|
41 | #define MODE4 0x08
|
---|
42 | #define MODE5 0x0A
|
---|
43 |
|
---|
44 | #define BINARY_COUNT 0x00
|
---|
45 | #define BCD_COUNT 0x01
|
---|
46 |
|
---|
47 | /* Timers tick over at this rate */
|
---|
48 | #define CLOCK_TICK_RATE 1193180U
|
---|
49 | #define TICKS_PER_MS (CLOCK_TICK_RATE/1000)
|
---|
50 |
|
---|
51 | /* Parallel Peripheral Controller Port B */
|
---|
52 | #define PPC_PORTB 0x61
|
---|
53 |
|
---|
54 | /* Meaning of the port bits */
|
---|
55 | #define PPCB_T2OUT 0x20 /* Bit 5 */
|
---|
56 | #define PPCB_SPKR 0x02 /* Bit 1 */
|
---|
57 | #define PPCB_T2GATE 0x01 /* Bit 0 */
|
---|
58 |
|
---|
59 | /* Ticks must be between 0 and 65535 (0 == 65536)
|
---|
60 | because it is a 16 bit counter */
|
---|
61 | extern void load_timer2(unsigned int ticks);
|
---|
62 | extern inline int timer2_running(void);
|
---|
63 | extern void waiton_timer2(unsigned int ticks);
|
---|
64 |
|
---|
65 | extern void setup_timers(void);
|
---|
66 | extern void ndelay(unsigned int nsecs);
|
---|
67 | extern void udelay(unsigned int usecs);
|
---|
68 | extern void mdelay(unsigned int msecs);
|
---|
69 |
|
---|
70 |
|
---|
71 | #endif /* TIMER_H */
|
---|