cpu_init.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  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_M5253)
  100. /*
  101. * Breath some life into the CPU...
  102. *
  103. * Set up the memory map,
  104. * initialize a bunch of registers,
  105. * initialize the UPM's
  106. */
  107. void cpu_init_f(void)
  108. {
  109. mbar_writeByte(MCFSIM_MPARK, 0x40); /* 5249 Internal Core takes priority over DMA */
  110. mbar_writeByte(MCFSIM_SYPCR, 0x00);
  111. mbar_writeByte(MCFSIM_SWIVR, 0x0f);
  112. mbar_writeByte(MCFSIM_SWSR, 0x00);
  113. mbar_writeByte(MCFSIM_SWDICR, 0x00);
  114. mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
  115. mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
  116. mbar_writeByte(MCFSIM_I2CICR, 0x00);
  117. mbar_writeByte(MCFSIM_UART1ICR, 0x00);
  118. mbar_writeByte(MCFSIM_UART2ICR, 0x00);
  119. mbar_writeByte(MCFSIM_ICR6, 0x00);
  120. mbar_writeByte(MCFSIM_ICR7, 0x00);
  121. mbar_writeByte(MCFSIM_ICR8, 0x00);
  122. mbar_writeByte(MCFSIM_ICR9, 0x00);
  123. mbar_writeByte(MCFSIM_QSPIICR, 0x00);
  124. mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
  125. mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
  126. mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
  127. /*mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); *//* Enable a 1 cycle pre-drive cycle on CS1 */
  128. /* FlexBus Chipselect */
  129. init_fbcs();
  130. #ifdef CONFIG_FSL_I2C
  131. CONFIG_SYS_I2C_PINMUX_REG =
  132. CONFIG_SYS_I2C_PINMUX_REG & CONFIG_SYS_I2C_PINMUX_CLR;
  133. CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
  134. #ifdef CONFIG_SYS_I2C2_OFFSET
  135. CONFIG_SYS_I2C2_PINMUX_REG &= CONFIG_SYS_I2C2_PINMUX_CLR;
  136. CONFIG_SYS_I2C2_PINMUX_REG |= CONFIG_SYS_I2C2_PINMUX_SET;
  137. #endif
  138. #endif
  139. /* enable instruction cache now */
  140. icache_enable();
  141. }
  142. /*initialize higher level parts of CPU like timers */
  143. int cpu_init_r(void)
  144. {
  145. return (0);
  146. }
  147. void uart_port_conf(void)
  148. {
  149. /* Setup Ports: */
  150. switch (CONFIG_SYS_UART_PORT) {
  151. case 0:
  152. break;
  153. case 1:
  154. break;
  155. case 2:
  156. break;
  157. }
  158. }
  159. #endif /* #if defined(CONFIG_M5253) */
  160. #if defined(CONFIG_M5271)
  161. void cpu_init_f(void)
  162. {
  163. #ifndef CONFIG_WATCHDOG
  164. /* Disable the watchdog if we aren't using it */
  165. mbar_writeShort(MCF_WTM_WCR, 0);
  166. #endif
  167. /* FlexBus Chipselect */
  168. init_fbcs();
  169. /* Set clockspeed to 100MHz */
  170. mbar_writeShort(MCF_FMPLL_SYNCR,
  171. MCF_FMPLL_SYNCR_MFD(0) | MCF_FMPLL_SYNCR_RFD(0));
  172. while (!mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK) ;
  173. }
  174. /*
  175. * initialize higher level parts of CPU like timers
  176. */
  177. int cpu_init_r(void)
  178. {
  179. return (0);
  180. }
  181. void uart_port_conf(void)
  182. {
  183. /* Setup Ports: */
  184. switch (CONFIG_SYS_UART_PORT) {
  185. case 0:
  186. mbar_writeShort(MCF_GPIO_PAR_UART, MCF_GPIO_PAR_UART_U0TXD |
  187. MCF_GPIO_PAR_UART_U0RXD);
  188. break;
  189. case 1:
  190. mbar_writeShort(MCF_GPIO_PAR_UART,
  191. MCF_GPIO_PAR_UART_U1RXD_UART1 |
  192. MCF_GPIO_PAR_UART_U1TXD_UART1);
  193. break;
  194. case 2:
  195. mbar_writeShort(MCF_GPIO_PAR_UART, 0x3000);
  196. break;
  197. }
  198. }
  199. #if defined(CONFIG_CMD_NET)
  200. int fecpin_setclear(struct eth_device *dev, int setclear)
  201. {
  202. if (setclear) {
  203. /* Enable Ethernet pins */
  204. mbar_writeByte(MCF_GPIO_PAR_FECI2C, CONFIG_SYS_FECI2C);
  205. } else {
  206. }
  207. return 0;
  208. }
  209. #endif /* CONFIG_CMD_NET */
  210. #endif
  211. #if defined(CONFIG_M5272)
  212. /*
  213. * Breath some life into the CPU...
  214. *
  215. * Set up the memory map,
  216. * initialize a bunch of registers,
  217. * initialize the UPM's
  218. */
  219. void cpu_init_f(void)
  220. {
  221. /* if we come from RAM we assume the CPU is
  222. * already initialized.
  223. */
  224. #ifndef CONFIG_MONITOR_IS_IN_RAM
  225. volatile sysctrl_t *sysctrl = (sysctrl_t *) (CONFIG_SYS_MBAR);
  226. volatile gpio_t *gpio = (gpio_t *) (MMAP_GPIO);
  227. volatile csctrl_t *csctrl = (csctrl_t *) (MMAP_FBCS);
  228. sysctrl->sc_scr = CONFIG_SYS_SCR;
  229. sysctrl->sc_spr = CONFIG_SYS_SPR;
  230. /* Setup Ports: */
  231. gpio->gpio_pacnt = CONFIG_SYS_PACNT;
  232. gpio->gpio_paddr = CONFIG_SYS_PADDR;
  233. gpio->gpio_padat = CONFIG_SYS_PADAT;
  234. gpio->gpio_pbcnt = CONFIG_SYS_PBCNT;
  235. gpio->gpio_pbddr = CONFIG_SYS_PBDDR;
  236. gpio->gpio_pbdat = CONFIG_SYS_PBDAT;
  237. gpio->gpio_pdcnt = CONFIG_SYS_PDCNT;
  238. /* Memory Controller: */
  239. csctrl->cs_br0 = CONFIG_SYS_BR0_PRELIM;
  240. csctrl->cs_or0 = CONFIG_SYS_OR0_PRELIM;
  241. #if (defined(CONFIG_SYS_OR1_PRELIM) && defined(CONFIG_SYS_BR1_PRELIM))
  242. csctrl->cs_br1 = CONFIG_SYS_BR1_PRELIM;
  243. csctrl->cs_or1 = CONFIG_SYS_OR1_PRELIM;
  244. #endif
  245. #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
  246. csctrl->cs_br2 = CONFIG_SYS_BR2_PRELIM;
  247. csctrl->cs_or2 = CONFIG_SYS_OR2_PRELIM;
  248. #endif
  249. #if defined(CONFIG_SYS_OR3_PRELIM) && defined(CONFIG_SYS_BR3_PRELIM)
  250. csctrl->cs_br3 = CONFIG_SYS_BR3_PRELIM;
  251. csctrl->cs_or3 = CONFIG_SYS_OR3_PRELIM;
  252. #endif
  253. #if defined(CONFIG_SYS_OR4_PRELIM) && defined(CONFIG_SYS_BR4_PRELIM)
  254. csctrl->cs_br4 = CONFIG_SYS_BR4_PRELIM;
  255. csctrl->cs_or4 = CONFIG_SYS_OR4_PRELIM;
  256. #endif
  257. #if defined(CONFIG_SYS_OR5_PRELIM) && defined(CONFIG_SYS_BR5_PRELIM)
  258. csctrl->cs_br5 = CONFIG_SYS_BR5_PRELIM;
  259. csctrl->cs_or5 = CONFIG_SYS_OR5_PRELIM;
  260. #endif
  261. #if defined(CONFIG_SYS_OR6_PRELIM) && defined(CONFIG_SYS_BR6_PRELIM)
  262. csctrl->cs_br6 = CONFIG_SYS_BR6_PRELIM;
  263. csctrl->cs_or6 = CONFIG_SYS_OR6_PRELIM;
  264. #endif
  265. #if defined(CONFIG_SYS_OR7_PRELIM) && defined(CONFIG_SYS_BR7_PRELIM)
  266. csctrl->cs_br7 = CONFIG_SYS_BR7_PRELIM;
  267. csctrl->cs_or7 = CONFIG_SYS_OR7_PRELIM;
  268. #endif
  269. #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
  270. /* enable instruction cache now */
  271. icache_enable();
  272. }
  273. /*
  274. * initialize higher level parts of CPU like timers
  275. */
  276. int cpu_init_r(void)
  277. {
  278. return (0);
  279. }
  280. void uart_port_conf(void)
  281. {
  282. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  283. /* Setup Ports: */
  284. switch (CONFIG_SYS_UART_PORT) {
  285. case 0:
  286. gpio->gpio_pbcnt &= ~(GPIO_PBCNT_PB0MSK | GPIO_PBCNT_PB1MSK);
  287. gpio->gpio_pbcnt |= (GPIO_PBCNT_URT0_TXD | GPIO_PBCNT_URT0_RXD);
  288. break;
  289. case 1:
  290. gpio->gpio_pdcnt &= ~(GPIO_PDCNT_PD1MSK | GPIO_PDCNT_PD4MSK);
  291. gpio->gpio_pdcnt |= (GPIO_PDCNT_URT1_RXD | GPIO_PDCNT_URT1_TXD);
  292. break;
  293. }
  294. }
  295. #if defined(CONFIG_CMD_NET)
  296. int fecpin_setclear(struct eth_device *dev, int setclear)
  297. {
  298. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  299. if (setclear) {
  300. gpio->gpio_pbcnt |= GPIO_PBCNT_E_MDC | GPIO_PBCNT_E_RXER |
  301. GPIO_PBCNT_E_RXD1 | GPIO_PBCNT_E_RXD2 |
  302. GPIO_PBCNT_E_RXD3 | GPIO_PBCNT_E_TXD1 |
  303. GPIO_PBCNT_E_TXD2 | GPIO_PBCNT_E_TXD3;
  304. } else {
  305. }
  306. return 0;
  307. }
  308. #endif /* CONFIG_CMD_NET */
  309. #endif /* #if defined(CONFIG_M5272) */
  310. #if defined(CONFIG_M5275)
  311. /*
  312. * Breathe some life into the CPU...
  313. *
  314. * Set up the memory map,
  315. * initialize a bunch of registers,
  316. * initialize the UPM's
  317. */
  318. void cpu_init_f(void)
  319. {
  320. /*
  321. * if we come from RAM we assume the CPU is
  322. * already initialized.
  323. */
  324. #ifndef CONFIG_MONITOR_IS_IN_RAM
  325. volatile wdog_t *wdog_reg = (wdog_t *) (MMAP_WDOG);
  326. volatile gpio_t *gpio_reg = (gpio_t *) (MMAP_GPIO);
  327. /* Kill watchdog so we can initialize the PLL */
  328. wdog_reg->wcr = 0;
  329. /* FlexBus Chipselect */
  330. init_fbcs();
  331. #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
  332. #ifdef CONFIG_FSL_I2C
  333. CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR;
  334. CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
  335. #endif
  336. /* enable instruction cache now */
  337. icache_enable();
  338. }
  339. /*
  340. * initialize higher level parts of CPU like timers
  341. */
  342. int cpu_init_r(void)
  343. {
  344. return (0);
  345. }
  346. void uart_port_conf(void)
  347. {
  348. volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  349. /* Setup Ports: */
  350. switch (CONFIG_SYS_UART_PORT) {
  351. case 0:
  352. gpio->par_uart |= UART0_ENABLE_MASK;
  353. break;
  354. case 1:
  355. gpio->par_uart |= UART1_ENABLE_MASK;
  356. break;
  357. case 2:
  358. gpio->par_uart |= UART2_ENABLE_MASK;
  359. break;
  360. }
  361. }
  362. #if defined(CONFIG_CMD_NET)
  363. int fecpin_setclear(struct eth_device *dev, int setclear)
  364. {
  365. struct fec_info_s *info = (struct fec_info_s *) dev->priv;
  366. volatile gpio_t *gpio = (gpio_t *)MMAP_GPIO;
  367. if (setclear) {
  368. /* Enable Ethernet pins */
  369. if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
  370. gpio->par_feci2c |= 0x0F00;
  371. gpio->par_fec0hl |= 0xC0;
  372. } else {
  373. gpio->par_feci2c |= 0x00A0;
  374. gpio->par_fec1hl |= 0xC0;
  375. }
  376. } else {
  377. if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
  378. gpio->par_feci2c &= ~0x0F00;
  379. gpio->par_fec0hl &= ~0xC0;
  380. } else {
  381. gpio->par_feci2c &= ~0x00A0;
  382. gpio->par_fec1hl &= ~0xC0;
  383. }
  384. }
  385. return 0;
  386. }
  387. #endif /* CONFIG_CMD_NET */
  388. #endif /* #if defined(CONFIG_M5275) */
  389. #if defined(CONFIG_M5282)
  390. /*
  391. * Breath some life into the CPU...
  392. *
  393. * Set up the memory map,
  394. * initialize a bunch of registers,
  395. * initialize the UPM's
  396. */
  397. void cpu_init_f(void)
  398. {
  399. #ifndef CONFIG_WATCHDOG
  400. /* disable watchdog if we aren't using it */
  401. MCFWTM_WCR = 0;
  402. #endif
  403. #ifndef CONFIG_MONITOR_IS_IN_RAM
  404. /* Set speed /PLL */
  405. MCFCLOCK_SYNCR =
  406. MCFCLOCK_SYNCR_MFD(CONFIG_SYS_MFD) |
  407. MCFCLOCK_SYNCR_RFD(CONFIG_SYS_RFD);
  408. while (!(MCFCLOCK_SYNSR & MCFCLOCK_SYNSR_LOCK)) ;
  409. MCFGPIO_PBCDPAR = 0xc0;
  410. /* Set up the GPIO ports */
  411. #ifdef CONFIG_SYS_PEPAR
  412. MCFGPIO_PEPAR = CONFIG_SYS_PEPAR;
  413. #endif
  414. #ifdef CONFIG_SYS_PFPAR
  415. MCFGPIO_PFPAR = CONFIG_SYS_PFPAR;
  416. #endif
  417. #ifdef CONFIG_SYS_PJPAR
  418. MCFGPIO_PJPAR = CONFIG_SYS_PJPAR;
  419. #endif
  420. #ifdef CONFIG_SYS_PSDPAR
  421. MCFGPIO_PSDPAR = CONFIG_SYS_PSDPAR;
  422. #endif
  423. #ifdef CONFIG_SYS_PASPAR
  424. MCFGPIO_PASPAR = CONFIG_SYS_PASPAR;
  425. #endif
  426. #ifdef CONFIG_SYS_PEHLPAR
  427. MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
  428. #endif
  429. #ifdef CONFIG_SYS_PQSPAR
  430. MCFGPIO_PQSPAR = CONFIG_SYS_PQSPAR;
  431. #endif
  432. #ifdef CONFIG_SYS_PTCPAR
  433. MCFGPIO_PTCPAR = CONFIG_SYS_PTCPAR;
  434. #endif
  435. #ifdef CONFIG_SYS_PTDPAR
  436. MCFGPIO_PTDPAR = CONFIG_SYS_PTDPAR;
  437. #endif
  438. #ifdef CONFIG_SYS_PUAPAR
  439. MCFGPIO_PUAPAR = CONFIG_SYS_PUAPAR;
  440. #endif
  441. #ifdef CONFIG_SYS_DDRUA
  442. MCFGPIO_DDRUA = CONFIG_SYS_DDRUA;
  443. #endif
  444. /* FlexBus Chipselect */
  445. init_fbcs();
  446. #endif /* CONFIG_MONITOR_IS_IN_RAM */
  447. /* defer enabling cache until boot (see do_go) */
  448. /* icache_enable(); */
  449. }
  450. /*
  451. * initialize higher level parts of CPU like timers
  452. */
  453. int cpu_init_r(void)
  454. {
  455. return (0);
  456. }
  457. void uart_port_conf(void)
  458. {
  459. /* Setup Ports: */
  460. switch (CONFIG_SYS_UART_PORT) {
  461. case 0:
  462. MCFGPIO_PUAPAR &= 0xFc;
  463. MCFGPIO_PUAPAR |= 0x03;
  464. break;
  465. case 1:
  466. MCFGPIO_PUAPAR &= 0xF3;
  467. MCFGPIO_PUAPAR |= 0x0C;
  468. break;
  469. case 2:
  470. MCFGPIO_PASPAR &= 0xFF0F;
  471. MCFGPIO_PASPAR |= 0x00A0;
  472. break;
  473. }
  474. }
  475. #if defined(CONFIG_CMD_NET)
  476. int fecpin_setclear(struct eth_device *dev, int setclear)
  477. {
  478. if (setclear) {
  479. MCFGPIO_PASPAR |= 0x0F00;
  480. MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
  481. } else {
  482. MCFGPIO_PASPAR &= 0xF0FF;
  483. MCFGPIO_PEHLPAR &= ~CONFIG_SYS_PEHLPAR;
  484. }
  485. return 0;
  486. }
  487. #endif /* CONFIG_CMD_NET */
  488. #endif
  489. #if defined(CONFIG_M5249)
  490. /*
  491. * Breath some life into the CPU...
  492. *
  493. * Set up the memory map,
  494. * initialize a bunch of registers,
  495. * initialize the UPM's
  496. */
  497. void cpu_init_f(void)
  498. {
  499. /*
  500. * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins
  501. * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins
  502. * which is their primary function.
  503. * ~Jeremy
  504. */
  505. mbar2_writeLong(MCFSIM_GPIO_FUNC, CONFIG_SYS_GPIO_FUNC);
  506. mbar2_writeLong(MCFSIM_GPIO1_FUNC, CONFIG_SYS_GPIO1_FUNC);
  507. mbar2_writeLong(MCFSIM_GPIO_EN, CONFIG_SYS_GPIO_EN);
  508. mbar2_writeLong(MCFSIM_GPIO1_EN, CONFIG_SYS_GPIO1_EN);
  509. mbar2_writeLong(MCFSIM_GPIO_OUT, CONFIG_SYS_GPIO_OUT);
  510. mbar2_writeLong(MCFSIM_GPIO1_OUT, CONFIG_SYS_GPIO1_OUT);
  511. /*
  512. * dBug Compliance:
  513. * You can verify these values by using dBug's 'ird'
  514. * (Internal Register Display) command
  515. * ~Jeremy
  516. *
  517. */
  518. mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */
  519. mbar_writeByte(MCFSIM_SYPCR, 0x00);
  520. mbar_writeByte(MCFSIM_SWIVR, 0x0f);
  521. mbar_writeByte(MCFSIM_SWSR, 0x00);
  522. mbar_writeLong(MCFSIM_IMR, 0xfffffbff);
  523. mbar_writeByte(MCFSIM_SWDICR, 0x00);
  524. mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
  525. mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
  526. mbar_writeByte(MCFSIM_I2CICR, 0x00);
  527. mbar_writeByte(MCFSIM_UART1ICR, 0x00);
  528. mbar_writeByte(MCFSIM_UART2ICR, 0x00);
  529. mbar_writeByte(MCFSIM_ICR6, 0x00);
  530. mbar_writeByte(MCFSIM_ICR7, 0x00);
  531. mbar_writeByte(MCFSIM_ICR8, 0x00);
  532. mbar_writeByte(MCFSIM_ICR9, 0x00);
  533. mbar_writeByte(MCFSIM_QSPIICR, 0x00);
  534. mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
  535. mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
  536. mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
  537. mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */
  538. /* Setup interrupt priorities for gpio7 */
  539. /* mbar2_writeLong(MCFSIM_INTLEV5, 0x70000000); */
  540. /* IDE Config registers */
  541. mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020);
  542. mbar2_writeLong(MCFSIM_IDECONFIG2, 0x00000000);
  543. /* FlexBus Chipselect */
  544. init_fbcs();
  545. /* enable instruction cache now */
  546. icache_enable();
  547. }
  548. /*
  549. * initialize higher level parts of CPU like timers
  550. */
  551. int cpu_init_r(void)
  552. {
  553. return (0);
  554. }
  555. void uart_port_conf(void)
  556. {
  557. /* Setup Ports: */
  558. switch (CONFIG_SYS_UART_PORT) {
  559. case 0:
  560. break;
  561. case 1:
  562. break;
  563. }
  564. }
  565. #endif /* #if defined(CONFIG_M5249) */