cpu.c 5.9 KB

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