Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000-2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * m8xx.c |
| 10 | * |
| 11 | * CPU specific code |
| 12 | * |
| 13 | * written or collected and sometimes rewritten by |
| 14 | * Magnus Damm <damm@bitsmart.com> |
| 15 | * |
| 16 | * minor modifications by |
| 17 | * Wolfgang Denk <wd@denx.de> |
| 18 | */ |
| 19 | |
| 20 | #include <common.h> |
| 21 | #include <watchdog.h> |
| 22 | #include <command.h> |
| 23 | #include <mpc8xx.h> |
| 24 | #include <commproc.h> |
| 25 | #include <netdev.h> |
| 26 | #include <asm/cache.h> |
| 27 | #include <linux/compiler.h> |
| 28 | #include <asm/io.h> |
| 29 | |
| 30 | #if defined(CONFIG_OF_LIBFDT) |
| 31 | #include <libfdt.h> |
| 32 | #include <fdt_support.h> |
| 33 | #endif |
| 34 | |
| 35 | DECLARE_GLOBAL_DATA_PTR; |
| 36 | |
| 37 | static char *cpu_warning = "\n " \ |
| 38 | "*** Warning: CPU Core has Silicon Bugs -- Check the Errata ***"; |
| 39 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 40 | static int check_CPU(long clock, uint pvr, uint immr) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 41 | { |
| 42 | char *id_str = |
| 43 | NULL; |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 44 | immap_t __iomem *immap = (immap_t __iomem *)(immr & 0xFFFF0000); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 45 | uint k, m; |
| 46 | char buf[32]; |
| 47 | char pre = 'X'; |
| 48 | char *mid = "xx"; |
| 49 | char *suf; |
| 50 | |
| 51 | /* the highest 16 bits should be 0x0050 for a 860 */ |
| 52 | |
| 53 | if ((pvr >> 16) != 0x0050) |
| 54 | return -1; |
| 55 | |
| 56 | k = (immr << 16) | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 57 | in_be16(&immap->im_cpm.cp_dparam16[PROFF_REVNUM / sizeof(u16)]); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 58 | m = 0; |
| 59 | suf = ""; |
| 60 | |
| 61 | /* |
| 62 | * Some boards use sockets so different CPUs can be used. |
| 63 | * We have to check chip version in run time. |
| 64 | */ |
| 65 | switch (k) { |
| 66 | /* MPC866P/MPC866T/MPC859T/MPC859DSL/MPC852T */ |
| 67 | case 0x08010004: /* Rev. A.0 */ |
| 68 | suf = "A"; |
| 69 | /* fall through */ |
| 70 | case 0x08000003: /* Rev. 0.3 */ |
| 71 | pre = 'M'; m = 1; |
| 72 | if (id_str == NULL) |
| 73 | id_str = |
| 74 | "PC866x"; /* Unknown chip from MPC866 family */ |
| 75 | break; |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 76 | case 0x09000000: |
| 77 | pre = 'M'; mid = suf = ""; m = 1; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 78 | if (id_str == NULL) |
| 79 | id_str = "PC885"; /* 870/875/880/885 */ |
| 80 | break; |
| 81 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 82 | default: |
| 83 | suf = NULL; |
| 84 | break; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | if (id_str == NULL) |
| 88 | id_str = "PC86x"; /* Unknown 86x chip */ |
| 89 | if (suf) |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 90 | printf("%c%s%sZPnn%s", pre, id_str, mid, suf); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 91 | else |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 92 | printf("unknown M%s (0x%08x)", id_str, k); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 93 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 94 | printf(" at %s MHz: ", strmhz(buf, clock)); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 95 | |
| 96 | print_size(checkicache(), " I-Cache "); |
| 97 | print_size(checkdcache(), " D-Cache"); |
| 98 | |
| 99 | /* do we have a FEC (860T/P or 852/859/866/885)? */ |
| 100 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 101 | out_be32(&immap->im_cpm.cp_fec.fec_addr_low, 0x12345678); |
| 102 | if (in_be32(&immap->im_cpm.cp_fec.fec_addr_low) == 0x12345678) |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 103 | printf(" FEC present"); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 104 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 105 | if (!m) |
| 106 | puts(cpu_warning); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 107 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 108 | putc('\n'); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 109 | |
| 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | /* ------------------------------------------------------------------------- */ |
| 114 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 115 | int checkcpu(void) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 116 | { |
| 117 | ulong clock = gd->cpu_clk; |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 118 | uint immr = get_immr(0); /* Return full IMMR contents */ |
| 119 | uint pvr = get_pvr(); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 120 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 121 | puts("CPU: "); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 122 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 123 | return check_CPU(clock, pvr, immr); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /* ------------------------------------------------------------------------- */ |
| 127 | /* L1 i-cache */ |
| 128 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 129 | int checkicache(void) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 130 | { |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 131 | immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 132 | memctl8xx_t __iomem *memctl = &immap->im_memctl; |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 133 | u32 cacheon = rd_ic_cst() & IDC_ENABLED; |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 134 | /* probe in flash memoryarea */ |
| 135 | u32 k = in_be32(&memctl->memc_br0) & ~0x00007fff; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 136 | u32 m; |
| 137 | u32 lines = -1; |
| 138 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 139 | wr_ic_cst(IDC_UNALL); |
| 140 | wr_ic_cst(IDC_INVALL); |
| 141 | wr_ic_cst(IDC_DISABLE); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 142 | __asm__ volatile ("isync"); |
| 143 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 144 | while (!((m = rd_ic_cst()) & IDC_CERR2)) { |
| 145 | wr_ic_adr(k); |
| 146 | wr_ic_cst(IDC_LDLCK); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 147 | __asm__ volatile ("isync"); |
| 148 | |
| 149 | lines++; |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 150 | k += 0x10; /* the number of bytes in a cacheline */ |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 151 | } |
| 152 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 153 | wr_ic_cst(IDC_UNALL); |
| 154 | wr_ic_cst(IDC_INVALL); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 155 | |
| 156 | if (cacheon) |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 157 | wr_ic_cst(IDC_ENABLE); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 158 | else |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 159 | wr_ic_cst(IDC_DISABLE); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 160 | |
| 161 | __asm__ volatile ("isync"); |
| 162 | |
| 163 | return lines << 4; |
| 164 | }; |
| 165 | |
| 166 | /* ------------------------------------------------------------------------- */ |
| 167 | /* L1 d-cache */ |
| 168 | /* call with cache disabled */ |
| 169 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 170 | int checkdcache(void) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 171 | { |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 172 | immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 173 | memctl8xx_t __iomem *memctl = &immap->im_memctl; |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 174 | u32 cacheon = rd_dc_cst() & IDC_ENABLED; |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 175 | /* probe in flash memoryarea */ |
| 176 | u32 k = in_be32(&memctl->memc_br0) & ~0x00007fff; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 177 | u32 m; |
| 178 | u32 lines = -1; |
| 179 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 180 | wr_dc_cst(IDC_UNALL); |
| 181 | wr_dc_cst(IDC_INVALL); |
| 182 | wr_dc_cst(IDC_DISABLE); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 183 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 184 | while (!((m = rd_dc_cst()) & IDC_CERR2)) { |
| 185 | wr_dc_adr(k); |
| 186 | wr_dc_cst(IDC_LDLCK); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 187 | lines++; |
| 188 | k += 0x10; /* the number of bytes in a cacheline */ |
| 189 | } |
| 190 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 191 | wr_dc_cst(IDC_UNALL); |
| 192 | wr_dc_cst(IDC_INVALL); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 193 | |
| 194 | if (cacheon) |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 195 | wr_dc_cst(IDC_ENABLE); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 196 | else |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 197 | wr_dc_cst(IDC_DISABLE); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 198 | |
| 199 | return lines << 4; |
| 200 | }; |
| 201 | |
| 202 | /* ------------------------------------------------------------------------- */ |
| 203 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 204 | void upmconfig(uint upm, uint *table, uint size) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 205 | { |
| 206 | uint i; |
| 207 | uint addr = 0; |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 208 | immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 209 | memctl8xx_t __iomem *memctl = &immap->im_memctl; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 210 | |
| 211 | for (i = 0; i < size; i++) { |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 212 | out_be32(&memctl->memc_mdr, table[i]); /* (16-15) */ |
| 213 | out_be32(&memctl->memc_mcr, addr | upm); /* (16-16) */ |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 214 | addr++; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | /* ------------------------------------------------------------------------- */ |
| 219 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 220 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 221 | { |
| 222 | ulong msr, addr; |
| 223 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 224 | immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 225 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 226 | /* Checkstop Reset enable */ |
| 227 | setbits_be32(&immap->im_clkrst.car_plprcr, PLPRCR_CSR); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 228 | |
| 229 | /* Interrupts and MMU off */ |
| 230 | __asm__ volatile ("mtspr 81, 0"); |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 231 | __asm__ volatile ("mfmsr %0" : "=r" (msr)); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 232 | |
| 233 | msr &= ~0x1030; |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 234 | __asm__ volatile ("mtmsr %0" : : "r" (msr)); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 235 | |
| 236 | /* |
| 237 | * Trying to execute the next instruction at a non-existing address |
| 238 | * should cause a machine check, resulting in reset |
| 239 | */ |
| 240 | #ifdef CONFIG_SYS_RESET_ADDRESS |
| 241 | addr = CONFIG_SYS_RESET_ADDRESS; |
| 242 | #else |
| 243 | /* |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 244 | * note: when CONFIG_SYS_MONITOR_BASE points to a RAM address, |
| 245 | * CONFIG_SYS_MONITOR_BASE - sizeof (ulong) is usually a valid address. |
| 246 | * Better pick an address known to be invalid on your system and assign |
| 247 | * it to CONFIG_SYS_RESET_ADDRESS. |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 248 | * "(ulong)-1" used to be a good choice for many systems... |
| 249 | */ |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 250 | addr = CONFIG_SYS_MONITOR_BASE - sizeof(ulong); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 251 | #endif |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 252 | ((void (*)(void)) addr)(); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 253 | return 1; |
| 254 | } |
| 255 | |
| 256 | /* ------------------------------------------------------------------------- */ |
| 257 | |
| 258 | /* |
| 259 | * Get timebase clock frequency (like cpu_clk in Hz) |
| 260 | * |
| 261 | * See sections 14.2 and 14.6 of the User's Manual |
| 262 | */ |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 263 | unsigned long get_tbclk(void) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 264 | { |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 265 | uint immr = get_immr(0); /* Return full IMMR contents */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 266 | immap_t __iomem *immap = (immap_t __iomem *)(immr & 0xFFFF0000); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 267 | ulong oscclk, factor, pll; |
| 268 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 269 | if (in_be32(&immap->im_clkrst.car_sccr) & SCCR_TBS) |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 270 | return gd->cpu_clk / 16; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 271 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 272 | pll = in_be32(&immap->im_clkrst.car_plprcr); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 273 | |
| 274 | #define PLPRCR_val(a) ((pll & PLPRCR_ ## a ## _MSK) >> PLPRCR_ ## a ## _SHIFT) |
| 275 | |
| 276 | /* |
| 277 | * For newer PQ1 chips (MPC866/87x/88x families), PLL multiplication |
| 278 | * factor is calculated as follows: |
| 279 | * |
| 280 | * MFN |
| 281 | * MFI + ------- |
| 282 | * MFD + 1 |
| 283 | * factor = ----------------- |
| 284 | * (PDF + 1) * 2^S |
| 285 | * |
| 286 | */ |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 287 | factor = (PLPRCR_val(MFI) + PLPRCR_val(MFN) / (PLPRCR_val(MFD) + 1)) / |
| 288 | (PLPRCR_val(PDF) + 1) / (1 << PLPRCR_val(S)); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 289 | |
| 290 | oscclk = gd->cpu_clk / factor; |
| 291 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 292 | if ((in_be32(&immap->im_clkrst.car_sccr) & SCCR_RTSEL) == 0 || |
| 293 | factor > 2) |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 294 | return oscclk / 4; |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 295 | |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 296 | return oscclk / 16; |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | /* ------------------------------------------------------------------------- */ |
| 300 | |
| 301 | #if defined(CONFIG_WATCHDOG) |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 302 | void watchdog_reset(void) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 303 | { |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 304 | int re_enable = disable_interrupts(); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 305 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 306 | reset_8xx_watchdog((immap_t __iomem *)CONFIG_SYS_IMMR); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 307 | if (re_enable) |
Christophe Leroy | 48f896d | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 308 | enable_interrupts(); |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 309 | } |
| 310 | #endif /* CONFIG_WATCHDOG */ |
| 311 | |
| 312 | #if defined(CONFIG_WATCHDOG) |
| 313 | |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 314 | void reset_8xx_watchdog(immap_t __iomem *immr) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 315 | { |
| 316 | /* |
| 317 | * All other boards use the MPC8xx Internal Watchdog |
| 318 | */ |
Christophe Leroy | 394f9b3 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 319 | out_be16(&immr->im_siu_conf.sc_swsr, 0x556c); /* write magic1 */ |
| 320 | out_be16(&immr->im_siu_conf.sc_swsr, 0xaa39); /* write magic2 */ |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 321 | } |
| 322 | #endif /* CONFIG_WATCHDOG */ |
| 323 | |
| 324 | /* |
| 325 | * Initializes on-chip ethernet controllers. |
| 326 | * to override, implement board_eth_init() |
| 327 | */ |
| 328 | int cpu_eth_init(bd_t *bis) |
| 329 | { |
Christophe Leroy | 56ef30a | 2017-07-06 10:33:23 +0200 | [diff] [blame] | 330 | #if defined(CONFIG_MPC8XX_FEC) |
Christophe Leroy | 069fa83 | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 331 | fec_initialize(bis); |
| 332 | #endif |
| 333 | return 0; |
| 334 | } |