cpu.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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_405GP)
  38. #define PCI_ARBITER_ENABLED (mfdcr(strap) & PSR_PCI_ARBIT_EN)
  39. #define PCI_ASYNC_ENABLED (mfdcr(strap) & PSR_PCI_ASYNC_EN)
  40. #endif
  41. #if defined(CONFIG_405EP)
  42. #define PCI_ARBITER_ENABLED (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN)
  43. #define I2C_BOOTROM_ENABLED (mfdcr(cpc0_boot) & CPC0_BOOT_SEP)
  44. #endif
  45. #if defined(CONFIG_440EP) || defined(CONFIG_440GR)
  46. #define SDR0_SDSTP1_PAE (0x80000000 >> 21)
  47. #define SDR0_SDSTP1_PAME (0x80000000 >> 27)
  48. #define PCI_ARBITER_ENABLED (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAE)
  49. #define PCI_ASYNC_ENABLED (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAME)
  50. #endif
  51. #if defined(CONFIG_440GP)
  52. #define CPC0_STRP1_PAE (0x80000000 >> 11)
  53. #define PCI_ARBITER_ENABLED (mfdcr(cpc0_strp1) & CPC0_STRP1_PAE)
  54. #endif
  55. #if defined(CONFIG_440GX)
  56. #define SDR0_SDSTP1_PAE (0x80000000 >> 13)
  57. #define PCI_ARBITER_ENABLED (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAE)
  58. #endif
  59. #if defined(CONFIG_440)
  60. #define FREQ_EBC (sys_info.freqEPB)
  61. #else
  62. #define FREQ_EBC (sys_info.freqPLB / sys_info.pllExtBusDiv)
  63. #endif
  64. #if defined(CONFIG_440)
  65. static int do_chip_reset(unsigned long sys0, unsigned long sys1);
  66. #endif
  67. int checkcpu (void)
  68. {
  69. #if !defined(CONFIG_405) /* not used on Xilinx 405 FPGA implementations */
  70. DECLARE_GLOBAL_DATA_PTR;
  71. uint pvr = get_pvr();
  72. ulong clock = gd->cpu_clk;
  73. char buf[32];
  74. #if !defined(CONFIG_IOP480)
  75. sys_info_t sys_info;
  76. puts ("CPU: ");
  77. get_sys_info(&sys_info);
  78. puts("AMCC PowerPC 4");
  79. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP)
  80. puts("05");
  81. #endif
  82. #if defined(CONFIG_440)
  83. puts("40");
  84. #endif
  85. switch (pvr) {
  86. case PVR_405GP_RB:
  87. puts("GP Rev. B");
  88. break;
  89. case PVR_405GP_RC:
  90. puts("GP Rev. C");
  91. break;
  92. case PVR_405GP_RD:
  93. puts("GP Rev. D");
  94. break;
  95. #ifdef CONFIG_405GP
  96. case PVR_405GP_RE: /* 405GP rev E and 405CR rev C have same PVR */
  97. puts("GP Rev. E");
  98. break;
  99. #endif
  100. case PVR_405CR_RA:
  101. puts("CR Rev. A");
  102. break;
  103. case PVR_405CR_RB:
  104. puts("CR Rev. B");
  105. break;
  106. #ifdef CONFIG_405CR
  107. case PVR_405CR_RC: /* 405GP rev E and 405CR rev C have same PVR */
  108. puts("CR Rev. C");
  109. break;
  110. #endif
  111. case PVR_405GPR_RB:
  112. puts("GPr Rev. B");
  113. break;
  114. case PVR_405EP_RB:
  115. puts("EP Rev. B");
  116. break;
  117. #if defined(CONFIG_440)
  118. case PVR_440GP_RB:
  119. puts("GP Rev. B");
  120. /* See errata 1.12: CHIP_4 */
  121. if ((mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0)) ||
  122. (mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1)) ){
  123. puts ( "\n\t CPC0_SYSx DCRs corrupted. "
  124. "Resetting chip ...\n");
  125. udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
  126. do_chip_reset ( mfdcr(cpc0_strp0),
  127. mfdcr(cpc0_strp1) );
  128. }
  129. break;
  130. case PVR_440GP_RC:
  131. puts("GP Rev. C");
  132. break;
  133. case PVR_440GX_RA:
  134. puts("GX Rev. A");
  135. break;
  136. case PVR_440GX_RB:
  137. puts("GX Rev. B");
  138. break;
  139. case PVR_440GX_RC:
  140. puts("GX Rev. C");
  141. break;
  142. case PVR_440GX_RF:
  143. puts("GX Rev. F");
  144. break;
  145. case PVR_440EP_RA:
  146. puts("EP Rev. A");
  147. break;
  148. #ifdef CONFIG_440EP
  149. case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */
  150. puts("EP Rev. B");
  151. break;
  152. #endif /* CONFIG_440EP */
  153. #ifdef CONFIG_440GR
  154. case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */
  155. puts("GR Rev. A");
  156. break;
  157. #endif /* CONFIG_440GR */
  158. #endif /* CONFIG_440 */
  159. default:
  160. printf (" UNKNOWN (PVR=%08x)", pvr);
  161. break;
  162. }
  163. printf (" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
  164. sys_info.freqPLB / 1000000,
  165. sys_info.freqPLB / sys_info.pllOpbDiv / 1000000,
  166. FREQ_EBC / 1000000);
  167. #if defined(I2C_BOOTROM_ENABLED)
  168. printf (" IIC Boot EEPROM %sabled\n", I2C_BOOTROM_ENABLED ? "en" : "dis");
  169. #endif
  170. #if defined(PCI_ARBITER_ENABLED)
  171. printf (" %sternal PCI arbiter enabled",
  172. (PCI_ARBITER_ENABLED) ? "In" : "Ex");
  173. #endif
  174. #if defined(PCI_ASYNC_ENABLED)
  175. if (PCI_ASYNC_ENABLED) {
  176. printf (", PCI async ext clock used");
  177. } else {
  178. printf (", PCI sync clock at %lu MHz",
  179. sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
  180. }
  181. #endif
  182. #if defined(PCI_ARBITER_ENABLED) || defined(PCI_ASYNC_ENABLED)
  183. putc('\n');
  184. #endif
  185. #if defined(CONFIG_405EP)
  186. printf (" 16 kB I-Cache 16 kB D-Cache");
  187. #elif defined(CONFIG_440)
  188. printf (" 32 kB I-Cache 32 kB D-Cache");
  189. #else
  190. printf (" 16 kB I-Cache %d kB D-Cache",
  191. ((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
  192. #endif
  193. #endif /* !defined(CONFIG_IOP480) */
  194. #if defined(CONFIG_IOP480)
  195. printf ("PLX IOP480 (PVR=%08x)", pvr);
  196. printf (" at %s MHz:", strmhz(buf, clock));
  197. printf (" %u kB I-Cache", 4);
  198. printf (" %u kB D-Cache", 2);
  199. #endif
  200. #endif /* !defined(CONFIG_405) */
  201. putc ('\n');
  202. return 0;
  203. }
  204. /* ------------------------------------------------------------------------- */
  205. int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  206. {
  207. #if defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)
  208. /*give reset to BCSR*/
  209. *(unsigned char*)(CFG_BCSR_BASE | 0x06) = 0x09;
  210. #else
  211. /*
  212. * Initiate system reset in debug control register DBCR
  213. */
  214. __asm__ __volatile__("lis 3, 0x3000" ::: "r3");
  215. #if defined(CONFIG_440)
  216. __asm__ __volatile__("mtspr 0x134, 3");
  217. #else
  218. __asm__ __volatile__("mtspr 0x3f2, 3");
  219. #endif
  220. #endif/* defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)*/
  221. return 1;
  222. }
  223. #if defined(CONFIG_440)
  224. static int do_chip_reset (unsigned long sys0, unsigned long sys1)
  225. {
  226. /* Changes to cpc0_sys0 and cpc0_sys1 require chip
  227. * reset.
  228. */
  229. mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000); /* Set SWE */
  230. mtdcr (cpc0_sys0, sys0);
  231. mtdcr (cpc0_sys1, sys1);
  232. mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000); /* Clr SWE */
  233. mtspr (dbcr0, 0x20000000); /* Reset the chip */
  234. return 1;
  235. }
  236. #endif
  237. /*
  238. * Get timebase clock frequency
  239. */
  240. unsigned long get_tbclk (void)
  241. {
  242. #if !defined(CONFIG_IOP480)
  243. sys_info_t sys_info;
  244. get_sys_info(&sys_info);
  245. return (sys_info.freqProcessor);
  246. #else
  247. return (66000000);
  248. #endif
  249. }
  250. #if defined(CONFIG_WATCHDOG)
  251. void
  252. watchdog_reset(void)
  253. {
  254. int re_enable = disable_interrupts();
  255. reset_4xx_watchdog();
  256. if (re_enable) enable_interrupts();
  257. }
  258. void
  259. reset_4xx_watchdog(void)
  260. {
  261. /*
  262. * Clear TSR(WIS) bit
  263. */
  264. mtspr(tsr, 0x40000000);
  265. }
  266. #endif /* CONFIG_WATCHDOG */