cpu.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /*
  2. * (C) Copyright 2000
  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. * m8xx.c
  25. *
  26. * CPU specific code
  27. *
  28. * written or collected and sometimes rewritten by
  29. * Magnus Damm <damm@bitsmart.com>
  30. *
  31. * minor modifications by
  32. * Wolfgang Denk <wd@denx.de>
  33. */
  34. #include <common.h>
  35. #include <watchdog.h>
  36. #include <command.h>
  37. #include <asm/cache.h>
  38. #include <ppc4xx.h>
  39. #if defined(CONFIG_440)
  40. static int do_chip_reset( unsigned long sys0, unsigned long sys1 );
  41. #endif
  42. /* ------------------------------------------------------------------------- */
  43. int checkcpu (void)
  44. {
  45. #if defined(CONFIG_405GP) || \
  46. defined(CONFIG_405CR) || \
  47. defined(CONFIG_IOP480) || \
  48. defined(CONFIG_440) || \
  49. defined(CONFIG_405EP)
  50. uint pvr = get_pvr();
  51. #endif
  52. #if defined(CONFIG_405GP) || \
  53. defined(CONFIG_405CR) || \
  54. defined(CONFIG_IOP480) || \
  55. defined(CONFIG_405EP)
  56. DECLARE_GLOBAL_DATA_PTR;
  57. ulong clock = gd->cpu_clk;
  58. char buf[32];
  59. #endif
  60. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP)
  61. PPC405_SYS_INFO sys_info;
  62. puts ("CPU: ");
  63. get_sys_info(&sys_info);
  64. #if CONFIG_405GP
  65. puts("IBM PowerPC 405GP");
  66. if (pvr == PVR_405GPR_RB) {
  67. putc('r');
  68. }
  69. puts(" Rev. ");
  70. #endif
  71. #if CONFIG_405CR
  72. puts("IBM PowerPC 405CR Rev. ");
  73. #endif
  74. #if CONFIG_405EP
  75. puts("IBM PowerPC 405EP Rev. ");
  76. #endif
  77. switch (pvr) {
  78. case PVR_405GP_RB:
  79. case PVR_405GPR_RB:
  80. putc('B');
  81. break;
  82. case PVR_405GP_RC:
  83. #if CONFIG_405CR
  84. case PVR_405CR_RC:
  85. #endif
  86. putc('C');
  87. break;
  88. case PVR_405GP_RD:
  89. putc('D');
  90. break;
  91. #if CONFIG_405GP
  92. case PVR_405GP_RE:
  93. putc('E');
  94. break;
  95. #endif
  96. case PVR_405CR_RA:
  97. putc('A');
  98. break;
  99. case PVR_405CR_RB:
  100. case PVR_405EP_RB:
  101. putc('B');
  102. break;
  103. default:
  104. printf("? (PVR=%08x)", pvr);
  105. break;
  106. }
  107. printf(" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
  108. sys_info.freqPLB / 1000000,
  109. sys_info.freqPLB / sys_info.pllOpbDiv / 1000000,
  110. sys_info.freqPLB / sys_info.pllExtBusDiv / 1000000);
  111. #if defined(CONFIG_405GP)
  112. if (mfdcr(strap) & PSR_PCI_ASYNC_EN)
  113. printf(" PCI async ext clock used, ");
  114. else
  115. printf(" PCI sync clock at %lu MHz, ",
  116. sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
  117. if (mfdcr(strap) & PSR_PCI_ARBIT_EN)
  118. printf("internal PCI arbiter enabled\n");
  119. else
  120. printf("external PCI arbiter enabled\n");
  121. #elif defined(CONFIG_405EP)
  122. if (mfdcr(cpc0_boot) & CPC0_BOOT_SEP)
  123. printf(" IIC Boot EEPROM enabled\n");
  124. else
  125. printf(" IIC Boot EEPROM disabled\n");
  126. printf(" PCI async ext clock used, ");
  127. if (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN)
  128. printf("internal PCI arbiter enabled\n");
  129. else
  130. printf("external PCI arbiter enabled\n");
  131. #endif
  132. #if defined(CONFIG_405EP)
  133. printf(" 16 kB I-Cache 16 kB D-Cache");
  134. #else
  135. if ((pvr | 0x00000001) == PVR_405GPR_RB) {
  136. printf(" 16 kB I-Cache 16 kB D-Cache");
  137. } else {
  138. printf(" 16 kB I-Cache 8 kB D-Cache");
  139. }
  140. #endif
  141. #endif /* defined(CONFIG_405GP) || defined(CONFIG_405CR) */
  142. #ifdef CONFIG_IOP480
  143. printf("PLX IOP480 (PVR=%08x)", pvr);
  144. printf(" at %s MHz:", strmhz(buf, clock));
  145. printf(" %u kB I-Cache", 4);
  146. printf(" %u kB D-Cache", 2);
  147. #endif
  148. #if defined(CONFIG_440)
  149. puts("IBM PowerPC 440 Rev. ");
  150. switch(pvr)
  151. {
  152. case PVR_440GP_RB:
  153. putc('B');
  154. /* See errata 1.12: CHIP_4 */
  155. if( ( mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0) )
  156. ||( mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1) ) ){
  157. puts("\n\t CPC0_SYSx DCRs corrupted. Resetting chip ...\n");
  158. udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
  159. do_chip_reset( mfdcr(cpc0_strp0), mfdcr(cpc0_strp1) );
  160. }
  161. break;
  162. case PVR_440GP_RC:
  163. putc('C');
  164. break;
  165. default:
  166. printf("UNKNOWN (PVR=%08x)", pvr);
  167. break;
  168. }
  169. #endif
  170. printf("\n");
  171. return 0;
  172. }
  173. /* ------------------------------------------------------------------------- */
  174. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
  175. {
  176. /*
  177. * Initiate system reset in debug control register DBCR
  178. */
  179. __asm__ __volatile__("lis 3, 0x3000" ::: "r3");
  180. #if defined(CONFIG_440)
  181. __asm__ __volatile__("mtspr 0x134, 3");
  182. #else
  183. __asm__ __volatile__("mtspr 0x3f2, 3");
  184. #endif
  185. return 1;
  186. }
  187. #if defined(CONFIG_440)
  188. static
  189. int do_chip_reset( unsigned long sys0, unsigned long sys1 )
  190. {
  191. /* Changes to cpc0_sys0 and cpc0_sys1 require chip
  192. * reset.
  193. */
  194. mtdcr( cntrl0, mfdcr(cntrl0) | 0x80000000 ); /* Set SWE */
  195. mtdcr( cpc0_sys0, sys0 );
  196. mtdcr( cpc0_sys1, sys1 );
  197. mtdcr( cntrl0, mfdcr(cntrl0) & ~0x80000000 ); /* Clr SWE */
  198. mtspr( dbcr0, 0x20000000); /* Reset the chip */
  199. return 1;
  200. }
  201. #endif
  202. /*
  203. * Get timebase clock frequency
  204. */
  205. unsigned long get_tbclk (void)
  206. {
  207. #if defined(CONFIG_440)
  208. sys_info_t sys_info;
  209. get_sys_info(&sys_info);
  210. return (sys_info.freqProcessor);
  211. #elif defined(CONFIG_405GP) || \
  212. defined(CONFIG_405CR) || \
  213. defined(CONFIG_405) || \
  214. defined(CONFIG_405EP)
  215. PPC405_SYS_INFO sys_info;
  216. get_sys_info(&sys_info);
  217. return (sys_info.freqProcessor);
  218. #elif defined(CONFIG_IOP480)
  219. return (66000000);
  220. #else
  221. # error get_tbclk() not implemented
  222. #endif
  223. }
  224. #if defined(CONFIG_WATCHDOG)
  225. void
  226. watchdog_reset(void)
  227. {
  228. int re_enable = disable_interrupts();
  229. reset_4xx_watchdog();
  230. if (re_enable) enable_interrupts();
  231. }
  232. void
  233. reset_4xx_watchdog(void)
  234. {
  235. /*
  236. * Clear TSR(WIS) bit
  237. */
  238. mtspr(tsr, 0x40000000);
  239. }
  240. #endif /* CONFIG_WATCHDOG */