cpu_init.c 18 KB

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