cpu_init.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. #ifdef CONFIG_CPM2
  32. static void config_8560_ioports (volatile immap_t * immr)
  33. {
  34. int portnum;
  35. for (portnum = 0; portnum < 4; portnum++) {
  36. uint pmsk = 0,
  37. ppar = 0,
  38. psor = 0,
  39. pdir = 0,
  40. podr = 0,
  41. pdat = 0;
  42. iop_conf_t *iopc = (iop_conf_t *) & iop_conf_tab[portnum][0];
  43. iop_conf_t *eiopc = iopc + 32;
  44. uint msk = 1;
  45. /*
  46. * NOTE:
  47. * index 0 refers to pin 31,
  48. * index 31 refers to pin 0
  49. */
  50. while (iopc < eiopc) {
  51. if (iopc->conf) {
  52. pmsk |= msk;
  53. if (iopc->ppar)
  54. ppar |= msk;
  55. if (iopc->psor)
  56. psor |= msk;
  57. if (iopc->pdir)
  58. pdir |= msk;
  59. if (iopc->podr)
  60. podr |= msk;
  61. if (iopc->pdat)
  62. pdat |= msk;
  63. }
  64. msk <<= 1;
  65. iopc++;
  66. }
  67. if (pmsk != 0) {
  68. volatile ioport_t *iop = ioport_addr (immr, portnum);
  69. uint tpmsk = ~pmsk;
  70. /*
  71. * the (somewhat confused) paragraph at the
  72. * bottom of page 35-5 warns that there might
  73. * be "unknown behaviour" when programming
  74. * PSORx and PDIRx, if PPARx = 1, so I
  75. * decided this meant I had to disable the
  76. * dedicated function first, and enable it
  77. * last.
  78. */
  79. iop->ppar &= tpmsk;
  80. iop->psor = (iop->psor & tpmsk) | psor;
  81. iop->podr = (iop->podr & tpmsk) | podr;
  82. iop->pdat = (iop->pdat & tpmsk) | pdat;
  83. iop->pdir = (iop->pdir & tpmsk) | pdir;
  84. iop->ppar |= ppar;
  85. }
  86. }
  87. }
  88. #endif
  89. /*
  90. * Breathe some life into the CPU...
  91. *
  92. * Set up the memory map
  93. * initialize a bunch of registers
  94. */
  95. void cpu_init_f (void)
  96. {
  97. DECLARE_GLOBAL_DATA_PTR;
  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(CONFIG_MPC85xx)
  128. #if defined(CFG_BR2_PRELIM) && defined(CFG_OR2_PRELIM)
  129. memctl->or2 = CFG_OR2_PRELIM;
  130. memctl->br2 = CFG_BR2_PRELIM;
  131. #endif
  132. #endif
  133. #if defined(CFG_BR3_PRELIM) && defined(CFG_OR3_PRELIM)
  134. memctl->or3 = CFG_OR3_PRELIM;
  135. memctl->br3 = CFG_BR3_PRELIM;
  136. #endif
  137. #if defined(CFG_BR4_PRELIM) && defined(CFG_OR4_PRELIM)
  138. memctl->or4 = CFG_OR4_PRELIM;
  139. memctl->br4 = CFG_BR4_PRELIM;
  140. #endif
  141. #if defined(CFG_BR5_PRELIM) && defined(CFG_OR5_PRELIM)
  142. memctl->or5 = CFG_OR5_PRELIM;
  143. memctl->br5 = CFG_BR5_PRELIM;
  144. #endif
  145. #if defined(CFG_BR6_PRELIM) && defined(CFG_OR6_PRELIM)
  146. memctl->or6 = CFG_OR6_PRELIM;
  147. memctl->br6 = CFG_BR6_PRELIM;
  148. #endif
  149. #if defined(CFG_BR7_PRELIM) && defined(CFG_OR7_PRELIM)
  150. memctl->or7 = CFG_OR7_PRELIM;
  151. memctl->br7 = CFG_BR7_PRELIM;
  152. #endif
  153. #if defined(CONFIG_CPM2)
  154. m8560_cpm_reset();
  155. #endif
  156. }
  157. /*
  158. * We initialize L2 as cache here.
  159. */
  160. int cpu_init_r (void)
  161. {
  162. #if defined(CONFIG_L2_CACHE)
  163. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  164. volatile ccsr_l2cache_t *l2cache = &immap->im_l2cache;
  165. volatile uint temp;
  166. asm("msync;isync");
  167. l2cache->l2ctl = 0x68000000; /* invalidate */
  168. temp = l2cache->l2ctl;
  169. asm("msync;isync");
  170. l2cache->l2ctl = 0xa8000000; /* enable 256KB L2 cache */
  171. temp = l2cache->l2ctl;
  172. asm("msync;isync");
  173. printf("L2: 256 kB enabled\n");
  174. #else
  175. printf("L2: disabled.\n");
  176. #endif
  177. return 0;
  178. }