]> git.sur5r.net Git - freertos/blob - Demo/MCF5235_GCC/system/init.c
Update version numbers to V4.8.0
[freertos] / Demo / MCF5235_GCC / system / init.c
1 /*\r
2     FreeRTOS MCF5235 port - Copyright (C) 2006 Christian Walter.\r
3 \r
4     This file is part of the FreeRTOS distribution.\r
5 \r
6     FreeRTOS is free software; you can redistribute it and/or modify\r
7     it under the terms of the GNU General Public License as published by\r
8     the Free Software Foundation; either version 2 of the License, or\r
9     (at your option) any later version.\r
10 \r
11     FreeRTOS is distributed in the hope that it will be useful,\r
12     but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14     GNU General Public License for more details.\r
15 \r
16     You should have received a copy of the GNU General Public License\r
17     along with FreeRTOS; if not, write to the Free Software\r
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
19 \r
20     A special exception to the GPL can be applied should you wish to distribute\r
21     a combined work that includes FreeRTOS, without being obliged to provide\r
22     the source code for any proprietary components.  See the licensing section\r
23     of http://www.FreeRTOS.org for full details of how and when the exception\r
24     can be applied.\r
25 \r
26         ***************************************************************************\r
27         ***************************************************************************\r
28         *                                                                                                                                                 *\r
29         * SAVE TIME AND MONEY!  Why not get us to quote to get FreeRTOS.org               *\r
30         * running on your hardware - or even write all or part of your application*\r
31         * for you?  See http://www.OpenRTOS.com for details.                                      *\r
32         *                                                                                                                                                 *\r
33         ***************************************************************************\r
34         ***************************************************************************\r
35 \r
36         Please ensure to read the configuration and relevant port sections of the\r
37         online documentation.\r
38 \r
39         http://www.FreeRTOS.org - Documentation, latest information, license and \r
40         contact details.\r
41 \r
42         http://www.SafeRTOS.com - A version that is certified for use in safety \r
43         critical systems.\r
44 \r
45         http://www.OpenRTOS.com - Commercial support, development, porting, \r
46         licensing and training services.\r
47 */\r
48 \r
49 #include "mcf5xxx.h"\r
50 #include "mcf523x.h"\r
51 \r
52 /* Function prototypes */\r
53 void            init_main( void );\r
54 static void     disable_interrupts( void );\r
55 static void     disable_watchdog_timer( void );\r
56 static void     disable_cache( void );\r
57 static void     init_ipsbar( void );\r
58 static void     init_basics( void );\r
59 static void     init_clock_config( void );\r
60 static void     init_chip_selects( void );\r
61 static void     init_bus_config( void );\r
62 static void     init_cache( void );\r
63 static void     init_eport( void );\r
64 static void     init_flexcan( void );\r
65 static void     init_power_management( void );\r
66 static void     init_dma_timers( void );\r
67 static void     init_interrupt_timers( void );\r
68 static void     init_watchdog_timers( void );\r
69 static void     init_pin_assignments( void );\r
70 static void     init_sdram_controller( void );\r
71 static void     init_interrupt_controller( void );\r
72 \r
73 \r
74 /*********************************************************************\r
75 * init_main - Main entry point for initialisation code               *\r
76 **********************************************************************/\r
77 void\r
78 init_main( void )\r
79 {\r
80 \r
81     /* Initialise base address of peripherals, VBR, etc */\r
82     init_ipsbar(  );\r
83     init_basics(  );\r
84     init_clock_config(  );\r
85 \r
86     /* Disable interrupts, watchdog timer, cache */\r
87     disable_interrupts(  );\r
88     disable_watchdog_timer(  );\r
89     disable_cache(  );\r
90 \r
91     /* Initialise individual modules */\r
92     init_chip_selects(  );\r
93     init_bus_config(  );\r
94     init_cache(  );\r
95     init_eport(  );\r
96     init_flexcan(  );\r
97     init_power_management(  );\r
98     init_dma_timers(  );\r
99     init_interrupt_timers(  );\r
100     init_watchdog_timers(  );\r
101     init_pin_assignments(  );\r
102     init_sdram_controller(  );\r
103 \r
104     /* Initialise interrupt controller */\r
105     init_interrupt_controller(  );\r
106 }\r
107 \r
108 /*********************************************************************\r
109 * disable_interrupts - Disable all interrupt sources                 *\r
110 **********************************************************************/\r
111 static void\r
112 disable_interrupts( void )\r
113 {\r
114     vuint8         *p;\r
115     int             i;\r
116 \r
117 \r
118     /* Set ICR008-ICR063 to 0x0 */\r
119     p = ( vuint8 * ) & MCF_INTC0_ICR8;\r
120     for( i = 8; i <= 63; i++ )\r
121         *p++ = 0x0;\r
122 \r
123     /* Set ICR108-ICR163 to 0x0 */\r
124     p = ( vuint8 * ) & MCF_INTC1_ICR8;\r
125     for( i = 108; i <= 163; i++ )\r
126         *p++ = 0x0;\r
127 }\r
128 \r
129 \r
130 /*********************************************************************\r
131 * disable_watchdog_timer - Disable system watchdog timer             *\r
132 **********************************************************************/\r
133 static void\r
134 disable_watchdog_timer( void )\r
135 {\r
136 \r
137     /* Disable Core Watchdog Timer */\r
138     MCF_SCM_CWCR = 0;\r
139 }\r
140 \r
141 /*********************************************************************\r
142 * disable_cache - Disable and invalidate cache                       *\r
143 **********************************************************************/\r
144 static void\r
145 disable_cache( void )\r
146 {\r
147     asm ( "move.l   #0x01000000, %d0" );\r
148     asm ( "movec    %d0, %CACR" );\r
149 }\r
150 \r
151 /*********************************************************************\r
152 * init_basics - Configuration Information & VBR                      *\r
153 **********************************************************************/\r
154 static void\r
155 init_basics( void )\r
156 {\r
157     int             i;\r
158     extern uint32   __RAMVEC[];\r
159     extern uint32   __ROMVEC[];\r
160 \r
161     /* Transfer size not driven on SIZ[1:0] pins during external cycles\r
162        Processor Status (PST) and Debug Data (DDATA) functions disabled\r
163        Bus monitor disabled\r
164        Output pads configured for full strength\r
165      */\r
166     MCF_CCM_CCR = ( 0x1 << 15 ) | MCF_CCM_CCR_BME;\r
167 \r
168     /* Set up RAM vectors */\r
169     for( i = 0; i < 256; i++ )\r
170 \r
171     {\r
172         __RAMVEC[i] = __ROMVEC[i];\r
173     }\r
174     asm( "move.l   %0,%%d0": :"i"( __RAMVEC ) );\r
175     asm( "movec    %d0,%vbr" );\r
176 }\r
177 \r
178 \r
179 /*********************************************************************\r
180 * init_clock_config - Clock Module                                   *\r
181 **********************************************************************/\r
182 static void\r
183 init_clock_config( void )\r
184 {\r
185     /* Clock module uses normal PLL mode with 25.0000 MHz external reference (Fref)\r
186        MFD = 0, RFD = 1\r
187        Bus clock frequency = 25.00 MHz\r
188        Processor clock frequency = 2 x bus clock = 50.00 MHz\r
189        Frequency Modulation disabled\r
190        Loss of clock detection disabled\r
191        Reset/Interrupt on loss of lock disabled\r
192      */\r
193     MCF_FMPLL_SYNCR = 0x00100000;       /* Set RFD=RFD+1 to avoid frequency overshoot */\r
194     while( ( MCF_FMPLL_SYNSR & 0x08 ) == 0 )    /* Wait for PLL to lock */\r
195         ;\r
196     MCF_FMPLL_SYNCR = 0x00080000;       /* Set desired RFD */\r
197     while( ( MCF_FMPLL_SYNSR & 0x08 ) == 0 )    /* Wait for PLL to lock */\r
198         ;\r
199 }\r
200 \r
201 \r
202 /*********************************************************************\r
203 * init_ipsbar - Internal Peripheral System Base Address (IPSBAR)     *\r
204 **********************************************************************/\r
205 static void\r
206 init_ipsbar( void )\r
207 {\r
208     extern int  __SRAM;\r
209 \r
210     /* Base address of internal peripherals (IPSBAR) = 0x40000000\r
211 \r
212        Note: Processor powers up with IPS base address = 0x40000000\r
213        Write to IPS base + 0x00000000 to set new value\r
214      */\r
215     *( vuint32 * ) 0x40000000 = ( vuint32 ) __IPSBAR + 1;\r
216 \r
217     /* Configure RAMBAR in SCM module and allow dual-ported access. */\r
218     MCF_SCM_RAMBAR = ( uint32 ) &__SRAM | MCF_SCM_RAMBAR_BDE;\r
219 }\r
220 \r
221 /*********************************************************************\r
222 * init_chip_selects - Chip Select Module                             *\r
223 **********************************************************************/\r
224 static void\r
225 init_chip_selects( void )\r
226 {\r
227     extern void __FLASH;\r
228     uint32 FLASH_ADDR = (uint32)&__FLASH;\r
229 \r
230     /* Chip Select 0 - External Flash */\r
231     MCF_CS_CSAR0 = MCF_CS_CSAR_BA( FLASH_ADDR );\r
232     MCF_CS_CSCR0 = ( 0\r
233                      | MCF_CS_CSCR_IWS( 6 )\r
234                      | MCF_CS_CSCR_AA | MCF_CS_CSCR_PS_16 );\r
235     MCF_CS_CSMR0 = MCF_CS_CSMR_BAM_2M | MCF_CS_CSMR_V;\r
236 \r
237     /* Chip Select 1 disabled (CSMR1[V] = 0) */\r
238     MCF_CS_CSAR1 = 0;\r
239     MCF_CS_CSMR1 = 0;\r
240     MCF_CS_CSCR1 = 0;\r
241 \r
242     /* Chip Select 2 disabled (CSMR2[V] = 0) */\r
243     MCF_CS_CSAR2 = 0;\r
244     MCF_CS_CSMR2 = 0;\r
245     MCF_CS_CSCR2 = 0;\r
246 \r
247     /* Chip Select 3 disabled (CSMR3[V] = 0) */\r
248     MCF_CS_CSAR3 = 0;\r
249     MCF_CS_CSMR3 = 0;\r
250     MCF_CS_CSCR3 = 0;\r
251 \r
252     /* Chip Select 4 disabled (CSMR4[V] = 0) */\r
253     MCF_CS_CSAR4 = 0;\r
254     MCF_CS_CSMR4 = 0;\r
255     MCF_CS_CSCR4 = 0;\r
256 \r
257     /* Chip Select 5 disabled (CSMR5[V] = 0) */\r
258     MCF_CS_CSAR5 = 0;\r
259     MCF_CS_CSMR5 = 0;\r
260     MCF_CS_CSCR5 = 0;\r
261 \r
262     /* Chip Select 6 disabled (CSMR6[V] = 0) */\r
263     MCF_CS_CSAR6 = 0;\r
264     MCF_CS_CSMR6 = 0;\r
265     MCF_CS_CSCR6 = 0;\r
266 \r
267     /* Chip Select 7 disabled (CSMR7[V] = 0) */\r
268     MCF_CS_CSAR7 = 0;\r
269     MCF_CS_CSMR7 = 0;\r
270     MCF_CS_CSCR7 = 0;\r
271 }\r
272 \r
273 /*********************************************************************\r
274 * init_bus_config - Internal Bus Arbitration                         *\r
275 **********************************************************************/\r
276 static void\r
277 init_bus_config( void )\r
278 {\r
279 \r
280     /* Use round robin arbitration scheme\r
281        Assigned priorities (highest first):\r
282        Ethernet\r
283        DMA Controller\r
284        ColdFire Core\r
285        DMA bandwidth control disabled\r
286        Park on last active bus master\r
287      */\r
288     MCF_SCM_MPARK =\r
289         MCF_SCM_MPARK_M3_PRTY( 0x3 ) | MCF_SCM_MPARK_M2_PRTY( 0x2 ) |\r
290         MCF_SCM_MPARK_M1_PRTY( 0x1 );\r
291 }\r
292 \r
293 /*********************************************************************\r
294 * init_cache - Instruction/Data Cache                                *\r
295 **********************************************************************/\r
296 static void\r
297 init_cache( void )\r
298 {\r
299     /* Configured as split cache: 4 KByte instruction cache and 4 Kbyte data cache\r
300        ACR0: Don't cache accesses to 16 MB memory region at address $20000000\r
301        ACR1: Don't cache accesses to 1 GB memory region at address $40000000\r
302        CACR: Cache accesses to the rest of memory\r
303     */\r
304     asm("move.l   #0x80000000,%d0");\r
305     asm("movec    %d0,%CACR");\r
306     asm("move.l   #0x2000c040,%d0");\r
307     asm("movec    %d0,%ACR0");\r
308     asm("move.l   #0x403fc040,%d0");\r
309     asm("movec    %d0,%ACR1");\r
310 \r
311     /* Instruction/Data cache disabled. */\r
312     //asm( "move.l   #0x00000000, %d0" );\r
313     //asm( "movec    %d0,%cacr" );\r
314 }\r
315 \r
316 /*********************************************************************\r
317 * init_eport - Edge Port Module (EPORT)                              *\r
318 **********************************************************************/\r
319 static void\r
320 init_eport( void )\r
321 {\r
322 \r
323     /* Pins 1-7 configured as GPIO inputs */\r
324     MCF_EPORT_EPPAR = 0;\r
325     MCF_EPORT_EPDDR = 0;\r
326     MCF_EPORT_EPIER = 0;\r
327 }\r
328 \r
329 /*********************************************************************\r
330 * init_flexcan - FlexCAN Module                                      *\r
331 **********************************************************************/\r
332 static void\r
333 init_flexcan( void )\r
334 {\r
335 \r
336     /* FlexCAN controller 0 disabled (CANMCR0[MDIS]=1) */\r
337     MCF_CAN_IMASK0 = 0;\r
338     MCF_CAN_RXGMASK0 = MCF_CAN_RXGMASK_MI( 0x1fffffff );\r
339     MCF_CAN_RX14MASK0 = MCF_CAN_RX14MASK_MI( 0x1fffffff );\r
340     MCF_CAN_RX15MASK0 = MCF_CAN_RX15MASK_MI( 0x1fffffff );\r
341     MCF_CAN_CANCTRL0 = 0;\r
342     MCF_CAN_CANMCR0 =\r
343         MCF_CAN_CANMCR_MDIS | MCF_CAN_CANMCR_FRZ | MCF_CAN_CANMCR_HALT |\r
344         MCF_CAN_CANMCR_SUPV | MCF_CAN_CANMCR_MAXMB( 0xf );\r
345 \r
346     /* FlexCAN controller 1 disabled (CANMCR1[MDIS]=1) */\r
347     MCF_CAN_IMASK1 = 0;\r
348     MCF_CAN_RXGMASK1 = MCF_CAN_RXGMASK_MI( 0x1fffffff );\r
349     MCF_CAN_RX14MASK1 = MCF_CAN_RX14MASK_MI( 0x1fffffff );\r
350     MCF_CAN_RX15MASK1 = MCF_CAN_RX15MASK_MI( 0x1fffffff );\r
351     MCF_CAN_CANCTRL1 = 0;\r
352     MCF_CAN_CANMCR1 =\r
353         MCF_CAN_CANMCR_MDIS | MCF_CAN_CANMCR_FRZ | MCF_CAN_CANMCR_HALT |\r
354         MCF_CAN_CANMCR_SUPV | MCF_CAN_CANMCR_MAXMB( 0xf );\r
355 }\r
356 \r
357 /*********************************************************************\r
358 * init_power_management - Power Management                           *\r
359 **********************************************************************/\r
360 static void\r
361 init_power_management( void )\r
362 {\r
363 \r
364     /* On executing STOP instruction, processor enters RUN mode\r
365        Mode is exited when an interrupt of level 1 or higher is received\r
366      */\r
367     MCF_SCM_LPICR = MCF_SCM_LPICR_ENBSTOP;\r
368     MCF_CCM_LPCR = 0;\r
369 }\r
370 \r
371 /*********************************************************************\r
372 * init_sdram_controller - SDRAM Controller                           *\r
373 **********************************************************************/\r
374 static void\r
375 init_sdram_controller( void )\r
376 {\r
377     extern void __SDRAM;\r
378     uint32 SDRAM_ADDR = (uint32)&__SDRAM;\r
379     int             i;\r
380 \r
381 \r
382     /*\r
383      * Check to see if the SDRAM has already been initialized\r
384      * by a run control tool\r
385      */\r
386     if( !( MCF_SDRAMC_DACR0 & MCF_SDRAMC_DACR0_RE ) )\r
387     {\r
388         /* Initialize DRAM Control Register: DCR */\r
389         MCF_SDRAMC_DCR = ( MCF_SDRAMC_DCR_RTIM( 1 ) |\r
390                            MCF_SDRAMC_DCR_RC( ( 15 * FSYS_2 ) >> 4 ) );\r
391 \r
392         /* Initialize DACR0 */\r
393         MCF_SDRAMC_DACR0 = ( MCF_SDRAMC_DACR0_BA( SDRAM_ADDR >> 18UL ) |\r
394                              MCF_SDRAMC_DACR0_CASL( 1 ) |\r
395                              MCF_SDRAMC_DACR0_CBM( 3 ) |\r
396                              MCF_SDRAMC_DACR0_PS( 0 ) );\r
397 \r
398         /* Initialize DMR0 */\r
399         MCF_SDRAMC_DMR0 = ( MCF_SDRAMC_DMR_BAM_16M | MCF_SDRAMC_DMR0_V );\r
400 \r
401         /* Set IP (bit 3) in DACR */\r
402         MCF_SDRAMC_DACR0 |= MCF_SDRAMC_DACR0_IP;\r
403 \r
404         /* Wait 30ns to allow banks to precharge */\r
405         for( i = 0; i < 5; i++ )\r
406         {\r
407             asm volatile    ( " nop" );\r
408         }\r
409         /* Write to this block to initiate precharge */\r
410         *( uint32 * ) ( SDRAM_ADDR ) = 0xA5A59696;\r
411 \r
412         /* Set RE (bit 15) in DACR */\r
413         MCF_SDRAMC_DACR0 |= MCF_SDRAMC_DACR0_RE;\r
414 \r
415         /* Wait for at least 8 auto refresh cycles to occur */\r
416         for( i = 0; i < 2000; i++ )\r
417         {\r
418             asm volatile    ( "nop" );\r
419         }\r
420         /* Finish the configuration by issuing the IMRS. */\r
421         MCF_SDRAMC_DACR0 |= MCF_SDRAMC_DACR0_MRS;\r
422 \r
423         /* Write to the SDRAM Mode Register */\r
424         *( uint32 * ) ( SDRAM_ADDR + 0x400 ) = 0xA5A59696;\r
425     }\r
426 }\r
427 \r
428 /*********************************************************************\r
429 * init_dma_timers - DMA Timer Modules                                *\r
430 **********************************************************************/\r
431 static void\r
432 init_dma_timers( void )\r
433 {\r
434 \r
435     /* DMA Timer 0 disabled (DTMR0[RST] = 0) */\r
436     MCF_TIMER_DTMR0 = 0;\r
437     MCF_TIMER_DTXMR0 = 0;\r
438     MCF_TIMER_DTRR0 = 0xffffffff;\r
439 \r
440     /* DMA Timer 1 disabled (DTMR1[RST] = 0) */\r
441     MCF_TIMER_DTMR1 = 0;\r
442     MCF_TIMER_DTXMR1 = 0;\r
443     MCF_TIMER_DTRR1 = 0xffffffff;\r
444 \r
445     /* DMA Timer 2 disabled (DTMR2[RST] = 0) */\r
446     MCF_TIMER_DTMR2 = 0;\r
447     MCF_TIMER_DTXMR2 = 0;\r
448     MCF_TIMER_DTRR2 = 0xffffffff;\r
449 \r
450     /* DMA Timer 3 disabled (DTMR3[RST] = 0) */\r
451     MCF_TIMER_DTMR3 = 0;\r
452     MCF_TIMER_DTXMR3 = 0;\r
453     MCF_TIMER_DTRR3 = 0xffffffff;\r
454 }\r
455 \r
456 /**********************************************************************\r
457 * init_interrupt_timers - Programmable Interrupt Timer (PIT) Modules  *\r
458 ***********************************************************************/\r
459 static void\r
460 init_interrupt_timers( void )\r
461 {\r
462 \r
463     /* PIT0 disabled (PCSR0[EN]=0) */\r
464     MCF_PIT_PCSR0 = 0;\r
465 \r
466     /* PIT1 disabled (PCSR1[EN]=0) */\r
467     MCF_PIT_PCSR1 = 0;\r
468 \r
469     /* PIT2 disabled (PCSR2[EN]=0) */\r
470     MCF_PIT_PCSR2 = 0;\r
471 \r
472     /* PIT3 disabled (PCSR3[EN]=0) */\r
473     MCF_PIT_PCSR3 = 0;\r
474 }\r
475 \r
476 /*********************************************************************\r
477 * init_watchdog_timers - Watchdog Timer Modules                      *\r
478 **********************************************************************/\r
479 static void\r
480 init_watchdog_timers( void )\r
481 {\r
482 \r
483     /* Watchdog Timer disabled (WCR[EN]=0)\r
484        NOTE: WCR and WMR cannot be written again until after the\r
485        processor is reset.\r
486      */\r
487     MCF_WTM_WCR = MCF_WTM_WCR_WAIT | MCF_WTM_WCR_DOZE | MCF_WTM_WCR_HALTED;\r
488     MCF_WTM_WMR = 0xffff;\r
489 \r
490     /* Core Watchdog Timer disabled (CWCR[CWE]=0) */\r
491     MCF_SCM_CWCR = 0;\r
492 }\r
493 \r
494 /*********************************************************************\r
495 * init_interrupt_controller - Interrupt Controller                   *\r
496 **********************************************************************/\r
497 static void\r
498 init_interrupt_controller( void )\r
499 {\r
500 \r
501     /* Configured interrupt sources in order of priority...\r
502        Level 7:  External interrupt /IRQ7, (initially masked)\r
503        Level 6:  External interrupt /IRQ6, (initially masked)\r
504        Level 5:  External interrupt /IRQ5, (initially masked)\r
505        Level 4:  External interrupt /IRQ4, (initially masked)\r
506        Level 3:  External interrupt /IRQ3, (initially masked)\r
507        Level 2:  External interrupt /IRQ2, (initially masked)\r
508        Level 1:  External interrupt /IRQ1, (initially masked)\r
509      */\r
510     MCF_INTC0_ICR1 = 0;\r
511     MCF_INTC0_ICR2 = 0;\r
512     MCF_INTC0_ICR3 = 0;\r
513     MCF_INTC0_ICR4 = 0;\r
514     MCF_INTC0_ICR5 = 0;\r
515     MCF_INTC0_ICR6 = 0;\r
516     MCF_INTC0_ICR7 = 0;\r
517     MCF_INTC0_ICR8 = 0;\r
518     MCF_INTC0_ICR9 = 0;\r
519     MCF_INTC0_ICR10 = 0;\r
520     MCF_INTC0_ICR11 = 0;\r
521     MCF_INTC0_ICR12 = 0;\r
522     MCF_INTC0_ICR13 = 0;\r
523     MCF_INTC0_ICR14 = 0;\r
524     MCF_INTC0_ICR15 = 0;\r
525     MCF_INTC0_ICR17 = 0;\r
526     MCF_INTC0_ICR18 = 0;\r
527     MCF_INTC0_ICR19 = 0;\r
528     MCF_INTC0_ICR20 = 0;\r
529     MCF_INTC0_ICR21 = 0;\r
530     MCF_INTC0_ICR22 = 0;\r
531     MCF_INTC0_ICR23 = 0;\r
532     MCF_INTC0_ICR24 = 0;\r
533     MCF_INTC0_ICR25 = 0;\r
534     MCF_INTC0_ICR26 = 0;\r
535     MCF_INTC0_ICR27 = 0;\r
536     MCF_INTC0_ICR28 = 0;\r
537     MCF_INTC0_ICR29 = 0;\r
538     MCF_INTC0_ICR30 = 0;\r
539     MCF_INTC0_ICR31 = 0;\r
540     MCF_INTC0_ICR32 = 0;\r
541     MCF_INTC0_ICR33 = 0;\r
542     MCF_INTC0_ICR34 = 0;\r
543     MCF_INTC0_ICR35 = 0;\r
544     MCF_INTC0_ICR36 = 0;\r
545     MCF_INTC0_ICR37 = 0;\r
546     MCF_INTC0_ICR38 = 0;\r
547     MCF_INTC0_ICR39 = 0;\r
548     MCF_INTC0_ICR40 = 0;\r
549     MCF_INTC0_ICR41 = 0;\r
550     MCF_INTC0_ICR42 = 0;\r
551     MCF_INTC0_ICR43 = 0;\r
552     MCF_INTC0_ICR44 = 0;\r
553     MCF_INTC0_ICR45 = 0;\r
554     MCF_INTC0_ICR46 = 0;\r
555     MCF_INTC0_ICR47 = 0;\r
556     MCF_INTC0_ICR48 = 0;\r
557     MCF_INTC0_ICR49 = 0;\r
558     MCF_INTC0_ICR50 = 0;\r
559     MCF_INTC0_ICR51 = 0;\r
560     MCF_INTC0_ICR52 = 0;\r
561     MCF_INTC0_ICR53 = 0;\r
562     MCF_INTC0_ICR54 = 0;\r
563     MCF_INTC0_ICR55 = 0;\r
564     MCF_INTC0_ICR56 = 0;\r
565     MCF_INTC0_ICR57 = 0;\r
566     MCF_INTC0_ICR58 = 0;\r
567     MCF_INTC0_ICR59 = 0;\r
568     MCF_INTC0_ICR60 = 0;\r
569     MCF_INTC1_ICR8 = 0;\r
570     MCF_INTC1_ICR9 = 0;\r
571     MCF_INTC1_ICR10 = 0;\r
572     MCF_INTC1_ICR11 = 0;\r
573     MCF_INTC1_ICR12 = 0;\r
574     MCF_INTC1_ICR13 = 0;\r
575     MCF_INTC1_ICR14 = 0;\r
576     MCF_INTC1_ICR15 = 0;\r
577     MCF_INTC1_ICR16 = 0;\r
578     MCF_INTC1_ICR17 = 0;\r
579     MCF_INTC1_ICR18 = 0;\r
580     MCF_INTC1_ICR19 = 0;\r
581     MCF_INTC1_ICR20 = 0;\r
582     MCF_INTC1_ICR21 = 0;\r
583     MCF_INTC1_ICR22 = 0;\r
584     MCF_INTC1_ICR23 = 0;\r
585     MCF_INTC1_ICR24 = 0;\r
586     MCF_INTC1_ICR25 = 0;\r
587     MCF_INTC1_ICR27 = 0;\r
588     MCF_INTC1_ICR28 = 0;\r
589     MCF_INTC1_ICR29 = 0;\r
590     MCF_INTC1_ICR30 = 0;\r
591     MCF_INTC1_ICR31 = 0;\r
592     MCF_INTC1_ICR32 = 0;\r
593     MCF_INTC1_ICR33 = 0;\r
594     MCF_INTC1_ICR34 = 0;\r
595     MCF_INTC1_ICR35 = 0;\r
596     MCF_INTC1_ICR36 = 0;\r
597     MCF_INTC1_ICR37 = 0;\r
598     MCF_INTC1_ICR38 = 0;\r
599     MCF_INTC1_ICR39 = 0;\r
600     MCF_INTC1_ICR40 = 0;\r
601     MCF_INTC1_ICR41 = 0;\r
602     MCF_INTC1_ICR42 = 0;\r
603     MCF_INTC1_ICR59 = 0;\r
604     MCF_INTC0_IMRH = 0xffffffff;\r
605     MCF_INTC0_IMRL =\r
606         MCF_INTC0_IMRL_INT_MASK31 | MCF_INTC0_IMRL_INT_MASK30 |\r
607         MCF_INTC0_IMRL_INT_MASK29 | MCF_INTC0_IMRL_INT_MASK28 |\r
608         MCF_INTC0_IMRL_INT_MASK27 | MCF_INTC0_IMRL_INT_MASK26 |\r
609         MCF_INTC0_IMRL_INT_MASK25 | MCF_INTC0_IMRL_INT_MASK24 |\r
610         MCF_INTC0_IMRL_INT_MASK23 | MCF_INTC0_IMRL_INT_MASK22 |\r
611         MCF_INTC0_IMRL_INT_MASK21 | MCF_INTC0_IMRL_INT_MASK20 |\r
612         MCF_INTC0_IMRL_INT_MASK19 | MCF_INTC0_IMRL_INT_MASK18 |\r
613         MCF_INTC0_IMRL_INT_MASK17 | MCF_INTC0_IMRL_INT_MASK16 |\r
614         MCF_INTC0_IMRL_INT_MASK15 | MCF_INTC0_IMRL_INT_MASK14 |\r
615         MCF_INTC0_IMRL_INT_MASK13 | MCF_INTC0_IMRL_INT_MASK12 |\r
616         MCF_INTC0_IMRL_INT_MASK11 | MCF_INTC0_IMRL_INT_MASK10 |\r
617         MCF_INTC0_IMRL_INT_MASK9 | MCF_INTC0_IMRL_INT_MASK8 |\r
618         MCF_INTC0_IMRL_INT_MASK7 | MCF_INTC0_IMRL_INT_MASK6 |\r
619         MCF_INTC0_IMRL_INT_MASK5 | MCF_INTC0_IMRL_INT_MASK4 |\r
620         MCF_INTC0_IMRL_INT_MASK3 | MCF_INTC0_IMRL_INT_MASK2 |\r
621         MCF_INTC0_IMRL_INT_MASK1;\r
622     MCF_INTC1_IMRH = 0xffffffff;\r
623     MCF_INTC1_IMRL =\r
624         MCF_INTC1_IMRL_INT_MASK31 | MCF_INTC1_IMRL_INT_MASK30 |\r
625         MCF_INTC1_IMRL_INT_MASK29 | MCF_INTC1_IMRL_INT_MASK28 |\r
626         MCF_INTC1_IMRL_INT_MASK27 | MCF_INTC1_IMRL_INT_MASK26 |\r
627         MCF_INTC1_IMRL_INT_MASK25 | MCF_INTC1_IMRL_INT_MASK24 |\r
628         MCF_INTC1_IMRL_INT_MASK23 | MCF_INTC1_IMRL_INT_MASK22 |\r
629         MCF_INTC1_IMRL_INT_MASK21 | MCF_INTC1_IMRL_INT_MASK20 |\r
630         MCF_INTC1_IMRL_INT_MASK19 | MCF_INTC1_IMRL_INT_MASK18 |\r
631         MCF_INTC1_IMRL_INT_MASK17 | MCF_INTC1_IMRL_INT_MASK16 |\r
632         MCF_INTC1_IMRL_INT_MASK15 | MCF_INTC1_IMRL_INT_MASK14 |\r
633         MCF_INTC1_IMRL_INT_MASK13 | MCF_INTC1_IMRL_INT_MASK12 |\r
634         MCF_INTC1_IMRL_INT_MASK11 | MCF_INTC1_IMRL_INT_MASK10 |\r
635         MCF_INTC1_IMRL_INT_MASK9 | MCF_INTC1_IMRL_INT_MASK8 |\r
636         MCF_INTC1_IMRL_INT_MASK7 | MCF_INTC1_IMRL_INT_MASK6 |\r
637         MCF_INTC1_IMRL_INT_MASK5 | MCF_INTC1_IMRL_INT_MASK4 |\r
638         MCF_INTC1_IMRL_INT_MASK3 | MCF_INTC1_IMRL_INT_MASK2 |\r
639         MCF_INTC1_IMRL_INT_MASK1;\r
640 }\r
641 \r
642 /*********************************************************************\r
643 * init_pin_assignments - Pin Assignment and General Purpose I/O      *\r
644 **********************************************************************/\r
645 static void\r
646 init_pin_assignments( void )\r
647 {\r
648 \r
649     /* Pin assignments for port ADDR\r
650        Pins are all GPIO inputs\r
651      */\r
652     MCF_GPIO_PDDR_APDDR = 0;\r
653     MCF_GPIO_PAR_AD = MCF_GPIO_PAR_AD_PAR_ADDR23\r
654         | MCF_GPIO_PAR_AD_PAR_ADDR22\r
655         | MCF_GPIO_PAR_AD_PAR_ADDR21 | MCF_GPIO_PAR_AD_PAR_DATAL;\r
656 \r
657     /* Pin assignments for ports DATAH and DATAL\r
658        Pins are all GPIO inputs\r
659      */\r
660     MCF_GPIO_PDDR_DATAH = 0;\r
661     MCF_GPIO_PDDR_DATAL = 0;\r
662 \r
663     /* Pin assignments for port BUSCTL\r
664        Pin /OE        : External bus output enable, /OE\r
665        Pin /TA        : External bus transfer acknowledge, /TA\r
666        Pin /TEA       : External bus transfer error acknowledge, /TEA\r
667        Pin R/W        : External bus read/write indication, R/W\r
668        Pin TSIZ1      : External bus transfer size TSIZ1 or DMA acknowledge /DACK1\r
669        Pin TSIZ0      : External bus transfer size TSIZ0 or DMA acknowledge /DACK0\r
670        Pin /TS        : External bus transfer start, /TS\r
671        Pin /TIP       : External bus transfer in progess, /TIP\r
672      */\r
673     MCF_GPIO_PDDR_BUSCTL = 0;\r
674     MCF_GPIO_PAR_BUSCTL =\r
675         MCF_GPIO_PAR_BUSCTL_PAR_OE | MCF_GPIO_PAR_BUSCTL_PAR_TA |\r
676         MCF_GPIO_PAR_BUSCTL_PAR_TEA( 0x3 ) | MCF_GPIO_PAR_BUSCTL_PAR_RWB |\r
677         MCF_GPIO_PAR_BUSCTL_PAR_TSIZ1 | MCF_GPIO_PAR_BUSCTL_PAR_TSIZ0 |\r
678         MCF_GPIO_PAR_BUSCTL_PAR_TS( 0x3 ) |\r
679         MCF_GPIO_PAR_BUSCTL_PAR_TIP( 0x3 );\r
680 \r
681     /* Pin assignments for port BS\r
682        Pin /BS3       : External byte strobe /BS3\r
683        Pin /BS2       : External byte strobe /BS2\r
684        Pin /BS1       : External byte strobe /BS1\r
685        Pin /BS0       : External byte strobe /BS0\r
686      */\r
687     MCF_GPIO_PDDR_BS = 0;\r
688     MCF_GPIO_PAR_BS =\r
689         MCF_GPIO_PAR_BS_PAR_BS3 | MCF_GPIO_PAR_BS_PAR_BS2 |\r
690         MCF_GPIO_PAR_BS_PAR_BS1 | MCF_GPIO_PAR_BS_PAR_BS0;\r
691 \r
692     /* Pin assignments for port CS\r
693        Pin /CS7       : Chip select /CS7\r
694        Pin /CS6       : Chip select /CS6\r
695        Pin /CS5       : Chip select /CS5\r
696        Pin /CS4       : Chip select /CS4\r
697        Pin /CS3       : Chip select /CS3\r
698        Pin /CS2       : Chip select /CS2\r
699        Pin /CS1       : Chip select /CS1\r
700      */\r
701     MCF_GPIO_PDDR_CS = 0;\r
702     MCF_GPIO_PAR_CS =\r
703         MCF_GPIO_PAR_CS_PAR_CS7 | MCF_GPIO_PAR_CS_PAR_CS6 |\r
704         MCF_GPIO_PAR_CS_PAR_CS5 | MCF_GPIO_PAR_CS_PAR_CS4 |\r
705         MCF_GPIO_PAR_CS_PAR_CS3 | MCF_GPIO_PAR_CS_PAR_CS2 |\r
706         MCF_GPIO_PAR_CS_PAR_CS1;\r
707 \r
708     /* Pin assignments for port SDRAM\r
709        Pin /SD_WE     : SDRAM controller /SD_WE\r
710        Pin /SD_SCAS   : SDRAM controller /SD_SCAS\r
711        Pin /SD_SRAS   : SDRAM controller /SD_SRAS\r
712        Pin /SD_SCKE   : SDRAM controller /SD_SCKE\r
713        Pin /SD_CS1    : SDRAM controller /SD_CS1\r
714        Pin /SD_CS0    : SDRAM controller /SD_CS0\r
715      */\r
716     MCF_GPIO_PDDR_SDRAM = 0;\r
717     MCF_GPIO_PAR_SDRAM =\r
718         MCF_GPIO_PAR_SDRAM_PAR_SDWE | MCF_GPIO_PAR_SDRAM_PAR_SCAS |\r
719         MCF_GPIO_PAR_SDRAM_PAR_SRAS | MCF_GPIO_PAR_SDRAM_PAR_SCKE |\r
720         MCF_GPIO_PAR_SDRAM_PAR_SDCS1 | MCF_GPIO_PAR_SDRAM_PAR_SDCS0;\r
721 \r
722     /* Pin assignments for port FECI2C\r
723        Pins are all GPIO inputs\r
724      */\r
725     MCF_GPIO_PDDR_FECI2C = 0;\r
726     MCF_GPIO_PAR_FECI2C =\r
727         MCF_GPIO_PAR_FECI2C_PAR_EMDC_FEC | MCF_GPIO_PAR_FECI2C_PAR_EMDIO_FEC;\r
728 \r
729     /* Pin assignments for port UARTL\r
730        Pins are all GPIO inputs\r
731      */\r
732     MCF_GPIO_PDDR_UARTL = 0;\r
733     MCF_GPIO_PAR_UART = 0;\r
734 \r
735     /* Pin assignments for port UARTH\r
736        Pin U2TXD      : GPIO input\r
737        Pin U2RXD      : GPIO input\r
738        Pin /IRQ2      : Interrupt request /IRQ2 or GPIO\r
739      */\r
740     MCF_GPIO_PDDR_UARTH = 0;\r
741 \r
742     /* Pin assignments for port QSPI\r
743        Pins are all GPIO inputs\r
744      */\r
745     MCF_GPIO_PDDR_QSPI = 0;\r
746     MCF_GPIO_PAR_QSPI = 0;\r
747 \r
748     /* Pin assignments for port TIMER\r
749        Pins are all GPIO inputs\r
750      */\r
751     MCF_GPIO_PDDR_TIMER = 0;\r
752     MCF_GPIO_PAR_TIMER = 0;\r
753 \r
754     /* Pin assignments for port ETPU\r
755        Pins are all GPIO inputs\r
756      */\r
757     MCF_GPIO_PDDR_ETPU = 0;\r
758     MCF_GPIO_PAR_ETPU = 0;\r
759 }\r