blob: 4080e28b3811ecaa9de745ada3515923ee1b37b3 [file] [log] [blame]
Brian Swetlanddfdb4612009-01-01 11:44:36 -08001/*
2 * Copyright (c) 2008, QUALCOMM Incorporated.
3 * Copyright (c) 2008, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google, Inc. nor the names of its contributors
16 * may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33
34/* TODO:
35 * - style cleanup
36 * - do we need to do *all* of this at boot?
37 */
38
39.text
40.code 32
41
42#define DSB .byte 0x4f, 0xf0, 0x7f, 0xf5
43#define ISB .byte 0x6f, 0xf0, 0x7f, 0xf5
44
45/*
46 ; LVT Ring Osc counter
47 ; used to determine sense amp settings
48 ; Clobbers registers r0, r4, r5, r6, r7, r9, r10, r11
49*/
50.equ CLK_CTL_BASE, 0xA8600000
51.equ A_GLBL_CLK_ENA, 0x0000
52.equ A_PRPH_WEB_NS_REG,0x0080
53.equ A_MSM_CLK_RINGOSC,0x00D0
54.equ A_TCXO_CNT, 0x00D4
55.equ A_TCXO_CNT_DONE, 0x00D8
56.equ A_RINGOSC_CNT, 0x00DC
57.equ A_MISC_CLK_CTL, 0x0108
58.equ CLK_TEST, 0xA8600114
59.equ SPSS_CSR_BASE, 0xAC100000
60.equ A_SCRINGOSC, 0x0510
61
62//;; Number of TCXO cycles to count ring oscillations
63.equ TCXO_CNT_VAL, 0x100
Brian Swetlanddfdb4612009-01-01 11:44:36 -080064
Ajay Dudaniae80c6e2009-11-28 14:15:03 -080065//; Raptor addresses
66.equ TCSR_SPARE2, 0xA8700060
Brian Swetlanddfdb4612009-01-01 11:44:36 -080067
Ajay Dudaniae80c6e2009-11-28 14:15:03 -080068/*
69;=======================================================================
70; Set_SA code to set cache settings based on ring oscillator/sense amps
71;=======================================================================
72*/
73SET_SA:
74 //; no stack at this point and any registers we use will be 0'd
75 //; after we return
76 LDR r0, =TCSR_SPARE2
77 LDR r1, [r0]
78 LDR r0, = 0x010F
79 AND r2, r1, r0 //; concerned with bits [8, 3:0]
Brian Swetlanddfdb4612009-01-01 11:44:36 -080080
Ajay Dudaniae80c6e2009-11-28 14:15:03 -080081 //;--------------------------------------------------------------------
82 //; Fuse bits used to determine sense amp settings
83 //;--------------------------------------------------------------------
Brian Swetlanddfdb4612009-01-01 11:44:36 -080084
Ajay Dudaniae80c6e2009-11-28 14:15:03 -080085 LDR r0, = 0x0105
86 AND r4, r2, r0 //; mask off all but L1 ACC2, L1 ACC1 and L1 ACC0
87 //;set to default of FC00
88 LDR r5, =PVR0F0_6bits //; point to PVR0F0
89 LDR r3, =PVR2F0_6bits //; point to PVR2F0
Brian Swetlanddfdb4612009-01-01 11:44:36 -080090
Ajay Dudaniae80c6e2009-11-28 14:15:03 -080091ck_0:
92 //; if L1_[2:0] == 000 then ACC setting = FC00
93 LDR r1, = 0x0
94 CMP r4, r1
95 BNE ck_1
96 B WRITE_L1_SA_SETTINGS
Brian Swetlanddfdb4612009-01-01 11:44:36 -080097
Ajay Dudaniae80c6e2009-11-28 14:15:03 -080098ck_1:
99 //; if L1_[2:0] == 001 then ACC setting = FC00
100 LDR r1, = 0x01
101 CMP r4, r1
102 BNE ck_2
103 B WRITE_L1_SA_SETTINGS
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800104
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800105ck_2:
106 //; if L1_[2:0] == 010 then ACC setting = 7C00
107 LDR r1, = 0x04
108 CMP r4, r1
109 BNE ck_3
110 LDR r5, =PVR0F0_5bits //; point to PVR0F0
111 LDR r3, =PVR2F0_5bits //; point to PVR2F0
112 B WRITE_L1_SA_SETTINGS
113
114ck_3:
115 //; if L1_[2:0] == 011 then ACC setting = FC00
116 LDR r1, = 0x05
117 CMP r4, r1
118 BNE ck_4
119 LDR r5, =PVR0F0_6bits //; point to PVR0F0
120 LDR r3, =PVR2F0_6bits //; point to PVR2F0
121 B WRITE_L1_SA_SETTINGS
122
123ck_4:
124 //; if L1_[2:0] == 0100 then ACC setting = 3C00
125 LDR r1, = 0x0100
126 CMP r4, r1
127 BNE ck_5
128 LDR r5, =PVR0F0_4bits //; point to PVR0F0
129 LDR r3, =PVR2F0_4bits //; point to PVR2F0
130 B WRITE_L1_SA_SETTINGS
131
132ck_5:
133 //; if L1_[2:0] == 0101 then ACC setting = 0400
134 LDR r1, = 0x0101
135 CMP r4, r1
136 BNE ck_6
137 LDR r5, =PVR0F0_1bits //; point to PVR0F0
138 LDR r3, =PVR2F0_1bits //; point to PVR2F0
139 B WRITE_L1_SA_SETTINGS
140
141ck_6:
142 //; if L1_[2:0] == 0110 then ACC setting = 0C00
143 LDR r1, = 0x0104
144 CMP r4, r1
145 BNE ck_7
146 LDR r5, =PVR0F0_2bits //; point to PVR0F0
147 LDR r3, =PVR2F0_2bits //; point to PVR2F0
148 B WRITE_L1_SA_SETTINGS
149
150ck_7:
151 //; if L1_[2:0] == 0111 then ACC setting = 1C00
152 LDR r1, = 0x0105
153 CMP r4, r1
154 LDREQ r5, =PVR0F0_3bits //; point to PVR0F0
155 LDREQ r3, =PVR2F0_3bits //; point to PVR2F0
156
157WRITE_L1_SA_SETTINGS:
158
159 LDR r5, [r5]
160 LDR r3, [r3]
161
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800162 //;WCP15_PVR0F0 r5
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800163 MCR p15,0x0,r5,c15,c15,0 //; write R5 to PVR0F0
164
165 //;WCP15_PVR2F0 r3
166 MCR p15,0x2,r3,c15,c15,0 //; write R3 to PVR2F0
167
168 AND r4, r2, #0x000A //; mask off all but L2 array SA settings
169 LDR r5, =HVT_010102 //; point to L2VR3F1 setting
170 //;it gets ovewritten if its one of the other two cases
171 //; if L2_1 and L2_0 == 0 ACC setting = 010102
172 LDR r1, = 0x0000
173 CMP r4, r1
174 BEQ WRITE_L2_SA_SETTINGS
175
176 //; if L2_1 = 0 & L2_0 = 1 ACC setting = 010102
177 LDR R1, = 0x0002
178 CMP r4, r1
179 BEQ WRITE_L2_SA_SETTINGS
180
181 //; if L2_1 = 1 & L2_0 = 0 ACC setting = 010101
182 LDR r5, =HVT_010101
183 LDR R1, = 0x0008
184 CMP r4, r1
185 BEQ WRITE_L2_SA_SETTINGS
186
187 //; else L2_1 = 1 & L2_0 = 1 ACC setting = 212102
188 LDR r5, =HVT_212102
189
190
191WRITE_L2_SA_SETTINGS:
192 //;WCP15_L2VR3F1 r4
193 LDR r5, [r5]
194 MCR p15,0x3,r5,c15,c15,1 //;write r4 to L2VR3F1
195
196 LDR r0, =0 //;make sure the registers we touched
197 LDR r1, =0 //;are cleared when we return
198 LDR r2, =0
199 LDR r3, =0
200 LDR r4, =0
201 LDR r5, =0
202
203 //; routine complete
204 BX LR
205
206//; L1 SA settings according to LVT speed
207PVR0F0_0bits:
208.word 0x38000000 //; PVR0F0
209PVR2F0_0bits:
210.word 0x00000000 //; PVR2F0 0 bits set
211
212PVR0F0_1bits:
213.word 0x38000400 //; PVR0F0
214PVR2F0_1bits:
215.word 0x04000000 //; PVR2F0 1 bits set
216
217PVR0F0_2bits:
218.word 0x38000C00 //; PVR0F0
219PVR2F0_2bits:
220.word 0x0C000000 //; PVR2F0 2 bits set
221
222PVR0F0_3bits:
223.word 0x38001C00 //; PVR0F0
224PVR2F0_3bits:
225.word 0x1C000000 //; PVR2F0 3 bits set
226
227PVR0F0_4bits:
228.word 0x38003C00 //; PVR0F0
229PVR2F0_4bits:
230.word 0x3C000000 //; PVR2F0 4 bits set
231
232PVR0F0_5bits:
233.word 0x38007C00 //; PVR0F0
234PVR2F0_5bits:
235.word 0x7C000000 //; PVR2F0 5 bits set
236
237PVR0F0_6bits:
238.word 0x3800FC00 //; PVR0F0
239PVR2F0_6bits:
240.word 0xFC000000 //; PVR2F0 6 bits set
241
242//; L2 SA settings according to HVT speed
243HVT_212102:
244.word 0x00212102 //; L2VR3F1
245
246HVT_010102:
247.word 0x00010102 //; L2VR3F1
248
249HVT_010101:
250.word 0x00010101 //; L2VR3F1
251.ltorg
252
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800253
254.globl __cpu_early_init
255__cpu_early_init:
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800256 b SET_SA
257 //; Zero out r0 for use throughout this code. All other GPRs
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800258 //; (r1-r3) are set throughout this code to help establish
259 //; a consistent startup state for any code that follows.
260 //; Users should add code at the end of this routine to establish
261 //; their own stack address (r13), add translation page tables, enable
262 //; the caches, etc.
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800263 MOV r0, #0x0
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800264
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800265
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800266 //; Remove hardcoded cache settings. appsbl_handler.s calls Set_SA
267 //; API to dynamically configure cache for slow/nominal/fast parts
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800268
269 //; DCIALL to invalidate L2 cache bank (needs to be run 4 times, once per bank)
270 //; This must be done early in code (prior to enabling the caches)
271 MOV r1, #0x2
272 MCR p15, 0, r1, c9, c0, 6 //; DCIALL bank D ([15:14] == 2'b00)
273 ORR r1, r1, #0x00004000
274 MCR p15, 0, r1, c9, c0, 6 //; DCIALL bank C ([15:14] == 2'b01)
275 ADD r1, r1, #0x00004000
276 MCR p15, 0, r1, c9, c0, 6 //; DCIALL bank B ([15:14] == 2'b10)
277 ADD r1, r1, #0x00004000
278 MCR p15, 0, r1, c9, c0, 6 //; DCIALL bank A ([15:14] == 2'b11)
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800279
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800280 //; Initialize the BPCR - setup Global History Mask (GHRM) to all 1's
281 //; and have all address bits (AM) participate.
282 //; Different settings can be used to improve performance
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800283 // MOVW r1, #0x01FF
284.word 0xe30011ff // hardcoded MOVW instruction due to lack of compiler support
285 // MOVT r1, #0x01FF
286.word 0xe34011ff // hardcoded MOVT instruction due to lack of compiler support
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800287 MCR p15, 7, r1, c15, c0, 2 //; WCP15_BPCR
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800288
289
290 //; Initialize all I$ Victim Registers to 0 for startup
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800291 MCR p15, 0, r0, c9, c1, 0 //; WCP15_ICVIC0 r0
292 MCR p15, 0, r0, c9, c1, 1 //; WCP15_ICVIC1 r0
293 MCR p15, 0, r0, c9, c1, 2 //; WCP15_ICVIC2 r0
294 MCR p15, 0, r0, c9, c1, 3 //; WCP15_ICVIC3 r0
295 MCR p15, 0, r0, c9, c1, 4 //; WCP15_ICVIC4 r0
296 MCR p15, 0, r0, c9, c1, 5 //; WCP15_ICVIC5 r0
297 MCR p15, 0, r0, c9, c1, 6 //; WCP15_ICVIC5 r0
298 MCR p15, 0, r0, c9, c1, 7 //; WCP15_ICVIC7 r0
299
300 //; Initialize all I$ Locked Victim Registers (Unlocked Floors) to 0
301 MCR p15, 1, r0, c9, c1, 0 //; WCP15_ICFLOOR0 r0
302 MCR p15, 1, r0, c9, c1, 1 //; WCP15_ICFLOOR1 r0
303 MCR p15, 1, r0, c9, c1, 2 //; WCP15_ICFLOOR2 r0
304 MCR p15, 1, r0, c9, c1, 3 //; WCP15_ICFLOOR3 r0
305 MCR p15, 1, r0, c9, c1, 4 //; WCP15_ICFLOOR4 r0
306 MCR p15, 1, r0, c9, c1, 5 //; WCP15_ICFLOOR5 r0
307 MCR p15, 1, r0, c9, c1, 6 //; WCP15_ICFLOOR6 r0
308 MCR p15, 1, r0, c9, c1, 7 //; WCP15_ICFLOOR7 r0
309
310 //; Initialize all D$ Victim Registers to 0
311 MCR p15, 2, r0, c9, c1, 0 //; WP15_DCVIC0 r0
312 MCR p15, 2, r0, c9, c1, 1 //; WP15_DCVIC1 r0
313 MCR p15, 2, r0, c9, c1, 2 //; WP15_DCVIC2 r0
314 MCR p15, 2, r0, c9, c1, 3 //; WP15_DCVIC3 r0
315 MCR p15, 2, r0, c9, c1, 4 //; WP15_DCVIC4 r0
316 MCR p15, 2, r0, c9, c1, 5 //; WP15_DCVIC5 r0
317 MCR p15, 2, r0, c9, c1, 6 //; WP15_DCVIC6 r0
318 MCR p15, 2, r0, c9, c1, 7 //; WP15_DCVIC7 r0
319
320 //; Initialize all D$ Locked VDCtim Registers (Unlocked Floors) to 0
321 MCR p15, 3, r0, c9, c1, 0 //; WCP15_DCFLOOR0 r0
322 MCR p15, 3, r0, c9, c1, 1 //; WCP15_DCFLOOR1 r0
323 MCR p15, 3, r0, c9, c1, 2 //; WCP15_DCFLOOR2 r0
324 MCR p15, 3, r0, c9, c1, 3 //; WCP15_DCFLOOR3 r0
325 MCR p15, 3, r0, c9, c1, 4 //; WCP15_DCFLOOR4 r0
326 MCR p15, 3, r0, c9, c1, 5 //; WCP15_DCFLOOR5 r0
327 MCR p15, 3, r0, c9, c1, 6 //; WCP15_DCFLOOR6 r0
328 MCR p15, 3, r0, c9, c1, 7 //; WCP15_DCFLOOR7 r0
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800329
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800330 //; Initialize ASID to zero
331 MCR p15, 0, r0, c13, c0, 1 //; WCP15_CONTEXTIDR r0
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800332
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800333 //; ICIALL to invalidate entire I-Cache
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800334 MCR p15, 0, r0, c7, c5, 0 //; ICIALLU
335
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800336 //; DCIALL to invalidate entire D-Cache
337 MCR p15, 0, r0, c9, c0, 6 //; DCIALL r0
338
339
340 //; The VBAR (Vector Base Address Register) should be initialized
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800341 //; early in your code. We are setting it to zero
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800342 MCR p15, 0, r0, c12, c0, 0 //; WCP15_VBAR r0
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800343
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800344 //; Ensure the MCR's above have completed their operation before continuing
345 DSB
346 ISB
347
348 //;-------------------------------------------------------------------
349 //; There are a number of registers that must be set prior to enabling
350 //; the MMU. The DCAR is one of these registers. We are setting
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800351 //; it to zero (no access) to easily detect improper setup in subsequent
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800352 //; code sequences
353 //;-------------------------------------------------------------------
354 //; Setup DACR (Domain Access Control Register) to zero
355 MCR p15, 0, r0, c3, c0, 0 //; WCP15_DACR r0
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800356
357 //; Setup DCLKCR to allow normal D-Cache line fills
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800358 MCR p15, 1, r0, c9, c0, 7 //; WCP15_DCLKCR r0
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800359
360 //; Setup the TLBLKCR
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800361 //; Victim = 6'b000000; Floor = 6'b000000;
362 //; IASIDCFG = 2'b00 (State-Machine); IALLCFG = 2'b01 (Flash); BNA = 1'b0;
363 MOV r1, #0x02
364 MCR p15, 0, r1, c10, c1, 3 //; WCP15_TLBLKCR r1
365
366 //;Make sure TLBLKCR is complete before continuing
367 ISB
368
369 //; Invalidate the UTLB
370 MCR p15, 0, r0, c8, c7, 0 //; UTLBIALL
371
372 //; Make sure UTLB request has been presented to macro before continuing
373 ISB
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800374
375 // Disable predecode repair cache on certain Scorpion revisions
376 // (Raptor V2 and earlier, or Halcyon V1)
377 MRC p15, 0, r1, c0, c0, 0 //; MIDR
378 BIC r2, r1, #0xf7 //; check for Raptor2 or below
379 LDR r3, =0x510f0000
380 CMP r2, r3
381 BEQ DPRC
382 BIC r2, r1, #0xf0 //; check for Halcyon V1
383 LDR r3, =0x511f0000
384 CMP r2, r3
385 BNE SYSI2
386
387DPRC:
388 MRC p15, 0, r1, c15, c15, 2 //; PVR0F2
389 ORR r1, r1, #0x10 //; enable bit 4
390 MCR p15, 0, r1, c15, c15, 2 //; disable predecode repair cache
391
392SYSI2:
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800393 //; setup L2CR1 to some default Instruction and data prefetching values
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800394 //; Users may want specific settings for various performance enhancements
395 //; In Halcyon we do not have broadcasting barriers. So we need to turn
396 // ; on bit 8 of L2CR1; which DBB:( Disable barrier broadcast )
397 MOV r2, #0x100
398 MCR p15, 3, r2, c15, c0, 3 //; WCP15_L2CR1 r0
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800399
400
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800401 //; Enable Z bit to enable branch prediction (default is off)
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800402 MRC p15, 0, r2, c1, c0, 0 //; RCP15_SCTLR r2
403 ORR r2, r2, #0x00000800
404 MCR p15, 0, r2, c1, c0, 0 //; WCP15_SCTLR r2
405
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800406 //; Make sure Link stack is initialized with branch and links to sequential addresses
407 //; This aids in creating a predictable startup environment
408 BL SEQ1
409SEQ1: BL SEQ2
410SEQ2: BL SEQ3
411SEQ3: BL SEQ4
412SEQ4: BL SEQ5
413SEQ5: BL SEQ6
414SEQ6: BL SEQ7
415SEQ7: BL SEQ8
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800416SEQ8:
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800417
418 //; REMOVE FOLLOWING THREE INSTRUCTIONS WHEN POWER COLLAPSE IS ENA
419 //;Make sure the DBGOSLSR[LOCK] bit is cleared to allow access to the debug registers
420 //; Writing anything but the "secret code" to the DBGOSLAR clears the DBGOSLSR[LOCK] bit
421 MCR p14, 0, r0, c1, c0, 4 //; WCP14_DBGOSLAR r0
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800422
423
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800424 //; Read the DBGPRSR to clear the DBGPRSR[STICKYPD]
425 //; Any read to DBGPRSR clear the STICKYPD bit
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800426 //; ISB guarantees the read completes before attempting to
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800427 //; execute a CP14 instruction.
428 MRC p14, 0, r3, c1, c5, 4 //; RCP14_DBGPRSR r3
429 ISB
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800430
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800431 //; Initialize the Watchpoint Control Registers to zero (optional)
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800432 //;;; MCR p14, 0, r0, c0, c0, 7 ; WCP14_DBGWCR0 r0
433 //;;; MCR p14, 0, r0, c0, c1, 7 ; WCP14_DBGWCR1 r0
434
435
436 //;----------------------------------------------------------------------
437 //; The saved Program Status Registers (SPSRs) should be setup
438 //; prior to any automatic mode switches. The following
439 //; code sets these registers up to a known state. Users will need to
440 //; customize these settings to meet their needs.
441 //;----------------------------------------------------------------------
442 MOV r2, #0x1f
443 MOV r1, #0x17 //;ABT mode
444 msr cpsr_c, r1 //;ABT mode
445 msr spsr_cxfs, r2 //;clear the spsr
446 MOV r1, #0x1b //;UND mode
447 msr cpsr_c, r1 //;UND mode
448 msr spsr_cxfs, r2 //;clear the spsr
449 MOV r1, #0x11 //;FIQ mode
450 msr cpsr_c, r1 //;FIQ mode
451 msr spsr_cxfs, r2 //;clear the spsr
452 MOV r1, #0x12 //;IRQ mode
453 msr cpsr_c, r1 //;IRQ mode
454 msr spsr_cxfs, r2 //;clear the spsr
455 MOV r1, #0x16 //;Monitor mode
456 msr cpsr_c, r1 //;Monitor mode
457 msr spsr_cxfs, r2 //;clear the spsr
458 MOV r1, #0x13 //;SVC mode
459 msr cpsr_c, r1 //;SVC mode
460 msr spsr_cxfs, r2 //;clear the spsr
461
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800462
463 //;----------------------------------------------------------------------
464 //; Enabling Error reporting is something users may want to do at
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800465 //; some other point in time. We have chosen some default settings
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800466 //; that should be reviewed. Most of these registers come up in an
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800467 //; unpredictable state after reset.
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800468 //;----------------------------------------------------------------------
469//;Start of error and control setting
470
471 //; setup L2CR0 with various L2/TCM control settings
472 //; enable out of order bus attributes and error reporting
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800473 //; this register comes up unpredictable after reset
474 // MOVW r1, #0x0F0F
475.word 0xe3001f0f // hardcoded MOVW instruction due to lack of compiler support
476 // MOVT r1, #0xC005
477.word 0xe34c1005 // hardcoded MOVW instruction due to lack of compiler support
478 MCR p15, 3, r1, c15, c0, 1 //; WCP15_L2CR0 r1
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800479
480 //; setup L2CPUCR
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800481 //; MOV r2, #0xFF
482 //; Enable I and D cache parity
483 //;L2CPUCR[7:5] = 3~Rh7 ~V enable parity error reporting for modified,
484 //;tag, and data parity errors
485 MOV r2, #0xe0
486 MCR p15, 3, r2, c15, c0, 2 //; WCP15_L2CPUCR r2
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800487
488 //; setup SPCR
489 //; enable all error reporting (reset value is unpredicatble for most bits)
490 MOV r3, #0x0F
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800491 MCR p15, 0, r3, c9, c7, 0 //; WCP15_SPCR r3
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800492
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800493 //; setup DMACHCRs (reset value unpredictable)
494 //; control setting and enable all error reporting
495 MOV r1, #0x0F
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800496
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800497 //; DMACHCR0 = 0000000F
498 MOV r2, #0x00 //; channel 0
499 MCR p15, 0, r2, c11, c0, 0 //; WCP15_DMASELR r2
500 MCR p15, 0, r1, c11, c0, 2 //; WCP15_DMACHCR r1
501
502 //; DMACHCR1 = 0000000F
503 MOV r2, #0x01 //; channel 1
504 MCR p15, 0, r2, c11, c0, 0 //; WCP15_DMASELR r2
505 MCR p15, 0, r1, c11, c0, 2 //; WCP15_DMACHCR r1
506
507 //; DMACHCR2 = 0000000F
508 MOV r2, #0x02 //; channel 2
509 MCR p15, 0, r2, c11, c0, 0 //; WCP15_DMASELR r2
510 MCR p15, 0, r1, c11, c0, 2 //; WCP15_DMACHCR r1
511
512 //; DMACHCR3 = 0000000F
513 MOV r2, #0x03 //; channel 3
514 MCR p15, 0, r2, c11, c0, 0 //; WCP15_DMASELR r2
515 MCR p15, 0, r1, c11, c0, 2 //; WCP15_DMACHCR r1
516
517 //; Set ACTLR (reset unpredictable)
518 //; Set AVIVT control, error reporting, etc.
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800519 //; MOV r3, #0x07
520 //; Enable I and D cache parity
521 //;ACTLR[2:0] = 3'h7 - enable parity error reporting from L2/I$/D$)
522 //;ACTLR[5:4] = 2'h3 - enable parity
523 //;ACTLR[19:18] =2'h3 - always generate and check parity(when MMU disabled).
524 //;Value to be written #0xC0037
525 // MOVW r3, #0x0037
526.word 0xe3003037 // hardcoded MOVW instruction due to lack of compiler support
527 // MOVT r3, #0x000C
528.word 0xe340300c // hardcoded MOVW instruction due to lack of compiler support
529 //; read the version_id to determine if d-cache should be disabled
530 LDR r2, = 0xa8e00270 //;Read HW_REVISION_NUMBER, HWIO_HW_REVISION_NUMBER_ADDR
531 LDR r2,[r2]
532 AND r2,r2,#0xf0000000 //;hw_revision mask off bits 28-31
533 //;if HW_revision is 1.0 or older, (revision==0)
534 CMP r2,#0
535 //; Disable d-cache on older QSD8650 (Rev 1.0) silicon
536 orreq r3, r3, #0x4000 //;disable dcache
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800537 MCR p15, 0, r3, c1, c0, 1 //; WCP15_ACTLR r3
538
539//;End of error and control setting
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800540
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800541 //;----------------------------------------------------------------------
542 //; Unlock ETM and read StickyPD to halt the ETM clocks from running.
543 //; This is required for power saving whether the ETM is used or not.
544 //;----------------------------------------------------------------------
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800545
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800546 //;Clear ETMOSLSR[LOCK] bit
547 MOV r1, #0x00000000
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800548 MCR p14, 1, r1, c1, c0, 4 //; WCP14_ETMOSLAR r1
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800549
550 //;Clear ETMPDSR[STICKYPD] bit
551 MRC p14, 1, r2, c1, c5, 4 //; RCP14_ETMPDSR r2
552
553/*
554#ifdef APPSBL_ETM_ENABLE
555 ;----------------------------------------------------------------------
556 ; Optionally Enable the ETM (Embedded Trace Macro) which is used for debug
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800557 ;----------------------------------------------------------------------
558
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800559 ; enable ETM clock if disabled
560 MRC p15, 7, r1, c15, c0, 5 ; RCP15_CPMR r1
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800561 ORR r1, r1, #0x00000008
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800562 MCR p15, 7, r1, c15, c0, 5 ; WCP15_CPMR r1
563 ISB
564
565 ; set trigger event to counter1 being zero
566 MOV r3, #0x00000040
567 MCR p14, 1, r3, c0, c2, 0 ; WCP14_ETMTRIGGER r3
568
569 ; clear ETMSR
570 MOV r2, #0x00000000
571 MCR p14, 1, r2, c0, c4, 0 ; WCP14_ETMSR r2
572
573 ; clear trace enable single address comparator usage
574 MCR p14, 1, r2, c0, c7, 0 ; WCP14_ETMTECR2 r2
575
576 ; set trace enable to always
577 MOV r2, #0x0000006F
578 MCR p14, 1, r2, c0, c8, 0 ; WCP14_ETMTEEVR r2
579
580 ; clear trace enable address range comparator usage and exclude nothing
581 MOV r2, #0x01000000
582 MCR p14, 1, r2, c0, c9, 0 ; WCP14_ETMTECR1 r2
583
584 ; set view data to always
585 MOV r2, #0x0000006F
586 MCR p14, 1, r2, c0, c12, 0 ; WCP14_ETMVDEVR r2
587
588 ; clear view data single address comparator usage
589 MOV r2, #0x00000000
590 MCR p14, 1, r2, c0, c13, 0 ; WCP14_ETMVDCR1 r2
591
592 ; clear view data address range comparator usage and exclude nothing
593 MOV r2, #0x00010000
594 MCR p14, 1, r2, c0, c15, 0 ; WCP14_ETMVDCR3 r2
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800595
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800596 ; set counter1 to 194
597 MOV r2, #0x000000C2
598 MCR p14, 1, r2, c0, c0, 5 ; WCP14_ETMCNTRLDVR1 r2
599
600 ; set counter1 to never reload
601 MOV r2, #0x0000406F
602 MCR p14, 1, r2, c0, c8, 5 ; WCP14_ETMCNTRLDEVR1 r2
603
604 ; set counter1 to decrement every cycle
605 MOV r2, #0x0000006F
606 MCR p14, 1, r2, c0, c4, 5 ; WCP14_ETMCNTENR1 r2
607
608 ; Set trace synchronization frequency 1024 bytes
609 MOV r2, #0x00000400
610 MCR p14, 1, r2, c0, c8, 7 ; WCP14_ETMSYNCFR r2
611
612 ; Program etm control register
613 ; - Set the CPU to ETM clock ratio to 1:1
614 ; - Set the ETM to perform data address tracing
615 MOV r2, #0x00002008
616 MCR p14, 1, r2, c0, c0, 0 ; WCP14_ETMCR r2
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800617 ISB
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800618#endif *//* APPSBL_ETM_ENABLE */
619
620/*
621#ifdef APPSBL_VFP_ENABLE
622 ;----------------------------------------------------------------------
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800623 ; Perform the following operations if you intend to make use of
624 ; the VFP/Neon unit. Note that the FMXR instruction requires a CPU ID
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800625 ; indicating the VFP unit is present (i.e.Cortex-A8). .
626 ; Some tools will require full double precision floating point support
627 ; which will become available in Scorpion pass 2
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800628 ;----------------------------------------------------------------------
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800629 ; allow full access to CP 10 and 11 space for VFP/NEON use
630 MRC p15, 0, r1, c1, c0, 2 ; Read CP Access Control Register
631 ORR r1, r1, #0x00F00000 ; enable full access for p10,11
632 MCR p15, 0, r1, c1, c0, 2 ; Write CPACR
633
634 ;make sure the CPACR is complete before continuing
635 ISB
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800636
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800637 ; Enable VFP itself (certain OSes may want to dynamically set/clear
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800638 ; the enable bit based on the application being executed
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800639 MOV r1, #0x40000000
640 FMXR FPEXC, r1
641#endif *//* APPSBL_VFP_ENABLE */
642
Ajay Dudaniae80c6e2009-11-28 14:15:03 -0800643/*
644 MEND
645
646#endif *//* _ARM_ASM_ */
Brian Swetlanddfdb4612009-01-01 11:44:36 -0800647
648.ltorg