watchdog.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * include/asm-sh/watchdog.h
  3. *
  4. * Copyright (C) 2002, 2003 Paul Mundt
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #ifndef __ASM_SH_WATCHDOG_H
  12. #define __ASM_SH_WATCHDOG_H
  13. #ifdef __KERNEL__
  14. #include <linux/types.h>
  15. #include <linux/config.h>
  16. #include <asm/cpu/watchdog.h>
  17. #include <asm/io.h>
  18. /*
  19. * See asm/cpu-sh2/watchdog.h for explanation of this stupidity..
  20. */
  21. #ifndef WTCNT_R
  22. # define WTCNT_R WTCNT
  23. #endif
  24. #ifndef WTCSR_R
  25. # define WTCSR_R WTCSR
  26. #endif
  27. #define WTCNT_HIGH 0x5a
  28. #define WTCSR_HIGH 0xa5
  29. #define WTCSR_CKS2 0x04
  30. #define WTCSR_CKS1 0x02
  31. #define WTCSR_CKS0 0x01
  32. /*
  33. * CKS0-2 supports a number of clock division ratios. At the time the watchdog
  34. * is enabled, it defaults to a 41 usec overflow period .. we overload this to
  35. * something a little more reasonable, and really can't deal with anything
  36. * lower than WTCSR_CKS_1024, else we drop back into the usec range.
  37. *
  38. * Clock Division Ratio Overflow Period
  39. * --------------------------------------------
  40. * 1/32 (initial value) 41 usecs
  41. * 1/64 82 usecs
  42. * 1/128 164 usecs
  43. * 1/256 328 usecs
  44. * 1/512 656 usecs
  45. * 1/1024 1.31 msecs
  46. * 1/2048 2.62 msecs
  47. * 1/4096 5.25 msecs
  48. */
  49. #define WTCSR_CKS_32 0x00
  50. #define WTCSR_CKS_64 0x01
  51. #define WTCSR_CKS_128 0x02
  52. #define WTCSR_CKS_256 0x03
  53. #define WTCSR_CKS_512 0x04
  54. #define WTCSR_CKS_1024 0x05
  55. #define WTCSR_CKS_2048 0x06
  56. #define WTCSR_CKS_4096 0x07
  57. /**
  58. * sh_wdt_read_cnt - Read from Counter
  59. *
  60. * Reads back the WTCNT value.
  61. */
  62. static inline __u8 sh_wdt_read_cnt(void)
  63. {
  64. return ctrl_inb(WTCNT_R);
  65. }
  66. /**
  67. * sh_wdt_write_cnt - Write to Counter
  68. *
  69. * @val: Value to write
  70. *
  71. * Writes the given value @val to the lower byte of the timer counter.
  72. * The upper byte is set manually on each write.
  73. */
  74. static inline void sh_wdt_write_cnt(__u8 val)
  75. {
  76. ctrl_outw((WTCNT_HIGH << 8) | (__u16)val, WTCNT);
  77. }
  78. /**
  79. * sh_wdt_read_csr - Read from Control/Status Register
  80. *
  81. * Reads back the WTCSR value.
  82. */
  83. static inline __u8 sh_wdt_read_csr(void)
  84. {
  85. return ctrl_inb(WTCSR_R);
  86. }
  87. /**
  88. * sh_wdt_write_csr - Write to Control/Status Register
  89. *
  90. * @val: Value to write
  91. *
  92. * Writes the given value @val to the lower byte of the control/status
  93. * register. The upper byte is set manually on each write.
  94. */
  95. static inline void sh_wdt_write_csr(__u8 val)
  96. {
  97. ctrl_outw((WTCSR_HIGH << 8) | (__u16)val, WTCSR);
  98. }
  99. #endif /* __KERNEL__ */
  100. #endif /* __ASM_SH_WATCHDOG_H */