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