cpu.c 4.4 KB

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