cpu.c 7.5 KB

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