cpu.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. * CPU specific code for the MPC8260
  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. * modified for 8260 by
  33. * Murray Jensen <Murray.Jensen@cmst.csiro.au>
  34. *
  35. * added 8260 masks by
  36. * Marius Groeger <mag@sysgo.de>
  37. */
  38. #include <common.h>
  39. #include <watchdog.h>
  40. #include <command.h>
  41. #include <mpc8260.h>
  42. #include <asm/processor.h>
  43. #include <asm/cpm_8260.h>
  44. int checkcpu (void)
  45. {
  46. DECLARE_GLOBAL_DATA_PTR;
  47. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  48. ulong clock = gd->cpu_clk;
  49. uint pvr = get_pvr ();
  50. uint immr, rev, m, k;
  51. char buf[32];
  52. puts ("CPU: ");
  53. if (((pvr >> 16) & 0xff) != 0x81)
  54. return -1; /* whoops! not an MPC8260 */
  55. rev = pvr & 0xff;
  56. immr = immap->im_memctl.memc_immr;
  57. if ((immr & IMMR_ISB_MSK) != CFG_IMMR)
  58. return -1; /* whoops! someone moved the IMMR */
  59. printf ("MPC8260 (Rev %02x, Mask ", rev);
  60. /*
  61. * the bottom 16 bits of the immr are the Part Number and Mask Number
  62. * (4-34); the 16 bits at PROFF_REVNUM (0x8af0) in dual port ram is the
  63. * RISC Microcode Revision Number (13-10).
  64. * For the 8260, Motorola doesn't include the Microcode Revision
  65. * in the mask.
  66. */
  67. m = immr & (IMMR_PARTNUM_MSK | IMMR_MASKNUM_MSK);
  68. k = *((ushort *) & immap->im_dprambase[PROFF_REVNUM]);
  69. switch (m) {
  70. case 0x0000:
  71. printf ("0.2 2J24M");
  72. break;
  73. case 0x0010:
  74. printf ("A.0 K22A");
  75. break;
  76. case 0x0011:
  77. printf ("A.1 1K22A-XC");
  78. break;
  79. case 0x0001:
  80. printf ("B.1 1K23A");
  81. break;
  82. case 0x0021:
  83. printf ("B.2 2K23A-XC");
  84. break;
  85. case 0x0023:
  86. printf ("B.3 3K23A");
  87. break;
  88. case 0x0024:
  89. printf ("C.2 6K23A");
  90. break;
  91. case 0x0060:
  92. printf ("A.0(A) 2K25A");
  93. break;
  94. default:
  95. printf ("unknown [immr=0x%04x,k=0x%04x]", m, k);
  96. break;
  97. }
  98. printf (") at %s MHz\n", strmhz (buf, clock));
  99. return 0;
  100. }
  101. /* ------------------------------------------------------------------------- */
  102. /* configures a UPM by writing into the UPM RAM array */
  103. /* uses bank 11 and a dummy physical address (=BRx_BA_MSK) */
  104. /* NOTE: the physical address chosen must not overlap into any other area */
  105. /* mapped by the memory controller because bank 11 has the lowest priority */
  106. void upmconfig (uint upm, uint * table, uint size)
  107. {
  108. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  109. volatile memctl8260_t *memctl = &immap->im_memctl;
  110. volatile uchar *dummy = (uchar *) BRx_BA_MSK; /* set all BA bits */
  111. uint i;
  112. /* first set up bank 11 to reference the correct UPM at a dummy address */
  113. memctl->memc_or11 = ORxU_AM_MSK; /* set all AM bits */
  114. switch (upm) {
  115. case UPMA:
  116. memctl->memc_br11 =
  117. ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMA |
  118. BRx_V;
  119. memctl->memc_mamr = MxMR_OP_WARR;
  120. break;
  121. case UPMB:
  122. memctl->memc_br11 =
  123. ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMB |
  124. BRx_V;
  125. memctl->memc_mbmr = MxMR_OP_WARR;
  126. break;
  127. case UPMC:
  128. memctl->memc_br11 =
  129. ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMC |
  130. BRx_V;
  131. memctl->memc_mcmr = MxMR_OP_WARR;
  132. break;
  133. default:
  134. panic ("upmconfig passed invalid UPM number (%u)\n", upm);
  135. break;
  136. }
  137. /*
  138. * at this point, the dummy address is set up to access the selected UPM,
  139. * the MAD pointer is zero, and the MxMR OP is set for writing to RAM
  140. *
  141. * now we simply load the mdr with each word and poke the dummy address.
  142. * the MAD is incremented on each access.
  143. */
  144. for (i = 0; i < size; i++) {
  145. memctl->memc_mdr = table[i];
  146. *dummy = 0;
  147. }
  148. /* now kill bank 11 */
  149. memctl->memc_br11 = 0;
  150. }
  151. /* ------------------------------------------------------------------------- */
  152. int
  153. do_reset (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
  154. {
  155. ulong msr, addr;
  156. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  157. immap->im_clkrst.car_rmr = RMR_CSRE; /* Checkstop Reset enable */
  158. /* Interrupts and MMU off */
  159. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  160. msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
  161. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  162. /*
  163. * Trying to execute the next instruction at a non-existing address
  164. * should cause a machine check, resulting in reset
  165. */
  166. #ifdef CFG_RESET_ADDRESS
  167. addr = CFG_RESET_ADDRESS;
  168. #else
  169. /*
  170. * note: when CFG_MONITOR_BASE points to a RAM address, CFG_MONITOR_BASE
  171. * - sizeof (ulong) is usually a valid address. Better pick an address
  172. * known to be invalid on your system and assign it to CFG_RESET_ADDRESS.
  173. */
  174. addr = CFG_MONITOR_BASE - sizeof (ulong);
  175. #endif
  176. ((void (*)(void)) addr) ();
  177. return 1;
  178. }
  179. /* ------------------------------------------------------------------------- */
  180. /*
  181. * Get timebase clock frequency (like cpu_clk in Hz)
  182. *
  183. */
  184. unsigned long get_tbclk (void)
  185. {
  186. DECLARE_GLOBAL_DATA_PTR;
  187. ulong tbclk;
  188. tbclk = (gd->bus_clk + 3L) / 4L;
  189. return (tbclk);
  190. }
  191. /* ------------------------------------------------------------------------- */
  192. #if defined(CONFIG_WATCHDOG)
  193. void watchdog_reset (void)
  194. {
  195. int re_enable = disable_interrupts ();
  196. reset_8260_watchdog ((immap_t *) CFG_IMMR);
  197. if (re_enable)
  198. enable_interrupts ();
  199. }
  200. #endif /* CONFIG_WATCHDOG */
  201. /* ------------------------------------------------------------------------- */