cpu.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /*
  2. * (C) Copyright 2000-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /*
  24. * CPU specific code
  25. *
  26. * written or collected and sometimes rewritten by
  27. * Magnus Damm <damm@bitsmart.com>
  28. *
  29. * minor modifications by
  30. * Wolfgang Denk <wd@denx.de>
  31. */
  32. #include <common.h>
  33. #include <watchdog.h>
  34. #include <command.h>
  35. #include <asm/cache.h>
  36. #include <ppc4xx.h>
  37. #if defined(CONFIG_440)
  38. static int do_chip_reset( unsigned long sys0, unsigned long sys1 );
  39. #endif
  40. /* ------------------------------------------------------------------------- */
  41. int checkcpu (void)
  42. {
  43. #if defined(CONFIG_405GP) || \
  44. defined(CONFIG_405CR) || \
  45. defined(CONFIG_405EP) || \
  46. defined(CONFIG_440) || \
  47. defined(CONFIG_IOP480)
  48. uint pvr = get_pvr();
  49. #endif
  50. #if defined(CONFIG_405GP) || \
  51. defined(CONFIG_405CR) || \
  52. defined(CONFIG_405EP) || \
  53. defined(CONFIG_IOP480)
  54. DECLARE_GLOBAL_DATA_PTR;
  55. ulong clock = gd->cpu_clk;
  56. char buf[32];
  57. #endif
  58. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP)
  59. PPC405_SYS_INFO sys_info;
  60. puts ("CPU: ");
  61. get_sys_info(&sys_info);
  62. #ifdef CONFIG_405GP
  63. puts ("AMCC PowerPC 405GP");
  64. if (pvr == PVR_405GPR_RB) {
  65. putc('r');
  66. }
  67. puts (" Rev. ");
  68. #endif
  69. #ifdef CONFIG_405CR
  70. puts ("AMCC PowerPC 405CR Rev. ");
  71. #endif
  72. #ifdef CONFIG_405EP
  73. puts ("AMCC PowerPC 405EP Rev. ");
  74. #endif
  75. switch (pvr) {
  76. case PVR_405GP_RB:
  77. case PVR_405GPR_RB:
  78. putc('B');
  79. break;
  80. case PVR_405GP_RC:
  81. #ifdef CONFIG_405CR
  82. case PVR_405CR_RC:
  83. #endif
  84. putc('C');
  85. break;
  86. case PVR_405GP_RD:
  87. putc('D');
  88. break;
  89. #ifdef CONFIG_405GP
  90. case PVR_405GP_RE:
  91. putc('E');
  92. break;
  93. #endif
  94. case PVR_405CR_RA:
  95. putc('A');
  96. break;
  97. case PVR_405CR_RB:
  98. case PVR_405EP_RB:
  99. putc('B');
  100. break;
  101. default:
  102. printf ("? (PVR=%08x)", pvr);
  103. break;
  104. }
  105. printf (" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
  106. sys_info.freqPLB / 1000000,
  107. sys_info.freqPLB / sys_info.pllOpbDiv / 1000000,
  108. sys_info.freqPLB / sys_info.pllExtBusDiv / 1000000);
  109. #if defined(CONFIG_405GP)
  110. if (mfdcr(strap) & PSR_PCI_ASYNC_EN) {
  111. printf (" PCI async ext clock used, ");
  112. } else {
  113. printf (" PCI sync clock at %lu MHz, ",
  114. sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
  115. }
  116. printf ("%sternal PCI arbiter enabled\n",
  117. (mfdcr(strap) & PSR_PCI_ARBIT_EN) ? "in" : "ex");
  118. #elif defined(CONFIG_405EP)
  119. printf (" IIC Boot EEPROM %sabled\n",
  120. (mfdcr(cpc0_boot) & CPC0_BOOT_SEP) ? "en" : "dis");
  121. printf (" PCI async ext clock used, ");
  122. printf ("%sternal PCI arbiter enabled\n",
  123. (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN) ? "in" : "ex");
  124. #endif
  125. #if defined(CONFIG_405EP)
  126. printf (" 16 kB I-Cache 16 kB D-Cache");
  127. #else
  128. printf (" 16 kB I-Cache %d kB D-Cache",
  129. ((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
  130. #endif
  131. #endif /* defined(CONFIG_405GP) || defined(CONFIG_405CR) */
  132. #ifdef CONFIG_IOP480
  133. printf ("PLX IOP480 (PVR=%08x)", pvr);
  134. printf (" at %s MHz:", strmhz(buf, clock));
  135. printf (" %u kB I-Cache", 4);
  136. printf (" %u kB D-Cache", 2);
  137. #endif
  138. #if defined(CONFIG_440)
  139. puts ("AMCC PowerPC 440");
  140. switch(pvr) {
  141. case PVR_440GP_RB:
  142. puts("GP Rev. B");
  143. /* See errata 1.12: CHIP_4 */
  144. if ((mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0)) ||
  145. (mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1)) ){
  146. puts ( "\n\t CPC0_SYSx DCRs corrupted. "
  147. "Resetting chip ...\n");
  148. udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
  149. do_chip_reset ( mfdcr(cpc0_strp0),
  150. mfdcr(cpc0_strp1) );
  151. }
  152. break;
  153. case PVR_440GP_RC:
  154. puts("GP Rev. C");
  155. break;
  156. case PVR_440GX_RA:
  157. puts("GX Rev. A");
  158. break;
  159. case PVR_440GX_RB:
  160. puts("GX Rev. B");
  161. break;
  162. case PVR_440GX_RC:
  163. puts("GX Rev. C");
  164. break;
  165. case PVR_440EP_RA:
  166. puts("EP Rev. A");
  167. break;
  168. #ifdef CONFIG_440EP
  169. case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */
  170. puts("EP Rev. B");
  171. break;
  172. #endif /* CONFIG_440EP */
  173. #ifdef CONFIG_440GR
  174. case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */
  175. puts("GR Rev. A");
  176. break;
  177. #endif /* CONFIG_440GR */
  178. default:
  179. printf (" UNKNOWN (PVR=%08x)", pvr);
  180. break;
  181. }
  182. #endif
  183. puts ("\n");
  184. return 0;
  185. }
  186. /* ------------------------------------------------------------------------- */
  187. int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  188. {
  189. #if defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)
  190. /*give reset to BCSR*/
  191. *(unsigned char*)(CFG_BCSR_BASE | 0x06) = 0x09;
  192. #else
  193. /*
  194. * Initiate system reset in debug control register DBCR
  195. */
  196. __asm__ __volatile__("lis 3, 0x3000" ::: "r3");
  197. #if defined(CONFIG_440)
  198. __asm__ __volatile__("mtspr 0x134, 3");
  199. #else
  200. __asm__ __volatile__("mtspr 0x3f2, 3");
  201. #endif
  202. #endif/* defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)*/
  203. return 1;
  204. }
  205. #if defined(CONFIG_440)
  206. static
  207. int do_chip_reset (unsigned long sys0, unsigned long sys1)
  208. {
  209. /* Changes to cpc0_sys0 and cpc0_sys1 require chip
  210. * reset.
  211. */
  212. mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000); /* Set SWE */
  213. mtdcr (cpc0_sys0, sys0);
  214. mtdcr (cpc0_sys1, sys1);
  215. mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000); /* Clr SWE */
  216. mtspr (dbcr0, 0x20000000); /* Reset the chip */
  217. return 1;
  218. }
  219. #endif
  220. /*
  221. * Get timebase clock frequency
  222. */
  223. unsigned long get_tbclk (void)
  224. {
  225. #if defined(CONFIG_440)
  226. sys_info_t sys_info;
  227. get_sys_info(&sys_info);
  228. return (sys_info.freqProcessor);
  229. #elif defined(CONFIG_405GP) || \
  230. defined(CONFIG_405CR) || \
  231. defined(CONFIG_405) || \
  232. defined(CONFIG_405EP)
  233. PPC405_SYS_INFO sys_info;
  234. get_sys_info(&sys_info);
  235. return (sys_info.freqProcessor);
  236. #elif defined(CONFIG_IOP480)
  237. return (66000000);
  238. #else
  239. # error get_tbclk() not implemented
  240. #endif
  241. }
  242. #if defined(CONFIG_WATCHDOG)
  243. void
  244. watchdog_reset(void)
  245. {
  246. int re_enable = disable_interrupts();
  247. reset_4xx_watchdog();
  248. if (re_enable) enable_interrupts();
  249. }
  250. void
  251. reset_4xx_watchdog(void)
  252. {
  253. /*
  254. * Clear TSR(WIS) bit
  255. */
  256. mtspr(tsr, 0x40000000);
  257. }
  258. #endif /* CONFIG_WATCHDOG */