1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#include "config.h"
29#include "version.h"
30
31
32
33
34
35
36#define MDCNFG 0x00
37#define MDCAS00 0x04
38#define MDCAS01 0x08
39#define MDCAS02 0x0C
40#define MSC0 0x10
41#define MSC1 0x14
42#define MECR 0x18
43#define MDREFR 0x1C
44#define MDCAS20 0x20
45#define MDCAS21 0x24
46#define MDCAS22 0x28
47#define MSC2 0x2C
48#define SMCNFG 0x30
49
50#define GPDR 0x04
51#define GPSR 0x08
52#define GPCR 0x0C
53#define GAFR 0x1C
54
55#define PPDR 0x00
56#define PPSR 0x04
57#define PPAR 0x08
58
59#define MDREFR_TRASR(n_) (n_ & (0x0000000f))
60#define MDREFR_DRI(n_) ((n_ & (0x00000fff)) << 4)
61#define MDREFR_K0DB2 (1 << 18)
62#define MDREFR_K1DB2 (1 << 22)
63#define MDREFR_K2DB2 (1 << 26)
64
65#define MDREFR_K0RUN (1 << 17)
66#define MDREFR_K1RUN (1 << 21)
67#define MDREFR_K2RUN (1 << 25)
68
69#define MDREFR_SLFRSH (1 << 31)
70#define MDREFR_E1PIN (1 << 20)
71
72#define PSSR 0x04
73#define PSSR_DH 0x00000008
74#define POSR 0x08
75#define RCSR 0x04
76
77
78
79
80MEM_BASE: .long 0xa0000000
81MEM_START: .long 0xc0000000
82PWR_BASE: .word 0x90020000
83RST_BASE: .long 0x90030000
84PPC_BASE: .long 0x90060000
85GPIO_BASE: .long 0x90040000
86IC_BASE: .word 0x90050000
87
88cpuspeed: .word 0xa0
89
90mdcnfg: .long 0x00037267
91mdcas00: .long 0x5555557f
92mdcas01: .long 0x55555555
93mdcas02: .long 0x55555555
94msc0: .long 0xfff04f78
95msc1: .long 0xfff8fff0
96mecr: .long 0x98c698c6
97mdrefr: .long 0x067600c7
98mdcas20: .long 0xd1284142
99mdcas21: .long 0x72249529
100mdcas22: .long 0x78414351
101msc2: .long 0x201d2959
102smcnfg: .long 0x00000000
103
104pin_set_out: .long 0x37ff70
105pin_set_dir: .long 0x11480
106
107gpdr_set: .long 0x0B3A0900
108gpsr_set: .long 0x02100800
109gpcr_set: .long 0x092A0100
110gafr_set: .long 0x08600000
111
112.globl lowlevel_init
113lowlevel_init:
114
115
116
117 ldr r0, PPC_BASE
118 ldr r1, pin_set_out
119 str r1, [r0,
120 ldr r1, pin_set_dir
121 str r1, [r0,
122
123
124
125
126 ldr r0, MEM_BASE
127
128 ldr r1, mdcnfg
129 str r1, [r0,
130 ldr r1, mdcas00
131 str r1, [r0,
132 ldr r1, mdcas01
133 str r1, [r0,
134 ldr r1, mdcas02
135 str r1, [r0,
136 ldr r1, mdcas20
137 str r1, [r0,
138 ldr r1, mdcas21
139 str r1, [r0,
140 ldr r1, mdcas22
141 str r1, [r0,
142
143
144 ldr r2, [r0,
145 bic r2, r2,
146 bic r2, r2,
147 bic r2, r2,
148 str r2, [r0,
149
150 ldr r2, [r0,
151 orr r2, r2,
152
153 mov r4,
154 spin: subs r4, r4,
155 bne spin
156
157 ldr r1, PWR_BASE
158 mov r2,
159 str r2, [r1,
160
161 ldr r2, [r0,
162 bic r2, r2,
163 bic r2, r2,
164 bic r2, r2,
165 str r2, [r0,
166
167 ldr r2, [r0,
168 orr r2, r2,
169 orr r2, r2,
170 orr r2, r2,
171 orr r2, r2,
172 orr r2, r2,
173 str r2, [r0,
174
175 ldr r2, [r0,
176 orr r2, r2,
177 orr r2, r2,
178 orr r2, r2,
179 str r2, [r0,
180
181 ldr r2, [r0,
182 bic r2, r2,
183 str r2, [r0,
184
185 ldr r2, [r0,
186 orr r2, r2,
187 str r2, [r0,
188
189 ldr r2, MEM_START
190.rept 8
191 ldr r3, [r2]
192.endr
193
194 ldr r2, [r0,
195 orr r2, r2,
196 orr r2, r2,
197 str r2, [r0,
198
199 ldr r1, msc0
200 str r1, [r0,
201 ldr r1, msc1
202 str r1, [r0,
203 ldr r1, msc2
204 str r1, [r0,
205 ldr r1, smcnfg
206 str r1, [r0,
207 ldr r1, mecr
208 str r1, [r0,
209
210 mov pc, lr
211