cpu.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /*
  2. * Copyright 2006 Freescale Semiconductor
  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 <tsec.h>
  31. #include <asm/fsl_law.h>
  32. struct cpu_type cpu_type_list [] = {
  33. CPU_TYPE_ENTRY(8610, 8610),
  34. CPU_TYPE_ENTRY(8641, 8641),
  35. CPU_TYPE_ENTRY(8641D, 8641D),
  36. };
  37. struct cpu_type *identify_cpu(u32 ver)
  38. {
  39. int i;
  40. for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++)
  41. if (cpu_type_list[i].soc_ver == ver)
  42. return &cpu_type_list[i];
  43. return NULL;
  44. }
  45. /*
  46. * Default board reset function
  47. */
  48. static void
  49. __board_reset(void)
  50. {
  51. /* Do nothing */
  52. }
  53. void board_reset(void) __attribute__((weak, alias("__board_reset")));
  54. int
  55. checkcpu(void)
  56. {
  57. sys_info_t sysinfo;
  58. uint pvr, svr;
  59. uint ver;
  60. uint major, minor;
  61. char buf1[32], buf2[32];
  62. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  63. volatile ccsr_gur_t *gur = &immap->im_gur;
  64. struct cpu_type *cpu;
  65. uint msscr0 = mfspr(MSSCR0);
  66. svr = get_svr();
  67. ver = SVR_SOC_VER(svr);
  68. major = SVR_MAJ(svr);
  69. minor = SVR_MIN(svr);
  70. puts("CPU: ");
  71. cpu = identify_cpu(ver);
  72. if (cpu) {
  73. puts(cpu->name);
  74. } else {
  75. puts("Unknown");
  76. }
  77. printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
  78. puts("Core: ");
  79. pvr = get_pvr();
  80. ver = PVR_E600_VER(pvr);
  81. major = PVR_E600_MAJ(pvr);
  82. minor = PVR_E600_MIN(pvr);
  83. printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 );
  84. if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE)
  85. puts("\n Core1Translation Enabled");
  86. debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr);
  87. printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
  88. get_sys_info(&sysinfo);
  89. puts("Clock Configuration:\n");
  90. printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor));
  91. printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus));
  92. printf(" DDR:%-4s MHz (%s MT/s data rate), ",
  93. strmhz(buf1, sysinfo.freqSystemBus / 2),
  94. strmhz(buf2, sysinfo.freqSystemBus));
  95. if (sysinfo.freqLocalBus > LCRR_CLKDIV) {
  96. printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus));
  97. } else {
  98. printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n",
  99. sysinfo.freqLocalBus);
  100. }
  101. puts("L1: D-cache 32 KB enabled\n");
  102. puts(" I-cache 32 KB enabled\n");
  103. puts("L2: ");
  104. if (get_l2cr() & 0x80000000) {
  105. #if defined(CONFIG_MPC8610)
  106. puts("256");
  107. #elif defined(CONFIG_MPC8641)
  108. puts("512");
  109. #endif
  110. puts(" KB enabled\n");
  111. } else {
  112. puts("Disabled\n");
  113. }
  114. return 0;
  115. }
  116. void
  117. do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  118. {
  119. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  120. volatile ccsr_gur_t *gur = &immap->im_gur;
  121. /* Attempt board-specific reset */
  122. board_reset();
  123. /* Next try asserting HRESET_REQ */
  124. out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ);
  125. while (1)
  126. ;
  127. }
  128. /*
  129. * Get timebase clock frequency
  130. */
  131. unsigned long
  132. get_tbclk(void)
  133. {
  134. sys_info_t sys_info;
  135. get_sys_info(&sys_info);
  136. return (sys_info.freqSystemBus + 3L) / 4L;
  137. }
  138. #if defined(CONFIG_WATCHDOG)
  139. void
  140. watchdog_reset(void)
  141. {
  142. #if defined(CONFIG_MPC8610)
  143. /*
  144. * This actually feed the hard enabled watchdog.
  145. */
  146. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  147. volatile ccsr_wdt_t *wdt = &immap->im_wdt;
  148. volatile ccsr_gur_t *gur = &immap->im_gur;
  149. u32 tmp = gur->pordevsr;
  150. if (tmp & 0x4000) {
  151. wdt->swsrr = 0x556c;
  152. wdt->swsrr = 0xaa39;
  153. }
  154. #endif
  155. }
  156. #endif /* CONFIG_WATCHDOG */
  157. #if defined(CONFIG_DDR_ECC)
  158. void
  159. dma_init(void)
  160. {
  161. volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR);
  162. volatile fsl_dma_t *dma = &dma_base->dma[0];
  163. dma->satr = 0x00040000;
  164. dma->datr = 0x00040000;
  165. dma->sr = 0xffffffff; /* clear any errors */
  166. asm("sync; isync");
  167. }
  168. uint
  169. dma_check(void)
  170. {
  171. volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR);
  172. volatile fsl_dma_t *dma = &dma_base->dma[0];
  173. volatile uint status = dma->sr;
  174. /* While the channel is busy, spin */
  175. while ((status & 4) == 4) {
  176. status = dma->sr;
  177. }
  178. /* clear MR[CS] channel start bit */
  179. dma->mr &= 0x00000001;
  180. asm("sync;isync");
  181. if (status != 0) {
  182. printf("DMA Error: status = %x\n", status);
  183. }
  184. return status;
  185. }
  186. int
  187. dma_xfer(void *dest, uint count, void *src)
  188. {
  189. volatile ccsr_dma_t *dma_base = (void *)(CONFIG_SYS_MPC86xx_DMA_ADDR);
  190. volatile fsl_dma_t *dma = &dma_base->dma[0];
  191. dma->dar = (uint) dest;
  192. dma->sar = (uint) src;
  193. dma->bcr = count;
  194. dma->mr = 0xf000004;
  195. asm("sync;isync");
  196. dma->mr = 0xf000005;
  197. asm("sync;isync");
  198. return dma_check();
  199. }
  200. #endif /* CONFIG_DDR_ECC */
  201. /*
  202. * Print out the state of various machine registers.
  203. * Currently prints out LAWs, BR0/OR0, and BATs
  204. */
  205. void mpc86xx_reginfo(void)
  206. {
  207. immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  208. ccsr_lbc_t *lbc = &immap->im_lbc;
  209. print_bats();
  210. print_laws();
  211. printf ("Local Bus Controller Registers\n"
  212. "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0));
  213. printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1));
  214. printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2));
  215. printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3));
  216. printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4));
  217. printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5));
  218. printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6));
  219. printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7));
  220. }
  221. /*
  222. * Initializes on-chip ethernet controllers.
  223. * to override, implement board_eth_init()
  224. */
  225. int cpu_eth_init(bd_t *bis)
  226. {
  227. #if defined(CONFIG_TSEC_ENET)
  228. tsec_standard_init(bis);
  229. #endif
  230. return 0;
  231. }