You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

timer.h 1.5KB

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