cpu.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * Copyright 2004,2007 Freescale Semiconductor, Inc.
  3. * (C) Copyright 2002, 2003 Motorola Inc.
  4. * Xianghua Xiao (X.Xiao@motorola.com)
  5. *
  6. * (C) Copyright 2000
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <common.h>
  28. #include <watchdog.h>
  29. #include <command.h>
  30. #include <asm/cache.h>
  31. int checkcpu (void)
  32. {
  33. sys_info_t sysinfo;
  34. uint lcrr; /* local bus clock ratio register */
  35. uint clkdiv; /* clock divider portion of lcrr */
  36. uint pvr, svr;
  37. uint fam;
  38. uint ver;
  39. uint major, minor;
  40. svr = get_svr();
  41. ver = SVR_VER(svr);
  42. major = SVR_MAJ(svr);
  43. minor = SVR_MIN(svr);
  44. puts("CPU: ");
  45. switch (ver) {
  46. case SVR_8540:
  47. puts("8540");
  48. break;
  49. case SVR_8541:
  50. puts("8541");
  51. break;
  52. case SVR_8555:
  53. puts("8555");
  54. break;
  55. case SVR_8560:
  56. puts("8560");
  57. break;
  58. case SVR_8548:
  59. puts("8548");
  60. break;
  61. case SVR_8548_E:
  62. puts("8548_E");
  63. break;
  64. case SVR_8544:
  65. puts("8544");
  66. break;
  67. case SVR_8544_E:
  68. puts("8544_E");
  69. break;
  70. case SVR_8568_E:
  71. puts("8568_E");
  72. break;
  73. default:
  74. puts("Unknown");
  75. break;
  76. }
  77. printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
  78. pvr = get_pvr();
  79. fam = PVR_FAM(pvr);
  80. ver = PVR_VER(pvr);
  81. major = PVR_MAJ(pvr);
  82. minor = PVR_MIN(pvr);
  83. printf("Core: ");
  84. switch (fam) {
  85. case PVR_FAM(PVR_85xx):
  86. puts("E500");
  87. break;
  88. default:
  89. puts("Unknown");
  90. break;
  91. }
  92. printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
  93. get_sys_info(&sysinfo);
  94. puts("Clock Configuration:\n");
  95. printf(" CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
  96. printf("CCB:%4lu MHz,\n", sysinfo.freqSystemBus / 1000000);
  97. printf(" DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
  98. #if defined(CFG_LBC_LCRR)
  99. lcrr = CFG_LBC_LCRR;
  100. #else
  101. {
  102. volatile ccsr_lbc_t *lbc = (void *)(CFG_MPC85xx_LBC_ADDR);
  103. lcrr = lbc->lcrr;
  104. }
  105. #endif
  106. clkdiv = lcrr & 0x0f;
  107. if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
  108. #if defined(CONFIG_MPC8548) || defined(CONFIG_MPC8544)
  109. /*
  110. * Yes, the entire PQ38 family use the same
  111. * bit-representation for twice the clock divider values.
  112. */
  113. clkdiv *= 2;
  114. #endif
  115. printf("LBC:%4lu MHz\n",
  116. sysinfo.freqSystemBus / 1000000 / clkdiv);
  117. } else {
  118. printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr);
  119. }
  120. if (ver == SVR_8560) {
  121. printf("CPM: %lu Mhz\n",
  122. sysinfo.freqSystemBus / 1000000);
  123. }
  124. puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
  125. return 0;
  126. }
  127. /* ------------------------------------------------------------------------- */
  128. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
  129. {
  130. uint pvr;
  131. uint ver;
  132. pvr = get_pvr();
  133. ver = PVR_VER(pvr);
  134. if (ver & 1){
  135. /* e500 v2 core has reset control register */
  136. volatile unsigned int * rstcr;
  137. rstcr = (volatile unsigned int *)(CFG_IMMR + 0xE00B0);
  138. *rstcr = 0x2; /* HRESET_REQ */
  139. }else{
  140. /*
  141. * Initiate hard reset in debug control register DBCR0
  142. * Make sure MSR[DE] = 1
  143. */
  144. unsigned long val, msr;
  145. msr = mfmsr ();
  146. msr |= MSR_DE;
  147. mtmsr (msr);
  148. val = mfspr(DBCR0);
  149. val |= 0x70000000;
  150. mtspr(DBCR0,val);
  151. }
  152. return 1;
  153. }
  154. /*
  155. * Get timebase clock frequency
  156. */
  157. unsigned long get_tbclk (void)
  158. {
  159. sys_info_t sys_info;
  160. get_sys_info(&sys_info);
  161. return ((sys_info.freqSystemBus + 7L) / 8L);
  162. }
  163. #if defined(CONFIG_WATCHDOG)
  164. void
  165. watchdog_reset(void)
  166. {
  167. int re_enable = disable_interrupts();
  168. reset_85xx_watchdog();
  169. if (re_enable) enable_interrupts();
  170. }
  171. void
  172. reset_85xx_watchdog(void)
  173. {
  174. /*
  175. * Clear TSR(WIS) bit by writing 1
  176. */
  177. unsigned long val;
  178. val = mfspr(SPRN_TSR);
  179. val |= TSR_WIS;
  180. mtspr(SPRN_TSR, val);
  181. }
  182. #endif /* CONFIG_WATCHDOG */
  183. #if defined(CONFIG_DDR_ECC)
  184. void dma_init(void) {
  185. volatile ccsr_dma_t *dma = (void *)(CFG_MPC85xx_DMA_ADDR);
  186. dma->satr0 = 0x02c40000;
  187. dma->datr0 = 0x02c40000;
  188. dma->sr0 = 0xfffffff; /* clear any errors */
  189. asm("sync; isync; msync");
  190. return;
  191. }
  192. uint dma_check(void) {
  193. volatile ccsr_dma_t *dma = (void *)(CFG_MPC85xx_DMA_ADDR);
  194. volatile uint status = dma->sr0;
  195. /* While the channel is busy, spin */
  196. while((status & 4) == 4) {
  197. status = dma->sr0;
  198. }
  199. /* clear MR0[CS] channel start bit */
  200. dma->mr0 &= 0x00000001;
  201. asm("sync;isync;msync");
  202. if (status != 0) {
  203. printf ("DMA Error: status = %x\n", status);
  204. }
  205. return status;
  206. }
  207. int dma_xfer(void *dest, uint count, void *src) {
  208. volatile ccsr_dma_t *dma = (void *)(CFG_MPC85xx_DMA_ADDR);
  209. dma->dar0 = (uint) dest;
  210. dma->sar0 = (uint) src;
  211. dma->bcr0 = count;
  212. dma->mr0 = 0xf000004;
  213. asm("sync;isync;msync");
  214. dma->mr0 = 0xf000005;
  215. asm("sync;isync;msync");
  216. return dma_check();
  217. }
  218. #endif