port generic and ixp4xx kernel patches to 2.6.27 (compiles except for iptables, but...
[openwrt.git] / target / linux / at91 / image / dfboot / src / init.c
1 //*----------------------------------------------------------------------------
2 //* ATMEL Microcontroller Software Support - ROUSSET -
3 //*----------------------------------------------------------------------------
4 //* The software is delivered "AS IS" without warranty or condition of any
5 //* kind, either express, implied or statutory. This includes without
6 //* limitation any warranty or condition with respect to merchantability or
7 //* fitness for any particular purpose, or against the infringements of
8 //* intellectual property rights of others.
9 //*----------------------------------------------------------------------------
10 //* File Name : init.c
11 //* Object : Low level initialisations written in C
12 //* Creation : HIi 10/10/2003
13 //*
14 //*----------------------------------------------------------------------------
15 #include "config.h"
16 #include "AT91RM9200.h"
17 #include "lib_AT91RM9200.h"
18 #include "stdio.h"
19
20 //*----------------------------------------------------------------------------
21 //* \fn AT91F_DataAbort
22 //* \brief This function reports an Abort
23 //*----------------------------------------------------------------------------
24 static void AT91F_SpuriousHandler()
25 {
26 puts("ISI");
27 while (1);
28 }
29
30
31 //*----------------------------------------------------------------------------
32 //* \fn AT91F_DataAbort
33 //* \brief This function reports an Abort
34 //*----------------------------------------------------------------------------
35 static void AT91F_DataAbort()
36 {
37 puts("IDA");
38 while (1);
39 }
40
41 //*----------------------------------------------------------------------------
42 //* \fn AT91F_FetchAbort
43 //* \brief This function reports an Abort
44 //*----------------------------------------------------------------------------
45 static void AT91F_FetchAbort()
46 {
47 puts("IFA");
48 while (1);
49 }
50
51 //*----------------------------------------------------------------------------
52 //* \fn AT91F_UndefHandler
53 //* \brief This function reports that no handler have been set for current IT
54 //*----------------------------------------------------------------------------
55 static void AT91F_UndefHandler()
56 {
57 puts("IUD");
58 while (1);
59 }
60
61
62 //*--------------------------------------------------------------------------------------
63 //* Function Name : AT91F_InitSdram
64 //* Object : Initialize the SDRAM
65 //* Input Parameters :
66 //* Output Parameters :
67 //*--------------------------------------------------------------------------------------
68 static void AT91F_InitSdram()
69 {
70 int *pRegister;
71
72 //* Configure PIOC as peripheral (D16/D31)
73
74 AT91F_PIO_CfgPeriph(
75 AT91C_BASE_PIOC, // PIO controller base address
76 0xFFFF0030,
77 0
78 );
79
80 //*Init SDRAM
81 pRegister = (int *)0xFFFFFF98;
82 *pRegister = 0x2188c155;
83 pRegister = (int *)0xFFFFFF90;
84 *pRegister = 0x2;
85 pRegister = (int *)0x20000000;
86 *pRegister = 0;
87 pRegister = (int *)0xFFFFFF90;
88 *pRegister = 0x4;
89 pRegister = (int *)0x20000000;
90 *pRegister = 0;
91 *pRegister = 0;
92 *pRegister = 0;
93 *pRegister = 0;
94 *pRegister = 0;
95 *pRegister = 0;
96 *pRegister = 0;
97 *pRegister = 0;
98 pRegister = (int *)0xFFFFFF90;
99 *pRegister = 0x3;
100 pRegister = (int *)0x20000080;
101 *pRegister = 0;
102
103 pRegister = (int *)0xFFFFFF94;
104 *pRegister = 0x2e0;
105 pRegister = (int *)0x20000000;
106 *pRegister = 0;
107
108 pRegister = (int *)0xFFFFFF90;
109 *pRegister = 0x00;
110 pRegister = (int *)0x20000000;
111 *pRegister = 0;
112 }
113
114
115 //*----------------------------------------------------------------------------
116 //* \fn AT91F_InitFlash
117 //* \brief This function performs low level HW initialization
118 //*----------------------------------------------------------------------------
119 static void AT91F_InitMemories()
120 {
121 int *pEbi = (int *)0xFFFFFF60;
122
123 //* Setup MEMC to support all connected memories (CS0 = FLASH; CS1=SDRAM)
124 pEbi = (int *)0xFFFFFF60;
125 *pEbi = 0x00000002;
126
127 //* CS0 cs for flash
128 pEbi = (int *)0xFFFFFF70;
129 *pEbi = 0x00003284;
130
131 AT91F_InitSdram();
132 }
133
134
135
136 //*----------------------------------------------------------------------------
137 //* \fn AT91F_LowLevelInit
138 //* \brief This function performs very low level HW initialization
139 //*----------------------------------------------------------------------------
140 void AT91F_LowLevelInit(void)
141 {
142 int i;
143
144 // Init Interrupt Controller
145 AT91F_AIC_Open(
146 AT91C_BASE_AIC, // pointer to the AIC registers
147 AT91C_AIC_BRANCH_OPCODE, // IRQ exception vector
148 AT91F_UndefHandler, // FIQ exception vector
149 AT91F_UndefHandler, // AIC default handler
150 AT91F_SpuriousHandler, // AIC spurious handler
151 0); // Protect mode
152
153 // Perform 8 End Of Interrupt Command to make sýre AIC will not Lock out nIRQ
154 for(i=0; i<8; i++)
155 AT91F_AIC_AcknowledgeIt(AT91C_BASE_AIC);
156
157 AT91F_AIC_SetExceptionVector((unsigned int *)0x0C, AT91F_FetchAbort);
158 AT91F_AIC_SetExceptionVector((unsigned int *)0x10, AT91F_DataAbort);
159 AT91F_AIC_SetExceptionVector((unsigned int *)0x4, AT91F_UndefHandler);
160
161 //Initialize SDRAM and Flash
162 AT91F_InitMemories();
163
164 }
165
This page took 0.054742 seconds and 5 git commands to generate.