]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - board/ti/omap1510inn/lowlevel_init.S
4d3ec39a65911b08e5c958e11fa1571918cde99e
[karo-tx-uboot.git] / board / ti / omap1510inn / lowlevel_init.S
1 /*
2  * Board specific setup info
3  *
4  * (C) Copyright 2003
5  * Texas Instruments, <www.ti.com>
6  *
7  * -- Some bits of code used from rrload's head_OMAP1510.s --
8  * Copyright (C) 2002 RidgeRun, Inc.
9  *
10  * SPDX-License-Identifier:     GPL-2.0+
11  */
12
13 #include <config.h>
14 #include <version.h>
15
16 #if defined(CONFIG_OMAP1510)
17 #include <./configs/omap1510.h>
18 #endif
19
20 #define OMAP1510_CLKS ((1<<EN_XORPCK)|(1<<EN_PERCK)|(1<<EN_TIMCK)|(1<<EN_GPIOCK))
21
22
23 _TEXT_BASE:
24         .word   CONFIG_SYS_TEXT_BASE        /* sdram load addr from config.mk */
25
26 .globl lowlevel_init
27 lowlevel_init:
28
29         /*
30          * Configure 1510 pins functions to match our board.
31          */
32         ldr     r0, REG_PULL_DWN_CTRL_0
33         ldr     r1, VAL_PULL_DWN_CTRL_0
34         str     r1, [r0]
35         ldr     r0, REG_PULL_DWN_CTRL_1
36         ldr     r1, VAL_PULL_DWN_CTRL_1
37         str     r1, [r0]
38         ldr     r0, REG_PULL_DWN_CTRL_2
39         ldr     r1, VAL_PULL_DWN_CTRL_2
40         str     r1, [r0]
41         ldr     r0, REG_PULL_DWN_CTRL_3
42         ldr     r1, VAL_PULL_DWN_CTRL_3
43         str     r1, [r0]
44         ldr     r0, REG_FUNC_MUX_CTRL_4
45         ldr     r1, VAL_FUNC_MUX_CTRL_4
46         str     r1, [r0]
47         ldr     r0, REG_FUNC_MUX_CTRL_5
48         ldr     r1, VAL_FUNC_MUX_CTRL_5
49         str     r1, [r0]
50         ldr     r0, REG_FUNC_MUX_CTRL_6
51         ldr     r1, VAL_FUNC_MUX_CTRL_6
52         str     r1, [r0]
53         ldr     r0, REG_FUNC_MUX_CTRL_7
54         ldr     r1, VAL_FUNC_MUX_CTRL_7
55         str     r1, [r0]
56         ldr     r0, REG_FUNC_MUX_CTRL_8
57         ldr     r1, VAL_FUNC_MUX_CTRL_8
58         str     r1, [r0]
59         ldr     r0, REG_FUNC_MUX_CTRL_9
60         ldr     r1, VAL_FUNC_MUX_CTRL_9
61         str     r1, [r0]
62         ldr     r0, REG_FUNC_MUX_CTRL_A
63         ldr     r1, VAL_FUNC_MUX_CTRL_A
64         str     r1, [r0]
65         ldr     r0, REG_FUNC_MUX_CTRL_B
66         ldr     r1, VAL_FUNC_MUX_CTRL_B
67         str     r1, [r0]
68         ldr     r0, REG_FUNC_MUX_CTRL_C
69         ldr     r1, VAL_FUNC_MUX_CTRL_C
70         str     r1, [r0]
71         ldr     r0, REG_FUNC_MUX_CTRL_D
72         ldr     r1, VAL_FUNC_MUX_CTRL_D
73         str     r1, [r0]
74         ldr     r0, REG_VOLTAGE_CTRL_0
75         ldr     r1, VAL_VOLTAGE_CTRL_0
76         str     r1, [r0]
77         ldr     r0, REG_TEST_DBG_CTRL_0
78         ldr     r1, VAL_TEST_DBG_CTRL_0
79         str     r1, [r0]
80         ldr     r0, REG_MOD_CONF_CTRL_0
81         ldr     r1, VAL_MOD_CONF_CTRL_0
82         str     r1, [r0]
83
84         /* Move to 1510 mode */
85         ldr     r0, REG_COMP_MODE_CTRL_0
86         ldr     r1, VAL_COMP_MODE_CTRL_0
87         str     r1, [r0]
88
89         /* Set up Traffic Ctlr*/
90         ldr r0, REG_TC_IMIF_PRIO
91         mov r1, #0x0
92         str r1, [r0]
93         ldr r0, REG_TC_EMIFS_PRIO
94         str r1, [r0]
95         ldr r0, REG_TC_EMIFF_PRIO
96         str r1, [r0]
97
98         ldr r0, REG_TC_EMIFS_CONFIG
99         ldr r1, [r0]
100         bic r1, r1, #0x08   /* clear the global power-down enable PDE bit */
101         bic r1, r1, #0x01   /* write protect flash by clearing the WP bit */
102         str r1, [r0]        /* EMIFS GlB Configuration. (value 0x12 most likely) */
103
104         /* Setup some clock domains */
105         ldr r1, =OMAP1510_CLKS
106         ldr r0, REG_ARM_IDLECT2
107         strh r1, [r0]  /* CLKM, Clock domain control. */
108
109         mov r1, #0x01  /* PER_EN bit */
110         ldr r0, REG_ARM_RSTCT2
111         strh r1, [r0]  /* CLKM; Peripheral reset. */
112
113         /* Set CLKM to Sync-Scalable  */
114         /* I supposidly need to enable the dsp clock before switching */
115         mov r1, #0x1000
116         ldr r0, REG_ARM_SYSST
117         strh r1, [r0]
118         mov r0, #0x400
119 1:
120         subs r0, r0, #0x1   /* wait for any bubbles to finish */
121         bne 1b
122
123         ldr r1, VAL_ARM_CKCTL  /* use 12Mhz ref, PER must be <= 50Mhz so /2 */
124         ldr r0, REG_ARM_CKCTL
125         strh r1, [r0]
126
127         /* setup DPLL 1 */
128         ldr r1, VAL_DPLL1_CTL
129         ldr r0, REG_DPLL1_CTL
130         strh r1, [r0]
131         ands r1, r1, #0x10  /* Check if PLL is enabled. */
132         beq lock_end        /* Do not look for lock if BYPASS selected */
133 2:
134         ldrh r1, [r0]
135         ands r1, r1, #0x01  /* Check the LOCK bit. */
136         beq 2b              /* ...loop until bit goes hi. */
137 lock_end:
138
139         /* Set memory timings corresponding to the new clock speed */
140
141         /* Check execution location to determine current execution location
142          * and branch to appropriate initialization code.
143          */
144         mov r0, #0x10000000                 /* Load physical SDRAM base. */
145         mov r1, pc                          /* Get current execution location. */
146         /* Zero all but top 6 bits of PC, as they alone detect whether an
147          * address is in the range 0x1000:0000-0x13ff:ffff, the 64M sized
148          * valid range for SDRAM on the OMAP 1510/5910.
149          */
150         and r1, r1, #0xfc000000
151         cmp r1, r0                      /* Compare. */
152         beq skip_sdram                  /* Skip over EMIF-fast initialization
153                                          * if running from SDRAM.
154                                          */
155
156         /*
157          * Delay for SDRAM initialization.
158          */
159         mov r3, #0x1800                        /* value should be checked */
160 3:
161         subs r3, r3, #0x1                     /* Decrement count */
162         bne 3b
163
164         /*
165          * Set SDRAM control values. Disable refresh before MRS command.
166          */
167         ldr r0, VAL_TC_EMIFF_SDRAM_CONFIG   /* get good value */
168         bic r3, r0, #0xC                    /* (BIT3|BIT2) ulConfig with auto-refresh disabled. */
169         orr r3, r3, #0x8000000              /* (BIT27) Disable CLK when Power down or Self-Refresh */
170         orr r3, r3, #0x4000000              /* BIT26 Power Down Enable */
171         ldr r2, REG_TC_EMIFF_SDRAM_CONFIG   /* Point to configuration register. */
172         str r3, [r2]                        /* Store the passed value with AR disabled. */
173
174         ldr r1, VAL_TC_EMIFF_MRS            /* get MRS value */
175         ldr r2, REG_TC_EMIFF_MRS            /* Point to MRS register. */
176         str r1, [r2]                        /* Store the passed value.*/
177
178         ldr r2, REG_TC_EMIFF_SDRAM_CONFIG   /* Point to configuration register. */
179         str r0, [r2]                        /* Store the passed value. */
180
181         /*
182          * Delay for SDRAM initialization.
183          */
184         mov r3, #0x1800
185 4:
186         subs r3, r3, #1                     /* Decrement count. */
187         bne 4b
188
189 skip_sdram:
190
191         /* slow interface */
192         ldr r1, VAL_TC_EMIFS_CS0_CONFIG
193         ldr r0, REG_TC_EMIFS_CS0_CONFIG
194         str r1, [r0] /* Chip Select 0 */
195         ldr r1, VAL_TC_EMIFS_CS1_CONFIG
196         ldr r0, REG_TC_EMIFS_CS1_CONFIG
197         str r1, [r0] /* Chip Select 1 */
198         ldr r1, VAL_TC_EMIFS_CS2_CONFIG
199         ldr r0, REG_TC_EMIFS_CS2_CONFIG
200         str r1, [r0] /* Chip Select 2 */
201         ldr r1, VAL_TC_EMIFS_CS3_CONFIG
202         ldr r0, REG_TC_EMIFS_CS3_CONFIG
203         str r1, [r0] /* Chip Select 3 */
204
205  /* Next, Enable the RS232 Line Drivers in the FPGA. */
206  /* Also, power on the audio CODEC's amplifier here, */
207  /* which will make a noise on the audio output. */
208  /* This is done here instead of in the kernel so there */
209  /* isn't a loud popping noise at the start of each */
210  /* song. */
211  /* Also, disable the CODEC's clocks. */
212  /* omap1510-HelenP1 [specific] */
213
214         ldr r0, REG_FPGA_POWER
215         mov r1, #0
216         ldr r2, REG_FPGA_DIP_SWITCH
217         ldrb r3, [r2]
218         cmp r3, #0x8
219         movne r1, #0x62     /* Enable the RS232 Line Drivers in the EPLD */
220         strb r1, [r0]
221         ldr r0, REG_FPGA_AUDIO
222         mov r1, #0x0     /* Disable sound driver (CODEC clocks) */
223         strb r1, [r0]
224
225         /* back to arch calling code */
226         mov     pc, lr
227
228 /* the literal pools origin */
229         .ltorg
230
231 /* OMAP configuration registers */
232 REG_FUNC_MUX_CTRL_0:            /* 32 bits */
233         .word 0xfffe1000
234 REG_FUNC_MUX_CTRL_1:            /* 32 bits */
235         .word 0xfffe1004
236 REG_FUNC_MUX_CTRL_2:            /* 32 bits */
237         .word 0xfffe1008
238 REG_COMP_MODE_CTRL_0:           /* 32 bits */
239         .word 0xfffe100c
240 REG_FUNC_MUX_CTRL_3:            /* 32 bits */
241         .word 0xfffe1010
242 REG_FUNC_MUX_CTRL_4:            /* 32 bits */
243         .word 0xfffe1014
244 REG_FUNC_MUX_CTRL_5:            /* 32 bits */
245         .word 0xfffe1018
246 REG_FUNC_MUX_CTRL_6:            /* 32 bits */
247         .word 0xfffe101c
248 REG_FUNC_MUX_CTRL_7:            /* 32 bits */
249         .word 0xfffe1020
250 REG_FUNC_MUX_CTRL_8:            /* 32 bits */
251         .word 0xfffe1024
252 REG_FUNC_MUX_CTRL_9:            /* 32 bits */
253         .word 0xfffe1028
254 REG_FUNC_MUX_CTRL_A:            /* 32 bits */
255         .word 0xfffe102C
256 REG_FUNC_MUX_CTRL_B:            /* 32 bits */
257         .word 0xfffe1030
258 REG_FUNC_MUX_CTRL_C:            /* 32 bits */
259         .word 0xfffe1034
260 REG_FUNC_MUX_CTRL_D:            /* 32 bits */
261         .word 0xfffe1038
262 REG_PULL_DWN_CTRL_0:            /* 32 bits */
263         .word 0xfffe1040
264 REG_PULL_DWN_CTRL_1:            /* 32 bits */
265         .word 0xfffe1044
266 REG_PULL_DWN_CTRL_2:            /* 32 bits */
267         .word 0xfffe1048
268 REG_PULL_DWN_CTRL_3:            /* 32 bits */
269         .word 0xfffe104c
270 REG_VOLTAGE_CTRL_0:             /* 32 bits */
271         .word 0xfffe1060
272 REG_TEST_DBG_CTRL_0:            /* 32 bits */
273         .word 0xfffe1070
274 REG_MOD_CONF_CTRL_0:            /* 32 bits */
275         .word 0xfffe1080
276 REG_TC_IMIF_PRIO:               /* 32 bits */
277         .word 0xfffecc00
278 REG_TC_EMIFS_PRIO:              /* 32 bits */
279         .word 0xfffecc04
280 REG_TC_EMIFF_PRIO:              /* 32 bits */
281         .word 0xfffecc08
282 REG_TC_EMIFS_CONFIG:            /* 32 bits */
283         .word 0xfffecc0c
284 REG_TC_EMIFS_CS0_CONFIG:        /* 32 bits */
285         .word 0xfffecc10
286 REG_TC_EMIFS_CS1_CONFIG:        /* 32 bits */
287         .word 0xfffecc14
288 REG_TC_EMIFS_CS2_CONFIG:        /* 32 bits */
289         .word 0xfffecc18
290 REG_TC_EMIFS_CS3_CONFIG:        /* 32 bits */
291         .word 0xfffecc1c
292 REG_TC_EMIFF_SDRAM_CONFIG:      /* 32 bits */
293         .word 0xfffecc20
294 REG_TC_EMIFF_MRS:               /* 32 bits */
295         .word 0xfffecc24
296 /* MPU clock/reset/power mode control registers */
297 REG_ARM_CKCTL:                  /* 16 bits */
298         .word 0xfffece00
299 REG_ARM_IDLECT2:                /* 16 bits */
300         .word 0xfffece08
301 REG_ARM_RSTCT2:                 /* 16 bits */
302         .word 0xfffece14
303 REG_ARM_SYSST:                  /* 16 bits */
304         .word 0xfffece18
305 /* DPLL control registers */
306 REG_DPLL1_CTL:                  /* 16 bits */
307         .word 0xfffecf00
308 /* identification code register */
309 REG_IDCODE:                     /* 32 bits */
310         .word 0xfffed404
311
312 /* Innovator specific */
313 REG_FPGA_LED_DIGIT:             /* 8 bits (not used on Innovator) */
314         .word 0x08000003
315 REG_FPGA_POWER:                 /* 8 bits */
316         .word 0x08000005
317 REG_FPGA_AUDIO:                 /* 8 bits (not used on Innovator) */
318         .word 0x0800000c
319 REG_FPGA_DIP_SWITCH:            /* 8 bits (not used on Innovator) */
320         .word 0x0800000e
321
322 VAL_COMP_MODE_CTRL_0:
323         .word 0x0000eaef
324 VAL_FUNC_MUX_CTRL_4:
325         .word 0x00000000
326 VAL_FUNC_MUX_CTRL_5:
327         .word 0x00000000
328 VAL_FUNC_MUX_CTRL_6:
329         .word 0x00000001
330 VAL_FUNC_MUX_CTRL_7:
331         .word 0x00000000
332 VAL_FUNC_MUX_CTRL_8:
333         .word 0x10001200
334 VAL_FUNC_MUX_CTRL_9:
335         .word 0x01201012
336 VAL_FUNC_MUX_CTRL_A:
337         .word 0x00000248
338 VAL_FUNC_MUX_CTRL_B:
339         .word 0x00000248
340 VAL_FUNC_MUX_CTRL_C:
341         .word 0x09000000
342 VAL_FUNC_MUX_CTRL_D:
343         .word 0x00000000
344 VAL_PULL_DWN_CTRL_0:
345         .word 0x11a10000
346 VAL_PULL_DWN_CTRL_1:
347         .word 0x2e047fff
348 VAL_PULL_DWN_CTRL_2:
349         .word 0xffd603a6
350 VAL_PULL_DWN_CTRL_3:
351         .word 0x00003e03
352 VAL_VOLTAGE_CTRL_0:
353         .word 0x00000007
354 VAL_TEST_DBG_CTRL_0:
355         /*  See Errata 4.13, This works around a SRAM bug, for chips below ES2.5 .
356          *   This slows down internal SRAM accesses.
357          */
358         .word 0x00000007
359 VAL_MOD_CONF_CTRL_0:
360         .word 0x0b000008
361 VAL_ARM_CKCTL:
362         .word 0x010f
363 VAL_DPLL1_CTL:
364         .word 0x2710
365 VAL_TC_EMIFS_CS1_CONFIG_PRELIM:
366         .word 0x00001149
367 VAL_TC_EMIFS_CS2_CONFIG_PRELIM:
368         .word 0x00004158
369 VAL_TC_EMIFS_CS0_CONFIG:
370         .word 0x002130b0
371 VAL_TC_EMIFS_CS1_CONFIG:
372         .word 0x0000f559
373 VAL_TC_EMIFS_CS2_CONFIG:
374         .word 0x000055f0
375 VAL_TC_EMIFS_CS3_CONFIG:
376         .word 0x00003331
377 VAL_TC_EMIFF_SDRAM_CONFIG:
378         .word 0x010290fc
379 VAL_TC_EMIFF_MRS:
380         .word 0x00000027