cpu_init.c 14 KB

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