cpu_init.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * (C) Copyright 2003 Motorola Inc.
  3. * Modified by Xianghua Xiao, X.Xiao@motorola.com
  4. *
  5. * (C) Copyright 2000
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <watchdog.h>
  28. #include <asm/processor.h>
  29. #include <ioports.h>
  30. #include <asm/io.h>
  31. DECLARE_GLOBAL_DATA_PTR;
  32. #ifdef CONFIG_CPM2
  33. static void config_8560_ioports (volatile immap_t * immr)
  34. {
  35. int portnum;
  36. for (portnum = 0; portnum < 4; portnum++) {
  37. uint pmsk = 0,
  38. ppar = 0,
  39. psor = 0,
  40. pdir = 0,
  41. podr = 0,
  42. pdat = 0;
  43. iop_conf_t *iopc = (iop_conf_t *) & iop_conf_tab[portnum][0];
  44. iop_conf_t *eiopc = iopc + 32;
  45. uint msk = 1;
  46. /*
  47. * NOTE:
  48. * index 0 refers to pin 31,
  49. * index 31 refers to pin 0
  50. */
  51. while (iopc < eiopc) {
  52. if (iopc->conf) {
  53. pmsk |= msk;
  54. if (iopc->ppar)
  55. ppar |= msk;
  56. if (iopc->psor)
  57. psor |= msk;
  58. if (iopc->pdir)
  59. pdir |= msk;
  60. if (iopc->podr)
  61. podr |= msk;
  62. if (iopc->pdat)
  63. pdat |= msk;
  64. }
  65. msk <<= 1;
  66. iopc++;
  67. }
  68. if (pmsk != 0) {
  69. volatile ioport_t *iop = ioport_addr (immr, portnum);
  70. uint tpmsk = ~pmsk;
  71. /*
  72. * the (somewhat confused) paragraph at the
  73. * bottom of page 35-5 warns that there might
  74. * be "unknown behaviour" when programming
  75. * PSORx and PDIRx, if PPARx = 1, so I
  76. * decided this meant I had to disable the
  77. * dedicated function first, and enable it
  78. * last.
  79. */
  80. iop->ppar &= tpmsk;
  81. iop->psor = (iop->psor & tpmsk) | psor;
  82. iop->podr = (iop->podr & tpmsk) | podr;
  83. iop->pdat = (iop->pdat & tpmsk) | pdat;
  84. iop->pdir = (iop->pdir & tpmsk) | pdir;
  85. iop->ppar |= ppar;
  86. }
  87. }
  88. }
  89. #endif
  90. /*
  91. * Breathe some life into the CPU...
  92. *
  93. * Set up the memory map
  94. * initialize a bunch of registers
  95. */
  96. void cpu_init_f (void)
  97. {
  98. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  99. volatile ccsr_lbc_t *memctl = &immap->im_lbc;
  100. extern void m8560_cpm_reset (void);
  101. /* Pointer is writable since we allocated a register for it */
  102. gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
  103. /* Clear initial global data */
  104. memset ((void *) gd, 0, sizeof (gd_t));
  105. #ifdef CONFIG_CPM2
  106. config_8560_ioports(immap);
  107. #endif
  108. /* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
  109. * addresses - these have to be modified later when FLASH size
  110. * has been determined
  111. */
  112. #if defined(CFG_OR0_REMAP)
  113. memctl->or0 = CFG_OR0_REMAP;
  114. #endif
  115. #if defined(CFG_OR1_REMAP)
  116. memctl->or1 = CFG_OR1_REMAP;
  117. #endif
  118. /* now restrict to preliminary range */
  119. #if defined(CFG_BR0_PRELIM) && defined(CFG_OR0_PRELIM)
  120. memctl->br0 = CFG_BR0_PRELIM;
  121. memctl->or0 = CFG_OR0_PRELIM;
  122. #endif
  123. #if defined(CFG_BR1_PRELIM) && defined(CFG_OR1_PRELIM)
  124. memctl->or1 = CFG_OR1_PRELIM;
  125. memctl->br1 = CFG_BR1_PRELIM;
  126. #endif
  127. #if defined(CFG_BR2_PRELIM) && defined(CFG_OR2_PRELIM)
  128. memctl->or2 = CFG_OR2_PRELIM;
  129. memctl->br2 = CFG_BR2_PRELIM;
  130. #endif
  131. #if defined(CFG_BR3_PRELIM) && defined(CFG_OR3_PRELIM)
  132. memctl->or3 = CFG_OR3_PRELIM;
  133. memctl->br3 = CFG_BR3_PRELIM;
  134. #endif
  135. #if defined(CFG_BR4_PRELIM) && defined(CFG_OR4_PRELIM)
  136. memctl->or4 = CFG_OR4_PRELIM;
  137. memctl->br4 = CFG_BR4_PRELIM;
  138. #endif
  139. #if defined(CFG_BR5_PRELIM) && defined(CFG_OR5_PRELIM)
  140. memctl->or5 = CFG_OR5_PRELIM;
  141. memctl->br5 = CFG_BR5_PRELIM;
  142. #endif
  143. #if defined(CFG_BR6_PRELIM) && defined(CFG_OR6_PRELIM)
  144. memctl->or6 = CFG_OR6_PRELIM;
  145. memctl->br6 = CFG_BR6_PRELIM;
  146. #endif
  147. #if defined(CFG_BR7_PRELIM) && defined(CFG_OR7_PRELIM)
  148. memctl->or7 = CFG_OR7_PRELIM;
  149. memctl->br7 = CFG_BR7_PRELIM;
  150. #endif
  151. #if defined(CONFIG_CPM2)
  152. m8560_cpm_reset();
  153. #endif
  154. }
  155. /*
  156. * Initialize L2 as cache.
  157. *
  158. * The newer 8548, etc, parts have twice as much cache, but
  159. * use the same bit-encoding as the older 8555, etc, parts.
  160. *
  161. * FIXME: Use PVR_VER(pvr) == 1 test here instead of SVR_VER()?
  162. */
  163. int cpu_init_r(void)
  164. {
  165. #if defined(CONFIG_L2_CACHE)
  166. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  167. volatile ccsr_l2cache_t *l2cache = &immap->im_l2cache;
  168. volatile uint cache_ctl;
  169. uint svr, ver;
  170. svr = get_svr();
  171. ver = SVR_VER(svr);
  172. asm("msync;isync");
  173. cache_ctl = l2cache->l2ctl;
  174. switch (cache_ctl & 0x30000000) {
  175. case 0x20000000:
  176. if (ver == SVR_8548 || ver == SVR_8548_E) {
  177. printf ("L2 cache 512KB:");
  178. } else {
  179. printf ("L2 cache 256KB:");
  180. }
  181. break;
  182. case 0x00000000:
  183. case 0x10000000:
  184. case 0x30000000:
  185. default:
  186. printf ("L2 cache unknown size (0x%08x)\n", cache_ctl);
  187. return -1;
  188. }
  189. asm("msync;isync");
  190. l2cache->l2ctl = 0x68000000; /* invalidate */
  191. cache_ctl = l2cache->l2ctl;
  192. asm("msync;isync");
  193. l2cache->l2ctl = 0xa8000000; /* enable 256KB L2 cache */
  194. cache_ctl = l2cache->l2ctl;
  195. asm("msync;isync");
  196. printf(" enabled\n");
  197. #else
  198. printf("L2 cache: disabled\n");
  199. #endif
  200. return 0;
  201. }