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