Tegra2: Use clock and pinmux functions to simplify code
[oweals/u-boot.git] / arch / arm / cpu / armv7 / tegra2 / lowlevel_init.S
1 /*
2  * SoC-specific setup info
3  *
4  * (C) Copyright 2010,2011
5  * NVIDIA Corporation <www.nvidia.com>
6  *
7  * See file CREDITS for list of people who contributed to this
8  * project.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License as
12  * published by the Free Software Foundation; either version 2 of
13  * the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23  * MA 02111-1307 USA
24  */
25
26 #include <config.h>
27 #include <version.h>
28
29
30 _TEXT_BASE:
31         .word   CONFIG_SYS_TEXT_BASE    @ sdram load addr from config file
32
33 .global invalidate_dcache
34 invalidate_dcache:
35         mov pc, lr
36
37         .align  5
38 .global reset_cpu
39 reset_cpu:
40         ldr     r1, rstctl                      @ get addr for global reset
41                                                 @ reg
42         ldr     r3, [r1]
43         orr     r3, r3, #0x10
44         str     r3, [r1]                        @ force reset
45         mov     r0, r0
46 _loop_forever:
47         b       _loop_forever
48 rstctl:
49         .word   PRM_RSTCTRL
50
51 .globl lowlevel_init
52 lowlevel_init:
53         ldr     sp, SRAM_STACK
54         str     ip, [sp]
55         mov     ip, lr
56         bl      s_init                          @ go setup pll, mux & memory
57         ldr     ip, [sp]
58         mov     lr, ip
59
60         mov     pc, lr                          @ back to arch calling code
61
62
63 .globl startup_cpu
64 startup_cpu:
65         @ Initialize the AVP, clocks, and memory controller
66         @ SDRAM is guaranteed to be on at this point
67
68         ldr     r0, =cold_boot                  @ R0 = reset vector for CPU
69         bl      start_cpu                       @ start the CPU
70
71         @ Transfer control to the AVP code
72         bl      halt_avp
73
74         @ Should never get here
75 _loop_forever2:
76         b       _loop_forever2
77
78 .globl cache_configure
79 cache_configure:
80         stmdb   r13!,{r14}
81         @ invalidate instruction cache
82         mov     r1, #0
83         mcr     p15, 0, r1, c7, c5, 0
84
85         @ invalidate the i&d tlb entries
86         mcr     p15, 0, r1, c8, c5, 0
87         mcr     p15, 0, r1, c8, c6, 0
88
89         @ enable instruction cache
90         mrc     p15, 0, r1, c1, c0, 0
91         orr     r1, r1, #(1<<12)
92         mcr     p15, 0, r1, c1, c0, 0
93
94         bl      enable_scu
95
96         @ enable SMP mode and FW for CPU0, by writing to Auxiliary Ctl reg
97         mrc     p15, 0, r0, c1, c0, 1
98         orr     r0, r0, #0x41
99         mcr     p15, 0, r0, c1, c0, 1
100
101         @ Now flush the Dcache
102         mov     r0, #0
103         @ 256 cache lines
104         mov     r1, #256
105
106 invalidate_loop:
107         add     r1, r1, #-1
108         mov     r0, r1, lsl #5
109         @ invalidate d-cache using line (way0)
110         mcr     p15, 0, r0, c7, c6, 2
111
112         orr     r2, r0, #(1<<30)
113         @ invalidate d-cache using line (way1)
114         mcr     p15, 0, r2, c7, c6, 2
115
116         orr     r2, r0, #(2<<30)
117         @ invalidate d-cache using line (way2)
118         mcr     p15, 0, r2, c7, c6, 2
119
120         orr     r2, r0, #(3<<30)
121         @ invalidate d-cache using line (way3)
122         mcr     p15, 0, r2, c7, c6, 2
123         cmp     r1, #0
124         bne     invalidate_loop
125
126         @ FIXME: should have ap20's L2 disabled too?
127 invalidate_done:
128         ldmia   r13!,{pc}
129
130 .globl cold_boot
131 cold_boot:
132         msr     cpsr_c, #0xD3
133         @ Check current processor: CPU or AVP?
134         @  If CPU, go to CPU boot code, else continue on AVP path
135
136         ldr     r0, =NV_PA_PG_UP_BASE
137         ldr     r1, [r0]
138         ldr     r2, =PG_UP_TAG_AVP
139
140         @ are we the CPU?
141         ldr     sp, CPU_STACK
142         cmp     r1, r2
143         @ yep, we are the CPU
144         bne     _armboot_start
145
146         @ AVP initialization follows this path
147         ldr     sp, AVP_STACK
148         @ Init AVP and start CPU
149         b       startup_cpu
150
151         @ the literal pools origin
152         .ltorg
153
154 SRAM_STACK:
155         .word LOW_LEVEL_SRAM_STACK
156 AVP_STACK:
157         .word EARLY_AVP_STACK
158 CPU_STACK:
159         .word EARLY_CPU_STACK