wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Josef Baumgartner <josef.baumgartner@telex.de> |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <watchdog.h> |
| 26 | #include <command.h> |
| 27 | |
| 28 | #ifdef CONFIG_M5272 |
| 29 | #include <asm/immap_5272.h> |
| 30 | #include <asm/m5272.h> |
| 31 | #endif |
| 32 | |
| 33 | #ifdef CONFIG_M5282 |
| 34 | |
| 35 | #endif |
| 36 | |
stroese | 8c725b9 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 37 | #ifdef CONFIG_M5249 |
| 38 | #include <asm/m5249.h> |
| 39 | #endif |
| 40 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 41 | |
| 42 | #ifdef CONFIG_M5272 |
| 43 | int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { |
| 44 | volatile wdog_t * wdp = (wdog_t *)(CFG_MBAR + MCFSIM_WRRR); |
| 45 | |
| 46 | wdp->wdog_wrrr = 0; |
| 47 | udelay (1000); |
| 48 | |
| 49 | /* enable watchdog, set timeout to 0 and wait */ |
| 50 | wdp->wdog_wrrr = 1; |
| 51 | while (1); |
| 52 | |
| 53 | /* we don't return! */ |
| 54 | return 0; |
| 55 | }; |
| 56 | |
| 57 | int checkcpu(void) { |
| 58 | ulong *dirp = (ulong *)(CFG_MBAR + MCFSIM_DIR); |
| 59 | uchar msk; |
| 60 | char *suf; |
| 61 | |
| 62 | puts ("CPU: "); |
| 63 | msk = (*dirp > 28) & 0xf; |
| 64 | switch (msk) { |
| 65 | case 0x2: suf = "1K75N"; break; |
| 66 | case 0x4: suf = "3K75N"; break; |
| 67 | default: |
| 68 | suf = NULL; |
| 69 | printf ("MOTOROLA MCF5272 (Mask:%01x)\n", msk); |
| 70 | break; |
| 71 | } |
| 72 | |
| 73 | if (suf) |
| 74 | printf ("MOTOROLA MCF5272 %s\n", suf); |
| 75 | return 0; |
| 76 | }; |
| 77 | |
| 78 | |
| 79 | #if defined(CONFIG_WATCHDOG) |
| 80 | /* Called by macro WATCHDOG_RESET */ |
| 81 | void watchdog_reset (void) |
| 82 | { |
| 83 | volatile immap_t * regp = (volatile immap_t *)CFG_MBAR; |
| 84 | regp->wdog_reg.wdog_wcr = 0; |
| 85 | } |
| 86 | |
| 87 | int watchdog_disable (void) |
| 88 | { |
| 89 | volatile immap_t *regp = (volatile immap_t *)CFG_MBAR; |
| 90 | |
| 91 | regp->wdog_reg.wdog_wcr = 0; /* reset watchdog counter */ |
| 92 | regp->wdog_reg.wdog_wirr = 0; /* disable watchdog interrupt */ |
| 93 | regp->wdog_reg.wdog_wrrr = 0; /* disable watchdog timer */ |
| 94 | |
| 95 | puts ("WATCHDOG:disabled\n"); |
| 96 | return (0); |
| 97 | } |
| 98 | |
| 99 | int watchdog_init (void) |
| 100 | { |
| 101 | volatile immap_t *regp = (volatile immap_t *)CFG_MBAR; |
| 102 | |
| 103 | regp->wdog_reg.wdog_wirr = 0; /* disable watchdog interrupt */ |
| 104 | |
| 105 | /* set timeout and enable watchdog */ |
| 106 | regp->wdog_reg.wdog_wrrr = ((CONFIG_WATCHDOG_TIMEOUT * CFG_HZ) / (32768 * 1000)) - 1; |
| 107 | regp->wdog_reg.wdog_wcr = 0; /* reset watchdog counter */ |
| 108 | |
| 109 | puts ("WATCHDOG:enabled\n"); |
| 110 | return (0); |
| 111 | } |
| 112 | #endif /* #ifdef CONFIG_WATCHDOG */ |
| 113 | |
| 114 | #endif /* #ifdef CONFIG_M5272 */ |
| 115 | |
| 116 | |
| 117 | #ifdef CONFIG_M5282 |
| 118 | int checkcpu (void) |
| 119 | { |
| 120 | puts ("CPU: MOTOROLA Coldfire MCF5282\n"); |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { |
| 125 | return 0; |
| 126 | }; |
| 127 | #endif |
stroese | 8c725b9 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 128 | |
| 129 | #ifdef CONFIG_M5249 /* test-only: todo... */ |
| 130 | int checkcpu (void) |
| 131 | { |
| 132 | char buf[32]; |
| 133 | |
| 134 | printf ("CPU: MOTOROLA Coldfire MCF5249 at %s MHz\n", strmhz(buf, CFG_CLK)); |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { |
| 139 | /* enable watchdog, set timeout to 0 and wait */ |
| 140 | mbar_writeByte(MCFSIM_SYPCR, 0xc0); |
| 141 | while (1); |
| 142 | |
| 143 | /* we don't return! */ |
| 144 | return 0; |
| 145 | }; |
| 146 | #endif |