cpu.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /*
  2. * Copyright 2004,2007-2009 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. DECLARE_GLOBAL_DATA_PTR;
  35. int checkcpu (void)
  36. {
  37. sys_info_t sysinfo;
  38. uint pvr, svr;
  39. uint fam;
  40. uint ver;
  41. uint major, minor;
  42. struct cpu_type *cpu;
  43. char buf1[32], buf2[32];
  44. #ifdef CONFIG_DDR_CLK_FREQ
  45. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  46. #ifdef CONFIG_FSL_CORENET
  47. u32 ddr_sync = ((gur->rcwsr[5]) & FSL_CORENET_RCWSR5_DDR_SYNC)
  48. >> FSL_CORENET_RCWSR5_DDR_SYNC_SHIFT;
  49. #else
  50. u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO)
  51. >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT;
  52. #endif
  53. #else
  54. #ifdef CONFIG_FSL_CORENET
  55. u32 ddr_sync = 0;
  56. #else
  57. u32 ddr_ratio = 0;
  58. #endif
  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_MPC85xx_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. switch (fam) {
  89. case PVR_FAM(PVR_85xx):
  90. puts("E500");
  91. break;
  92. default:
  93. puts("Unknown");
  94. break;
  95. }
  96. if (PVR_MEM(pvr) == 0x03)
  97. puts("MC");
  98. printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
  99. get_sys_info(&sysinfo);
  100. puts("Clock Configuration:");
  101. for (i = 0; i < cpu_numcores(); i++) {
  102. if (!(i & 3))
  103. printf ("\n ");
  104. printf("CPU%d:%-4s MHz, ",
  105. i,strmhz(buf1, sysinfo.freqProcessor[i]));
  106. }
  107. printf("\n CCB:%-4s MHz,\n", strmhz(buf1, sysinfo.freqSystemBus));
  108. #ifdef CONFIG_FSL_CORENET
  109. if (ddr_sync == 1) {
  110. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  111. "(Synchronous), ",
  112. strmhz(buf1, sysinfo.freqDDRBus/2),
  113. strmhz(buf2, sysinfo.freqDDRBus));
  114. } else {
  115. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  116. "(Asynchronous), ",
  117. strmhz(buf1, sysinfo.freqDDRBus/2),
  118. strmhz(buf2, sysinfo.freqDDRBus));
  119. }
  120. #else
  121. switch (ddr_ratio) {
  122. case 0x0:
  123. printf(" DDR:%-4s MHz (%s MT/s data rate), ",
  124. strmhz(buf1, sysinfo.freqDDRBus/2),
  125. strmhz(buf2, sysinfo.freqDDRBus));
  126. break;
  127. case 0x7:
  128. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  129. "(Synchronous), ",
  130. strmhz(buf1, sysinfo.freqDDRBus/2),
  131. strmhz(buf2, sysinfo.freqDDRBus));
  132. break;
  133. default:
  134. printf(" DDR:%-4s MHz (%s MT/s data rate) "
  135. "(Asynchronous), ",
  136. strmhz(buf1, sysinfo.freqDDRBus/2),
  137. strmhz(buf2, sysinfo.freqDDRBus));
  138. break;
  139. }
  140. #endif
  141. if (sysinfo.freqLocalBus > LCRR_CLKDIV) {
  142. printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus));
  143. } else {
  144. printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n",
  145. sysinfo.freqLocalBus);
  146. }
  147. #ifdef CONFIG_CPM2
  148. printf("CPM: %s MHz\n", strmhz(buf1, sysinfo.freqSystemBus));
  149. #endif
  150. #ifdef CONFIG_QE
  151. printf(" QE:%-4s MHz\n", strmhz(buf1, sysinfo.freqQE));
  152. #endif
  153. #ifdef CONFIG_SYS_DPAA_FMAN
  154. for (i = 0; i < CONFIG_SYS_NUM_FMAN; i++) {
  155. printf(" FMAN%d: %s MHz\n", i,
  156. strmhz(buf1, sysinfo.freqFMan[i]));
  157. }
  158. #endif
  159. #ifdef CONFIG_SYS_DPAA_PME
  160. printf(" PME: %s MHz\n", strmhz(buf1, sysinfo.freqPME));
  161. #endif
  162. puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
  163. return 0;
  164. }
  165. /* ------------------------------------------------------------------------- */
  166. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
  167. {
  168. /* Everything after the first generation of PQ3 parts has RSTCR */
  169. #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \
  170. defined(CONFIG_MPC8555) || defined(CONFIG_MPC8560)
  171. unsigned long val, msr;
  172. /*
  173. * Initiate hard reset in debug control register DBCR0
  174. * Make sure MSR[DE] = 1. This only resets the core.
  175. */
  176. msr = mfmsr ();
  177. msr |= MSR_DE;
  178. mtmsr (msr);
  179. val = mfspr(DBCR0);
  180. val |= 0x70000000;
  181. mtspr(DBCR0,val);
  182. #else
  183. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  184. out_be32(&gur->rstcr, 0x2); /* HRESET_REQ */
  185. udelay(100);
  186. #endif
  187. return 1;
  188. }
  189. /*
  190. * Get timebase clock frequency
  191. */
  192. unsigned long get_tbclk (void)
  193. {
  194. #ifdef CONFIG_FSL_CORENET
  195. return (gd->bus_clk + 8) / 16;
  196. #else
  197. return (gd->bus_clk + 4UL)/8UL;
  198. #endif
  199. }
  200. #if defined(CONFIG_WATCHDOG)
  201. void
  202. watchdog_reset(void)
  203. {
  204. int re_enable = disable_interrupts();
  205. reset_85xx_watchdog();
  206. if (re_enable) enable_interrupts();
  207. }
  208. void
  209. reset_85xx_watchdog(void)
  210. {
  211. /*
  212. * Clear TSR(WIS) bit by writing 1
  213. */
  214. unsigned long val;
  215. val = mfspr(SPRN_TSR);
  216. val |= TSR_WIS;
  217. mtspr(SPRN_TSR, val);
  218. }
  219. #endif /* CONFIG_WATCHDOG */
  220. /*
  221. * Configures a UPM. The function requires the respective MxMR to be set
  222. * before calling this function. "size" is the number or entries, not a sizeof.
  223. */
  224. void upmconfig (uint upm, uint * table, uint size)
  225. {
  226. int i, mdr, mad, old_mad = 0;
  227. volatile u32 *mxmr;
  228. volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
  229. volatile u32 *brp,*orp;
  230. volatile u8* dummy = NULL;
  231. int upmmask;
  232. switch (upm) {
  233. case UPMA:
  234. mxmr = &lbc->mamr;
  235. upmmask = BR_MS_UPMA;
  236. break;
  237. case UPMB:
  238. mxmr = &lbc->mbmr;
  239. upmmask = BR_MS_UPMB;
  240. break;
  241. case UPMC:
  242. mxmr = &lbc->mcmr;
  243. upmmask = BR_MS_UPMC;
  244. break;
  245. default:
  246. printf("%s: Bad UPM index %d to configure\n", __FUNCTION__, upm);
  247. hang();
  248. }
  249. /* Find the address for the dummy write transaction */
  250. for (brp = &lbc->br0, orp = &lbc->or0, i = 0; i < 8;
  251. i++, brp += 2, orp += 2) {
  252. /* Look for a valid BR with selected UPM */
  253. if ((in_be32(brp) & (BR_V | BR_MSEL)) == (BR_V | upmmask)) {
  254. dummy = (volatile u8*)(in_be32(brp) & BR_BA);
  255. break;
  256. }
  257. }
  258. if (i == 8) {
  259. printf("Error: %s() could not find matching BR\n", __FUNCTION__);
  260. hang();
  261. }
  262. for (i = 0; i < size; i++) {
  263. /* 1 */
  264. out_be32(mxmr, (in_be32(mxmr) & 0x4fffffc0) | MxMR_OP_WARR | i);
  265. /* 2 */
  266. out_be32(&lbc->mdr, table[i]);
  267. /* 3 */
  268. mdr = in_be32(&lbc->mdr);
  269. /* 4 */
  270. *(volatile u8 *)dummy = 0;
  271. /* 5 */
  272. do {
  273. mad = in_be32(mxmr) & MxMR_MAD_MSK;
  274. } while (mad <= old_mad && !(!mad && i == (size-1)));
  275. old_mad = mad;
  276. }
  277. out_be32(mxmr, (in_be32(mxmr) & 0x4fffffc0) | MxMR_OP_NORM);
  278. }
  279. /*
  280. * Initializes on-chip MMC controllers.
  281. * to override, implement board_mmc_init()
  282. */
  283. int cpu_mmc_init(bd_t *bis)
  284. {
  285. #ifdef CONFIG_FSL_ESDHC
  286. return fsl_esdhc_mmc_init(bis);
  287. #else
  288. return 0;
  289. #endif
  290. }