cpu.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * Copyright 2004 Freescale Semiconductor.
  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. /* ------------------------------------------------------------------------- */
  32. int checkcpu (void)
  33. {
  34. sys_info_t sysinfo;
  35. uint lcrr; /* local bus clock ratio register */
  36. uint clkdiv; /* clock divider portion of lcrr */
  37. uint pvr, svr;
  38. uint fam;
  39. uint ver;
  40. uint major, minor;
  41. svr = get_svr();
  42. ver = SVR_VER(svr);
  43. major = SVR_MAJ(svr);
  44. minor = SVR_MIN(svr);
  45. puts("CPU: ");
  46. switch (ver) {
  47. case SVR_8540:
  48. puts("8540");
  49. break;
  50. case SVR_8541:
  51. puts("8541");
  52. break;
  53. case SVR_8555:
  54. puts("8555");
  55. break;
  56. case SVR_8560:
  57. puts("8560");
  58. break;
  59. case SVR_8548:
  60. puts("8548");
  61. break;
  62. case SVR_8548_E:
  63. puts("8548_E");
  64. break;
  65. default:
  66. puts("Unknown");
  67. break;
  68. }
  69. printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
  70. pvr = get_pvr();
  71. fam = PVR_FAM(pvr);
  72. ver = PVR_VER(pvr);
  73. major = PVR_MAJ(pvr);
  74. minor = PVR_MIN(pvr);
  75. printf("Core: ");
  76. switch (fam) {
  77. case PVR_FAM(PVR_85xx):
  78. puts("E500");
  79. break;
  80. default:
  81. puts("Unknown");
  82. break;
  83. }
  84. printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
  85. get_sys_info(&sysinfo);
  86. puts("Clock Configuration:\n");
  87. printf(" CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
  88. printf("CCB:%4lu MHz,\n", sysinfo.freqSystemBus / 1000000);
  89. printf(" DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
  90. #if defined(CFG_LBC_LCRR)
  91. lcrr = CFG_LBC_LCRR;
  92. #else
  93. {
  94. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  95. volatile ccsr_lbc_t *lbc= &immap->im_lbc;
  96. lcrr = lbc->lcrr;
  97. }
  98. #endif
  99. clkdiv = lcrr & 0x0f;
  100. if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
  101. #ifdef CONFIG_MPC8548
  102. /*
  103. * Yes, the entire PQ38 family use the same
  104. * bit-representation for twice the clock divider values.
  105. */
  106. clkdiv *= 2;
  107. #endif
  108. printf("LBC:%4lu MHz\n",
  109. sysinfo.freqSystemBus / 1000000 / clkdiv);
  110. } else {
  111. printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr);
  112. }
  113. if (ver == SVR_8560) {
  114. printf("CPM: %lu Mhz\n",
  115. sysinfo.freqSystemBus / 1000000);
  116. }
  117. puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n");
  118. return 0;
  119. }
  120. /* ------------------------------------------------------------------------- */
  121. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
  122. {
  123. /*
  124. * Initiate hard reset in debug control register DBCR0
  125. * Make sure MSR[DE] = 1
  126. */
  127. unsigned long val;
  128. val = mfspr(DBCR0);
  129. val |= 0x70000000;
  130. mtspr(DBCR0,val);
  131. return 1;
  132. }
  133. /*
  134. * Get timebase clock frequency
  135. */
  136. unsigned long get_tbclk (void)
  137. {
  138. sys_info_t sys_info;
  139. get_sys_info(&sys_info);
  140. return ((sys_info.freqSystemBus + 7L) / 8L);
  141. }
  142. #if defined(CONFIG_WATCHDOG)
  143. void
  144. watchdog_reset(void)
  145. {
  146. int re_enable = disable_interrupts();
  147. reset_85xx_watchdog();
  148. if (re_enable) enable_interrupts();
  149. }
  150. void
  151. reset_85xx_watchdog(void)
  152. {
  153. /*
  154. * Clear TSR(WIS) bit by writing 1
  155. */
  156. unsigned long val;
  157. val = mfspr(tsr);
  158. val |= 0x40000000;
  159. mtspr(tsr, val);
  160. }
  161. #endif /* CONFIG_WATCHDOG */
  162. #if defined(CONFIG_DDR_ECC)
  163. void dma_init(void) {
  164. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  165. volatile ccsr_dma_t *dma = &immap->im_dma;
  166. dma->satr0 = 0x02c40000;
  167. dma->datr0 = 0x02c40000;
  168. asm("sync; isync; msync");
  169. return;
  170. }
  171. uint dma_check(void) {
  172. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  173. volatile ccsr_dma_t *dma = &immap->im_dma;
  174. volatile uint status = dma->sr0;
  175. /* While the channel is busy, spin */
  176. while((status & 4) == 4) {
  177. status = dma->sr0;
  178. }
  179. if (status != 0) {
  180. printf ("DMA Error: status = %x\n", status);
  181. }
  182. return status;
  183. }
  184. int dma_xfer(void *dest, uint count, void *src) {
  185. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  186. volatile ccsr_dma_t *dma = &immap->im_dma;
  187. dma->dar0 = (uint) dest;
  188. dma->sar0 = (uint) src;
  189. dma->bcr0 = count;
  190. dma->mr0 = 0xf000004;
  191. asm("sync;isync;msync");
  192. dma->mr0 = 0xf000005;
  193. asm("sync;isync;msync");
  194. return dma_check();
  195. }
  196. #endif