cpu.c 4.6 KB

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