]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/scb9328/lowlevel_init.S
remove unnecessary version.h includes
[karo-tx-uboot.git] / board / scb9328 / lowlevel_init.S
1 /*
2  * Copyright (C) 2004 Sascha Hauer, Synertronixx GmbH
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <config.h>
8 #include <asm/arch/imx-regs.h>
9
10 .globl lowlevel_init
11 lowlevel_init:
12
13         mov     r10, lr
14
15 /* Change PERCLK1DIV to 14 ie 14+1 */
16         ldr             r0,     =PCDR
17         ldr             r1,     =CONFIG_SYS_PCDR_VAL
18         str             r1,   [r0]
19
20 /* set MCU PLL Control Register 0 */
21
22         ldr             r0,     =MPCTL0
23         ldr             r1,     =CONFIG_SYS_MPCTL0_VAL
24         str             r1,   [r0]
25
26 /* set mpll restart bit */
27         ldr             r0, =CSCR
28         ldr             r1, [r0]
29         orr             r1,r1,#(1<<21)
30         str             r1, [r0]
31
32         mov             r2,#0x10
33 1:
34         mov             r3,#0x2000
35 2:
36         subs    r3,r3,#1
37         bne             2b
38
39         subs    r2,r2,#1
40         bne             1b
41
42 /* set System PLL Control Register 0 */
43
44         ldr             r0,     =SPCTL0
45         ldr             r1,     =CONFIG_SYS_SPCTL0_VAL
46         str             r1,   [r0]
47
48 /* set spll restart bit */
49         ldr             r0, =CSCR
50         ldr             r1, [r0]
51         orr             r1,r1,#(1<<22)
52         str             r1, [r0]
53
54         mov             r2,#0x10
55 1:
56         mov             r3,#0x2000
57 2:
58         subs    r3,r3,#1
59         bne             2b
60
61         subs    r2,r2,#1
62         bne             1b
63
64         ldr             r0,   =CSCR
65         ldr             r1,   =CONFIG_SYS_CSCR_VAL
66         str             r1,   [r0]
67
68 /* I have now read the ARM920 DataSheet back-to-Back, and have stumbled upon
69  *this.....
70  *
71  * It would appear that from a Cold-Boot the ARM920T enters "FastBus" mode CP15
72  * register 1, this stops it using the output of the PLL and thus runs at the
73  * slow rate. Unless you place the Core into "Asynch" mode, the CPU will never
74  * use the value set in the CM_OSC registers...regardless of what you set it
75  * too!  Thus, although i thought i was running at 140MHz, i'm actually running
76  * at 40!..
77
78  * Slapping this into my bootloader does the trick...
79
80  * MRC p15,0,r0,c1,c0,0    ; read core configuration register
81  * ORR r0,r0,#0xC0000000   ; set asynchronous clocks and not fastbus mode
82  * MCR p15,0,r0,c1,c0,0    ; write modified value to core configuration
83  * register
84  */
85         MRC p15,0,r0,c1,c0,0
86         ORR r0,r0,#0xC0000000
87         MCR p15,0,r0,c1,c0,0
88
89         ldr             r0,     =GPR(0)
90         ldr             r1,     =CONFIG_SYS_GPR_A_VAL
91         str             r1,   [r0]
92
93         ldr             r0,     =GIUS(0)
94         ldr             r1,     =CONFIG_SYS_GIUS_A_VAL
95         str             r1,   [r0]
96
97 /* CS3 becomes CS3 by clearing reset default bit 1 in FMCR */
98
99         ldr             r0,     =FMCR
100         ldr             r1,     =CONFIG_SYS_FMCR_VAL
101         str             r1,   [r0]
102
103         ldr             r0,     =CS0U
104         ldr             r1,     =CONFIG_SYS_CS0U_VAL
105         str             r1,   [r0]
106
107         ldr             r0,     =CS0L
108         ldr             r1,     =CONFIG_SYS_CS0L_VAL
109         str             r1,   [r0]
110
111         ldr             r0,     =CS1U
112         ldr             r1,     =CONFIG_SYS_CS1U_VAL
113         str             r1,   [r0]
114
115         ldr             r0,     =CS1L
116         ldr             r1,     =CONFIG_SYS_CS1L_VAL
117         str             r1,   [r0]
118
119         ldr             r0,     =CS2U
120         ldr             r1,     =CONFIG_SYS_CS2U_VAL
121         str             r1,   [r0]
122
123         ldr             r0,     =CS2L
124         ldr             r1,     =CONFIG_SYS_CS2L_VAL
125         str             r1,   [r0]
126
127         ldr             r0,     =CS3U
128         ldr             r1,     =CONFIG_SYS_CS3U_VAL
129         str             r1,   [r0]
130
131         ldr             r0,     =CS3L
132         ldr             r1,     =CONFIG_SYS_CS3L_VAL
133         str             r1,   [r0]
134
135         ldr             r0,     =CS4U
136         ldr             r1,     =CONFIG_SYS_CS4U_VAL
137         str             r1,   [r0]
138
139         ldr             r0,     =CS4L
140         ldr             r1,     =CONFIG_SYS_CS4L_VAL
141         str             r1,   [r0]
142
143         ldr             r0,     =CS5U
144         ldr             r1,     =CONFIG_SYS_CS5U_VAL
145         str             r1,   [r0]
146
147         ldr             r0,     =CS5L
148         ldr             r1,     =CONFIG_SYS_CS5L_VAL
149         str             r1,   [r0]
150
151 /* SDRAM Setup */
152
153         ldr             r0, =SDCTL0
154         ldr             r1, =PRECHARGE_CMD
155         str             r1,   [r0]
156
157         ldr             r0, =0x08200000
158         ldr             r1, =0x0 /* Issue Precharge all Command */
159         str             r1,   [r0]
160
161         ldr             r0, =SDCTL0
162         ldr             r1, =AUTOREFRESH_CMD
163         str             r1,   [r0]
164
165         ldr             r0, =0x08000000
166         ldr             r1, =0x0 /* Issue AutoRefresh Command */
167         str             r1,   [r0]
168         str             r1,   [r0]
169         str             r1,   [r0]
170         str             r1,   [r0]
171         str             r1,   [r0]
172         str             r1,   [r0]
173         str             r1,   [r0]
174         str             r1,   [r0]
175
176         ldr             r0, =SDCTL0
177         ldr             r1, =0xb10a8300
178         str             r1,   [r0]
179
180         ldr             r0, =0x08223000 /* CAS Latency 2 */
181         ldr             r1, =0x0   /* Issue Mode Register Command, Burst Length = 8 */
182         str             r1,   [r0]
183
184         ldr             r0, =SDCTL0
185         ldr             r1, =0x810a8200 /* Set to Normal Mode CAS 2 */
186         str             r1,   [r0]
187
188         mov     pc,r10