timer.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* $Id: timer.h,v 1.21 1999/04/20 13:22:51 anton Exp $
  2. * timer.h: Definitions for the timer chips on the Sparc.
  3. *
  4. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5. */
  6. #ifndef _SPARC_TIMER_H
  7. #define _SPARC_TIMER_H
  8. #include <asm/system.h> /* For SUN4M_NCPUS */
  9. #include <asm/sun4paddr.h>
  10. #include <asm/btfixup.h>
  11. /* Timer structures. The interrupt timer has two properties which
  12. * are the counter (which is handled in do_timer in sched.c) and the limit.
  13. * This limit is where the timer's counter 'wraps' around. Oddly enough,
  14. * the sun4c timer when it hits the limit wraps back to 1 and not zero
  15. * thus when calculating the value at which it will fire a microsecond you
  16. * must adjust by one. Thanks SUN for designing such great hardware ;(
  17. */
  18. /* Note that I am only going to use the timer that interrupts at
  19. * Sparc IRQ 10. There is another one available that can fire at
  20. * IRQ 14. Currently it is left untouched, we keep the PROM's limit
  21. * register value and let the prom take these interrupts. This allows
  22. * L1-A to work.
  23. */
  24. struct sun4c_timer_info {
  25. __volatile__ unsigned int cur_count10;
  26. __volatile__ unsigned int timer_limit10;
  27. __volatile__ unsigned int cur_count14;
  28. __volatile__ unsigned int timer_limit14;
  29. };
  30. #define SUN4C_TIMER_PHYSADDR 0xf3000000
  31. #ifdef CONFIG_SUN4
  32. #define SUN_TIMER_PHYSADDR SUN4_300_TIMER_PHYSADDR
  33. #else
  34. #define SUN_TIMER_PHYSADDR SUN4C_TIMER_PHYSADDR
  35. #endif
  36. /* A sun4m has two blocks of registers which are probably of the same
  37. * structure. LSI Logic's L64851 is told to _decrement_ from the limit
  38. * value. Aurora behaves similarly but its limit value is compacted in
  39. * other fashion (it's wider). Documented fields are defined here.
  40. */
  41. /* As with the interrupt register, we have two classes of timer registers
  42. * which are per-cpu and master. Per-cpu timers only hit that cpu and are
  43. * only level 14 ticks, master timer hits all cpus and is level 10.
  44. */
  45. #define SUN4M_PRM_CNT_L 0x80000000
  46. #define SUN4M_PRM_CNT_LVALUE 0x7FFFFC00
  47. struct sun4m_timer_percpu_info {
  48. __volatile__ unsigned int l14_timer_limit; /* Initial value is 0x009c4000 */
  49. __volatile__ unsigned int l14_cur_count;
  50. /* This register appears to be write only and/or inaccessible
  51. * on Uni-Processor sun4m machines.
  52. */
  53. __volatile__ unsigned int l14_limit_noclear; /* Data access error is here */
  54. __volatile__ unsigned int cntrl; /* =1 after POST on Aurora */
  55. __volatile__ unsigned char space[PAGE_SIZE - 16];
  56. };
  57. struct sun4m_timer_regs {
  58. struct sun4m_timer_percpu_info cpu_timers[SUN4M_NCPUS];
  59. volatile unsigned int l10_timer_limit;
  60. volatile unsigned int l10_cur_count;
  61. /* Again, this appears to be write only and/or inaccessible
  62. * on uni-processor sun4m machines.
  63. */
  64. volatile unsigned int l10_limit_noclear;
  65. /* This register too, it must be magic. */
  66. volatile unsigned int foobar;
  67. volatile unsigned int cfg; /* equals zero at boot time... */
  68. };
  69. extern struct sun4m_timer_regs *sun4m_timers;
  70. #define SUN4D_PRM_CNT_L 0x80000000
  71. #define SUN4D_PRM_CNT_LVALUE 0x7FFFFC00
  72. struct sun4d_timer_regs {
  73. volatile unsigned int l10_timer_limit;
  74. volatile unsigned int l10_cur_countx;
  75. volatile unsigned int l10_limit_noclear;
  76. volatile unsigned int ctrl;
  77. volatile unsigned int l10_cur_count;
  78. };
  79. extern struct sun4d_timer_regs *sun4d_timers;
  80. extern __volatile__ unsigned int *master_l10_counter;
  81. extern __volatile__ unsigned int *master_l10_limit;
  82. /* FIXME: Make do_[gs]ettimeofday btfixup calls */
  83. BTFIXUPDEF_CALL(int, bus_do_settimeofday, struct timespec *tv)
  84. #define bus_do_settimeofday(tv) BTFIXUP_CALL(bus_do_settimeofday)(tv)
  85. #endif /* !(_SPARC_TIMER_H) */