cpu.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * Copyright 2006,2009 Freescale Semiconductor, Inc.
  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 <asm/fsl_law.h>
  31. /*
  32. * Default board reset function
  33. */
  34. static void
  35. __board_reset(void)
  36. {
  37. /* Do nothing */
  38. }
  39. void board_reset(void) __attribute__((weak, alias("__board_reset")));
  40. int
  41. checkcpu(void)
  42. {
  43. sys_info_t sysinfo;
  44. uint pvr, svr;
  45. uint ver;
  46. uint major, minor;
  47. char buf1[32], buf2[32];
  48. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  49. volatile ccsr_gur_t *gur = &immap->im_gur;
  50. struct cpu_type *cpu;
  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. cpu = identify_cpu(ver);
  58. if (cpu) {
  59. puts(cpu->name);
  60. } else {
  61. puts("Unknown");
  62. }
  63. printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
  64. puts("Core: ");
  65. pvr = get_pvr();
  66. ver = PVR_E600_VER(pvr);
  67. major = PVR_E600_MAJ(pvr);
  68. minor = PVR_E600_MIN(pvr);
  69. printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 );
  70. if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE)
  71. puts("\n Core1Translation Enabled");
  72. debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr);
  73. printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
  74. get_sys_info(&sysinfo);
  75. puts("Clock Configuration:\n");
  76. printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor));
  77. printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus));
  78. printf(" DDR:%-4s MHz (%s MT/s data rate), ",
  79. strmhz(buf1, sysinfo.freqSystemBus / 2),
  80. strmhz(buf2, sysinfo.freqSystemBus));
  81. if (sysinfo.freqLocalBus > LCRR_CLKDIV) {
  82. printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus));
  83. } else {
  84. printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n",
  85. sysinfo.freqLocalBus);
  86. }
  87. puts("L1: D-cache 32 KB enabled\n");
  88. puts(" I-cache 32 KB enabled\n");
  89. puts("L2: ");
  90. if (get_l2cr() & 0x80000000) {
  91. #if defined(CONFIG_MPC8610)
  92. puts("256");
  93. #elif defined(CONFIG_MPC8641)
  94. puts("512");
  95. #endif
  96. puts(" KB enabled\n");
  97. } else {
  98. puts("Disabled\n");
  99. }
  100. return 0;
  101. }
  102. void
  103. do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  104. {
  105. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  106. volatile ccsr_gur_t *gur = &immap->im_gur;
  107. /* Attempt board-specific reset */
  108. board_reset();
  109. /* Next try asserting HRESET_REQ */
  110. out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ);
  111. while (1)
  112. ;
  113. }
  114. /*
  115. * Get timebase clock frequency
  116. */
  117. unsigned long
  118. get_tbclk(void)
  119. {
  120. sys_info_t sys_info;
  121. get_sys_info(&sys_info);
  122. return (sys_info.freqSystemBus + 3L) / 4L;
  123. }
  124. #if defined(CONFIG_WATCHDOG)
  125. void
  126. watchdog_reset(void)
  127. {
  128. #if defined(CONFIG_MPC8610)
  129. /*
  130. * This actually feed the hard enabled watchdog.
  131. */
  132. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  133. volatile ccsr_wdt_t *wdt = &immap->im_wdt;
  134. volatile ccsr_gur_t *gur = &immap->im_gur;
  135. u32 tmp = gur->pordevsr;
  136. if (tmp & 0x4000) {
  137. wdt->swsrr = 0x556c;
  138. wdt->swsrr = 0xaa39;
  139. }
  140. #endif
  141. }
  142. #endif /* CONFIG_WATCHDOG */
  143. /*
  144. * Print out the state of various machine registers.
  145. * Currently prints out LAWs, BR0/OR0, and BATs
  146. */
  147. void mpc86xx_reginfo(void)
  148. {
  149. immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  150. ccsr_lbc_t *lbc = &immap->im_lbc;
  151. print_bats();
  152. print_laws();
  153. printf ("Local Bus Controller Registers\n"
  154. "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0));
  155. printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1));
  156. printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2));
  157. printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3));
  158. printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4));
  159. printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5));
  160. printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6));
  161. printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7));
  162. }