cpu_init.c 16 KB

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