cpu_init.c 19 KB

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