blob: d5727248db5cd49b92ef77f0e4baa5ceac77e6fb [file] [log] [blame]
wdenk7ac16102004-08-01 22:48:16 +00001/*
2 * Copyright (C) 2004 Sascha Hauer, Synertronixx GmbH
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
wdenk7ac16102004-08-01 22:48:16 +00005 */
6
7#include <config.h>
wdenk7ac16102004-08-01 22:48:16 +00008#include <asm/arch/imx-regs.h>
9
wdenk336b2bc2005-04-02 23:52:25 +000010.globl lowlevel_init
11lowlevel_init:
wdenk7ac16102004-08-01 22:48:16 +000012
13 mov r10, lr
14
15/* Change PERCLK1DIV to 14 ie 14+1 */
16 ldr r0, =PCDR
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020017 ldr r1, =CONFIG_SYS_PCDR_VAL
wdenk7ac16102004-08-01 22:48:16 +000018 str r1, [r0]
19
20/* set MCU PLL Control Register 0 */
21
22 ldr r0, =MPCTL0
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020023 ldr r1, =CONFIG_SYS_MPCTL0_VAL
wdenk7ac16102004-08-01 22:48:16 +000024 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
331:
34 mov r3,#0x2000
352:
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
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020045 ldr r1, =CONFIG_SYS_SPCTL0_VAL
wdenk7ac16102004-08-01 22:48:16 +000046 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
551:
56 mov r3,#0x2000
572:
58 subs r3,r3,#1
59 bne 2b
60
61 subs r2,r2,#1
62 bne 1b
63
64 ldr r0, =CSCR
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020065 ldr r1, =CONFIG_SYS_CSCR_VAL
wdenk7ac16102004-08-01 22:48:16 +000066 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)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020090 ldr r1, =CONFIG_SYS_GPR_A_VAL
wdenk7ac16102004-08-01 22:48:16 +000091 str r1, [r0]
92
93 ldr r0, =GIUS(0)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020094 ldr r1, =CONFIG_SYS_GIUS_A_VAL
wdenk7ac16102004-08-01 22:48:16 +000095 str r1, [r0]
96
97/* CS3 becomes CS3 by clearing reset default bit 1 in FMCR */
98
99 ldr r0, =FMCR
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200100 ldr r1, =CONFIG_SYS_FMCR_VAL
wdenk7ac16102004-08-01 22:48:16 +0000101 str r1, [r0]
102
103 ldr r0, =CS0U
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200104 ldr r1, =CONFIG_SYS_CS0U_VAL
wdenk7ac16102004-08-01 22:48:16 +0000105 str r1, [r0]
106
107 ldr r0, =CS0L
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200108 ldr r1, =CONFIG_SYS_CS0L_VAL
wdenk7ac16102004-08-01 22:48:16 +0000109 str r1, [r0]
110
111 ldr r0, =CS1U
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200112 ldr r1, =CONFIG_SYS_CS1U_VAL
wdenk7ac16102004-08-01 22:48:16 +0000113 str r1, [r0]
114
115 ldr r0, =CS1L
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200116 ldr r1, =CONFIG_SYS_CS1L_VAL
wdenk7ac16102004-08-01 22:48:16 +0000117 str r1, [r0]
118
119 ldr r0, =CS2U
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200120 ldr r1, =CONFIG_SYS_CS2U_VAL
wdenk7ac16102004-08-01 22:48:16 +0000121 str r1, [r0]
122
123 ldr r0, =CS2L
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200124 ldr r1, =CONFIG_SYS_CS2L_VAL
wdenk7ac16102004-08-01 22:48:16 +0000125 str r1, [r0]
126
127 ldr r0, =CS3U
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200128 ldr r1, =CONFIG_SYS_CS3U_VAL
wdenk7ac16102004-08-01 22:48:16 +0000129 str r1, [r0]
130
131 ldr r0, =CS3L
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200132 ldr r1, =CONFIG_SYS_CS3L_VAL
wdenk7ac16102004-08-01 22:48:16 +0000133 str r1, [r0]
134
135 ldr r0, =CS4U
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200136 ldr r1, =CONFIG_SYS_CS4U_VAL
wdenk7ac16102004-08-01 22:48:16 +0000137 str r1, [r0]
138
139 ldr r0, =CS4L
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200140 ldr r1, =CONFIG_SYS_CS4L_VAL
wdenk7ac16102004-08-01 22:48:16 +0000141 str r1, [r0]
142
143 ldr r0, =CS5U
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200144 ldr r1, =CONFIG_SYS_CS5U_VAL
wdenk7ac16102004-08-01 22:48:16 +0000145 str r1, [r0]
146
147 ldr r0, =CS5L
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200148 ldr r1, =CONFIG_SYS_CS5L_VAL
wdenk7ac16102004-08-01 22:48:16 +0000149 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