]> git.sur5r.net Git - u-boot/blob - cpu/mcf532x/cpu.c
071c5030477cbcbb284d4a88907f8b210714fc5d
[u-boot] / cpu / mcf532x / cpu.c
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_5329.h>
33 #include <asm/m5329.h>
34
35 int do_reset(cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
36 {
37         volatile wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
38
39         wdp->cr = 0;
40         udelay(1000);
41
42         /* enable watchdog, set timeout to 0 and wait */
43         wdp->cr = WTM_WCR_EN;
44         while (1) ;
45
46         /* we don't return! */
47         return 0;
48 };
49
50 int checkcpu(void)
51 {
52         DECLARE_GLOBAL_DATA_PTR;
53
54         volatile ccm_t *ccm = (ccm_t *) MMAP_CCM;
55         u16 msk;
56         u16 id = 0;
57         u8 ver;
58
59         puts("CPU:   ");
60         msk = (ccm->cir >> 6);
61         ver = (ccm->cir & 0x003f);
62         switch (msk) {
63         case 0x54:
64                 id = 5329;
65                 break;
66         case 0x59:
67                 id = 5328;
68                 break;
69         case 0x61:
70                 id = 5327;
71                 break;
72         }
73
74         if (id) {
75                 printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk,
76                        ver);
77                 printf("       CPU CLK %d Mhz BUS CLK %d Mhz\n",
78                        (int)(gd->cpu_clk / 1000000),
79                        (int)(gd->bus_clk / 1000000));
80         }
81
82         return 0;
83 };
84
85 #if defined(CONFIG_WATCHDOG)
86 /* Called by macro WATCHDOG_RESET */
87 void watchdog_reset(void)
88 {
89         volatile wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
90
91         wdp->sr = 0x5555;       /* Count register */
92 }
93
94 int watchdog_disable(void)
95 {
96         volatile wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
97
98         /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
99         wdp->cr |= WTM_WCR_HALTED;      /* halted watchdog timer */
100
101         puts("WATCHDOG:disabled\n");
102         return (0);
103 }
104
105 int watchdog_init(void)
106 {
107         volatile wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
108         u32 wdog_module = 0;
109
110         /* set timeout and enable watchdog */
111         wdog_module = ((CFG_CLK / 1000) * CONFIG_WATCHDOG_TIMEOUT);
112         wdog_module |= (wdog_module / 8192);
113         wdp->mr = wdog_module;
114
115         wdp->cr = WTM_WCR_EN;
116         puts("WATCHDOG:enabled\n");
117
118         return (0);
119 }
120 #endif                          /* #ifdef CONFIG_WATCHDOG */
121
122 #ifdef CONFIG_MCFINTC
123 int interrupt_init(void)
124 {
125         volatile int0_t *intp = (int0_t *) (CFG_INTR_BASE);
126
127         /* Make sure all interrupts are disabled */
128         intp->imrh0 |= 0xFFFFFFFF;
129         intp->imrl0 |= 0xFFFFFFFF;
130
131         enable_interrupts();
132         return 0;
133 }
134 #endif                          /* CONFIG_MCFINTC */