Nobuhiro Iwamatsu | 0b135cf | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 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 | |
| 18 | #include <common.h> |
| 19 | #include <asm/processor.h> |
| 20 | |
| 21 | #define WDT_BASE WTCNT |
| 22 | |
| 23 | static unsigned char cnt_read (void){ |
| 24 | return *((volatile unsigned char *)(WDT_BASE + 0x00)); |
| 25 | } |
| 26 | |
| 27 | static unsigned char csr_read (void){ |
| 28 | return *((volatile unsigned char *)(WDT_BASE + 0x04)); |
| 29 | } |
| 30 | |
| 31 | static void cnt_write (unsigned char value){ |
| 32 | while (csr_read() & (1 << 5)) { |
| 33 | /* delay */ |
| 34 | } |
Wolfgang Denk | 61fb15c5 | 2007-12-27 01:52:50 +0100 | [diff] [blame] | 35 | *((volatile unsigned short *)(WDT_BASE + 0x00)) |
Nobuhiro Iwamatsu | b02bad1 | 2007-09-23 02:12:30 +0900 | [diff] [blame] | 36 | = ((unsigned short) value) | 0x5A00; |
Nobuhiro Iwamatsu | 0b135cf | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | static void csr_write (unsigned char value){ |
Wolfgang Denk | 61fb15c5 | 2007-12-27 01:52:50 +0100 | [diff] [blame] | 40 | *((volatile unsigned short *)(WDT_BASE + 0x04)) |
Nobuhiro Iwamatsu | b02bad1 | 2007-09-23 02:12:30 +0900 | [diff] [blame] | 41 | = ((unsigned short) value) | 0xA500; |
Nobuhiro Iwamatsu | 0b135cf | 2007-05-13 20:58:00 +0900 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | |
| 45 | int watchdog_init (void){ return 0; } |
| 46 | |
| 47 | void reset_cpu (unsigned long ignored) |
| 48 | { |
| 49 | while(1); |
| 50 | } |