cpu_init.c 7.6 KB

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