cpu.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*
  2. * Copyright 2004,2007-2010 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. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <config.h>
  28. #include <common.h>
  29. #include <watchdog.h>
  30. #include <command.h>
  31. #include <fsl_esdhc.h>
  32. #include <asm/cache.h>
  33. #include <asm/io.h>
  34. #include <asm/mmu.h>
  35. #include <asm/fsl_law.h>
  36. DECLARE_GLOBAL_DATA_PTR;
  37. int checkcpu (void)
  38. {
  39. sys_info_t sysinfo;
  40. uint pvr, svr;
  41. uint fam;
  42. uint ver;
  43. uint major, minor;
  44. struct cpu_type *cpu;
  45. char buf1[32], buf2[32];
  46. #if defined(CONFIG_DDR_CLK_FREQ) || defined(CONFIG_FSL_CORENET)
  47. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  48. #endif /* CONFIG_FSL_CORENET */
  49. #ifdef CONFIG_DDR_CLK_FREQ
  50. u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO)
  51. >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT;
  52. #else
  53. #ifdef CONFIG_FSL_CORENET
  54. u32 ddr_sync = ((gur->rcwsr[5]) & FSL_CORENET_RCWSR5_DDR_SYNC)
  55. >> FSL_CORENET_RCWSR5_DDR_SYNC_SHIFT;
  56. #else
  57. u32 ddr_ratio = 0;
  58. #endif /* CONFIG_FSL_CORENET */
  59. #endif /* CONFIG_DDR_CLK_FREQ */
  60. int i;
  61. svr = get_svr();
  62. major = SVR_MAJ(svr);
  63. #ifdef CONFIG_MPC8536
  64. major &= 0x7; /* the msb of this nibble is a mfg code */
  65. #endif
  66. minor = SVR_MIN(svr);
  67. if (cpu_numcores() > 1) {
  68. #ifndef CONFIG_MP
  69. puts("Unicore software on multiprocessor system!!\n"
  70. "To enable mutlticore build define CONFIG_MP\n");
  71. #endif
  72. volatile ccsr_pic_t *pic = (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR);
  73. printf("CPU%d: ", pic->whoami);
  74. } else {
  75. puts("CPU: ");
  76. }
  77. cpu = gd->cpu;
  78. puts(cpu->name);
  79. if (IS_E_PROCESSOR(svr))
  80. puts("E");
  81. printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
  82. pvr = get_pvr();
  83. fam = PVR_FAM(pvr);
  84. ver = PVR_VER(pvr);
  85. major = PVR_MAJ(pvr);
  86. minor = PVR_MIN(pvr);
  87. printf("Core: ");
  88. if (PVR_FAM(PVR_85xx)) {
  89. switch(PVR_MEM(pvr)) {
  90. case 0x1:
  91. case 0x2:
  92. puts("E500");
  93. break;
  94. case 0x3:
  95. puts("E500MC");
  96. break;
  97. case 0x4:
  98. puts("E5500");
  99. break;
  100. default:
  101. puts("Unknown");
  102. break;
  103. }
  104. } else {
  105. puts("Unknown");
  106. }
  107. printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
  108. get_sys_info(&sysinfo);
  109. puts("Clock Configuration:");
  110. for (i = 0; i < cpu_numcores(); i++) {
  111. if (!(i & 3))
  112. printf ("\n ");
  113. printf("CPU%d:%-4s MHz, ",
  114. i,strmhz(buf1, sysinfo.freqProcessor[i]));
  115. }
  116. printf("\n CCB:%-4s MHz,\n", strmhz(buf1, sysinfo.freqSystemBus));
  117. #ifdef CONFIG_FSL_CORENET
  118. if (ddr_sync == 1) {
  119. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  120. "(Synchronous), ",
  121. strmhz(buf1, sysinfo.freqDDRBus/2),
  122. strmhz(buf2, sysinfo.freqDDRBus));
  123. } else {
  124. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  125. "(Asynchronous), ",
  126. strmhz(buf1, sysinfo.freqDDRBus/2),
  127. strmhz(buf2, sysinfo.freqDDRBus));
  128. }
  129. #else
  130. switch (ddr_ratio) {
  131. case 0x0:
  132. printf(" DDR:%-4s MHz (%s MT/s data rate), ",
  133. strmhz(buf1, sysinfo.freqDDRBus/2),
  134. strmhz(buf2, sysinfo.freqDDRBus));
  135. break;
  136. case 0x7:
  137. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  138. "(Synchronous), ",
  139. strmhz(buf1, sysinfo.freqDDRBus/2),
  140. strmhz(buf2, sysinfo.freqDDRBus));
  141. break;
  142. default:
  143. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  144. "(Asynchronous), ",
  145. strmhz(buf1, sysinfo.freqDDRBus/2),
  146. strmhz(buf2, sysinfo.freqDDRBus));
  147. break;
  148. }
  149. #endif
  150. if (sysinfo.freqLocalBus > LCRR_CLKDIV) {
  151. printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus));
  152. } else {
  153. printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n",
  154. sysinfo.freqLocalBus);
  155. }
  156. #ifdef CONFIG_CPM2
  157. printf("CPM: %s MHz\n", strmhz(buf1, sysinfo.freqSystemBus));
  158. #endif
  159. #ifdef CONFIG_QE
  160. printf(" QE:%-4s MHz\n", strmhz(buf1, sysinfo.freqQE));
  161. #endif
  162. #ifdef CONFIG_SYS_DPAA_FMAN
  163. for (i = 0; i < CONFIG_SYS_NUM_FMAN; i++) {
  164. printf(" FMAN%d: %s MHz\n", i + 1,
  165. strmhz(buf1, sysinfo.freqFMan[i]));
  166. }
  167. #endif
  168. #ifdef CONFIG_SYS_DPAA_PME
  169. printf(" PME: %s MHz\n", strmhz(buf1, sysinfo.freqPME));
  170. #endif
  171. puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
  172. return 0;
  173. }
  174. /* ------------------------------------------------------------------------- */
  175. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char * const argv[])
  176. {
  177. /* Everything after the first generation of PQ3 parts has RSTCR */
  178. #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \
  179. defined(CONFIG_MPC8555) || defined(CONFIG_MPC8560)
  180. unsigned long val, msr;
  181. /*
  182. * Initiate hard reset in debug control register DBCR0
  183. * Make sure MSR[DE] = 1. This only resets the core.
  184. */
  185. msr = mfmsr ();
  186. msr |= MSR_DE;
  187. mtmsr (msr);
  188. val = mfspr(DBCR0);
  189. val |= 0x70000000;
  190. mtspr(DBCR0,val);
  191. #else
  192. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  193. out_be32(&gur->rstcr, 0x2); /* HRESET_REQ */
  194. udelay(100);
  195. #endif
  196. return 1;
  197. }
  198. /*
  199. * Get timebase clock frequency
  200. */
  201. unsigned long get_tbclk (void)
  202. {
  203. #ifdef CONFIG_FSL_CORENET
  204. return (gd->bus_clk + 8) / 16;
  205. #else
  206. return (gd->bus_clk + 4UL)/8UL;
  207. #endif
  208. }
  209. #if defined(CONFIG_WATCHDOG)
  210. void
  211. watchdog_reset(void)
  212. {
  213. int re_enable = disable_interrupts();
  214. reset_85xx_watchdog();
  215. if (re_enable) enable_interrupts();
  216. }
  217. void
  218. reset_85xx_watchdog(void)
  219. {
  220. /*
  221. * Clear TSR(WIS) bit by writing 1
  222. */
  223. unsigned long val;
  224. val = mfspr(SPRN_TSR);
  225. val |= TSR_WIS;
  226. mtspr(SPRN_TSR, val);
  227. }
  228. #endif /* CONFIG_WATCHDOG */
  229. /*
  230. * Initializes on-chip MMC controllers.
  231. * to override, implement board_mmc_init()
  232. */
  233. int cpu_mmc_init(bd_t *bis)
  234. {
  235. #ifdef CONFIG_FSL_ESDHC
  236. return fsl_esdhc_mmc_init(bis);
  237. #else
  238. return 0;
  239. #endif
  240. }
  241. /*
  242. * Print out the state of various machine registers.
  243. * Currently prints out LAWs, BR0/OR0, and TLBs
  244. */
  245. void mpc85xx_reginfo(void)
  246. {
  247. print_tlbcam();
  248. print_laws();
  249. print_lbc_regs();
  250. }