cpu.c 5.2 KB

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