cpu_init.c 18 KB

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