watchdog.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #define WDT_BASE WTCNT
  20. static unsigned char cnt_read (void){
  21. return *((volatile unsigned char *)(WDT_BASE + 0x00));
  22. }
  23. static unsigned char csr_read (void){
  24. return *((volatile unsigned char *)(WDT_BASE + 0x04));
  25. }
  26. static void cnt_write (unsigned char value){
  27. while (csr_read() & (1 << 5)) {
  28. /* delay */
  29. }
  30. *((volatile unsigned short *)(WDT_BASE + 0x00))
  31. = ((unsigned short) value) | 0x5A00;
  32. }
  33. static void csr_write (unsigned char value){
  34. *((volatile unsigned short *)(WDT_BASE + 0x04))
  35. = ((unsigned short) value) | 0xA500;
  36. }
  37. int watchdog_init (void){ return 0; }
  38. void reset_cpu (unsigned long ignored)
  39. {
  40. while(1);
  41. }