]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
debb7354 | 2 | /* |
9ff32d8c | 3 | * Copyright 2006,2009-2010 Freescale Semiconductor, Inc. |
cb5965fb | 4 | * Jeff Brown |
debb7354 | 5 | * Srikanth Srinivasan ([email protected]) |
debb7354 JL |
6 | */ |
7 | ||
8 | #include <common.h> | |
b5981474 | 9 | #include <cpu_func.h> |
049f8d6f | 10 | #include <time.h> |
2189d5f1 | 11 | #include <vsprintf.h> |
debb7354 JL |
12 | #include <watchdog.h> |
13 | #include <command.h> | |
14 | #include <asm/cache.h> | |
e34a0e91 | 15 | #include <asm/mmu.h> |
debb7354 | 16 | #include <mpc86xx.h> |
4f93f8b1 | 17 | #include <asm/fsl_law.h> |
f3603b43 | 18 | #include <asm/ppc.h> |
debb7354 | 19 | |
0e870980 PA |
20 | DECLARE_GLOBAL_DATA_PTR; |
21 | ||
4ef630df PT |
22 | /* |
23 | * Default board reset function | |
24 | */ | |
25 | static void | |
26 | __board_reset(void) | |
27 | { | |
28 | /* Do nothing */ | |
29 | } | |
f9a109b3 | 30 | void board_reset(void) __attribute__((weak, alias("__board_reset"))); |
4ef630df PT |
31 | |
32 | ||
ffff3ae5 JL |
33 | int |
34 | checkcpu(void) | |
debb7354 JL |
35 | { |
36 | sys_info_t sysinfo; | |
37 | uint pvr, svr; | |
debb7354 | 38 | uint major, minor; |
a1c8a719 | 39 | char buf1[32], buf2[32]; |
6d0f6bcf | 40 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
9553df86 | 41 | volatile ccsr_gur_t *gur = &immap->im_gur; |
480f6179 | 42 | struct cpu_type *cpu; |
a1c8a719 | 43 | uint msscr0 = mfspr(MSSCR0); |
debb7354 JL |
44 | |
45 | svr = get_svr(); | |
debb7354 JL |
46 | major = SVR_MAJ(svr); |
47 | minor = SVR_MIN(svr); | |
48 | ||
21170c80 PA |
49 | if (cpu_numcores() > 1) { |
50 | #ifndef CONFIG_MP | |
51 | puts("Unicore software on multiprocessor system!!\n" | |
52 | "To enable mutlticore build define CONFIG_MP\n"); | |
53 | #endif | |
54 | } | |
a1c8a719 PT |
55 | puts("CPU: "); |
56 | ||
67ac13b1 | 57 | cpu = gd->arch.cpu; |
0e870980 | 58 | |
58442dc0 | 59 | puts(cpu->name); |
480f6179 | 60 | |
debb7354 | 61 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); |
a1c8a719 PT |
62 | puts("Core: "); |
63 | ||
64 | pvr = get_pvr(); | |
a1c8a719 PT |
65 | major = PVR_E600_MAJ(pvr); |
66 | minor = PVR_E600_MIN(pvr); | |
67 | ||
6770c5e2 | 68 | printf("e600 Core %d", (msscr0 & 0x20) ? 1 : 0); |
a1c8a719 PT |
69 | if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE) |
70 | puts("\n Core1Translation Enabled"); | |
71 | debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr); | |
72 | ||
73 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); | |
debb7354 JL |
74 | |
75 | get_sys_info(&sysinfo); | |
76 | ||
a1c8a719 | 77 | puts("Clock Configuration:\n"); |
997399fa PK |
78 | printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freq_processor)); |
79 | printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freq_systembus)); | |
a1c8a719 | 80 | printf(" DDR:%-4s MHz (%s MT/s data rate), ", |
997399fa PK |
81 | strmhz(buf1, sysinfo.freq_systembus / 2), |
82 | strmhz(buf2, sysinfo.freq_systembus)); | |
5c9efb36 | 83 | |
997399fa PK |
84 | if (sysinfo.freq_localbus > LCRR_CLKDIV) { |
85 | printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freq_localbus)); | |
debb7354 | 86 | } else { |
a9f3acbc | 87 | printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n", |
997399fa | 88 | sysinfo.freq_localbus); |
debb7354 JL |
89 | } |
90 | ||
6b44d9e5 SK |
91 | puts("L1: D-cache 32 KiB enabled\n"); |
92 | puts(" I-cache 32 KiB enabled\n"); | |
a1c8a719 PT |
93 | |
94 | puts("L2: "); | |
95 | if (get_l2cr() & 0x80000000) { | |
1425a87b | 96 | #if defined(CONFIG_ARCH_MPC8610) |
a1c8a719 | 97 | puts("256"); |
4f5554c6 | 98 | #elif defined(CONFIG_ARCH_MPC8641) |
a1c8a719 PT |
99 | puts("512"); |
100 | #endif | |
6b44d9e5 | 101 | puts(" KiB enabled\n"); |
a1c8a719 | 102 | } else { |
cb5965fb | 103 | puts("Disabled\n"); |
a1c8a719 | 104 | } |
5c9efb36 JL |
105 | |
106 | return 0; | |
debb7354 JL |
107 | } |
108 | ||
109 | ||
09140113 | 110 | int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
debb7354 | 111 | { |
4ef630df PT |
112 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
113 | volatile ccsr_gur_t *gur = &immap->im_gur; | |
5c9efb36 | 114 | |
4ef630df PT |
115 | /* Attempt board-specific reset */ |
116 | board_reset(); | |
5c9efb36 | 117 | |
4ef630df PT |
118 | /* Next try asserting HRESET_REQ */ |
119 | out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ); | |
5c9efb36 | 120 | |
4ef630df PT |
121 | while (1) |
122 | ; | |
c22a711d PT |
123 | |
124 | return 1; | |
debb7354 JL |
125 | } |
126 | ||
127 | ||
debb7354 JL |
128 | /* |
129 | * Get timebase clock frequency | |
130 | */ | |
ffff3ae5 JL |
131 | unsigned long |
132 | get_tbclk(void) | |
debb7354 | 133 | { |
ffff3ae5 | 134 | sys_info_t sys_info; |
debb7354 JL |
135 | |
136 | get_sys_info(&sys_info); | |
997399fa | 137 | return (sys_info.freq_systembus + 3L) / 4L; |
debb7354 JL |
138 | } |
139 | ||
debb7354 JL |
140 | |
141 | #if defined(CONFIG_WATCHDOG) | |
142 | void | |
143 | watchdog_reset(void) | |
144 | { | |
1425a87b | 145 | #if defined(CONFIG_ARCH_MPC8610) |
3473ab73 JJ |
146 | /* |
147 | * This actually feed the hard enabled watchdog. | |
148 | */ | |
6d0f6bcf | 149 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
3473ab73 JJ |
150 | volatile ccsr_wdt_t *wdt = &immap->im_wdt; |
151 | volatile ccsr_gur_t *gur = &immap->im_gur; | |
152 | u32 tmp = gur->pordevsr; | |
153 | ||
154 | if (tmp & 0x4000) { | |
155 | wdt->swsrr = 0x556c; | |
156 | wdt->swsrr = 0xaa39; | |
157 | } | |
158 | #endif | |
debb7354 JL |
159 | } |
160 | #endif /* CONFIG_WATCHDOG */ | |
161 | ||
4f93f8b1 BB |
162 | /* |
163 | * Print out the state of various machine registers. | |
e34a0e91 | 164 | * Currently prints out LAWs, BR0/OR0, and BATs |
4f93f8b1 | 165 | */ |
f3603b43 | 166 | void print_reginfo(void) |
4f93f8b1 | 167 | { |
e34a0e91 | 168 | print_bats(); |
4f93f8b1 | 169 | print_laws(); |
f51cdaf1 | 170 | print_lbc_regs(); |
debb7354 | 171 | } |
9ff32d8c TT |
172 | |
173 | /* | |
174 | * Set the DDR BATs to reflect the actual size of DDR. | |
175 | * | |
176 | * dram_size is the actual size of DDR, in bytes | |
177 | * | |
178 | * Note: we assume that CONFIG_MAX_MEM_MAPPED is 2G or smaller as we only | |
179 | * are using a single BAT to cover DDR. | |
180 | * | |
181 | * If this is not true, (e.g. CONFIG_MAX_MEM_MAPPED is 2GB but HID0_XBSEN | |
182 | * is not defined) then we might have a situation where U-Boot will attempt | |
183 | * to relocated itself outside of the region mapped by DBAT0. | |
184 | * This will cause a machine check. | |
185 | * | |
186 | * Currently we are limited to power of two sized DDR since we only use a | |
187 | * single bat. If a non-power of two size is used that is less than | |
188 | * CONFIG_MAX_MEM_MAPPED u-boot will crash. | |
189 | * | |
190 | */ | |
191 | void setup_ddr_bat(phys_addr_t dram_size) | |
192 | { | |
193 | unsigned long batu, bl; | |
194 | ||
195 | bl = TO_BATU_BL(min(dram_size, CONFIG_MAX_MEM_MAPPED)); | |
196 | ||
197 | if (BATU_SIZE(bl) != dram_size) { | |
198 | u64 sz = (u64)dram_size - BATU_SIZE(bl); | |
199 | print_size(sz, " left unmapped\n"); | |
200 | } | |
201 | ||
202 | batu = bl | BATU_VS | BATU_VP; | |
203 | write_bat(DBAT0, batu, CONFIG_SYS_DBAT0L); | |
204 | write_bat(IBAT0, batu, CONFIG_SYS_IBAT0L); | |
205 | } |