]>
Commit | Line | Data |
---|---|---|
debb7354 | 1 | /* |
cb5965fb JL |
2 | * Copyright 2006 Freescale Semiconductor |
3 | * Jeff Brown | |
debb7354 JL |
4 | * Srikanth Srinivasan ([email protected]) |
5 | * | |
6 | * See file CREDITS for list of people who contributed to this | |
7 | * project. | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU General Public License as | |
11 | * published by the Free Software Foundation; either version 2 of | |
12 | * the License, or (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
22 | * MA 02111-1307 USA | |
23 | */ | |
24 | ||
25 | #include <common.h> | |
26 | #include <watchdog.h> | |
27 | #include <command.h> | |
28 | #include <asm/cache.h> | |
e34a0e91 | 29 | #include <asm/mmu.h> |
debb7354 | 30 | #include <mpc86xx.h> |
75b9d4ae | 31 | #include <tsec.h> |
4f93f8b1 | 32 | #include <asm/fsl_law.h> |
debb7354 | 33 | |
debb7354 | 34 | |
4ef630df PT |
35 | /* |
36 | * Default board reset function | |
37 | */ | |
38 | static void | |
39 | __board_reset(void) | |
40 | { | |
41 | /* Do nothing */ | |
42 | } | |
f9a109b3 | 43 | void board_reset(void) __attribute__((weak, alias("__board_reset"))); |
4ef630df PT |
44 | |
45 | ||
ffff3ae5 JL |
46 | int |
47 | checkcpu(void) | |
debb7354 JL |
48 | { |
49 | sys_info_t sysinfo; | |
50 | uint pvr, svr; | |
51 | uint ver; | |
52 | uint major, minor; | |
a1c8a719 | 53 | char buf1[32], buf2[32]; |
6d0f6bcf | 54 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
9553df86 | 55 | volatile ccsr_gur_t *gur = &immap->im_gur; |
a1c8a719 | 56 | uint msscr0 = mfspr(MSSCR0); |
debb7354 JL |
57 | |
58 | svr = get_svr(); | |
1ced1216 | 59 | ver = SVR_SOC_VER(svr); |
debb7354 JL |
60 | major = SVR_MAJ(svr); |
61 | minor = SVR_MIN(svr); | |
62 | ||
a1c8a719 PT |
63 | puts("CPU: "); |
64 | ||
5c9efb36 | 65 | switch (ver) { |
debb7354 | 66 | case SVR_8641: |
d14ba6a7 | 67 | puts("8641"); |
a1c8a719 PT |
68 | break; |
69 | case SVR_8641D: | |
70 | puts("8641D"); | |
71 | break; | |
9553df86 JL |
72 | case SVR_8610: |
73 | puts("8610"); | |
74 | break; | |
debb7354 JL |
75 | default: |
76 | puts("Unknown"); | |
77 | break; | |
78 | } | |
79 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); | |
a1c8a719 PT |
80 | puts("Core: "); |
81 | ||
82 | pvr = get_pvr(); | |
83 | ver = PVR_E600_VER(pvr); | |
84 | major = PVR_E600_MAJ(pvr); | |
85 | minor = PVR_E600_MIN(pvr); | |
86 | ||
87 | printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 ); | |
88 | if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE) | |
89 | puts("\n Core1Translation Enabled"); | |
90 | debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr); | |
91 | ||
92 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); | |
debb7354 JL |
93 | |
94 | get_sys_info(&sysinfo); | |
95 | ||
a1c8a719 PT |
96 | puts("Clock Configuration:\n"); |
97 | printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor)); | |
98 | printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus)); | |
99 | printf(" DDR:%-4s MHz (%s MT/s data rate), ", | |
100 | strmhz(buf1, sysinfo.freqSystemBus / 2), | |
101 | strmhz(buf2, sysinfo.freqSystemBus)); | |
5c9efb36 | 102 | |
ada591d2 | 103 | if (sysinfo.freqLocalBus > LCRR_CLKDIV) { |
a1c8a719 | 104 | printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus)); |
debb7354 | 105 | } else { |
a9f3acbc | 106 | printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n", |
ada591d2 | 107 | sysinfo.freqLocalBus); |
debb7354 JL |
108 | } |
109 | ||
a1c8a719 PT |
110 | puts("L1: D-cache 32 KB enabled\n"); |
111 | puts(" I-cache 32 KB enabled\n"); | |
112 | ||
113 | puts("L2: "); | |
114 | if (get_l2cr() & 0x80000000) { | |
115 | #if defined(CONFIG_MPC8610) | |
116 | puts("256"); | |
117 | #elif defined(CONFIG_MPC8641) | |
118 | puts("512"); | |
119 | #endif | |
120 | puts(" KB enabled\n"); | |
121 | } else { | |
cb5965fb | 122 | puts("Disabled\n"); |
a1c8a719 | 123 | } |
5c9efb36 JL |
124 | |
125 | return 0; | |
debb7354 JL |
126 | } |
127 | ||
128 | ||
debb7354 | 129 | void |
126aa70f | 130 | do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
debb7354 | 131 | { |
4ef630df PT |
132 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
133 | volatile ccsr_gur_t *gur = &immap->im_gur; | |
5c9efb36 | 134 | |
4ef630df PT |
135 | /* Attempt board-specific reset */ |
136 | board_reset(); | |
5c9efb36 | 137 | |
4ef630df PT |
138 | /* Next try asserting HRESET_REQ */ |
139 | out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ); | |
5c9efb36 | 140 | |
4ef630df PT |
141 | while (1) |
142 | ; | |
debb7354 JL |
143 | } |
144 | ||
145 | ||
debb7354 JL |
146 | /* |
147 | * Get timebase clock frequency | |
148 | */ | |
ffff3ae5 JL |
149 | unsigned long |
150 | get_tbclk(void) | |
debb7354 | 151 | { |
ffff3ae5 | 152 | sys_info_t sys_info; |
debb7354 JL |
153 | |
154 | get_sys_info(&sys_info); | |
5c9efb36 | 155 | return (sys_info.freqSystemBus + 3L) / 4L; |
debb7354 JL |
156 | } |
157 | ||
debb7354 JL |
158 | |
159 | #if defined(CONFIG_WATCHDOG) | |
160 | void | |
161 | watchdog_reset(void) | |
162 | { | |
3473ab73 JJ |
163 | #if defined(CONFIG_MPC8610) |
164 | /* | |
165 | * This actually feed the hard enabled watchdog. | |
166 | */ | |
6d0f6bcf | 167 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
3473ab73 JJ |
168 | volatile ccsr_wdt_t *wdt = &immap->im_wdt; |
169 | volatile ccsr_gur_t *gur = &immap->im_gur; | |
170 | u32 tmp = gur->pordevsr; | |
171 | ||
172 | if (tmp & 0x4000) { | |
173 | wdt->swsrr = 0x556c; | |
174 | wdt->swsrr = 0xaa39; | |
175 | } | |
176 | #endif | |
debb7354 JL |
177 | } |
178 | #endif /* CONFIG_WATCHDOG */ | |
179 | ||
debb7354 JL |
180 | |
181 | #if defined(CONFIG_DDR_ECC) | |
ffff3ae5 JL |
182 | void |
183 | dma_init(void) | |
5c9efb36 | 184 | { |
2f21ce4d | 185 | volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR); |
b1f12650 | 186 | volatile fsl_dma_t *dma = &dma_base->dma[0]; |
debb7354 | 187 | |
b1f12650 PT |
188 | dma->satr = 0x00040000; |
189 | dma->datr = 0x00040000; | |
2f21ce4d | 190 | dma->sr = 0xffffffff; /* clear any errors */ |
debb7354 | 191 | asm("sync; isync"); |
debb7354 JL |
192 | } |
193 | ||
ffff3ae5 JL |
194 | uint |
195 | dma_check(void) | |
5c9efb36 | 196 | { |
2f21ce4d | 197 | volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR); |
b1f12650 PT |
198 | volatile fsl_dma_t *dma = &dma_base->dma[0]; |
199 | volatile uint status = dma->sr; | |
debb7354 JL |
200 | |
201 | /* While the channel is busy, spin */ | |
ffff3ae5 | 202 | while ((status & 4) == 4) { |
b1f12650 | 203 | status = dma->sr; |
debb7354 JL |
204 | } |
205 | ||
2f21ce4d PT |
206 | /* clear MR[CS] channel start bit */ |
207 | dma->mr &= 0x00000001; | |
208 | asm("sync;isync"); | |
209 | ||
debb7354 | 210 | if (status != 0) { |
ffff3ae5 | 211 | printf("DMA Error: status = %x\n", status); |
debb7354 JL |
212 | } |
213 | return status; | |
214 | } | |
215 | ||
ffff3ae5 JL |
216 | int |
217 | dma_xfer(void *dest, uint count, void *src) | |
5c9efb36 | 218 | { |
2f21ce4d | 219 | volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR); |
b1f12650 | 220 | volatile fsl_dma_t *dma = &dma_base->dma[0]; |
debb7354 | 221 | |
b1f12650 PT |
222 | dma->dar = (uint) dest; |
223 | dma->sar = (uint) src; | |
224 | dma->bcr = count; | |
225 | dma->mr = 0xf000004; | |
debb7354 | 226 | asm("sync;isync"); |
b1f12650 | 227 | dma->mr = 0xf000005; |
debb7354 JL |
228 | asm("sync;isync"); |
229 | return dma_check(); | |
230 | } | |
5c9efb36 | 231 | |
debb7354 JL |
232 | #endif /* CONFIG_DDR_ECC */ |
233 | ||
234 | ||
4f93f8b1 BB |
235 | /* |
236 | * Print out the state of various machine registers. | |
e34a0e91 | 237 | * Currently prints out LAWs, BR0/OR0, and BATs |
4f93f8b1 BB |
238 | */ |
239 | void mpc86xx_reginfo(void) | |
240 | { | |
6d0f6bcf | 241 | immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
4f93f8b1 BB |
242 | ccsr_lbc_t *lbc = &immap->im_lbc; |
243 | ||
e34a0e91 | 244 | print_bats(); |
4f93f8b1 BB |
245 | print_laws(); |
246 | ||
247 | printf ("Local Bus Controller Registers\n" | |
248 | "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0)); | |
249 | printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1)); | |
250 | printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2)); | |
251 | printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3)); | |
252 | printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4)); | |
253 | printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5)); | |
254 | printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6)); | |
255 | printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7)); | |
debb7354 JL |
256 | |
257 | } | |
dd35479a | 258 | |
75b9d4ae AF |
259 | /* |
260 | * Initializes on-chip ethernet controllers. | |
261 | * to override, implement board_eth_init() | |
dd35479a | 262 | */ |
dd35479a BW |
263 | int cpu_eth_init(bd_t *bis) |
264 | { | |
75b9d4ae AF |
265 | #if defined(CONFIG_TSEC_ENET) |
266 | tsec_standard_init(bis); | |
dd35479a | 267 | #endif |
75b9d4ae | 268 | |
dd35479a BW |
269 | return 0; |
270 | } |