source: rtems/c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c @ a840853

4.104.114.95
Last change on this file since a840853 was a840853, checked in by Ralf Corsepius <ralf.corsepius@…>, on 08/19/08 at 11:25:05

Add missing prototypes.

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[1612af0]1/*
2 *  This is where the real hardware setup is done. A minimal stack
3 *  has been provided by the start.S code. No normal C or RTEMS
4 *  functions can be called from here.
5 *
6 * This routine is pretty simple for the uC5235 because all the hard
7 * work has been done by the bootstrap dBUG code.
8 */
9
10#include <rtems.h>
11#include <bsp.h>
12#define m68k_set_cacr(_cacr) asm volatile ("movec %0,%%cacr" : : "d" (_cacr))
13#define m68k_set_acr0(_acr0) asm volatile ("movec %0,%%acr0" : : "d" (_acr0))
14#define m68k_set_acr1(_acr1) asm volatile ("movec %0,%%acr1" : : "d" (_acr1))
15#define MM_SDRAM_BASE           (0x00000000)
16
[504c5ca]17/*
18 * MCF5235_BSP_START_FROM_FLASH comes from the linker script
19 * If it is set to 0 then it is assumed that the motorola debug monitor
20 * is present and we do not need to re-initialize the SDRAM. Otherwise,
21 * if it is set to 1 then we want to boot our own code from flash and we
22 * do need to initialize the SDRAM.
23 */
24 
25 
26extern uint32_t MCF5235_BSP_START_FROM_FLASH;
27
[1612af0]28void Init5235 (void)
29{
30    extern void CopyDataClearBSSAndStart (void);
31    int x;
32    int temp = 0;
[504c5ca]33    int *address_of_MCF5235_BSP_START_FROM_FLASH;
[1612af0]34   
[1883c87]35    /*Setup the GPIO Registers */
[1612af0]36    MCF5235_GPIO_UART=0x3FFF;
37    MCF5235_GPIO_PAR_AD=0xE1;
38   
[1883c87]39    /*Setup the Chip Selects so CS0 is flash */
[1612af0]40    MCF5235_CS_CSAR0 =(0xFFE00000 & 0xffff0000)>>16;
41    MCF5235_CS_CSMR0 = 0x001f0001;
42    MCF5235_CS_CSCR0 = 0x1980;
43   
[504c5ca]44    address_of_MCF5235_BSP_START_FROM_FLASH = (int *) & MCF5235_BSP_START_FROM_FLASH;
45    if ( (int)address_of_MCF5235_BSP_START_FROM_FLASH == 1) {
[1883c87]46        /*Setup the SDRAM  */
[504c5ca]47        for(x=0; x<20000; x++)
48        {
49               temp +=1;
50        }
51        MCF5235_SDRAMC_DCR  = 0x042E;
52        MCF5235_SDRAMC_DACR0 = 0x00001300;
53        MCF5235_SDRAMC_DMR0 = (0x00FC0000) | (0x00000001);
54        for(x=0; x<20000; x++)
55        {
56                temp +=1;
57        }
[1883c87]58        /* set ip ( bit 3 ) in dacr */
[504c5ca]59        MCF5235_SDRAMC_DACR0 |= (0x00000008) ;
[1883c87]60        /* init precharge */
[504c5ca]61        *((unsigned long *)MM_SDRAM_BASE) = 0xDEADBEEF;
[1883c87]62        /* set RE in dacr */
[504c5ca]63        MCF5235_SDRAMC_DACR0 |= (0x00008000); 
[1883c87]64        /* wait */
[504c5ca]65        for(x=0; x<20000; x++)
66        {
67                temp +=1;
68        }
[1883c87]69        /* issue IMRS */
[504c5ca]70        MCF5235_SDRAMC_DACR0 |= (0x00000040);
71        *((short *)MM_SDRAM_BASE) = 0;
72        for(x=0; x<60000; x++)
73        {
74                temp +=1;
75        }
76        *((unsigned long*)MM_SDRAM_BASE)=0x12345678;
77    } /* we have finished setting up the sdram */
[1612af0]78       
79    /* Copy the interrupt vector table to address 0x0 in SDRAM */
80    {
[a840853]81        extern void INTERRUPT_VECTOR(void);
[1612af0]82        uint32_t *inttab = (uint32_t *)&INTERRUPT_VECTOR;
83        uint32_t *intvec = (uint32_t *)0x0;
84        register int i;
85        for (i = 0; i < 256; i++)
86        {
87            *(intvec++) = *(inttab++);
88        }
89    }
90
[504c5ca]91    m68k_set_vbr(0);
92
93    /*
[1612af0]94     * Copy data, clear BSS and call boot_card()
95     */
96    CopyDataClearBSSAndStart ();
97}
Note: See TracBrowser for help on using the repository browser.