TsiChungLiew | 570c018 | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * (C) Copyright 2000-2003 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
| 6 | * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. |
| 7 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <watchdog.h> |
| 30 | #include <command.h> |
| 31 | |
| 32 | #include <asm/immap.h> |
| 33 | |
| 34 | DECLARE_GLOBAL_DATA_PTR; |
| 35 | |
| 36 | int do_reset(cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[]) |
| 37 | { |
| 38 | volatile gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR); |
| 39 | |
| 40 | gptmr->pre = 10; |
| 41 | gptmr->cnt = 1; |
| 42 | |
| 43 | /* enable watchdog, set timeout to 0 and wait */ |
| 44 | gptmr->mode = GPT_TMS_SGPIO; |
| 45 | gptmr->ctrl = GPT_CTRL_WDEN | GPT_CTRL_CE; |
| 46 | |
| 47 | /* we don't return! */ |
| 48 | return 1; |
| 49 | }; |
| 50 | |
| 51 | int checkcpu(void) |
| 52 | { |
| 53 | volatile siu_t *siu = (siu_t *) MMAP_SIU; |
| 54 | u16 id = 0; |
| 55 | |
| 56 | puts("CPU: "); |
| 57 | |
| 58 | switch ((siu->jtagid & 0x000FF000) >> 12) { |
| 59 | case 0x0C: |
| 60 | id = 5485; |
| 61 | break; |
| 62 | case 0x0D: |
| 63 | id = 5484; |
| 64 | break; |
| 65 | case 0x0E: |
| 66 | id = 5483; |
| 67 | break; |
| 68 | case 0x0F: |
| 69 | id = 5482; |
| 70 | break; |
| 71 | case 0x10: |
| 72 | id = 5481; |
| 73 | break; |
| 74 | case 0x11: |
| 75 | id = 5480; |
| 76 | break; |
| 77 | case 0x12: |
| 78 | id = 5475; |
| 79 | break; |
| 80 | case 0x13: |
| 81 | id = 5474; |
| 82 | break; |
| 83 | case 0x14: |
| 84 | id = 5473; |
| 85 | break; |
| 86 | case 0x15: |
| 87 | id = 5472; |
| 88 | break; |
| 89 | case 0x16: |
| 90 | id = 5471; |
| 91 | break; |
| 92 | case 0x17: |
| 93 | id = 5470; |
| 94 | break; |
| 95 | } |
| 96 | |
| 97 | if (id) { |
| 98 | printf("Freescale MCF%d\n", id); |
| 99 | printf(" CPU CLK %d Mhz BUS CLK %d Mhz\n", |
| 100 | (int)(gd->cpu_clk / 1000000), |
| 101 | (int)(gd->bus_clk / 1000000)); |
| 102 | } |
| 103 | |
| 104 | return 0; |
| 105 | }; |
| 106 | |
| 107 | #if defined(CONFIG_HW_WATCHDOG) |
| 108 | /* Called by macro WATCHDOG_RESET */ |
| 109 | void hw_watchdog_reset(void) |
| 110 | { |
| 111 | volatile gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR); |
| 112 | |
| 113 | gptmr->ocpw = 0xa5; |
| 114 | } |
| 115 | |
| 116 | int watchdog_disable(void) |
| 117 | { |
| 118 | volatile gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR); |
| 119 | |
| 120 | /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */ |
| 121 | gptmr->mode = 0; |
| 122 | gptmr->ctrl = 0; |
| 123 | |
| 124 | puts("WATCHDOG:disabled\n"); |
| 125 | |
| 126 | return (0); |
| 127 | } |
| 128 | |
| 129 | int watchdog_init(void) |
| 130 | { |
| 131 | |
| 132 | volatile gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR); |
| 133 | |
| 134 | gptmr->pre = CONFIG_WATCHDOG_TIMEOUT; |
| 135 | gptmr->cnt = CFG_TIMER_PRESCALER * 1000; |
| 136 | |
| 137 | gptmr->mode = GPT_TMS_SGPIO; |
| 138 | gptmr->ctrl = GPT_CTRL_CE | GPT_CTRL_WDEN; |
| 139 | puts("WATCHDOG:enabled\n"); |
| 140 | |
| 141 | return (0); |
| 142 | } |
| 143 | #endif /* CONFIG_HW_WATCHDOG */ |