cpu_init.c 16 KB

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