cpu_init.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. /*
  2. * (C) Copyright 2003
  3. * Josef Baumgartner <josef.baumgartner@telex.de>
  4. *
  5. * MCF5282 additionals
  6. * (C) Copyright 2005
  7. * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de>
  8. * (c) Copyright 2010
  9. * Arcturus Networks Inc. <www.arcturusnetworks.com>
  10. *
  11. * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
  12. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  13. * Hayden Fraser (Hayden.Fraser@freescale.com)
  14. *
  15. * MCF5275 additions
  16. * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com)
  17. *
  18. * SPDX-License-Identifier: GPL-2.0+
  19. */
  20. #include <common.h>
  21. #include <watchdog.h>
  22. #include <asm/immap.h>
  23. #include <asm/io.h>
  24. #if defined(CONFIG_CMD_NET)
  25. #include <config.h>
  26. #include <net.h>
  27. #include <asm/fec.h>
  28. #endif
  29. #ifndef CONFIG_M5272
  30. /* Only 5272 Flexbus chipselect is different from the rest */
  31. void init_fbcs(void)
  32. {
  33. fbcs_t *fbcs = (fbcs_t *) (MMAP_FBCS);
  34. #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
  35. && defined(CONFIG_SYS_CS0_CTRL))
  36. out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
  37. out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
  38. out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
  39. #else
  40. #warning "Chip Select 0 are not initialized/used"
  41. #endif
  42. #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
  43. && defined(CONFIG_SYS_CS1_CTRL))
  44. out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
  45. out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
  46. out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
  47. #endif
  48. #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
  49. && defined(CONFIG_SYS_CS2_CTRL))
  50. out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
  51. out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
  52. out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
  53. #endif
  54. #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
  55. && defined(CONFIG_SYS_CS3_CTRL))
  56. out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
  57. out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
  58. out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
  59. #endif
  60. #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
  61. && defined(CONFIG_SYS_CS4_CTRL))
  62. out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
  63. out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
  64. out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
  65. #endif
  66. #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
  67. && defined(CONFIG_SYS_CS5_CTRL))
  68. out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
  69. out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
  70. out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
  71. #endif
  72. #if (defined(CONFIG_SYS_CS6_BASE) && defined(CONFIG_SYS_CS6_MASK) \
  73. && defined(CONFIG_SYS_CS6_CTRL))
  74. out_be32(&fbcs->csar6, CONFIG_SYS_CS6_BASE);
  75. out_be32(&fbcs->cscr6, CONFIG_SYS_CS6_CTRL);
  76. out_be32(&fbcs->csmr6, CONFIG_SYS_CS6_MASK);
  77. #endif
  78. #if (defined(CONFIG_SYS_CS7_BASE) && defined(CONFIG_SYS_CS7_MASK) \
  79. && defined(CONFIG_SYS_CS7_CTRL))
  80. out_be32(&fbcs->csar7, CONFIG_SYS_CS7_BASE);
  81. out_be32(&fbcs->cscr7, CONFIG_SYS_CS7_CTRL);
  82. out_be32(&fbcs->csmr7, CONFIG_SYS_CS7_MASK);
  83. #endif
  84. }
  85. #endif
  86. #if defined(CONFIG_M5208)
  87. void cpu_init_f(void)
  88. {
  89. scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
  90. #ifndef CONFIG_WATCHDOG
  91. wdog_t *wdg = (wdog_t *) MMAP_WDOG;
  92. /* Disable the watchdog if we aren't using it */
  93. out_be16(&wdg->cr, 0);
  94. #endif
  95. out_be32(&scm1->mpr, 0x77777777);
  96. out_be32(&scm1->pacra, 0);
  97. out_be32(&scm1->pacrb, 0);
  98. out_be32(&scm1->pacrc, 0);
  99. out_be32(&scm1->pacrd, 0);
  100. out_be32(&scm1->pacre, 0);
  101. out_be32(&scm1->pacrf, 0);
  102. /* FlexBus Chipselect */
  103. init_fbcs();
  104. icache_enable();
  105. }
  106. /* initialize higher level parts of CPU like timers */
  107. int cpu_init_r(void)
  108. {
  109. return (0);
  110. }
  111. void uart_port_conf(int port)
  112. {
  113. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  114. /* Setup Ports: */
  115. switch (port) {
  116. case 0:
  117. clrbits_be16(&gpio->par_uart, ~GPIO_PAR_UART0_UNMASK);
  118. setbits_be16(&gpio->par_uart, GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD);
  119. break;
  120. case 1:
  121. clrbits_be16(&gpio->par_uart, ~GPIO_PAR_UART0_UNMASK);
  122. setbits_be16(&gpio->par_uart, GPIO_PAR_UART_U1TXD | GPIO_PAR_UART_U1RXD);
  123. break;
  124. case 2:
  125. #ifdef CONFIG_SYS_UART2_PRI_GPIO
  126. clrbits_8(&gpio->par_timer,
  127. ~(GPIO_PAR_TMR_TIN0_UNMASK | GPIO_PAR_TMR_TIN1_UNMASK));
  128. setbits_8(&gpio->par_timer,
  129. GPIO_PAR_TMR_TIN0_U2TXD | GPIO_PAR_TMR_TIN1_U2RXD);
  130. #endif
  131. #ifdef CONFIG_SYS_UART2_ALT1_GPIO
  132. clrbits_8(&gpio->par_feci2c,
  133. ~(GPIO_PAR_FECI2C_MDC_UNMASK | GPIO_PAR_FECI2C_MDIO_UNMASK));
  134. setbits_8(&gpio->par_feci2c,
  135. GPIO_PAR_FECI2C_MDC_U2TXD | GPIO_PAR_FECI2C_MDIO_U2RXD);
  136. #endif
  137. #ifdef CONFIG_SYS_UART2_ALT1_GPIO
  138. clrbits_8(&gpio->par_feci2c,
  139. ~(GPIO_PAR_FECI2C_SDA_UNMASK | GPIO_PAR_FECI2C_SCL_UNMASK));
  140. setbits_8(&gpio->par_feci2c,
  141. GPIO_PAR_FECI2C_SDA_U2TXD | GPIO_PAR_FECI2C_SCL_U2RXD);
  142. #endif
  143. break;
  144. }
  145. }
  146. #if defined(CONFIG_CMD_NET)
  147. int fecpin_setclear(struct eth_device *dev, int setclear)
  148. {
  149. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  150. if (setclear) {
  151. setbits_8(&gpio->par_fec,
  152. GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
  153. setbits_8(&gpio->par_feci2c,
  154. GPIO_PAR_FECI2C_MDC_MDC | GPIO_PAR_FECI2C_MDIO_MDIO);
  155. } else {
  156. clrbits_8(&gpio->par_fec,
  157. ~(GPIO_PAR_FEC_7W_UNMASK & GPIO_PAR_FEC_MII_UNMASK));
  158. clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII_UNMASK);
  159. }
  160. return 0;
  161. }
  162. #endif /* CONFIG_CMD_NET */
  163. #endif /* CONFIG_M5208 */
  164. #if defined(CONFIG_M5253)
  165. /*
  166. * Breath some life into the CPU...
  167. *
  168. * Set up the memory map,
  169. * initialize a bunch of registers,
  170. * initialize the UPM's
  171. */
  172. void cpu_init_f(void)
  173. {
  174. mbar_writeByte(MCFSIM_MPARK, 0x40); /* 5249 Internal Core takes priority over DMA */
  175. mbar_writeByte(MCFSIM_SYPCR, 0x00);
  176. mbar_writeByte(MCFSIM_SWIVR, 0x0f);
  177. mbar_writeByte(MCFSIM_SWSR, 0x00);
  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. /* FlexBus Chipselect */
  194. init_fbcs();
  195. #ifdef CONFIG_SYS_I2C_FSL
  196. CONFIG_SYS_I2C_PINMUX_REG =
  197. CONFIG_SYS_I2C_PINMUX_REG & CONFIG_SYS_I2C_PINMUX_CLR;
  198. CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
  199. #ifdef CONFIG_SYS_I2C2_OFFSET
  200. CONFIG_SYS_I2C2_PINMUX_REG &= CONFIG_SYS_I2C2_PINMUX_CLR;
  201. CONFIG_SYS_I2C2_PINMUX_REG |= CONFIG_SYS_I2C2_PINMUX_SET;
  202. #endif
  203. #endif
  204. /* enable instruction cache now */
  205. icache_enable();
  206. }
  207. /*initialize higher level parts of CPU like timers */
  208. int cpu_init_r(void)
  209. {
  210. return (0);
  211. }
  212. void uart_port_conf(int port)
  213. {
  214. u32 *par = (u32 *) MMAP_PAR;
  215. /* Setup Ports: */
  216. switch (port) {
  217. case 1:
  218. clrbits_be32(par, 0x00180000);
  219. setbits_be32(par, 0x00180000);
  220. break;
  221. case 2:
  222. clrbits_be32(par, 0x00000003);
  223. clrbits_be32(par, 0xFFFFFFFC);
  224. break;
  225. }
  226. }
  227. #endif /* #if defined(CONFIG_M5253) */
  228. #if defined(CONFIG_M5271)
  229. void cpu_init_f(void)
  230. {
  231. #ifndef CONFIG_WATCHDOG
  232. /* Disable the watchdog if we aren't using it */
  233. mbar_writeShort(MCF_WTM_WCR, 0);
  234. #endif
  235. /* FlexBus Chipselect */
  236. init_fbcs();
  237. #ifdef CONFIG_SYS_MCF_SYNCR
  238. /* Set clockspeed according to board header file */
  239. mbar_writeLong(MCF_FMPLL_SYNCR, CONFIG_SYS_MCF_SYNCR);
  240. #else
  241. /* Set clockspeed to 100MHz */
  242. mbar_writeLong(MCF_FMPLL_SYNCR,
  243. MCF_FMPLL_SYNCR_MFD(0) | MCF_FMPLL_SYNCR_RFD(0));
  244. #endif
  245. while (!(mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK)) ;
  246. }
  247. /*
  248. * initialize higher level parts of CPU like timers
  249. */
  250. int cpu_init_r(void)
  251. {
  252. return (0);
  253. }
  254. void uart_port_conf(int port)
  255. {
  256. u16 temp;
  257. /* Setup Ports: */
  258. switch (port) {
  259. case 0:
  260. temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xFFF3;
  261. temp |= (MCF_GPIO_PAR_UART_U0TXD | MCF_GPIO_PAR_UART_U0RXD);
  262. mbar_writeShort(MCF_GPIO_PAR_UART, temp);
  263. break;
  264. case 1:
  265. temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xF0FF;
  266. temp |= (MCF_GPIO_PAR_UART_U1RXD_UART1 | MCF_GPIO_PAR_UART_U1TXD_UART1);
  267. mbar_writeShort(MCF_GPIO_PAR_UART, temp);
  268. break;
  269. case 2:
  270. temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xCFFF;
  271. temp |= (0x3000);
  272. mbar_writeShort(MCF_GPIO_PAR_UART, temp);
  273. break;
  274. }
  275. }
  276. #if defined(CONFIG_CMD_NET)
  277. int fecpin_setclear(struct eth_device *dev, int setclear)
  278. {
  279. if (setclear) {
  280. /* Enable Ethernet pins */
  281. mbar_writeByte(MCF_GPIO_PAR_FECI2C,
  282. (mbar_readByte(MCF_GPIO_PAR_FECI2C) | 0xF0));
  283. } else {
  284. }
  285. return 0;
  286. }
  287. #endif /* CONFIG_CMD_NET */
  288. #if defined(CONFIG_CF_QSPI)
  289. /* Configure PIOs for SIN, SOUT, and SCK */
  290. void cfspi_port_conf(void)
  291. {
  292. mbar_writeByte(MCF_GPIO_PAR_QSPI,
  293. MCF_GPIO_PAR_QSPI_SIN_SIN |
  294. MCF_GPIO_PAR_QSPI_SOUT_SOUT |
  295. MCF_GPIO_PAR_QSPI_SCK_SCK);
  296. }
  297. #endif /* CONFIG_CF_QSPI */
  298. #endif /* CONFIG_M5271 */
  299. #if defined(CONFIG_M5272)
  300. /*
  301. * Breath some life into the CPU...
  302. *
  303. * Set up the memory map,
  304. * initialize a bunch of registers,
  305. * initialize the UPM's
  306. */
  307. void cpu_init_f(void)
  308. {
  309. /* if we come from RAM we assume the CPU is
  310. * already initialized.
  311. */
  312. #ifndef CONFIG_MONITOR_IS_IN_RAM
  313. sysctrl_t *sysctrl = (sysctrl_t *) (CONFIG_SYS_MBAR);
  314. gpio_t *gpio = (gpio_t *) (MMAP_GPIO);
  315. csctrl_t *csctrl = (csctrl_t *) (MMAP_FBCS);
  316. out_be16(&sysctrl->sc_scr, CONFIG_SYS_SCR);
  317. out_be16(&sysctrl->sc_spr, CONFIG_SYS_SPR);
  318. /* Setup Ports: */
  319. out_be32(&gpio->gpio_pacnt, CONFIG_SYS_PACNT);
  320. out_be16(&gpio->gpio_paddr, CONFIG_SYS_PADDR);
  321. out_be16(&gpio->gpio_padat, CONFIG_SYS_PADAT);
  322. out_be32(&gpio->gpio_pbcnt, CONFIG_SYS_PBCNT);
  323. out_be16(&gpio->gpio_pbddr, CONFIG_SYS_PBDDR);
  324. out_be16(&gpio->gpio_pbdat, CONFIG_SYS_PBDAT);
  325. out_be32(&gpio->gpio_pdcnt, CONFIG_SYS_PDCNT);
  326. /* Memory Controller: */
  327. out_be32(&csctrl->cs_br0, CONFIG_SYS_BR0_PRELIM);
  328. out_be32(&csctrl->cs_or0, CONFIG_SYS_OR0_PRELIM);
  329. #if (defined(CONFIG_SYS_OR1_PRELIM) && defined(CONFIG_SYS_BR1_PRELIM))
  330. out_be32(&csctrl->cs_br1, CONFIG_SYS_BR1_PRELIM);
  331. out_be32(&csctrl->cs_or1, CONFIG_SYS_OR1_PRELIM);
  332. #endif
  333. #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
  334. out_be32(&csctrl->cs_br2, CONFIG_SYS_BR2_PRELIM);
  335. out_be32(&csctrl->cs_or2, CONFIG_SYS_OR2_PRELIM);
  336. #endif
  337. #if defined(CONFIG_SYS_OR3_PRELIM) && defined(CONFIG_SYS_BR3_PRELIM)
  338. out_be32(&csctrl->cs_br3, CONFIG_SYS_BR3_PRELIM);
  339. out_be32(&csctrl->cs_or3, CONFIG_SYS_OR3_PRELIM);
  340. #endif
  341. #if defined(CONFIG_SYS_OR4_PRELIM) && defined(CONFIG_SYS_BR4_PRELIM)
  342. out_be32(&csctrl->cs_br4, CONFIG_SYS_BR4_PRELIM);
  343. out_be32(&csctrl->cs_or4, CONFIG_SYS_OR4_PRELIM);
  344. #endif
  345. #if defined(CONFIG_SYS_OR5_PRELIM) && defined(CONFIG_SYS_BR5_PRELIM)
  346. out_be32(&csctrl->cs_br5, CONFIG_SYS_BR5_PRELIM);
  347. out_be32(&csctrl->cs_or5, CONFIG_SYS_OR5_PRELIM);
  348. #endif
  349. #if defined(CONFIG_SYS_OR6_PRELIM) && defined(CONFIG_SYS_BR6_PRELIM)
  350. out_be32(&csctrl->cs_br6, CONFIG_SYS_BR6_PRELIM);
  351. out_be32(&csctrl->cs_or6, CONFIG_SYS_OR6_PRELIM);
  352. #endif
  353. #if defined(CONFIG_SYS_OR7_PRELIM) && defined(CONFIG_SYS_BR7_PRELIM)
  354. out_be32(&csctrl->cs_br7, CONFIG_SYS_BR7_PRELIM);
  355. out_be32(&csctrl->cs_or7, CONFIG_SYS_OR7_PRELIM);
  356. #endif
  357. #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
  358. /* enable instruction cache now */
  359. icache_enable();
  360. }
  361. /*
  362. * initialize higher level parts of CPU like timers
  363. */
  364. int cpu_init_r(void)
  365. {
  366. return (0);
  367. }
  368. void uart_port_conf(int port)
  369. {
  370. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  371. /* Setup Ports: */
  372. switch (port) {
  373. case 0:
  374. clrbits_be32(&gpio->gpio_pbcnt,
  375. GPIO_PBCNT_PB0MSK | GPIO_PBCNT_PB1MSK);
  376. setbits_be32(&gpio->gpio_pbcnt,
  377. GPIO_PBCNT_URT0_TXD | GPIO_PBCNT_URT0_RXD);
  378. break;
  379. case 1:
  380. clrbits_be32(&gpio->gpio_pdcnt,
  381. GPIO_PDCNT_PD1MSK | GPIO_PDCNT_PD4MSK);
  382. setbits_be32(&gpio->gpio_pdcnt,
  383. GPIO_PDCNT_URT1_RXD | GPIO_PDCNT_URT1_TXD);
  384. break;
  385. }
  386. }
  387. #if defined(CONFIG_CMD_NET)
  388. int fecpin_setclear(struct eth_device *dev, int setclear)
  389. {
  390. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  391. if (setclear) {
  392. setbits_be32(&gpio->gpio_pbcnt,
  393. GPIO_PBCNT_E_MDC | GPIO_PBCNT_E_RXER |
  394. GPIO_PBCNT_E_RXD1 | GPIO_PBCNT_E_RXD2 |
  395. GPIO_PBCNT_E_RXD3 | GPIO_PBCNT_E_TXD1 |
  396. GPIO_PBCNT_E_TXD2 | GPIO_PBCNT_E_TXD3);
  397. } else {
  398. }
  399. return 0;
  400. }
  401. #endif /* CONFIG_CMD_NET */
  402. #endif /* #if defined(CONFIG_M5272) */
  403. #if defined(CONFIG_M5275)
  404. /*
  405. * Breathe some life into the CPU...
  406. *
  407. * Set up the memory map,
  408. * initialize a bunch of registers,
  409. * initialize the UPM's
  410. */
  411. void cpu_init_f(void)
  412. {
  413. /*
  414. * if we come from RAM we assume the CPU is
  415. * already initialized.
  416. */
  417. #ifndef CONFIG_MONITOR_IS_IN_RAM
  418. wdog_t *wdog_reg = (wdog_t *) (MMAP_WDOG);
  419. gpio_t *gpio_reg = (gpio_t *) (MMAP_GPIO);
  420. /* Kill watchdog so we can initialize the PLL */
  421. out_be16(&wdog_reg->wcr, 0);
  422. /* FlexBus Chipselect */
  423. init_fbcs();
  424. #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
  425. #ifdef CONFIG_SYS_I2C_FSL
  426. CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR;
  427. CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
  428. #endif
  429. /* enable instruction cache now */
  430. icache_enable();
  431. }
  432. /*
  433. * initialize higher level parts of CPU like timers
  434. */
  435. int cpu_init_r(void)
  436. {
  437. return (0);
  438. }
  439. void uart_port_conf(int port)
  440. {
  441. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  442. /* Setup Ports: */
  443. switch (port) {
  444. case 0:
  445. clrbits_be16(&gpio->par_uart, UART0_ENABLE_MASK);
  446. setbits_be16(&gpio->par_uart, UART0_ENABLE_MASK);
  447. break;
  448. case 1:
  449. clrbits_be16(&gpio->par_uart, UART1_ENABLE_MASK);
  450. setbits_be16(&gpio->par_uart, UART1_ENABLE_MASK);
  451. break;
  452. case 2:
  453. clrbits_be16(&gpio->par_uart, UART2_ENABLE_MASK);
  454. setbits_be16(&gpio->par_uart, UART2_ENABLE_MASK);
  455. break;
  456. }
  457. }
  458. #if defined(CONFIG_CMD_NET)
  459. int fecpin_setclear(struct eth_device *dev, int setclear)
  460. {
  461. struct fec_info_s *info = (struct fec_info_s *) dev->priv;
  462. gpio_t *gpio = (gpio_t *)MMAP_GPIO;
  463. if (setclear) {
  464. /* Enable Ethernet pins */
  465. if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
  466. setbits_be16(&gpio->par_feci2c, 0x0f00);
  467. setbits_8(&gpio->par_fec0hl, 0xc0);
  468. } else {
  469. setbits_be16(&gpio->par_feci2c, 0x00a0);
  470. setbits_8(&gpio->par_fec1hl, 0xc0);
  471. }
  472. } else {
  473. if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
  474. clrbits_be16(&gpio->par_feci2c, 0x0f00);
  475. clrbits_8(&gpio->par_fec0hl, 0xc0);
  476. } else {
  477. clrbits_be16(&gpio->par_feci2c, 0x00a0);
  478. clrbits_8(&gpio->par_fec1hl, 0xc0);
  479. }
  480. }
  481. return 0;
  482. }
  483. #endif /* CONFIG_CMD_NET */
  484. #endif /* #if defined(CONFIG_M5275) */
  485. #if defined(CONFIG_M5282)
  486. /*
  487. * Breath some life into the CPU...
  488. *
  489. * Set up the memory map,
  490. * initialize a bunch of registers,
  491. * initialize the UPM's
  492. */
  493. void cpu_init_f(void)
  494. {
  495. #ifndef CONFIG_WATCHDOG
  496. /* disable watchdog if we aren't using it */
  497. MCFWTM_WCR = 0;
  498. #endif
  499. #ifndef CONFIG_MONITOR_IS_IN_RAM
  500. /* Set speed /PLL */
  501. MCFCLOCK_SYNCR =
  502. MCFCLOCK_SYNCR_MFD(CONFIG_SYS_MFD) |
  503. MCFCLOCK_SYNCR_RFD(CONFIG_SYS_RFD);
  504. while (!(MCFCLOCK_SYNSR & MCFCLOCK_SYNSR_LOCK)) ;
  505. MCFGPIO_PBCDPAR = 0xc0;
  506. /* Set up the GPIO ports */
  507. #ifdef CONFIG_SYS_PEPAR
  508. MCFGPIO_PEPAR = CONFIG_SYS_PEPAR;
  509. #endif
  510. #ifdef CONFIG_SYS_PFPAR
  511. MCFGPIO_PFPAR = CONFIG_SYS_PFPAR;
  512. #endif
  513. #ifdef CONFIG_SYS_PJPAR
  514. MCFGPIO_PJPAR = CONFIG_SYS_PJPAR;
  515. #endif
  516. #ifdef CONFIG_SYS_PSDPAR
  517. MCFGPIO_PSDPAR = CONFIG_SYS_PSDPAR;
  518. #endif
  519. #ifdef CONFIG_SYS_PASPAR
  520. MCFGPIO_PASPAR = CONFIG_SYS_PASPAR;
  521. #endif
  522. #ifdef CONFIG_SYS_PEHLPAR
  523. MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
  524. #endif
  525. #ifdef CONFIG_SYS_PQSPAR
  526. MCFGPIO_PQSPAR = CONFIG_SYS_PQSPAR;
  527. #endif
  528. #ifdef CONFIG_SYS_PTCPAR
  529. MCFGPIO_PTCPAR = CONFIG_SYS_PTCPAR;
  530. #endif
  531. #if defined(CONFIG_SYS_PORTTC)
  532. MCFGPIO_PORTTC = CONFIG_SYS_PORTTC;
  533. #endif
  534. #if defined(CONFIG_SYS_DDRTC)
  535. MCFGPIO_DDRTC = CONFIG_SYS_DDRTC;
  536. #endif
  537. #ifdef CONFIG_SYS_PTDPAR
  538. MCFGPIO_PTDPAR = CONFIG_SYS_PTDPAR;
  539. #endif
  540. #ifdef CONFIG_SYS_PUAPAR
  541. MCFGPIO_PUAPAR = CONFIG_SYS_PUAPAR;
  542. #endif
  543. #if defined(CONFIG_SYS_DDRD)
  544. MCFGPIO_DDRD = CONFIG_SYS_DDRD;
  545. #endif
  546. #ifdef CONFIG_SYS_DDRUA
  547. MCFGPIO_DDRUA = CONFIG_SYS_DDRUA;
  548. #endif
  549. /* FlexBus Chipselect */
  550. init_fbcs();
  551. #endif /* CONFIG_MONITOR_IS_IN_RAM */
  552. /* defer enabling cache until boot (see do_go) */
  553. /* icache_enable(); */
  554. }
  555. /*
  556. * initialize higher level parts of CPU like timers
  557. */
  558. int cpu_init_r(void)
  559. {
  560. return (0);
  561. }
  562. void uart_port_conf(int port)
  563. {
  564. /* Setup Ports: */
  565. switch (port) {
  566. case 0:
  567. MCFGPIO_PUAPAR &= 0xFc;
  568. MCFGPIO_PUAPAR |= 0x03;
  569. break;
  570. case 1:
  571. MCFGPIO_PUAPAR &= 0xF3;
  572. MCFGPIO_PUAPAR |= 0x0C;
  573. break;
  574. case 2:
  575. MCFGPIO_PASPAR &= 0xFF0F;
  576. MCFGPIO_PASPAR |= 0x00A0;
  577. break;
  578. }
  579. }
  580. #if defined(CONFIG_CMD_NET)
  581. int fecpin_setclear(struct eth_device *dev, int setclear)
  582. {
  583. if (setclear) {
  584. MCFGPIO_PASPAR |= 0x0F00;
  585. MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
  586. } else {
  587. MCFGPIO_PASPAR &= 0xF0FF;
  588. MCFGPIO_PEHLPAR &= ~CONFIG_SYS_PEHLPAR;
  589. }
  590. return 0;
  591. }
  592. #endif /* CONFIG_CMD_NET */
  593. #endif
  594. #if defined(CONFIG_M5249)
  595. /*
  596. * Breath some life into the CPU...
  597. *
  598. * Set up the memory map,
  599. * initialize a bunch of registers,
  600. * initialize the UPM's
  601. */
  602. void cpu_init_f(void)
  603. {
  604. /*
  605. * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins
  606. * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins
  607. * which is their primary function.
  608. * ~Jeremy
  609. */
  610. mbar2_writeLong(MCFSIM_GPIO_FUNC, CONFIG_SYS_GPIO_FUNC);
  611. mbar2_writeLong(MCFSIM_GPIO1_FUNC, CONFIG_SYS_GPIO1_FUNC);
  612. mbar2_writeLong(MCFSIM_GPIO_EN, CONFIG_SYS_GPIO_EN);
  613. mbar2_writeLong(MCFSIM_GPIO1_EN, CONFIG_SYS_GPIO1_EN);
  614. mbar2_writeLong(MCFSIM_GPIO_OUT, CONFIG_SYS_GPIO_OUT);
  615. mbar2_writeLong(MCFSIM_GPIO1_OUT, CONFIG_SYS_GPIO1_OUT);
  616. /*
  617. * dBug Compliance:
  618. * You can verify these values by using dBug's 'ird'
  619. * (Internal Register Display) command
  620. * ~Jeremy
  621. *
  622. */
  623. mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */
  624. mbar_writeByte(MCFSIM_SYPCR, 0x00);
  625. mbar_writeByte(MCFSIM_SWIVR, 0x0f);
  626. mbar_writeByte(MCFSIM_SWSR, 0x00);
  627. mbar_writeLong(MCFSIM_IMR, 0xfffffbff);
  628. mbar_writeByte(MCFSIM_SWDICR, 0x00);
  629. mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
  630. mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
  631. mbar_writeByte(MCFSIM_I2CICR, 0x00);
  632. mbar_writeByte(MCFSIM_UART1ICR, 0x00);
  633. mbar_writeByte(MCFSIM_UART2ICR, 0x00);
  634. mbar_writeByte(MCFSIM_ICR6, 0x00);
  635. mbar_writeByte(MCFSIM_ICR7, 0x00);
  636. mbar_writeByte(MCFSIM_ICR8, 0x00);
  637. mbar_writeByte(MCFSIM_ICR9, 0x00);
  638. mbar_writeByte(MCFSIM_QSPIICR, 0x00);
  639. mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
  640. mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
  641. mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
  642. mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */
  643. /* Setup interrupt priorities for gpio7 */
  644. /* mbar2_writeLong(MCFSIM_INTLEV5, 0x70000000); */
  645. /* IDE Config registers */
  646. mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020);
  647. mbar2_writeLong(MCFSIM_IDECONFIG2, 0x00000000);
  648. /* FlexBus Chipselect */
  649. init_fbcs();
  650. /* enable instruction cache now */
  651. icache_enable();
  652. }
  653. /*
  654. * initialize higher level parts of CPU like timers
  655. */
  656. int cpu_init_r(void)
  657. {
  658. return (0);
  659. }
  660. void uart_port_conf(int port)
  661. {
  662. }
  663. #endif /* #if defined(CONFIG_M5249) */