cpu_init.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  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. /*
  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. icache_enable();
  185. }
  186. /*
  187. * initialize higher level parts of CPU like timers
  188. */
  189. int cpu_init_r(void)
  190. {
  191. #ifdef CONFIG_MCFRTC
  192. rtc_t *rtc = (rtc_t *)(CONFIG_SYS_MCFRTC_BASE);
  193. rtcex_t *rtcex = (rtcex_t *)&rtc->extended;
  194. out_be32(&rtcex->gocu, (CONFIG_SYS_RTC_OSCILLATOR >> 16) & 0xffff);
  195. out_be32(&rtcex->gocl, CONFIG_SYS_RTC_OSCILLATOR & 0xffff);
  196. #endif
  197. return (0);
  198. }
  199. void uart_port_conf(int port)
  200. {
  201. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  202. #ifdef CONFIG_MCF5441x
  203. pm_t *pm = (pm_t *) MMAP_PM;
  204. #endif
  205. /* Setup Ports: */
  206. switch (port) {
  207. #ifdef CONFIG_MCF5441x
  208. case 0:
  209. /* UART0 */
  210. out_8(&pm->pmcr0, 24);
  211. clrbits_8(&gpio->par_uart0,
  212. ~(GPIO_PAR_UART0_U0RXD_MASK | GPIO_PAR_UART0_U0TXD_MASK));
  213. setbits_8(&gpio->par_uart0,
  214. GPIO_PAR_UART0_U0RXD_U0RXD | GPIO_PAR_UART0_U0TXD_U0TXD);
  215. break;
  216. case 1:
  217. /* UART1 */
  218. out_8(&pm->pmcr0, 25);
  219. clrbits_8(&gpio->par_uart1,
  220. ~(GPIO_PAR_UART1_U1RXD_MASK | GPIO_PAR_UART1_U1TXD_MASK));
  221. setbits_8(&gpio->par_uart1,
  222. GPIO_PAR_UART1_U1RXD_U1RXD | GPIO_PAR_UART1_U1TXD_U1TXD);
  223. break;
  224. case 2:
  225. /* UART2 */
  226. out_8(&pm->pmcr0, 26);
  227. clrbits_8(&gpio->par_uart2,
  228. ~(GPIO_PAR_UART2_U2RXD_MASK | GPIO_PAR_UART2_U2TXD_MASK));
  229. setbits_8(&gpio->par_uart2,
  230. GPIO_PAR_UART2_U2RXD_U2RXD | GPIO_PAR_UART2_U2TXD_U2TXD);
  231. break;
  232. case 3:
  233. /* UART3 */
  234. out_8(&pm->pmcr0, 27);
  235. clrbits_8(&gpio->par_dspi0,
  236. ~(GPIO_PAR_DSPI0_SIN_MASK | GPIO_PAR_DSPI0_SOUT_MASK));
  237. setbits_8(&gpio->par_dspi0,
  238. GPIO_PAR_DSPI0_SIN_U3RXD | GPIO_PAR_DSPI0_SOUT_U3TXD);
  239. break;
  240. case 4:
  241. /* UART4 */
  242. out_8(&pm->pmcr1, 24);
  243. clrbits_8(&gpio->par_uart0,
  244. ~(GPIO_PAR_UART0_U0CTS_MASK | GPIO_PAR_UART0_U0RTS_MASK));
  245. setbits_8(&gpio->par_uart0,
  246. GPIO_PAR_UART0_U0CTS_U4TXD | GPIO_PAR_UART0_U0RTS_U4RXD);
  247. break;
  248. case 5:
  249. /* UART5 */
  250. out_8(&pm->pmcr1, 25);
  251. clrbits_8(&gpio->par_uart1,
  252. ~(GPIO_PAR_UART1_U1CTS_MASK | GPIO_PAR_UART1_U1RTS_MASK));
  253. setbits_8(&gpio->par_uart1,
  254. GPIO_PAR_UART1_U1CTS_U5TXD | GPIO_PAR_UART1_U1RTS_U5RXD);
  255. break;
  256. case 6:
  257. /* UART6 */
  258. out_8(&pm->pmcr1, 26);
  259. clrbits_8(&gpio->par_uart2,
  260. ~(GPIO_PAR_UART2_U2CTS_MASK | GPIO_PAR_UART2_U2RTS_MASK));
  261. setbits_8(&gpio->par_uart2,
  262. GPIO_PAR_UART2_U2CTS_U6TXD | GPIO_PAR_UART2_U2RTS_U6RXD);
  263. break;
  264. case 7:
  265. /* UART7 */
  266. out_8(&pm->pmcr1, 27);
  267. clrbits_8(&gpio->par_ssi0h, ~GPIO_PAR_SSI0H_RXD_MASK);
  268. clrbits_8(&gpio->par_ssi0l, ~GPIO_PAR_SSI0L_BCLK_MASK);
  269. setbits_8(&gpio->par_ssi0h, GPIO_PAR_SSI0H_FS_U7TXD);
  270. setbits_8(&gpio->par_ssi0l, GPIO_PAR_SSI0L_BCLK_U7RXD);
  271. break;
  272. case 8:
  273. /* UART8 */
  274. out_8(&pm->pmcr0, 28);
  275. clrbits_8(&gpio->par_cani2c,
  276. ~(GPIO_PAR_CANI2C_I2C0SCL_MASK | GPIO_PAR_CANI2C_I2C0SDA_MASK));
  277. setbits_8(&gpio->par_cani2c,
  278. GPIO_PAR_CANI2C_I2C0SCL_U8TXD | GPIO_PAR_CANI2C_I2C0SDA_U8RXD);
  279. break;
  280. case 9:
  281. /* UART9 */
  282. out_8(&pm->pmcr1, 29);
  283. clrbits_8(&gpio->par_cani2c,
  284. ~(GPIO_PAR_CANI2C_CAN1TX_MASK | GPIO_PAR_CANI2C_CAN1RX_MASK));
  285. setbits_8(&gpio->par_cani2c,
  286. GPIO_PAR_CANI2C_CAN1TX_U9TXD | GPIO_PAR_CANI2C_CAN1RX_U9RXD);
  287. break;
  288. #endif
  289. #ifdef CONFIG_MCF5445x
  290. case 0:
  291. clrbits_8(&gpio->par_uart,
  292. GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
  293. setbits_8(&gpio->par_uart,
  294. GPIO_PAR_UART_U0TXD_U0TXD | GPIO_PAR_UART_U0RXD_U0RXD);
  295. break;
  296. case 1:
  297. #ifdef CONFIG_SYS_UART1_PRI_GPIO
  298. clrbits_8(&gpio->par_uart,
  299. GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
  300. setbits_8(&gpio->par_uart,
  301. GPIO_PAR_UART_U1TXD_U1TXD | GPIO_PAR_UART_U1RXD_U1RXD);
  302. #elif defined(CONFIG_SYS_UART1_ALT1_GPIO)
  303. clrbits_be16(&gpio->par_ssi,
  304. ~(GPIO_PAR_SSI_SRXD_UNMASK | GPIO_PAR_SSI_STXD_UNMASK));
  305. setbits_be16(&gpio->par_ssi,
  306. GPIO_PAR_SSI_SRXD_U1RXD | GPIO_PAR_SSI_STXD_U1TXD);
  307. #endif
  308. break;
  309. case 2:
  310. #if defined(CONFIG_SYS_UART2_ALT1_GPIO)
  311. clrbits_8(&gpio->par_timer,
  312. ~(GPIO_PAR_TIMER_T3IN_UNMASK | GPIO_PAR_TIMER_T2IN_UNMASK));
  313. setbits_8(&gpio->par_timer,
  314. GPIO_PAR_TIMER_T3IN_U2RXD | GPIO_PAR_TIMER_T2IN_U2TXD);
  315. #elif defined(CONFIG_SYS_UART2_ALT2_GPIO)
  316. clrbits_8(&gpio->par_timer,
  317. ~(GPIO_PAR_FECI2C_SCL_UNMASK | GPIO_PAR_FECI2C_SDA_UNMASK));
  318. setbits_8(&gpio->par_timer,
  319. GPIO_PAR_FECI2C_SCL_U2TXD | GPIO_PAR_FECI2C_SDA_U2RXD);
  320. #endif
  321. break;
  322. #endif /* CONFIG_MCF5445x */
  323. }
  324. }
  325. #if defined(CONFIG_CMD_NET)
  326. int fecpin_setclear(struct eth_device *dev, int setclear)
  327. {
  328. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  329. #ifdef CONFIG_MCF5445x
  330. struct fec_info_s *info = (struct fec_info_s *)dev->priv;
  331. if (setclear) {
  332. #ifdef CONFIG_SYS_FEC_NO_SHARED_PHY
  333. if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
  334. setbits_be16(&gpio->par_feci2c,
  335. GPIO_PAR_FECI2C_MDC0_MDC0 |
  336. GPIO_PAR_FECI2C_MDIO0_MDIO0);
  337. else
  338. setbits_be16(&gpio->par_feci2c,
  339. GPIO_PAR_FECI2C_MDC1_MDC1 |
  340. GPIO_PAR_FECI2C_MDIO1_MDIO1);
  341. #else
  342. setbits_be16(&gpio->par_feci2c,
  343. GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
  344. #endif
  345. if (info->iobase == CONFIG_SYS_FEC0_IOBASE)
  346. setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_RMII_GPIO);
  347. else
  348. setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_RMII_ATA);
  349. } else {
  350. clrbits_be16(&gpio->par_feci2c,
  351. GPIO_PAR_FECI2C_MDC0_MDC0 | GPIO_PAR_FECI2C_MDIO0_MDIO0);
  352. if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
  353. #ifdef CONFIG_SYS_FEC_FULL_MII
  354. setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC0_MII);
  355. #else
  356. clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC0_UNMASK);
  357. #endif
  358. } else {
  359. #ifdef CONFIG_SYS_FEC_FULL_MII
  360. setbits_8(&gpio->par_fec, GPIO_PAR_FEC_FEC1_MII);
  361. #else
  362. clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC1_UNMASK);
  363. #endif
  364. }
  365. }
  366. #endif /* CONFIG_MCF5445x */
  367. #ifdef CONFIG_MCF5441x
  368. if (setclear) {
  369. out_8(&gpio->par_fec, 0x03);
  370. out_8(&gpio->srcr_fec, 0x0F);
  371. clrsetbits_8(&gpio->par_simp0h, ~GPIO_PAR_SIMP0H_DAT_MASK,
  372. GPIO_PAR_SIMP0H_DAT_GPIO);
  373. clrsetbits_8(&gpio->pddr_g, ~GPIO_PDDR_G4_MASK,
  374. GPIO_PDDR_G4_OUTPUT);
  375. clrbits_8(&gpio->podr_g, ~GPIO_PODR_G4_MASK);
  376. } else
  377. clrbits_8(&gpio->par_fec, ~GPIO_PAR_FEC_FEC_MASK);
  378. #endif
  379. return 0;
  380. }
  381. #endif
  382. #ifdef CONFIG_CF_DSPI
  383. void cfspi_port_conf(void)
  384. {
  385. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  386. #ifdef CONFIG_MCF5445x
  387. out_8(&gpio->par_dspi,
  388. GPIO_PAR_DSPI_SIN_SIN |
  389. GPIO_PAR_DSPI_SOUT_SOUT |
  390. GPIO_PAR_DSPI_SCK_SCK);
  391. #endif
  392. #ifdef CONFIG_MCF5441x
  393. pm_t *pm = (pm_t *) MMAP_PM;
  394. out_8(&gpio->par_dspi0,
  395. GPIO_PAR_DSPI0_SIN_DSPI0SIN | GPIO_PAR_DSPI0_SOUT_DSPI0SOUT |
  396. GPIO_PAR_DSPI0_SCK_DSPI0SCK);
  397. out_8(&gpio->srcr_dspiow, 3);
  398. /* DSPI0 */
  399. out_8(&pm->pmcr0, 23);
  400. #endif
  401. }
  402. int cfspi_claim_bus(uint bus, uint cs)
  403. {
  404. dspi_t *dspi = (dspi_t *) MMAP_DSPI;
  405. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  406. if ((in_be32(&dspi->sr) & DSPI_SR_TXRXS) != DSPI_SR_TXRXS)
  407. return -1;
  408. /* Clear FIFO and resume transfer */
  409. clrbits_be32(&dspi->mcr, DSPI_MCR_CTXF | DSPI_MCR_CRXF);
  410. #ifdef CONFIG_MCF5445x
  411. switch (cs) {
  412. case 0:
  413. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
  414. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
  415. break;
  416. case 1:
  417. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
  418. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
  419. break;
  420. case 2:
  421. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
  422. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
  423. break;
  424. case 3:
  425. clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK);
  426. setbits_8(&gpio->par_dma, GPIO_PAR_DMA_DACK0_PCS3);
  427. break;
  428. case 5:
  429. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
  430. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
  431. break;
  432. }
  433. #endif
  434. #ifdef CONFIG_MCF5441x
  435. switch (cs) {
  436. case 0:
  437. clrbits_8(&gpio->par_dspi0, ~GPIO_PAR_DSPI0_PCS0_MASK);
  438. setbits_8(&gpio->par_dspi0, GPIO_PAR_DSPI0_PCS0_DSPI0PCS0);
  439. break;
  440. case 1:
  441. clrbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1);
  442. setbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1);
  443. break;
  444. }
  445. #endif
  446. return 0;
  447. }
  448. void cfspi_release_bus(uint bus, uint cs)
  449. {
  450. dspi_t *dspi = (dspi_t *) MMAP_DSPI;
  451. gpio_t *gpio = (gpio_t *) MMAP_GPIO;
  452. /* Clear FIFO */
  453. clrbits_be32(&dspi->mcr, DSPI_MCR_CTXF | DSPI_MCR_CRXF);
  454. #ifdef CONFIG_MCF5445x
  455. switch (cs) {
  456. case 0:
  457. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
  458. break;
  459. case 1:
  460. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
  461. break;
  462. case 2:
  463. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
  464. break;
  465. case 3:
  466. clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK);
  467. break;
  468. case 5:
  469. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
  470. break;
  471. }
  472. #endif
  473. #ifdef CONFIG_MCF5441x
  474. if (cs == 1)
  475. clrbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1);
  476. #endif
  477. }
  478. #endif