cpu.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /*
  2. * Copyright 2004,2007-2011 Freescale Semiconductor, Inc.
  3. * (C) Copyright 2002, 2003 Motorola Inc.
  4. * Xianghua Xiao (X.Xiao@motorola.com)
  5. *
  6. * (C) Copyright 2000
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <config.h>
  12. #include <common.h>
  13. #include <watchdog.h>
  14. #include <command.h>
  15. #include <fsl_esdhc.h>
  16. #include <asm/cache.h>
  17. #include <asm/io.h>
  18. #include <asm/mmu.h>
  19. #include <asm/fsl_ifc.h>
  20. #include <asm/fsl_law.h>
  21. #include <asm/fsl_lbc.h>
  22. #include <post.h>
  23. #include <asm/processor.h>
  24. #include <asm/fsl_ddr_sdram.h>
  25. DECLARE_GLOBAL_DATA_PTR;
  26. /*
  27. * Default board reset function
  28. */
  29. static void
  30. __board_reset(void)
  31. {
  32. /* Do nothing */
  33. }
  34. void board_reset(void) __attribute__((weak, alias("__board_reset")));
  35. int checkcpu (void)
  36. {
  37. sys_info_t sysinfo;
  38. uint pvr, svr;
  39. uint ver;
  40. uint major, minor;
  41. struct cpu_type *cpu;
  42. char buf1[32], buf2[32];
  43. #if defined(CONFIG_DDR_CLK_FREQ) || defined(CONFIG_FSL_CORENET)
  44. ccsr_gur_t __iomem *gur =
  45. (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  46. #endif
  47. /*
  48. * Cornet platforms use ddr sync bit in RCW to indicate sync vs async
  49. * mode. Previous platform use ddr ratio to do the same. This
  50. * information is only for display here.
  51. */
  52. #ifdef CONFIG_FSL_CORENET
  53. #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
  54. u32 ddr_sync = 0; /* only async mode is supported */
  55. #else
  56. u32 ddr_sync = ((gur->rcwsr[5]) & FSL_CORENET_RCWSR5_DDR_SYNC)
  57. >> FSL_CORENET_RCWSR5_DDR_SYNC_SHIFT;
  58. #endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */
  59. #else /* CONFIG_FSL_CORENET */
  60. #ifdef CONFIG_DDR_CLK_FREQ
  61. u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO)
  62. >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT;
  63. #else
  64. u32 ddr_ratio = 0;
  65. #endif /* CONFIG_DDR_CLK_FREQ */
  66. #endif /* CONFIG_FSL_CORENET */
  67. unsigned int i, core, nr_cores = cpu_numcores();
  68. u32 mask = cpu_mask();
  69. svr = get_svr();
  70. major = SVR_MAJ(svr);
  71. minor = SVR_MIN(svr);
  72. if (cpu_numcores() > 1) {
  73. #ifndef CONFIG_MP
  74. puts("Unicore software on multiprocessor system!!\n"
  75. "To enable mutlticore build define CONFIG_MP\n");
  76. #endif
  77. volatile ccsr_pic_t *pic = (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR);
  78. printf("CPU%d: ", pic->whoami);
  79. } else {
  80. puts("CPU: ");
  81. }
  82. cpu = gd->arch.cpu;
  83. puts(cpu->name);
  84. if (IS_E_PROCESSOR(svr))
  85. puts("E");
  86. printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
  87. pvr = get_pvr();
  88. ver = PVR_VER(pvr);
  89. major = PVR_MAJ(pvr);
  90. minor = PVR_MIN(pvr);
  91. printf("Core: ");
  92. switch(ver) {
  93. case PVR_VER_E500_V1:
  94. case PVR_VER_E500_V2:
  95. puts("e500");
  96. break;
  97. case PVR_VER_E500MC:
  98. puts("e500mc");
  99. break;
  100. case PVR_VER_E5500:
  101. puts("e5500");
  102. break;
  103. case PVR_VER_E6500:
  104. puts("e6500");
  105. break;
  106. default:
  107. puts("Unknown");
  108. break;
  109. }
  110. printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
  111. if (nr_cores > CONFIG_MAX_CPUS) {
  112. panic("\nUnexpected number of cores: %d, max is %d\n",
  113. nr_cores, CONFIG_MAX_CPUS);
  114. }
  115. get_sys_info(&sysinfo);
  116. puts("Clock Configuration:");
  117. for_each_cpu(i, core, nr_cores, mask) {
  118. if (!(i & 3))
  119. printf ("\n ");
  120. printf("CPU%d:%-4s MHz, ", core,
  121. strmhz(buf1, sysinfo.freqProcessor[core]));
  122. }
  123. printf("\n CCB:%-4s MHz,\n", strmhz(buf1, sysinfo.freqSystemBus));
  124. #ifdef CONFIG_FSL_CORENET
  125. if (ddr_sync == 1) {
  126. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  127. "(Synchronous), ",
  128. strmhz(buf1, sysinfo.freqDDRBus/2),
  129. strmhz(buf2, sysinfo.freqDDRBus));
  130. } else {
  131. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  132. "(Asynchronous), ",
  133. strmhz(buf1, sysinfo.freqDDRBus/2),
  134. strmhz(buf2, sysinfo.freqDDRBus));
  135. }
  136. #else
  137. switch (ddr_ratio) {
  138. case 0x0:
  139. printf(" DDR:%-4s MHz (%s MT/s data rate), ",
  140. strmhz(buf1, sysinfo.freqDDRBus/2),
  141. strmhz(buf2, sysinfo.freqDDRBus));
  142. break;
  143. case 0x7:
  144. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  145. "(Synchronous), ",
  146. strmhz(buf1, sysinfo.freqDDRBus/2),
  147. strmhz(buf2, sysinfo.freqDDRBus));
  148. break;
  149. default:
  150. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  151. "(Asynchronous), ",
  152. strmhz(buf1, sysinfo.freqDDRBus/2),
  153. strmhz(buf2, sysinfo.freqDDRBus));
  154. break;
  155. }
  156. #endif
  157. #if defined(CONFIG_FSL_LBC)
  158. if (sysinfo.freqLocalBus > LCRR_CLKDIV) {
  159. printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus));
  160. } else {
  161. printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n",
  162. sysinfo.freqLocalBus);
  163. }
  164. #endif
  165. #if defined(CONFIG_FSL_IFC)
  166. printf("IFC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus));
  167. #endif
  168. #ifdef CONFIG_CPM2
  169. printf("CPM: %s MHz\n", strmhz(buf1, sysinfo.freqSystemBus));
  170. #endif
  171. #ifdef CONFIG_QE
  172. printf(" QE:%-4s MHz\n", strmhz(buf1, sysinfo.freqQE));
  173. #endif
  174. #ifdef CONFIG_SYS_DPAA_FMAN
  175. for (i = 0; i < CONFIG_SYS_NUM_FMAN; i++) {
  176. printf(" FMAN%d: %s MHz\n", i + 1,
  177. strmhz(buf1, sysinfo.freqFMan[i]));
  178. }
  179. #endif
  180. #ifdef CONFIG_SYS_DPAA_QBMAN
  181. printf(" QMAN: %s MHz\n", strmhz(buf1, sysinfo.freqQMAN));
  182. #endif
  183. #ifdef CONFIG_SYS_DPAA_PME
  184. printf(" PME: %s MHz\n", strmhz(buf1, sysinfo.freqPME));
  185. #endif
  186. puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
  187. #ifdef CONFIG_FSL_CORENET
  188. /* Display the RCW, so that no one gets confused as to what RCW
  189. * we're actually using for this boot.
  190. */
  191. puts("Reset Configuration Word (RCW):");
  192. for (i = 0; i < ARRAY_SIZE(gur->rcwsr); i++) {
  193. u32 rcw = in_be32(&gur->rcwsr[i]);
  194. if ((i % 4) == 0)
  195. printf("\n %08x:", i * 4);
  196. printf(" %08x", rcw);
  197. }
  198. puts("\n");
  199. #endif
  200. return 0;
  201. }
  202. /* ------------------------------------------------------------------------- */
  203. int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  204. {
  205. /* Everything after the first generation of PQ3 parts has RSTCR */
  206. #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \
  207. defined(CONFIG_MPC8555) || defined(CONFIG_MPC8560)
  208. unsigned long val, msr;
  209. /*
  210. * Initiate hard reset in debug control register DBCR0
  211. * Make sure MSR[DE] = 1. This only resets the core.
  212. */
  213. msr = mfmsr ();
  214. msr |= MSR_DE;
  215. mtmsr (msr);
  216. val = mfspr(DBCR0);
  217. val |= 0x70000000;
  218. mtspr(DBCR0,val);
  219. #else
  220. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  221. /* Attempt board-specific reset */
  222. board_reset();
  223. /* Next try asserting HRESET_REQ */
  224. out_be32(&gur->rstcr, 0x2);
  225. udelay(100);
  226. #endif
  227. return 1;
  228. }
  229. /*
  230. * Get timebase clock frequency
  231. */
  232. #ifndef CONFIG_SYS_FSL_TBCLK_DIV
  233. #define CONFIG_SYS_FSL_TBCLK_DIV 8
  234. #endif
  235. unsigned long get_tbclk (void)
  236. {
  237. unsigned long tbclk_div = CONFIG_SYS_FSL_TBCLK_DIV;
  238. return (gd->bus_clk + (tbclk_div >> 1)) / tbclk_div;
  239. }
  240. #if defined(CONFIG_WATCHDOG)
  241. void
  242. reset_85xx_watchdog(void)
  243. {
  244. /*
  245. * Clear TSR(WIS) bit by writing 1
  246. */
  247. mtspr(SPRN_TSR, TSR_WIS);
  248. }
  249. void
  250. watchdog_reset(void)
  251. {
  252. int re_enable = disable_interrupts();
  253. reset_85xx_watchdog();
  254. if (re_enable)
  255. enable_interrupts();
  256. }
  257. #endif /* CONFIG_WATCHDOG */
  258. /*
  259. * Initializes on-chip MMC controllers.
  260. * to override, implement board_mmc_init()
  261. */
  262. int cpu_mmc_init(bd_t *bis)
  263. {
  264. #ifdef CONFIG_FSL_ESDHC
  265. return fsl_esdhc_mmc_init(bis);
  266. #else
  267. return 0;
  268. #endif
  269. }
  270. /*
  271. * Print out the state of various machine registers.
  272. * Currently prints out LAWs, BR0/OR0 for LBC, CSPR/CSOR/Timing
  273. * parameters for IFC and TLBs
  274. */
  275. void mpc85xx_reginfo(void)
  276. {
  277. print_tlbcam();
  278. print_laws();
  279. #if defined(CONFIG_FSL_LBC)
  280. print_lbc_regs();
  281. #endif
  282. #ifdef CONFIG_FSL_IFC
  283. print_ifc_regs();
  284. #endif
  285. }
  286. /* Common ddr init for non-corenet fsl 85xx platforms */
  287. #ifndef CONFIG_FSL_CORENET
  288. #if (defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_SPL)) && \
  289. !defined(CONFIG_SYS_INIT_L2_ADDR)
  290. phys_size_t initdram(int board_type)
  291. {
  292. #if defined(CONFIG_SPD_EEPROM) || defined(CONFIG_DDR_SPD)
  293. return fsl_ddr_sdram_size();
  294. #else
  295. return (phys_size_t)CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  296. #endif
  297. }
  298. #else /* CONFIG_SYS_RAMBOOT */
  299. phys_size_t initdram(int board_type)
  300. {
  301. phys_size_t dram_size = 0;
  302. #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_MSYNC_IN)
  303. {
  304. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  305. unsigned int x = 10;
  306. unsigned int i;
  307. /*
  308. * Work around to stabilize DDR DLL
  309. */
  310. out_be32(&gur->ddrdllcr, 0x81000000);
  311. asm("sync;isync;msync");
  312. udelay(200);
  313. while (in_be32(&gur->ddrdllcr) != 0x81000100) {
  314. setbits_be32(&gur->devdisr, 0x00010000);
  315. for (i = 0; i < x; i++)
  316. ;
  317. clrbits_be32(&gur->devdisr, 0x00010000);
  318. x++;
  319. }
  320. }
  321. #endif
  322. #if defined(CONFIG_SPD_EEPROM) || \
  323. defined(CONFIG_DDR_SPD) || \
  324. defined(CONFIG_SYS_DDR_RAW_TIMING)
  325. dram_size = fsl_ddr_sdram();
  326. #else
  327. dram_size = fixed_sdram();
  328. #endif
  329. dram_size = setup_ddr_tlbs(dram_size / 0x100000);
  330. dram_size *= 0x100000;
  331. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  332. /*
  333. * Initialize and enable DDR ECC.
  334. */
  335. ddr_enable_ecc(dram_size);
  336. #endif
  337. #if defined(CONFIG_FSL_LBC)
  338. /* Some boards also have sdram on the lbc */
  339. lbc_sdram_init();
  340. #endif
  341. debug("DDR: ");
  342. return dram_size;
  343. }
  344. #endif /* CONFIG_SYS_RAMBOOT */
  345. #endif
  346. #if CONFIG_POST & CONFIG_SYS_POST_MEMORY
  347. /* Board-specific functions defined in each board's ddr.c */
  348. void fsl_ddr_get_spd(generic_spd_eeprom_t *ctrl_dimms_spd,
  349. unsigned int ctrl_num);
  350. void read_tlbcam_entry(int idx, u32 *valid, u32 *tsize, unsigned long *epn,
  351. phys_addr_t *rpn);
  352. unsigned int
  353. setup_ddr_tlbs_phys(phys_addr_t p_addr, unsigned int memsize_in_meg);
  354. void clear_ddr_tlbs_phys(phys_addr_t p_addr, unsigned int memsize_in_meg);
  355. static void dump_spd_ddr_reg(void)
  356. {
  357. int i, j, k, m;
  358. u8 *p_8;
  359. u32 *p_32;
  360. ccsr_ddr_t *ddr[CONFIG_NUM_DDR_CONTROLLERS];
  361. generic_spd_eeprom_t
  362. spd[CONFIG_NUM_DDR_CONTROLLERS][CONFIG_DIMM_SLOTS_PER_CTLR];
  363. for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++)
  364. fsl_ddr_get_spd(spd[i], i);
  365. puts("SPD data of all dimms (zero vaule is omitted)...\n");
  366. puts("Byte (hex) ");
  367. k = 1;
  368. for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
  369. for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++)
  370. printf("Dimm%d ", k++);
  371. }
  372. puts("\n");
  373. for (k = 0; k < sizeof(generic_spd_eeprom_t); k++) {
  374. m = 0;
  375. printf("%3d (0x%02x) ", k, k);
  376. for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
  377. for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++) {
  378. p_8 = (u8 *) &spd[i][j];
  379. if (p_8[k]) {
  380. printf("0x%02x ", p_8[k]);
  381. m++;
  382. } else
  383. puts(" ");
  384. }
  385. }
  386. if (m)
  387. puts("\n");
  388. else
  389. puts("\r");
  390. }
  391. for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
  392. switch (i) {
  393. case 0:
  394. ddr[i] = (void *)CONFIG_SYS_MPC8xxx_DDR_ADDR;
  395. break;
  396. #if defined(CONFIG_SYS_MPC8xxx_DDR2_ADDR) && (CONFIG_NUM_DDR_CONTROLLERS > 1)
  397. case 1:
  398. ddr[i] = (void *)CONFIG_SYS_MPC8xxx_DDR2_ADDR;
  399. break;
  400. #endif
  401. #if defined(CONFIG_SYS_MPC8xxx_DDR3_ADDR) && (CONFIG_NUM_DDR_CONTROLLERS > 2)
  402. case 2:
  403. ddr[i] = (void *)CONFIG_SYS_MPC8xxx_DDR3_ADDR;
  404. break;
  405. #endif
  406. #if defined(CONFIG_SYS_MPC8xxx_DDR4_ADDR) && (CONFIG_NUM_DDR_CONTROLLERS > 3)
  407. case 3:
  408. ddr[i] = (void *)CONFIG_SYS_MPC8xxx_DDR4_ADDR;
  409. break;
  410. #endif
  411. default:
  412. printf("%s unexpected controller number = %u\n",
  413. __func__, i);
  414. return;
  415. }
  416. }
  417. printf("DDR registers dump for all controllers "
  418. "(zero vaule is omitted)...\n");
  419. puts("Offset (hex) ");
  420. for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++)
  421. printf(" Base + 0x%04x", (u32)ddr[i] & 0xFFFF);
  422. puts("\n");
  423. for (k = 0; k < sizeof(ccsr_ddr_t)/4; k++) {
  424. m = 0;
  425. printf("%6d (0x%04x)", k * 4, k * 4);
  426. for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
  427. p_32 = (u32 *) ddr[i];
  428. if (p_32[k]) {
  429. printf(" 0x%08x", p_32[k]);
  430. m++;
  431. } else
  432. puts(" ");
  433. }
  434. if (m)
  435. puts("\n");
  436. else
  437. puts("\r");
  438. }
  439. puts("\n");
  440. }
  441. /* invalid the TLBs for DDR and setup new ones to cover p_addr */
  442. static int reset_tlb(phys_addr_t p_addr, u32 size, phys_addr_t *phys_offset)
  443. {
  444. u32 vstart = CONFIG_SYS_DDR_SDRAM_BASE;
  445. unsigned long epn;
  446. u32 tsize, valid, ptr;
  447. int ddr_esel;
  448. clear_ddr_tlbs_phys(p_addr, size>>20);
  449. /* Setup new tlb to cover the physical address */
  450. setup_ddr_tlbs_phys(p_addr, size>>20);
  451. ptr = vstart;
  452. ddr_esel = find_tlb_idx((void *)ptr, 1);
  453. if (ddr_esel != -1) {
  454. read_tlbcam_entry(ddr_esel, &valid, &tsize, &epn, phys_offset);
  455. } else {
  456. printf("TLB error in function %s\n", __func__);
  457. return -1;
  458. }
  459. return 0;
  460. }
  461. /*
  462. * slide the testing window up to test another area
  463. * for 32_bit system, the maximum testable memory is limited to
  464. * CONFIG_MAX_MEM_MAPPED
  465. */
  466. int arch_memory_test_advance(u32 *vstart, u32 *size, phys_addr_t *phys_offset)
  467. {
  468. phys_addr_t test_cap, p_addr;
  469. phys_size_t p_size = min(gd->ram_size, CONFIG_MAX_MEM_MAPPED);
  470. #if !defined(CONFIG_PHYS_64BIT) || \
  471. !defined(CONFIG_SYS_INIT_RAM_ADDR_PHYS) || \
  472. (CONFIG_SYS_INIT_RAM_ADDR_PHYS < 0x100000000ull)
  473. test_cap = p_size;
  474. #else
  475. test_cap = gd->ram_size;
  476. #endif
  477. p_addr = (*vstart) + (*size) + (*phys_offset);
  478. if (p_addr < test_cap - 1) {
  479. p_size = min(test_cap - p_addr, CONFIG_MAX_MEM_MAPPED);
  480. if (reset_tlb(p_addr, p_size, phys_offset) == -1)
  481. return -1;
  482. *vstart = CONFIG_SYS_DDR_SDRAM_BASE;
  483. *size = (u32) p_size;
  484. printf("Testing 0x%08llx - 0x%08llx\n",
  485. (u64)(*vstart) + (*phys_offset),
  486. (u64)(*vstart) + (*phys_offset) + (*size) - 1);
  487. } else
  488. return 1;
  489. return 0;
  490. }
  491. /* initialization for testing area */
  492. int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset)
  493. {
  494. phys_size_t p_size = min(gd->ram_size, CONFIG_MAX_MEM_MAPPED);
  495. *vstart = CONFIG_SYS_DDR_SDRAM_BASE;
  496. *size = (u32) p_size; /* CONFIG_MAX_MEM_MAPPED < 4G */
  497. *phys_offset = 0;
  498. #if !defined(CONFIG_PHYS_64BIT) || \
  499. !defined(CONFIG_SYS_INIT_RAM_ADDR_PHYS) || \
  500. (CONFIG_SYS_INIT_RAM_ADDR_PHYS < 0x100000000ull)
  501. if (gd->ram_size > CONFIG_MAX_MEM_MAPPED) {
  502. puts("Cannot test more than ");
  503. print_size(CONFIG_MAX_MEM_MAPPED,
  504. " without proper 36BIT support.\n");
  505. }
  506. #endif
  507. printf("Testing 0x%08llx - 0x%08llx\n",
  508. (u64)(*vstart) + (*phys_offset),
  509. (u64)(*vstart) + (*phys_offset) + (*size) - 1);
  510. return 0;
  511. }
  512. /* invalid TLBs for DDR and remap as normal after testing */
  513. int arch_memory_test_cleanup(u32 *vstart, u32 *size, phys_addr_t *phys_offset)
  514. {
  515. unsigned long epn;
  516. u32 tsize, valid, ptr;
  517. phys_addr_t rpn = 0;
  518. int ddr_esel;
  519. /* disable the TLBs for this testing */
  520. ptr = *vstart;
  521. while (ptr < (*vstart) + (*size)) {
  522. ddr_esel = find_tlb_idx((void *)ptr, 1);
  523. if (ddr_esel != -1) {
  524. read_tlbcam_entry(ddr_esel, &valid, &tsize, &epn, &rpn);
  525. disable_tlb(ddr_esel);
  526. }
  527. ptr += TSIZE_TO_BYTES(tsize);
  528. }
  529. puts("Remap DDR ");
  530. setup_ddr_tlbs(gd->ram_size>>20);
  531. puts("\n");
  532. return 0;
  533. }
  534. void arch_memory_failure_handle(void)
  535. {
  536. dump_spd_ddr_reg();
  537. }
  538. #endif