cpu_init.c 18 KB

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