cpu_init.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /*
  2. * (C) Copyright 2003
  3. * Josef Baumgartner <josef.baumgartner@telex.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. #include <common.h>
  24. #include <watchdog.h>
  25. #ifdef CONFIG_M5272
  26. #include <asm/m5272.h>
  27. #include <asm/immap_5272.h>
  28. #endif
  29. #ifdef CONFIG_M5282
  30. #include <asm/m5282.h>
  31. #include <asm/immap_5282.h>
  32. #endif
  33. #ifdef CONFIG_M5249
  34. #include <asm/m5249.h>
  35. #endif
  36. #if defined(CONFIG_M5272)
  37. /*
  38. * Breath some life into the CPU...
  39. *
  40. * Set up the memory map,
  41. * initialize a bunch of registers,
  42. * initialize the UPM's
  43. */
  44. void cpu_init_f (void)
  45. {
  46. /* if we come from RAM we assume the CPU is
  47. * already initialized.
  48. */
  49. #ifndef CONFIG_MONITOR_IS_IN_RAM
  50. volatile immap_t *regp = (immap_t *)CFG_MBAR;
  51. volatile unsigned char *mbar;
  52. mbar = (volatile unsigned char *) CFG_MBAR;
  53. regp->sysctrl_reg.sc_scr = CFG_SCR;
  54. regp->sysctrl_reg.sc_spr = CFG_SPR;
  55. /* Setup Ports: */
  56. regp->gpio_reg.gpio_pacnt = CFG_PACNT;
  57. regp->gpio_reg.gpio_paddr = CFG_PADDR;
  58. regp->gpio_reg.gpio_padat = CFG_PADAT;
  59. regp->gpio_reg.gpio_pbcnt = CFG_PBCNT;
  60. regp->gpio_reg.gpio_pbddr = CFG_PBDDR;
  61. regp->gpio_reg.gpio_pbdat = CFG_PBDAT;
  62. regp->gpio_reg.gpio_pdcnt = CFG_PDCNT;
  63. /* Memory Controller: */
  64. regp->csctrl_reg.cs_br0 = CFG_BR0_PRELIM;
  65. regp->csctrl_reg.cs_or0 = CFG_OR0_PRELIM;
  66. #if (defined(CFG_OR1_PRELIM) && defined(CFG_BR1_PRELIM))
  67. regp->csctrl_reg.cs_br1 = CFG_BR1_PRELIM;
  68. regp->csctrl_reg.cs_or1 = CFG_OR1_PRELIM;
  69. #endif
  70. #if defined(CFG_OR2_PRELIM) && defined(CFG_BR2_PRELIM)
  71. regp->csctrl_reg.cs_br2 = CFG_BR2_PRELIM;
  72. regp->csctrl_reg.cs_or2 = CFG_OR2_PRELIM;
  73. #endif
  74. #if defined(CFG_OR3_PRELIM) && defined(CFG_BR3_PRELIM)
  75. regp->csctrl_reg.cs_br3 = CFG_BR3_PRELIM;
  76. regp->csctrl_reg.cs_or3 = CFG_OR3_PRELIM;
  77. #endif
  78. #if defined(CFG_OR4_PRELIM) && defined(CFG_BR4_PRELIM)
  79. regp->csctrl_reg.cs_br4 = CFG_BR4_PRELIM;
  80. regp->csctrl_reg.cs_or4 = CFG_OR4_PRELIM;
  81. #endif
  82. #if defined(CFG_OR5_PRELIM) && defined(CFG_BR5_PRELIM)
  83. regp->csctrl_reg.cs_br5 = CFG_BR5_PRELIM;
  84. regp->csctrl_reg.cs_or5 = CFG_OR5_PRELIM;
  85. #endif
  86. #if defined(CFG_OR6_PRELIM) && defined(CFG_BR6_PRELIM)
  87. regp->csctrl_reg.cs_br6 = CFG_BR6_PRELIM;
  88. regp->csctrl_reg.cs_or6 = CFG_OR6_PRELIM;
  89. #endif
  90. #if defined(CFG_OR7_PRELIM) && defined(CFG_BR7_PRELIM)
  91. regp->csctrl_reg.cs_br7 = CFG_BR7_PRELIM;
  92. regp->csctrl_reg.cs_or7 = CFG_OR7_PRELIM;
  93. #endif
  94. #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
  95. /* enable instruction cache now */
  96. icache_enable();
  97. }
  98. /*
  99. * initialize higher level parts of CPU like timers
  100. */
  101. int cpu_init_r (void)
  102. {
  103. return (0);
  104. }
  105. #endif /* #if defined(CONFIG_M5272) */
  106. #ifdef CONFIG_M5282
  107. /*
  108. * Breath some life into the CPU...
  109. *
  110. * Set up the memory map,
  111. * initialize a bunch of registers,
  112. * initialize the UPM's
  113. */
  114. void cpu_init_f (void)
  115. {
  116. }
  117. /*
  118. * initialize higher level parts of CPU like timers
  119. */
  120. int cpu_init_r (void)
  121. {
  122. return (0);
  123. }
  124. #endif
  125. #if defined(CONFIG_M5249)
  126. /*
  127. * Breath some life into the CPU...
  128. *
  129. * Set up the memory map,
  130. * initialize a bunch of registers,
  131. * initialize the UPM's
  132. */
  133. void cpu_init_f (void)
  134. {
  135. #ifndef CFG_PLL_BYPASS
  136. /*
  137. * Setup the PLL to run at the specified speed
  138. *
  139. */
  140. volatile unsigned long cpll = mbar2_readLong(MCFSIM_PLLCR);
  141. unsigned long pllcr;
  142. #ifdef CFG_FAST_CLK
  143. pllcr = 0x925a3100; /* ~140MHz clock (PLL bypass = 0) */
  144. #else
  145. pllcr = 0x135a4140; /* ~72MHz clock (PLL bypass = 0) */
  146. #endif
  147. cpll = cpll & 0xfffffffe; /* Set PLL bypass mode = 0 (PSTCLK = crystal) */
  148. mbar2_writeLong(MCFSIM_PLLCR, cpll); /* Set the PLL to bypass mode (PSTCLK = crystal) */
  149. mbar2_writeLong(MCFSIM_PLLCR, pllcr); /* set the clock speed */
  150. pllcr ^= 0x00000001; /* Set pll bypass to 1 */
  151. mbar2_writeLong(MCFSIM_PLLCR, pllcr); /* Start locking (pll bypass = 1) */
  152. udelay(0x20); /* Wait for a lock ... */
  153. #endif /* #ifndef CFG_PLL_BYPASS */
  154. /*
  155. * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins
  156. * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins
  157. * which is their primary function.
  158. * ~Jeremy
  159. */
  160. mbar2_writeLong(MCFSIM_GPIO_FUNC, CFG_GPIO_FUNC);
  161. mbar2_writeLong(MCFSIM_GPIO1_FUNC, CFG_GPIO1_FUNC);
  162. mbar2_writeLong(MCFSIM_GPIO_EN, CFG_GPIO_EN);
  163. mbar2_writeLong(MCFSIM_GPIO1_EN, CFG_GPIO1_EN);
  164. mbar2_writeLong(MCFSIM_GPIO_OUT, CFG_GPIO_OUT);
  165. mbar2_writeLong(MCFSIM_GPIO1_OUT, CFG_GPIO1_OUT);
  166. /*
  167. * dBug Compliance:
  168. * You can verify these values by using dBug's 'ird'
  169. * (Internal Register Display) command
  170. * ~Jeremy
  171. *
  172. */
  173. mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */
  174. mbar_writeByte(MCFSIM_SYPCR, 0x00);
  175. mbar_writeByte(MCFSIM_SWIVR, 0x0f);
  176. mbar_writeByte(MCFSIM_SWSR, 0x00);
  177. mbar_writeLong(MCFSIM_IMR, 0xfffffbff);
  178. mbar_writeByte(MCFSIM_SWDICR, 0x00);
  179. mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
  180. mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
  181. mbar_writeByte(MCFSIM_I2CICR, 0x00);
  182. mbar_writeByte(MCFSIM_UART1ICR, 0x00);
  183. mbar_writeByte(MCFSIM_UART2ICR, 0x00);
  184. mbar_writeByte(MCFSIM_ICR6, 0x00);
  185. mbar_writeByte(MCFSIM_ICR7, 0x00);
  186. mbar_writeByte(MCFSIM_ICR8, 0x00);
  187. mbar_writeByte(MCFSIM_ICR9, 0x00);
  188. mbar_writeByte(MCFSIM_QSPIICR, 0x00);
  189. mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
  190. mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
  191. mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
  192. mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */
  193. /* Setup interrupt priorities for gpio7 */
  194. /* mbar2_writeLong(MCFSIM_INTLEV5, 0x70000000); */
  195. /* IDE Config registers */
  196. mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020);
  197. mbar2_writeLong(MCFSIM_IDECONFIG2, 0x00000000);
  198. /*
  199. * Setup chip selects...
  200. */
  201. mbar_writeShort(MCFSIM_CSAR1, CFG_CSAR1);
  202. mbar_writeShort(MCFSIM_CSCR1, CFG_CSCR1);
  203. mbar_writeLong(MCFSIM_CSMR1, CFG_CSMR1);
  204. mbar_writeShort(MCFSIM_CSAR0, CFG_CSAR0);
  205. mbar_writeShort(MCFSIM_CSCR0, CFG_CSCR0);
  206. mbar_writeLong(MCFSIM_CSMR0, CFG_CSMR0);
  207. /* enable instruction cache now */
  208. icache_enable();
  209. }
  210. /*
  211. * initialize higher level parts of CPU like timers
  212. */
  213. int cpu_init_r (void)
  214. {
  215. return (0);
  216. }
  217. #endif /* #if defined(CONFIG_M5249) */