summaryrefslogtreecommitdiff
path: root/board/st/nhk8815/platform.S
blob: 2a6711023129af75467b1d2956ec042142438a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
/*
 * Board specific setup info
 *
 * (C) Copyright 2005
 * STMicrolelctronics, <www.st.com>
 *
 * (C) Copyright 2004, ARM Ltd.
 * Philippe Robin, <philippe.robin@arm.com>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <config.h>
#include <version.h>

.globl lowlevel_init
lowlevel_init:
	/* Jump to the flash address */
	ldr r0, =CFG_ONENAND_BASE

	/*
	 * Make it independent whether we boot from 0x0 or 0x30000000.
	 * Non-portable: it relies on the knowledge that ip has to be updated
	 */
	orr ip, ip, r0	/* adjust return address of cpu_init_crit */
	orr lr, lr, r0	/* adjust return address */
	orr pc, pc, r0	/* jump to the normal address */
	nop

	/* Initialize PLL, Remap clear, FSMC, MPMC here! */
	/* What about GPIO, CLCD and UART */

	/* PLL Initialization */
	/* Prog the PLL1 @ 266 MHz ==> SDRAM Clock = 100.8 MHz */
	ldr r0, =NOMADIK_SRC_BASE

	ldr r1, =0x2B013502

	str r1, [r0, #0x14]

	/* Used to set all the timers clock to 2.4MHZ */
	ldr r1, =0x2AAAA004
	str r1, [r0]

	ldr r1, =0x10000000
	str r1, [r0, #0x10]

	/* FSMC setup ---- */
	ldr r0, =NOMADIK_FSMC_BASE

	ldr r1, =0x10DB		/* For 16-bit NOR flash */
	str r1, [r0, #0x08]

	ldr r1, =0x03333333	/* For 16-bit NOR flash */
	str r1, [r0, #0xc]

	/* oneNAND setting */
	ldr r1, =0x0000105B	/* BCR0 Prog control register */
	str r1, [r0]

	ldr r1, =0x0A200551	/* BTR0 Prog timing register */
	str r1, [r0, #0x04]

	/* preload the instructions into icache */
	add r0, pc, #0x1F
	bic r0, r0, #0x1F
	mcr p15, 0, r0, c7, c13, 1
	add r0, r0, #0x20
	mcr p15, 0, r0, c7, c13, 1

	/* Now Clear Remap */
	ldr r0, =NOMADIK_SRC_BASE

	ldr r1, =0x2004
	str r1, [r0]

	ldr r1, =0x10000000
	str r1, [r0, #0x10]

	ldr r0, =0x101E9000
	ldr r1, =0x2004
	str r1, [r0]

	ldr r0, =NOMADIK_SRC_BASE
	ldr r1, =0x2104
	str r1, [r0]

	/* FSMC setup -- */
	mov r0, #(NOMADIK_FSMC_BASE & 0x10000000)
	orr r0, r0, #(NOMADIK_FSMC_BASE & 0x0FFFFFFF)

	ldr r1, =0x10DB		/* For 16-bit NOR flash */
	str r1, [r0, #0x8]

	ldr r1, =0x03333333	/* For 16-bit NOR flash */
	str r1, [r0, #0xc]

	/* MPMC Setup */
	ldr r0, =NOMADIK_MPMC_BASE

	ldr r1, =0xF00003
	str r1, [r0]		/* Enable the MPMC and the DLL */

	ldr r1, =0x183
	str r1, [r0, #0x20]

	ldr r2, =NOMADIK_PMU_BASE

	ldr r1, =0x1111
	str r1, [r2]

	ldr r1, =0x1111		/* Prog the, mand delay strategy */
	str r1, [r0, #0x28]

	ldr r1, =0x103		/* NOP ,mand */
	str r1, [r0, #0x20]

	/* FIXME -- Wait required here */

	ldr r1, =0x103		/* PALL ,mand*/
	str r1, [r0, #0x20]

	ldr r1, =0x1
	str r1, [r0, #0x24]	/* To do at least two auto-refresh */

	/* FIXME -- Wait required here */

	/* Auto-refresh period = 7.8us @ SDRAM Clock = 100.8 MHz */
	ldr r1, =0x31
	str r1, [r0, #0x24]

	/* Prog Little Endian, Not defined in 8800 board */
	ldr r1, =0x0
	str r1,	[r0, #0x8]


	ldr r1, =0x2
	str r1, [r0, #0x30]		/* Prog tRP timing */

	ldr r1, =0x4			/* Change for 8815 */
	str r1, [r0, #0x34]		/* Prog tRAS timing */

	ldr r1, =0xB
	str r1, [r0, #0x38]		/* Prog tSREX timing */


	ldr r1, =0x1
	str r1, [r0, #0x44]		/* Prog tWR timing */

	ldr r1, =0x8
	str r1, [r0, #0x48]		/* Prog tRC timing */

	ldr r1, =0xA
	str r1, [r0, #0x4C]		/* Prog tRFC timing */

	ldr r1, =0xB
	str r1, [r0, #0x50]		/* Prog tXSR timing */

	ldr r1, =0x1
	str r1, [r0, #0x54]		/* Prog tRRD timing */

	ldr r1, =0x1
	str r1, [r0, #0x58]		/* Prog tMRD timing */

	ldr r1, =0x1
	str r1, [r0, #0x5C]		/* Prog tCDLR timing */

	/* DDR-SDRAM MEMORY IS ON BANK0 8815 */
	ldr r1, =0x304			/* Prog RAS and CAS for CS 0 */
	str r1, [r0, #0x104]

	/* SDR-SDRAM MEMORY IS ON BANK1 8815 */
	ldr r1, =0x304			/* Prog RAS and CAS for CS 1 */
	str r1, [r0, #0x124]
	/* THE DATA BUS WIDE IS PROGRAM FOR 16-BITS */
	/* DDR-SDRAM MEMORY IS ON BANK0*/

	ldr r1, =0x884			/* 8815 : config reg in BRC for CS0 */
	str r1, [r0, #0x100]

	/*SDR-SDRAM MEMORY IS ON BANK1*/

	ldr r1, =0x884			/* 8815 : config reg in BRC for CS1 */
	str r1, [r0, #0x120]

	ldr r1, =0x83			/*MODE Mand*/
	str r1, [r0, #0x20]

	/* LOAD MODE REGISTER FOR 2 bursts of 16b, with DDR mem ON BANK0 */

	ldr r1, =0x62000			/*Data in*/
	ldr r1, [r1]

	/* LOAD MODE REGISTER FOR 2 bursts of 16b, with DDR mem ON BANK1 */

	ldr r1, =0x8062000
	ldr r1, [r1]

	ldr r1, =0x003
	str r1, [r0, #0x20]

	/* ENABLE ALL THE BUFFER FOR EACH AHB PORT*/

	ldr r1, =0x01			/* Enable buffer 0 */
	str r1, [r0, #0x400]

	ldr r1, =0x01			/* Enable buffer 1 */
	str r1, [r0, #0x420]

	ldr r1, =0x01			/* Enable buffer 2 */
	str r1, [r0, #0x440]

	ldr r1, =0x01			/* Enable buffer 3 */
	str r1, [r0, #0x460]

	ldr r1, =0x01			/* Enable buffer 4 */
	str r1, [r0, #0x480]

	ldr r1, =0x01			/* Enable buffer 5 */
	str r1, [r0, #0x4A0]

	/* GPIO settings */

	ldr r0, =NOMADIK_GPIO1_BASE

	ldr r1, =0xC0600000
	str r1, [r0, #0x20]

	ldr r1, =0x3F9FFFFF		/* ABHI change this for uart1 */
	str r1, [r0, #0x24]

	ldr r1, =0x3F9FFFFF		/* ABHI change this for uart1 */
	str r1, [r0, #0x28]

	ldr r0, =NOMADIK_GPIO0_BASE

	ldr r1, =0xFFFFFFFF
	str r1, [r0, #0x20]

	ldr r1, =0x00
	str r1, [r0, #0x24]

	ldr r1, =0x00
	str r1, [r0, #0x28]

	/* Configure CPLD_CTRL register for enabling MUX logic for UART0/UART2 */

	ldr r0, =NOMADIK_FSMC_BASE

	ldr r1, =0x10DB			/* INIT FSMC bank 0 */
	str r1, [r0, #0x00]

	ldr r1, =0x0FFFFFFF
	str r1, [r0, #0x04]

	ldr r1, =0x010DB		/* INIT FSMC bank 1 */
	str r1, [r0, #0x08]

	ldr r1, =0x00FFFFFFF
	str r1, [r0, #0x0C]

	ldr r0, =NOMADIK_UART0_BASE

	ldr r1, =0x00000000
	str r1, [r0, #0x30]

	ldr r1, =0x0000004e
	str r1, [r0, #0x24]

	ldr r1, =0x00000008
	str r1, [r0, #0x28]

	ldr r1, =0x00000060
	str r1, [r0, #0x2C]

	ldr r1, =0x00000301
	str r1, [r0, #0x30]

	ldr r1, =0x00000066
	str r1, [r0]

	ldr r0, =NOMADIK_UART1_BASE

	ldr r1, =0x00000000
	str r1, [r0, #0x30]

	ldr r1, =0x0000004e
	str r1, [r0, #0x24]

	ldr r1, =0x00000008
	str r1, [r0, #0x28]

	ldr r1, =0x00000060
	str r1, [r0, #0x2C]

	ldr r1, =0x00000301
	str r1, [r0, #0x30]

	ldr r1, =0x00000066
	str r1, [r0]

	ldr r0, =NOMADIK_UART2_BASE

	ldr r1, =0x00000000
	str r1, [r0, #0x30]

	ldr r1, =0x0000004e
	str r1, [r0, #0x24]

	ldr r1, =0x00000008
	str r1, [r0, #0x28]

	ldr r1, =0x00000060
	str r1, [r0, #0x2C]

	ldr r1, =0x00000301
	str r1, [r0, #0x30]

	ldr r1, =0x00000066
	str r1, [r0]

	/* Configure CPLD to enable UART0 */

	mov pc, lr