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