watchdog.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License as
  4. * published by the Free Software Foundation; either version 2 of
  5. * the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  15. * MA 02111-1307 USA
  16. */
  17. #include <common.h>
  18. #include <asm/processor.h>
  19. #include <asm/io.h>
  20. #define WDT_BASE WTCNT
  21. #define WDT_WD (1 << 6)
  22. #define WDT_RST_P (0)
  23. #define WDT_RST_M (1 << 5)
  24. #define WDT_ENABLE (1 << 7)
  25. #if defined(CONFIG_WATCHDOG)
  26. static unsigned char csr_read(void)
  27. {
  28. return inb(WDT_BASE + 0x04);
  29. }
  30. static void cnt_write(unsigned char value)
  31. {
  32. outl((unsigned short)value | 0x5A00, WDT_BASE + 0x00);
  33. }
  34. static void csr_write(unsigned char value)
  35. {
  36. outl((unsigned short)value | 0xA500, WDT_BASE + 0x04);
  37. }
  38. void watchdog_reset(void)
  39. {
  40. outl(0x55000000, WDT_BASE + 0x08);
  41. }
  42. int watchdog_init(void)
  43. {
  44. /* Set overflow time*/
  45. cnt_write(0);
  46. /* Power on reset */
  47. csr_write(WDT_WD|WDT_RST_P|WDT_ENABLE);
  48. return 0;
  49. }
  50. int watchdog_disable(void)
  51. {
  52. csr_write(csr_read() & ~WDT_ENABLE);
  53. return 0;
  54. }
  55. #endif
  56. void reset_cpu(unsigned long ignored)
  57. {
  58. while (1)
  59. ;
  60. }