1N/A/* Defines for routines to implement a low-overhead timer for drivers */
1N/A
1N/A /*
1N/A * This program is free software; you can redistribute it and/or
1N/A * modify it under the terms of the GNU General Public License as
1N/A * published by the Free Software Foundation; either version 2, or (at
1N/A * your option) any later version.
1N/A */
1N/A
1N/A#ifndef TIMER_H
1N/A#define TIMER_H
1N/A
1N/A/* Ports for the 8254 timer chip */
1N/A#define TIMER2_PORT 0x42
1N/A#define TIMER_MODE_PORT 0x43
1N/A
1N/A/* Meaning of the mode bits */
1N/A#define TIMER0_SEL 0x00
1N/A#define TIMER1_SEL 0x40
1N/A#define TIMER2_SEL 0x80
1N/A#define READBACK_SEL 0xC0
1N/A
1N/A#define LATCH_COUNT 0x00
1N/A#define LOBYTE_ACCESS 0x10
1N/A#define HIBYTE_ACCESS 0x20
1N/A#define WORD_ACCESS 0x30
1N/A
1N/A#define MODE0 0x00
1N/A#define MODE1 0x02
1N/A#define MODE2 0x04
1N/A#define MODE3 0x06
1N/A#define MODE4 0x08
1N/A#define MODE5 0x0A
1N/A
1N/A#define BINARY_COUNT 0x00
1N/A#define BCD_COUNT 0x01
1N/A
1N/A/* Timers tick over at this rate */
1N/A#define CLOCK_TICK_RATE 1193180U
1N/A#define TICKS_PER_MS (CLOCK_TICK_RATE/1000)
1N/A
1N/A/* Parallel Peripheral Controller Port B */
1N/A#define PPC_PORTB 0x61
1N/A
1N/A/* Meaning of the port bits */
1N/A#define PPCB_T2OUT 0x20 /* Bit 5 */
1N/A#define PPCB_SPKR 0x02 /* Bit 1 */
1N/A#define PPCB_T2GATE 0x01 /* Bit 0 */
1N/A
1N/A/* Ticks must be between 0 and 65535 (0 == 65536)
1N/A because it is a 16 bit counter */
1N/Aextern void load_timer2(unsigned int ticks);
1N/Aextern inline int timer2_running(void);
1N/Aextern void waiton_timer2(unsigned int ticks);
1N/Aextern void __load_timer2(unsigned int ticks);
1N/A
1N/Aextern void setup_timers(void);
1N/Aextern void ndelay(unsigned int nsecs);
1N/Aextern void udelay(unsigned int usecs);
1N/Aextern void mdelay(unsigned int msecs);
1N/A//extern unsigned long currticks(void);
1N/A
1N/Astruct timeval {
1N/A long tv_sec;
1N/A long tv_usec;
1N/A};
1N/A
1N/A#endif /* TIMER_H */