]>
Commit | Line | Data |
---|---|---|
42d1f039 | 1 | /* |
18bacc20 | 2 | * Copyright 2004,2007-2009 Freescale Semiconductor, Inc. |
42d1f039 WD |
3 | * (C) Copyright 2002, 2003 Motorola Inc. |
4 | * Xianghua Xiao ([email protected]) | |
5 | * | |
6 | * (C) Copyright 2000 | |
7 | * Wolfgang Denk, DENX Software Engineering, [email protected]. | |
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 | ||
75b9d4ae | 28 | #include <config.h> |
42d1f039 WD |
29 | #include <common.h> |
30 | #include <watchdog.h> | |
31 | #include <command.h> | |
80522dc8 | 32 | #include <fsl_esdhc.h> |
42d1f039 | 33 | #include <asm/cache.h> |
740280e6 | 34 | #include <asm/io.h> |
42d1f039 | 35 | |
591933ca JY |
36 | DECLARE_GLOBAL_DATA_PTR; |
37 | ||
42d1f039 WD |
38 | int checkcpu (void) |
39 | { | |
97d80fc3 | 40 | sys_info_t sysinfo; |
97d80fc3 | 41 | uint pvr, svr; |
d9b94f28 | 42 | uint fam; |
97d80fc3 WD |
43 | uint ver; |
44 | uint major, minor; | |
4dbdb768 | 45 | struct cpu_type *cpu; |
08ef89ec | 46 | char buf1[32], buf2[32]; |
ee1e35be | 47 | #ifdef CONFIG_DDR_CLK_FREQ |
6d0f6bcf | 48 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
c0391111 JJ |
49 | u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO) |
50 | >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT; | |
ee1e35be KG |
51 | #else |
52 | u32 ddr_ratio = 0; | |
53 | #endif | |
2fc7eb0c | 54 | int i; |
97d80fc3 | 55 | |
97d80fc3 | 56 | svr = get_svr(); |
97d80fc3 | 57 | major = SVR_MAJ(svr); |
ef50d6c0 KG |
58 | #ifdef CONFIG_MPC8536 |
59 | major &= 0x7; /* the msb of this nibble is a mfg code */ | |
60 | #endif | |
97d80fc3 | 61 | minor = SVR_MIN(svr); |
42d1f039 | 62 | |
0e870980 | 63 | if (cpu_numcores() > 1) { |
21170c80 PA |
64 | #ifndef CONFIG_MP |
65 | puts("Unicore software on multiprocessor system!!\n" | |
66 | "To enable mutlticore build define CONFIG_MP\n"); | |
67 | #endif | |
0e870980 PA |
68 | volatile ccsr_pic_t *pic = (void *)(CONFIG_SYS_MPC85xx_PIC_ADDR); |
69 | printf("CPU%d: ", pic->whoami); | |
70 | } else { | |
71 | puts("CPU: "); | |
72 | } | |
1ced1216 | 73 | |
0e870980 | 74 | cpu = gd->cpu; |
1ced1216 | 75 | |
58442dc0 PA |
76 | puts(cpu->name); |
77 | if (IS_E_PROCESSOR(svr)) | |
78 | puts("E"); | |
1ced1216 | 79 | |
97d80fc3 WD |
80 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); |
81 | ||
6c9e789e | 82 | pvr = get_pvr(); |
d9b94f28 | 83 | fam = PVR_FAM(pvr); |
6c9e789e WD |
84 | ver = PVR_VER(pvr); |
85 | major = PVR_MAJ(pvr); | |
86 | minor = PVR_MIN(pvr); | |
87 | ||
88 | printf("Core: "); | |
d9b94f28 JL |
89 | switch (fam) { |
90 | case PVR_FAM(PVR_85xx): | |
6c9e789e WD |
91 | puts("E500"); |
92 | break; | |
93 | default: | |
94 | puts("Unknown"); | |
95 | break; | |
96 | } | |
0f060c3b KG |
97 | |
98 | if (PVR_MEM(pvr) == 0x03) | |
99 | puts("MC"); | |
100 | ||
6c9e789e WD |
101 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); |
102 | ||
97d80fc3 WD |
103 | get_sys_info(&sysinfo); |
104 | ||
b29dee3c | 105 | puts("Clock Configuration:"); |
0e870980 | 106 | for (i = 0; i < cpu_numcores(); i++) { |
1bba30ef WD |
107 | if (!(i & 3)) |
108 | printf ("\n "); | |
2fc7eb0c HW |
109 | printf("CPU%d:%-4s MHz, ", |
110 | i,strmhz(buf1, sysinfo.freqProcessor[i])); | |
b29dee3c KG |
111 | } |
112 | printf("\n CCB:%-4s MHz,\n", strmhz(buf1, sysinfo.freqSystemBus)); | |
ee1e35be | 113 | |
d4357932 KG |
114 | switch (ddr_ratio) { |
115 | case 0x0: | |
08ef89ec WD |
116 | printf(" DDR:%-4s MHz (%s MT/s data rate), ", |
117 | strmhz(buf1, sysinfo.freqDDRBus/2), | |
118 | strmhz(buf2, sysinfo.freqDDRBus)); | |
d4357932 KG |
119 | break; |
120 | case 0x7: | |
08ef89ec WD |
121 | printf(" DDR:%-4s MHz (%s MT/s data rate) (Synchronous), ", |
122 | strmhz(buf1, sysinfo.freqDDRBus/2), | |
123 | strmhz(buf2, sysinfo.freqDDRBus)); | |
d4357932 KG |
124 | break; |
125 | default: | |
08ef89ec WD |
126 | printf(" DDR:%-4s MHz (%s MT/s data rate) (Asynchronous), ", |
127 | strmhz(buf1, sysinfo.freqDDRBus/2), | |
128 | strmhz(buf2, sysinfo.freqDDRBus)); | |
d4357932 KG |
129 | break; |
130 | } | |
97d80fc3 | 131 | |
ada591d2 TP |
132 | if (sysinfo.freqLocalBus > LCRR_CLKDIV) |
133 | printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus)); | |
134 | else | |
135 | printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n", | |
136 | sysinfo.freqLocalBus); | |
42d1f039 | 137 | |
1ced1216 | 138 | #ifdef CONFIG_CPM2 |
08ef89ec | 139 | printf("CPM: %s MHz\n", strmhz(buf1, sysinfo.freqSystemBus)); |
1ced1216 | 140 | #endif |
97d80fc3 | 141 | |
b3d7f20f HW |
142 | #ifdef CONFIG_QE |
143 | printf(" QE:%-4s MHz\n", strmhz(buf1, sysinfo.freqQE)); | |
144 | #endif | |
145 | ||
6c9e789e | 146 | puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n"); |
42d1f039 WD |
147 | |
148 | return 0; | |
149 | } | |
150 | ||
151 | ||
152 | /* ------------------------------------------------------------------------- */ | |
153 | ||
154 | int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) | |
155 | { | |
c348322a KG |
156 | /* Everything after the first generation of PQ3 parts has RSTCR */ |
157 | #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \ | |
158 | defined(CONFIG_MPC8555) || defined(CONFIG_MPC8560) | |
793670c3 SP |
159 | unsigned long val, msr; |
160 | ||
42d1f039 WD |
161 | /* |
162 | * Initiate hard reset in debug control register DBCR0 | |
c348322a | 163 | * Make sure MSR[DE] = 1. This only resets the core. |
42d1f039 | 164 | */ |
793670c3 SP |
165 | msr = mfmsr (); |
166 | msr |= MSR_DE; | |
167 | mtmsr (msr); | |
168 | ||
169 | val = mfspr(DBCR0); | |
170 | val |= 0x70000000; | |
171 | mtspr(DBCR0,val); | |
c348322a KG |
172 | #else |
173 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); | |
174 | out_be32(&gur->rstcr, 0x2); /* HRESET_REQ */ | |
175 | udelay(100); | |
176 | #endif | |
df90968b | 177 | |
42d1f039 WD |
178 | return 1; |
179 | } | |
180 | ||
181 | ||
182 | /* | |
183 | * Get timebase clock frequency | |
184 | */ | |
185 | unsigned long get_tbclk (void) | |
186 | { | |
3c2a67ee KG |
187 | #ifdef CONFIG_FSL_CORENET |
188 | return (gd->bus_clk + 8) / 16; | |
189 | #else | |
591933ca | 190 | return (gd->bus_clk + 4UL)/8UL; |
3c2a67ee | 191 | #endif |
42d1f039 WD |
192 | } |
193 | ||
194 | ||
195 | #if defined(CONFIG_WATCHDOG) | |
196 | void | |
197 | watchdog_reset(void) | |
198 | { | |
199 | int re_enable = disable_interrupts(); | |
200 | reset_85xx_watchdog(); | |
201 | if (re_enable) enable_interrupts(); | |
202 | } | |
203 | ||
204 | void | |
205 | reset_85xx_watchdog(void) | |
206 | { | |
207 | /* | |
208 | * Clear TSR(WIS) bit by writing 1 | |
209 | */ | |
210 | unsigned long val; | |
03b81b48 AF |
211 | val = mfspr(SPRN_TSR); |
212 | val |= TSR_WIS; | |
213 | mtspr(SPRN_TSR, val); | |
42d1f039 WD |
214 | } |
215 | #endif /* CONFIG_WATCHDOG */ | |
216 | ||
740280e6 | 217 | /* |
59f63058 SP |
218 | * Configures a UPM. The function requires the respective MxMR to be set |
219 | * before calling this function. "size" is the number or entries, not a sizeof. | |
740280e6 SP |
220 | */ |
221 | void upmconfig (uint upm, uint * table, uint size) | |
222 | { | |
223 | int i, mdr, mad, old_mad = 0; | |
224 | volatile u32 *mxmr; | |
6d0f6bcf | 225 | volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR); |
740280e6 SP |
226 | volatile u32 *brp,*orp; |
227 | volatile u8* dummy = NULL; | |
228 | int upmmask; | |
229 | ||
230 | switch (upm) { | |
231 | case UPMA: | |
232 | mxmr = &lbc->mamr; | |
233 | upmmask = BR_MS_UPMA; | |
234 | break; | |
235 | case UPMB: | |
236 | mxmr = &lbc->mbmr; | |
237 | upmmask = BR_MS_UPMB; | |
238 | break; | |
239 | case UPMC: | |
240 | mxmr = &lbc->mcmr; | |
241 | upmmask = BR_MS_UPMC; | |
242 | break; | |
243 | default: | |
244 | printf("%s: Bad UPM index %d to configure\n", __FUNCTION__, upm); | |
245 | hang(); | |
246 | } | |
247 | ||
248 | /* Find the address for the dummy write transaction */ | |
249 | for (brp = &lbc->br0, orp = &lbc->or0, i = 0; i < 8; | |
250 | i++, brp += 2, orp += 2) { | |
e093a247 | 251 | |
740280e6 | 252 | /* Look for a valid BR with selected UPM */ |
59f63058 SP |
253 | if ((in_be32(brp) & (BR_V | BR_MSEL)) == (BR_V | upmmask)) { |
254 | dummy = (volatile u8*)(in_be32(brp) & BR_BA); | |
740280e6 SP |
255 | break; |
256 | } | |
257 | } | |
258 | ||
259 | if (i == 8) { | |
260 | printf("Error: %s() could not find matching BR\n", __FUNCTION__); | |
261 | hang(); | |
262 | } | |
263 | ||
264 | for (i = 0; i < size; i++) { | |
265 | /* 1 */ | |
59f63058 | 266 | out_be32(mxmr, (in_be32(mxmr) & 0x4fffffc0) | MxMR_OP_WARR | i); |
740280e6 SP |
267 | /* 2 */ |
268 | out_be32(&lbc->mdr, table[i]); | |
269 | /* 3 */ | |
270 | mdr = in_be32(&lbc->mdr); | |
271 | /* 4 */ | |
272 | *(volatile u8 *)dummy = 0; | |
273 | /* 5 */ | |
274 | do { | |
59f63058 | 275 | mad = in_be32(mxmr) & MxMR_MAD_MSK; |
740280e6 SP |
276 | } while (mad <= old_mad && !(!mad && i == (size-1))); |
277 | old_mad = mad; | |
278 | } | |
59f63058 | 279 | out_be32(mxmr, (in_be32(mxmr) & 0x4fffffc0) | MxMR_OP_NORM); |
740280e6 | 280 | } |
dd35479a | 281 | |
80522dc8 AF |
282 | /* |
283 | * Initializes on-chip MMC controllers. | |
284 | * to override, implement board_mmc_init() | |
285 | */ | |
286 | int cpu_mmc_init(bd_t *bis) | |
287 | { | |
288 | #ifdef CONFIG_FSL_ESDHC | |
289 | return fsl_esdhc_mmc_init(bis); | |
290 | #else | |
291 | return 0; | |
292 | #endif | |
293 | } |