cpu.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. /*
  23. * CPU specific code for the MPC83xx family.
  24. *
  25. * Derived from the MPC8260 and MPC85xx.
  26. */
  27. #include <common.h>
  28. #include <watchdog.h>
  29. #include <command.h>
  30. #include <mpc83xx.h>
  31. #include <asm/processor.h>
  32. #include <libfdt.h>
  33. #include <tsec.h>
  34. #include <netdev.h>
  35. #include <fsl_esdhc.h>
  36. #ifdef CONFIG_BOOTCOUNT_LIMIT
  37. #include <asm/immap_qe.h>
  38. #include <asm/io.h>
  39. #endif
  40. DECLARE_GLOBAL_DATA_PTR;
  41. int checkcpu(void)
  42. {
  43. volatile immap_t *immr;
  44. ulong clock = gd->cpu_clk;
  45. u32 pvr = get_pvr();
  46. u32 spridr;
  47. char buf[32];
  48. int i;
  49. const struct cpu_type {
  50. char name[15];
  51. u32 partid;
  52. } cpu_type_list [] = {
  53. CPU_TYPE_ENTRY(8308),
  54. CPU_TYPE_ENTRY(8311),
  55. CPU_TYPE_ENTRY(8313),
  56. CPU_TYPE_ENTRY(8314),
  57. CPU_TYPE_ENTRY(8315),
  58. CPU_TYPE_ENTRY(8321),
  59. CPU_TYPE_ENTRY(8323),
  60. CPU_TYPE_ENTRY(8343),
  61. CPU_TYPE_ENTRY(8347_TBGA_),
  62. CPU_TYPE_ENTRY(8347_PBGA_),
  63. CPU_TYPE_ENTRY(8349),
  64. CPU_TYPE_ENTRY(8358_TBGA_),
  65. CPU_TYPE_ENTRY(8358_PBGA_),
  66. CPU_TYPE_ENTRY(8360),
  67. CPU_TYPE_ENTRY(8377),
  68. CPU_TYPE_ENTRY(8378),
  69. CPU_TYPE_ENTRY(8379),
  70. };
  71. immr = (immap_t *)CONFIG_SYS_IMMR;
  72. puts("CPU: ");
  73. switch (pvr & 0xffff0000) {
  74. case PVR_E300C1:
  75. printf("e300c1, ");
  76. break;
  77. case PVR_E300C2:
  78. printf("e300c2, ");
  79. break;
  80. case PVR_E300C3:
  81. printf("e300c3, ");
  82. break;
  83. case PVR_E300C4:
  84. printf("e300c4, ");
  85. break;
  86. default:
  87. printf("Unknown core, ");
  88. }
  89. spridr = immr->sysconf.spridr;
  90. for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++)
  91. if (cpu_type_list[i].partid == PARTID_NO_E(spridr)) {
  92. puts("MPC");
  93. puts(cpu_type_list[i].name);
  94. if (IS_E_PROCESSOR(spridr))
  95. puts("E");
  96. if ((SPR_FAMILY(spridr) == SPR_834X_FAMILY ||
  97. SPR_FAMILY(spridr) == SPR_836X_FAMILY) &&
  98. REVID_MAJOR(spridr) >= 2)
  99. puts("A");
  100. printf(", Rev: %d.%d", REVID_MAJOR(spridr),
  101. REVID_MINOR(spridr));
  102. break;
  103. }
  104. if (i == ARRAY_SIZE(cpu_type_list))
  105. printf("(SPRIDR %08x unknown), ", spridr);
  106. printf(" at %s MHz, ", strmhz(buf, clock));
  107. printf("CSB: %s MHz\n", strmhz(buf, gd->csb_clk));
  108. return 0;
  109. }
  110. int
  111. do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  112. {
  113. ulong msr;
  114. #ifndef MPC83xx_RESET
  115. ulong addr;
  116. #endif
  117. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  118. puts("Resetting the board.\n");
  119. #ifdef MPC83xx_RESET
  120. /* Interrupts and MMU off */
  121. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  122. msr &= ~( MSR_EE | MSR_IR | MSR_DR);
  123. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  124. /* enable Reset Control Reg */
  125. immap->reset.rpr = 0x52535445;
  126. __asm__ __volatile__ ("sync");
  127. __asm__ __volatile__ ("isync");
  128. /* confirm Reset Control Reg is enabled */
  129. while(!((immap->reset.rcer) & RCER_CRE));
  130. udelay(200);
  131. /* perform reset, only one bit */
  132. immap->reset.rcr = RCR_SWHR;
  133. #else /* ! MPC83xx_RESET */
  134. immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */
  135. /* Interrupts and MMU off */
  136. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  137. msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
  138. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  139. /*
  140. * Trying to execute the next instruction at a non-existing address
  141. * should cause a machine check, resulting in reset
  142. */
  143. addr = CONFIG_SYS_RESET_ADDRESS;
  144. ((void (*)(void)) addr) ();
  145. #endif /* MPC83xx_RESET */
  146. return 1;
  147. }
  148. /*
  149. * Get timebase clock frequency (like cpu_clk in Hz)
  150. */
  151. unsigned long get_tbclk(void)
  152. {
  153. ulong tbclk;
  154. tbclk = (gd->bus_clk + 3L) / 4L;
  155. return tbclk;
  156. }
  157. #if defined(CONFIG_WATCHDOG)
  158. void watchdog_reset (void)
  159. {
  160. int re_enable = disable_interrupts();
  161. /* Reset the 83xx watchdog */
  162. volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
  163. immr->wdt.swsrr = 0x556c;
  164. immr->wdt.swsrr = 0xaa39;
  165. if (re_enable)
  166. enable_interrupts ();
  167. }
  168. #endif
  169. /*
  170. * Initializes on-chip ethernet controllers.
  171. * to override, implement board_eth_init()
  172. */
  173. int cpu_eth_init(bd_t *bis)
  174. {
  175. #if defined(CONFIG_UEC_ETH)
  176. uec_standard_init(bis);
  177. #endif
  178. #if defined(CONFIG_TSEC_ENET)
  179. tsec_standard_init(bis);
  180. #endif
  181. return 0;
  182. }
  183. /*
  184. * Initializes on-chip MMC controllers.
  185. * to override, implement board_mmc_init()
  186. */
  187. int cpu_mmc_init(bd_t *bis)
  188. {
  189. #ifdef CONFIG_FSL_ESDHC
  190. return fsl_esdhc_mmc_init(bis);
  191. #else
  192. return 0;
  193. #endif
  194. }