cpu_init.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. /*
  2. *
  3. * (C) Copyright 2000-2003
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * (C) Copyright 2004-2007, 2012 Freescale Semiconductor, Inc.
  7. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <common.h>
  12. #include <watchdog.h>
  13. #include <asm/immap.h>
  14. #include <asm/processor.h>
  15. #include <asm/rtc.h>
  16. #include <asm/io.h>
  17. #include <linux/compiler.h>
  18. #if defined(CONFIG_CMD_NET)
  19. #include <config.h>
  20. #include <net.h>
  21. #include <asm/fec.h>
  22. #endif
  23. void init_fbcs(void)
  24. {
  25. fbcs_t *fbcs __maybe_unused = (fbcs_t *) MMAP_FBCS;
  26. #if !defined(CONFIG_SERIAL_BOOT)
  27. #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) && defined(CONFIG_SYS_CS0_CTRL))
  28. out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
  29. out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
  30. out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
  31. #endif
  32. #endif
  33. #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) && defined(CONFIG_SYS_CS1_CTRL))
  34. /* Latch chipselect */
  35. out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
  36. out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
  37. out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
  38. #endif
  39. #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) && defined(CONFIG_SYS_CS2_CTRL))
  40. out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
  41. out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
  42. out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
  43. #endif
  44. #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) && defined(CONFIG_SYS_CS3_CTRL))
  45. out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
  46. out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
  47. out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
  48. #endif
  49. #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) && defined(CONFIG_SYS_CS4_CTRL))
  50. out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
  51. out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
  52. out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
  53. #endif
  54. #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) && defined(CONFIG_SYS_CS5_CTRL))
  55. out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
  56. out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
  57. out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
  58. #endif
  59. }
  60. /*
  61. * Breath some life into the CPU...
  62. *
  63. * Set up the memory map,
  64. * initialize a bunch of registers,
  65. * initialize the UPM's
  66. */
  67. void cpu_init_f(void)
  68. {
  69. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  70. #ifdef CONFIG_MCF5441x
  71. scm_t *scm = (scm_t *) MMAP_SCM;
  72. pm_t *pm = (pm_t *) MMAP_PM;
  73. /* Disable Switch */
  74. *(unsigned long *)(MMAP_L2_SW0 + 0x00000024) = 0;
  75. /* Disable core watchdog */
  76. out_be16(&scm->cwcr, 0);
  77. out_8(&gpio->par_fbctl,
  78. GPIO_PAR_FBCTL_ALE_FB_ALE | GPIO_PAR_FBCTL_OE_FB_OE |
  79. GPIO_PAR_FBCTL_FBCLK | GPIO_PAR_FBCTL_RW |
  80. GPIO_PAR_FBCTL_TA_TA);
  81. out_8(&gpio->par_be,
  82. GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 |
  83. GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0);
  84. /* eDMA */
  85. out_8(&pm->pmcr0, 17);
  86. /* INTR0 - INTR2 */
  87. out_8(&pm->pmcr0, 18);
  88. out_8(&pm->pmcr0, 19);
  89. out_8(&pm->pmcr0, 20);
  90. /* I2C */
  91. out_8(&pm->pmcr0, 22);
  92. out_8(&pm->pmcr1, 4);
  93. out_8(&pm->pmcr1, 7);
  94. /* DTMR0 - DTMR3*/
  95. out_8(&pm->pmcr0, 28);
  96. out_8(&pm->pmcr0, 29);
  97. out_8(&pm->pmcr0, 30);
  98. out_8(&pm->pmcr0, 31);
  99. /* PIT0 - PIT3 */
  100. out_8(&pm->pmcr0, 32);
  101. out_8(&pm->pmcr0, 33);
  102. out_8(&pm->pmcr0, 34);
  103. out_8(&pm->pmcr0, 35);
  104. /* Edge Port */
  105. out_8(&pm->pmcr0, 36);
  106. out_8(&pm->pmcr0, 37);
  107. /* USB OTG */
  108. out_8(&pm->pmcr0, 44);
  109. /* USB Host */
  110. out_8(&pm->pmcr0, 45);
  111. /* ESDHC */
  112. out_8(&pm->pmcr0, 51);
  113. /* ENET0 - ENET1 */
  114. out_8(&pm->pmcr0, 53);
  115. out_8(&pm->pmcr0, 54);
  116. /* NAND */
  117. out_8(&pm->pmcr0, 63);
  118. #ifdef CONFIG_SYS_I2C_0
  119. out_8(&gpio->par_cani2c, 0xF0);
  120. /* I2C0 pull up */
  121. out_be16(&gpio->pcr_b, 0x003C);
  122. /* I2C0 max speed */
  123. out_8(&gpio->srcr_cani2c, 0x03);
  124. #endif
  125. #ifdef CONFIG_SYS_I2C_2
  126. /* I2C2 */
  127. out_8(&gpio->par_ssi0h, 0xA0);
  128. /* I2C2, UART7 */
  129. out_8(&gpio->par_ssi0h, 0xA8);
  130. /* UART7 */
  131. out_8(&gpio->par_ssi0l, 0x2);
  132. /* UART8, UART9 */
  133. out_8(&gpio->par_cani2c, 0xAA);
  134. /* UART4, UART0 */
  135. out_8(&gpio->par_uart0, 0xAF);
  136. /* UART5, UART1 */
  137. out_8(&gpio->par_uart1, 0xAF);
  138. /* UART6, UART2 */
  139. out_8(&gpio->par_uart2, 0xAF);
  140. /* I2C2 pull up */
  141. out_be16(&gpio->pcr_h, 0xF000);
  142. #endif
  143. #ifdef CONFIG_SYS_I2C_5
  144. /* I2C5 */
  145. out_8(&gpio->par_uart1, 0x0A);
  146. /* I2C5 pull up */
  147. out_be16(&gpio->pcr_e, 0x0003);
  148. out_be16(&gpio->pcr_f, 0xC000);
  149. #endif
  150. /* Lowest slew rate for UART0,1,2 */
  151. out_8(&gpio->srcr_uart, 0x00);
  152. #endif /* CONFIG_MCF5441x */
  153. #ifdef CONFIG_MCF5445x
  154. scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
  155. out_be32(&scm1->mpr, 0x77777777);
  156. out_be32(&scm1->pacra, 0);
  157. out_be32(&scm1->pacrb, 0);
  158. out_be32(&scm1->pacrc, 0);
  159. out_be32(&scm1->pacrd, 0);
  160. out_be32(&scm1->pacre, 0);
  161. out_be32(&scm1->pacrf, 0);
  162. out_be32(&scm1->pacrg, 0);
  163. /* FlexBus */
  164. out_8(&gpio->par_be,
  165. GPIO_PAR_BE_BE3_BE3 | GPIO_PAR_BE_BE2_BE2 |
  166. GPIO_PAR_BE_BE1_BE1 | GPIO_PAR_BE_BE0_BE0);
  167. out_8(&gpio->par_fbctl,
  168. GPIO_PAR_FBCTL_OE | GPIO_PAR_FBCTL_TA_TA |
  169. GPIO_PAR_FBCTL_RW_RW | GPIO_PAR_FBCTL_TS_TS);
  170. #ifdef CONFIG_SYS_FSL_I2C
  171. out_be16(&gpio->par_feci2c,
  172. GPIO_PAR_FECI2C_SCL_SCL | GPIO_PAR_FECI2C_SDA_SDA);
  173. #endif
  174. #endif /* CONFIG_MCF5445x */
  175. /* FlexBus Chipselect */
  176. init_fbcs();
  177. #ifdef CONFIG_SYS_CS0_BASE
  178. /*
  179. * now the flash base address is no longer at 0 (Newer ColdFire family
  180. * boot at address 0 instead of 0xFFnn_nnnn). The vector table must
  181. * also move to the new location.
  182. */
  183. if (CONFIG_SYS_CS0_BASE != 0)
  184. setvbr(CONFIG_SYS_CS0_BASE);
  185. #endif
  186. icache_enable();
  187. }
  188. /*
  189. * initialize higher level parts of CPU like timers
  190. */
  191. int cpu_init_r(void)
  192. {
  193. #ifdef CONFIG_MCFRTC
  194. rtc_t *rtc = (rtc_t *)(CONFIG_SYS_MCFRTC_BASE);
  195. rtcex_t *rtcex = (rtcex_t *)&rtc->extended;
  196. out_be32(&rtcex->gocu, (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xffff);
  197. out_be32(&rtcex->gocl, CONFIG_SYS_RTC_OSCILLATOR & 0xffff);
  198. #endif
  199. return (0);
  200. }
  201. void uart_port_conf(int port)
  202. {
  203. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  204. #ifdef CONFIG_MCF5441x
  205. pm_t *pm = (pm_t *) MMAP_PM;
  206. #endif
  207. /* Setup Ports: */
  208. switch (port) {
  209. #ifdef CONFIG_MCF5441x
  210. case 0:
  211. /* UART0 */
  212. out_8(&pm->pmcr0, 24);
  213. clrbits_8(&gpio->par_uart0,
  214. ~(GPIO_PAR_UART0_U0RXD_MASK | GPIO_PAR_UART0_U0TXD_MASK));
  215. setbits_8(&gpio->par_uart0,
  216. GPIO_PAR_UART0_U0RXD_U0RXD | GPIO_PAR_UART0_U0TXD_U0TXD);
  217. break;
  218. case 1:
  219. /* UART1 */
  220. out_8(&pm->pmcr0, 25);
  221. clrbits_8(&gpio->par_uart1,
  222. ~(GPIO_PAR_UART1_U1RXD_MASK | GPIO_PAR_UART1_U1TXD_MASK));
  223. setbits_8(&gpio->par_uart1,
  224. GPIO_PAR_UART1_U1RXD_U1RXD | GPIO_PAR_UART1_U1TXD_U1TXD);
  225. break;
  226. case 2:
  227. /* UART2 */
  228. out_8(&pm->pmcr0, 26);
  229. clrbits_8(&gpio->par_uart2,
  230. ~(GPIO_PAR_UART2_U2RXD_MASK | GPIO_PAR_UART2_U2TXD_MASK));
  231. setbits_8(&gpio->par_uart2,
  232. GPIO_PAR_UART2_U2RXD_U2RXD | GPIO_PAR_UART2_U2TXD_U2TXD);
  233. break;
  234. case 3:
  235. /* UART3 */
  236. out_8(&pm->pmcr0, 27);
  237. clrbits_8(&gpio->par_dspi0,
  238. ~(GPIO_PAR_DSPI0_SIN_MASK | GPIO_PAR_DSPI0_SOUT_MASK));
  239. setbits_8(&gpio->par_dspi0,
  240. GPIO_PAR_DSPI0_SIN_U3RXD | GPIO_PAR_DSPI0_SOUT_U3TXD);
  241. break;
  242. case 4:
  243. /* UART4 */
  244. out_8(&pm->pmcr1, 24);
  245. clrbits_8(&gpio->par_uart0,
  246. ~(GPIO_PAR_UART0_U0CTS_MASK | GPIO_PAR_UART0_U0RTS_MASK));
  247. setbits_8(&gpio->par_uart0,
  248. GPIO_PAR_UART0_U0CTS_U4TXD | GPIO_PAR_UART0_U0RTS_U4RXD);
  249. break;
  250. case 5:
  251. /* UART5 */
  252. out_8(&pm->pmcr1, 25);
  253. clrbits_8(&gpio->par_uart1,
  254. ~(GPIO_PAR_UART1_U1CTS_MASK | GPIO_PAR_UART1_U1RTS_MASK));
  255. setbits_8(&gpio->par_uart1,
  256. GPIO_PAR_UART1_U1CTS_U5TXD | GPIO_PAR_UART1_U1RTS_U5RXD);
  257. break;
  258. case 6:
  259. /* UART6 */
  260. out_8(&pm->pmcr1, 26);
  261. clrbits_8(&gpio->par_uart2,
  262. ~(GPIO_PAR_UART2_U2CTS_MASK | GPIO_PAR_UART2_U2RTS_MASK));
  263. setbits_8(&gpio->par_uart2,
  264. GPIO_PAR_UART2_U2CTS_U6TXD | GPIO_PAR_UART2_U2RTS_U6RXD);
  265. break;
  266. case 7:
  267. /* UART7 */
  268. out_8(&pm->pmcr1, 27);
  269. clrbits_8(&gpio->par_ssi0h, ~GPIO_PAR_SSI0H_RXD_MASK);
  270. clrbits_8(&gpio->par_ssi0l, ~GPIO_PAR_SSI0L_BCLK_MASK);
  271. setbits_8(&gpio->par_ssi0h, GPIO_PAR_SSI0H_FS_U7TXD);
  272. setbits_8(&gpio->par_ssi0l, GPIO_PAR_SSI0L_BCLK_U7RXD);
  273. break;
  274. case 8:
  275. /* UART8 */
  276. out_8(&pm->pmcr0, 28);
  277. clrbits_8(&gpio->par_cani2c,
  278. ~(GPIO_PAR_CANI2C_I2C0SCL_MASK | GPIO_PAR_CANI2C_I2C0SDA_MASK));
  279. setbits_8(&gpio->par_cani2c,
  280. GPIO_PAR_CANI2C_I2C0SCL_U8TXD | GPIO_PAR_CANI2C_I2C0SDA_U8RXD);
  281. break;
  282. case 9:
  283. /* UART9 */
  284. out_8(&pm->pmcr1, 29);
  285. clrbits_8(&gpio->par_cani2c,
  286. ~(GPIO_PAR_CANI2C_CAN1TX_MASK | GPIO_PAR_CANI2C_CAN1RX_MASK));
  287. setbits_8(&gpio->par_cani2c,
  288. GPIO_PAR_CANI2C_CAN1TX_U9TXD | GPIO_PAR_CANI2C_CAN1RX_U9RXD);
  289. break;
  290. #endif
  291. #ifdef CONFIG_MCF5445x
  292. case 0:
  293. clrbits_8(&gpio->par_uart,
  294. GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
  295. setbits_8(&gpio->par_uart,
  296. GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
  297. break;
  298. case 1:
  299. #ifdef CONFIG_SYS_UART1_PRI_GPIO
  300. clrbits_8(&gpio->par_uart,
  301. GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
  302. setbits_8(&gpio->par_uart,
  303. GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
  304. #elif defined(CONFIG_SYS_UART1_ALT1_GPIO)
  305. clrbits_be16(&gpio->par_ssi,
  306. ~(GPIO_PAR_SSI_SRXD_UNMASK | GPIO_PAR_SSI_STXD_UNMASK));
  307. setbits_be16(&gpio->par_ssi,
  308. GPIO_PAR_SSI_SRXD_U1RXD | GPIO_PAR_SSI_STXD_U1TXD);
  309. #endif
  310. break;
  311. case 2:
  312. #if defined(CONFIG_SYS_UART2_ALT1_GPIO)
  313. clrbits_8(&gpio->par_timer,
  314. ~(GPIO_PAR_TIMER_T3IN_UNMASK | GPIO_PAR_TIMER_T2IN_UNMASK));
  315. setbits_8(&gpio->par_timer,
  316. GPIO_PAR_TIMER_T3IN_U2RXD | GPIO_PAR_TIMER_T2IN_U2TXD);
  317. #elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
  318. clrbits_8(&gpio->par_timer,
  319. ~(GPIO_PAR_FECI2C_SCL_UNMASK | GPIO_PAR_FECI2C_SDA_UNMASK));
  320. setbits_8(&gpio->par_timer,
  321. GPIO_PAR_FECI2C_SCL_U2TXD | GPIO_PAR_FECI2C_SDA_U2RXD);
  322. #endif
  323. break;
  324. #endif /* CONFIG_MCF5445x */
  325. }
  326. }
  327. #if defined(CONFIG_CMD_NET)
  328. int fecpin_setclear(struct eth_device *dev, int setclear)
  329. {
  330. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  331. #ifdef CONFIG_MCF5445x
  332. struct fec_info_s *info = (struct fec_info_s *)dev->priv;
  333. if (setclear) {
  334. #ifdef CONFIG_SYS_FEC_NO_SHARED_PHY
  335. if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
  336. setbits_be16(&gpio->par_feci2c,
  337. GPIO_PAR_FECI2C_MDC0_MDC0 |
  338. GPIO_PAR_FECI2C_MDIO0_MDIO0);
  339. else
  340. setbits_be16(&gpio->par_feci2c,
  341. GPIO_PAR_FECI2C_MDC1_MDC1 |
  342. GPIO_PAR_FECI2C_MDIO1_MDIO1);
  343. #else
  344. setbits_be16(&gpio->par_feci2c,
  345. GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
  346. #endif
  347. if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
  348. setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_RMII_GPIO);
  349. else
  350. setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_RMII_ATA);
  351. } else {
  352. clrbits_be16(&gpio->par_feci2c,
  353. GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
  354. if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
  355. #ifdef CONFIG_SYS_FEC_FULL_MII
  356. setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_MII);
  357. #else
  358. clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC0_UNMASK);
  359. #endif
  360. } else {
  361. #ifdef CONFIG_SYS_FEC_FULL_MII
  362. setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_MII);
  363. #else
  364. clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC1_UNMASK);
  365. #endif
  366. }
  367. }
  368. #endif /* CONFIG_MCF5445x */
  369. #ifdef CONFIG_MCF5441x
  370. if (setclear) {
  371. out_8(&gpio->par_fec, 0x03);
  372. out_8(&gpio->srcr_fec, 0x0F);
  373. clrsetbits_8(&gpio->par_simp0h, ~GPIO_PAR_SIMP0H_DAT_MASK,
  374. GPIO_PAR_SIMP0H_DAT_GPIO);
  375. clrsetbits_8(&gpio->pddr_g, ~GPIO_PDDR_G4_MASK,
  376. GPIO_PDDR_G4_OUTPUT);
  377. clrbits_8(&gpio->podr_g, ~GPIO_PODR_G4_MASK);
  378. } else
  379. clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC_MASK);
  380. #endif
  381. return 0;
  382. }
  383. #endif
  384. #ifdef CONFIG_CF_DSPI
  385. void cfspi_port_conf(void)
  386. {
  387. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  388. #ifdef CONFIG_MCF5445x
  389. out_8(&gpio->par_dspi,
  390. GPIO_PAR_DSPI_SIN_SIN |
  391. GPIO_PAR_DSPI_SOUT_SOUT |
  392. GPIO_PAR_DSPI_SCK_SCK);
  393. #endif
  394. #ifdef CONFIG_MCF5441x
  395. pm_t *pm = (pm_t *) MMAP_PM;
  396. out_8(&gpio->par_dspi0,
  397. GPIO_PAR_DSPI0_SIN_DSPI0SIN | GPIO_PAR_DSPI0_SOUT_DSPI0SOUT |
  398. GPIO_PAR_DSPI0_SCK_DSPI0SCK);
  399. out_8(&gpio->srcr_dspiow, 3);
  400. /* DSPI0 */
  401. out_8(&pm->pmcr0, 23);
  402. #endif
  403. }
  404. int cfspi_claim_bus(uint bus, uint cs)
  405. {
  406. dspi_t *dspi = (dspi_t *) MMAP_DSPI;
  407. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  408. if ((in_be32(&dspi->sr) & DSPI_SR_TXRXS) != DSPI_SR_TXRXS)
  409. return -1;
  410. /* Clear FIFO and resume transfer */
  411. clrbits_be32(&dspi->mcr, DSPI_MCR_CTXF | DSPI_MCR_CRXF);
  412. #ifdef CONFIG_MCF5445x
  413. switch (cs) {
  414. case 0:
  415. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
  416. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
  417. break;
  418. case 1:
  419. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
  420. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
  421. break;
  422. case 2:
  423. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
  424. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
  425. break;
  426. case 3:
  427. clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK);
  428. setbits_8(&gpio->par_dma, GPIO_PAR_DMA_DACK0_PCS3);
  429. break;
  430. case 5:
  431. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
  432. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
  433. break;
  434. }
  435. #endif
  436. #ifdef CONFIG_MCF5441x
  437. switch (cs) {
  438. case 0:
  439. clrbits_8(&gpio->par_dspi0, ~GPIO_PAR_DSPI0_PCS0_MASK);
  440. setbits_8(&gpio->par_dspi0, GPIO_PAR_DSPI0_PCS0_DSPI0PCS0);
  441. break;
  442. case 1:
  443. clrbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1);
  444. setbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1);
  445. break;
  446. }
  447. #endif
  448. return 0;
  449. }
  450. void cfspi_release_bus(uint bus, uint cs)
  451. {
  452. dspi_t *dspi = (dspi_t *) MMAP_DSPI;
  453. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  454. /* Clear FIFO */
  455. clrbits_be32(&dspi->mcr, DSPI_MCR_CTXF | DSPI_MCR_CRXF);
  456. #ifdef CONFIG_MCF5445x
  457. switch (cs) {
  458. case 0:
  459. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
  460. break;
  461. case 1:
  462. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
  463. break;
  464. case 2:
  465. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
  466. break;
  467. case 3:
  468. clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK);
  469. break;
  470. case 5:
  471. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
  472. break;
  473. }
  474. #endif
  475. #ifdef CONFIG_MCF5441x
  476. if (cs == 1)
  477. clrbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1);
  478. #endif
  479. }
  480. #endif