17c478bd9Sstevel@tonic-gate /* Defines for routines to implement a low-overhead timer for drivers */ 27c478bd9Sstevel@tonic-gate 37c478bd9Sstevel@tonic-gate /* 47c478bd9Sstevel@tonic-gate * This program is free software; you can redistribute it and/or 57c478bd9Sstevel@tonic-gate * modify it under the terms of the GNU General Public License as 67c478bd9Sstevel@tonic-gate * published by the Free Software Foundation; either version 2, or (at 77c478bd9Sstevel@tonic-gate * your option) any later version. 87c478bd9Sstevel@tonic-gate */ 97c478bd9Sstevel@tonic-gate 107c478bd9Sstevel@tonic-gate #ifndef TIMER_H 117c478bd9Sstevel@tonic-gate #define TIMER_H 127c478bd9Sstevel@tonic-gate 137c478bd9Sstevel@tonic-gate /* Ports for the 8254 timer chip */ 147c478bd9Sstevel@tonic-gate #define TIMER2_PORT 0x42 157c478bd9Sstevel@tonic-gate #define TIMER_MODE_PORT 0x43 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate /* Meaning of the mode bits */ 187c478bd9Sstevel@tonic-gate #define TIMER0_SEL 0x00 197c478bd9Sstevel@tonic-gate #define TIMER1_SEL 0x40 207c478bd9Sstevel@tonic-gate #define TIMER2_SEL 0x80 217c478bd9Sstevel@tonic-gate #define READBACK_SEL 0xC0 227c478bd9Sstevel@tonic-gate 237c478bd9Sstevel@tonic-gate #define LATCH_COUNT 0x00 247c478bd9Sstevel@tonic-gate #define LOBYTE_ACCESS 0x10 257c478bd9Sstevel@tonic-gate #define HIBYTE_ACCESS 0x20 267c478bd9Sstevel@tonic-gate #define WORD_ACCESS 0x30 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #define MODE0 0x00 297c478bd9Sstevel@tonic-gate #define MODE1 0x02 307c478bd9Sstevel@tonic-gate #define MODE2 0x04 317c478bd9Sstevel@tonic-gate #define MODE3 0x06 327c478bd9Sstevel@tonic-gate #define MODE4 0x08 337c478bd9Sstevel@tonic-gate #define MODE5 0x0A 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #define BINARY_COUNT 0x00 367c478bd9Sstevel@tonic-gate #define BCD_COUNT 0x01 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* Timers tick over at this rate */ 397c478bd9Sstevel@tonic-gate #define CLOCK_TICK_RATE 1193180U 407c478bd9Sstevel@tonic-gate #define TICKS_PER_MS (CLOCK_TICK_RATE/1000) 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* Parallel Peripheral Controller Port B */ 437c478bd9Sstevel@tonic-gate #define PPC_PORTB 0x61 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* Meaning of the port bits */ 467c478bd9Sstevel@tonic-gate #define PPCB_T2OUT 0x20 /* Bit 5 */ 477c478bd9Sstevel@tonic-gate #define PPCB_SPKR 0x02 /* Bit 1 */ 487c478bd9Sstevel@tonic-gate #define PPCB_T2GATE 0x01 /* Bit 0 */ 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* Ticks must be between 0 and 65535 (0 == 65536) 517c478bd9Sstevel@tonic-gate because it is a 16 bit counter */ 527c478bd9Sstevel@tonic-gate extern void load_timer2(unsigned int ticks); 537c478bd9Sstevel@tonic-gate extern inline int timer2_running(void); 547c478bd9Sstevel@tonic-gate extern void waiton_timer2(unsigned int ticks); 557c478bd9Sstevel@tonic-gate extern void __load_timer2(unsigned int ticks); 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate extern void setup_timers(void); 587c478bd9Sstevel@tonic-gate extern void ndelay(unsigned int nsecs); 597c478bd9Sstevel@tonic-gate extern void udelay(unsigned int usecs); 607c478bd9Sstevel@tonic-gate extern void mdelay(unsigned int msecs); 617c478bd9Sstevel@tonic-gate //extern unsigned long currticks(void); 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate struct timeval { 647c478bd9Sstevel@tonic-gate long tv_sec; 657c478bd9Sstevel@tonic-gate long tv_usec; 667c478bd9Sstevel@tonic-gate }; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate #endif /* TIMER_H */ 69