watchdog.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * include/asm-sh/cpu-sh2/watchdog.h
  3. *
  4. * Copyright (C) 2002, 2003 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #ifndef __ASM_CPU_SH2_WATCHDOG_H
  11. #define __ASM_CPU_SH2_WATCHDOG_H
  12. /*
  13. * More SH-2 brilliance .. its not good enough that we can't read
  14. * and write the same sizes to WTCNT, now we have to read and write
  15. * with different sizes at different addresses for WTCNT _and_ RSTCSR.
  16. *
  17. * At least on the bright side no one has managed to screw over WTCSR
  18. * in this fashion .. yet.
  19. */
  20. /* Register definitions */
  21. #define WTCNT 0xfffffe80
  22. #define WTCSR 0xfffffe80
  23. #define RSTCSR 0xfffffe82
  24. #define WTCNT_R (WTCNT + 1)
  25. #define RSTCSR_R (RSTCSR + 1)
  26. /* Bit definitions */
  27. #define WTCSR_IOVF 0x80
  28. #define WTCSR_WT 0x40
  29. #define WTCSR_TME 0x20
  30. #define WTCSR_RSTS 0x00
  31. #define RSTCSR_RSTS 0x20
  32. /**
  33. * sh_wdt_read_rstcsr - Read from Reset Control/Status Register
  34. *
  35. * Reads back the RSTCSR value.
  36. */
  37. static inline __u8 sh_wdt_read_rstcsr(void)
  38. {
  39. /*
  40. * Same read/write brain-damage as for WTCNT here..
  41. */
  42. return __raw_readb(RSTCSR_R);
  43. }
  44. /**
  45. * sh_wdt_write_csr - Write to Reset Control/Status Register
  46. *
  47. * @val: Value to write
  48. *
  49. * Writes the given value @val to the lower byte of the control/status
  50. * register. The upper byte is set manually on each write.
  51. */
  52. static inline void sh_wdt_write_rstcsr(__u8 val)
  53. {
  54. /*
  55. * Note: Due to the brain-damaged nature of this register,
  56. * we can't presently touch the WOVF bit, since the upper byte
  57. * has to be swapped for this. So just leave it alone..
  58. */
  59. __raw_writeb((WTCNT_HIGH << 8) | (__u16)val, RSTCSR);
  60. }
  61. #endif /* __ASM_CPU_SH2_WATCHDOG_H */