]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/freescale/mx31_3stack/lowlevel_init.S
applied patches from Freescale and Ka-Ro
[karo-tx-uboot.git] / board / freescale / mx31_3stack / lowlevel_init.S
1 /*
2  * Copyright (C) 2008, Guennadi Liakhovetski <lg@denx.de>
3  * Copyright (C) 2008, Freescale Semiconductor
4  *      Modifications for MX31 3Stack board
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19  * MA 02111-1307 USA
20  */
21
22 #include <asm/arch/mx31-regs.h>
23
24 .macro REG reg, val
25         ldr r2, =\reg
26         ldr r3, =\val
27         str r3, [r2]
28 .endm
29
30 .macro REG8 reg, val
31         ldr r2, =\reg
32         ldr r3, =\val
33         strb r3, [r2]
34 .endm
35
36 .macro DELAY loops
37         ldr r2, =\loops
38 1:
39         subs    r2, r2, #1
40         nop
41         bcs 1b
42 .endm
43
44 .macro init_aips
45         /*
46          * Set all MPROTx to be non-bufferable, trusted for R/W,
47          * not forced to user-mode.
48          */
49         ldr r0, =0x43F00000
50         ldr r1, =0x77777777
51         str r1, [r0, #0x00]
52         str r1, [r0, #0x04]
53         ldr r0, =0x53F00000
54         str r1, [r0, #0x00]
55         str r1, [r0, #0x04]
56
57         /*
58          * Clear the on and off peripheral modules Supervisor Protect bit
59          * for SDMA to access them. Did not change the AIPS control registers
60          * (offset 0x20) access type
61          */
62         ldr r0, =0x43F00000
63         ldr r1, =0x0
64         str r1, [r0, #0x40]
65         str r1, [r0, #0x44]
66         str r1, [r0, #0x48]
67         str r1, [r0, #0x4C]
68         ldr r1, [r0, #0x50]
69         and r1, r1, #0x00FFFFFF
70         str r1, [r0, #0x50]
71
72         ldr r0, =0x53F00000
73         ldr r1, =0x0
74         str r1, [r0, #0x40]
75         str r1, [r0, #0x44]
76         str r1, [r0, #0x48]
77         str r1, [r0, #0x4C]
78         ldr r1, [r0, #0x50]
79         and r1, r1, #0x00FFFFFF
80         str r1, [r0, #0x50]
81 .endm /* init_aips */
82
83 .macro init_max
84         ldr r0, =0x43F04000
85         /* MPR - priority is M4 > M2 > M3 > M5 > M0 > M1 */
86         ldr r1, =0x00302154
87         str r1, [r0, #0x000]        /* for S0 */
88         str r1, [r0, #0x100]        /* for S1 */
89         str r1, [r0, #0x200]        /* for S2 */
90         str r1, [r0, #0x300]        /* for S3 */
91         str r1, [r0, #0x400]        /* for S4 */
92         /* SGPCR - always park on last master */
93         ldr r1, =0x10
94         str r1, [r0, #0x010]        /* for S0 */
95         str r1, [r0, #0x110]        /* for S1 */
96         str r1, [r0, #0x210]        /* for S2 */
97         str r1, [r0, #0x310]        /* for S3 */
98         str r1, [r0, #0x410]        /* for S4 */
99         /* MGPCR - restore default values */
100         ldr r1, =0x0
101         str r1, [r0, #0x800]        /* for M0 */
102         str r1, [r0, #0x900]        /* for M1 */
103         str r1, [r0, #0xA00]        /* for M2 */
104         str r1, [r0, #0xB00]        /* for M3 */
105         str r1, [r0, #0xC00]        /* for M4 */
106         str r1, [r0, #0xD00]        /* for M5 */
107 .endm /* init_max */
108
109 .macro init_m3if
110         /* Configure M3IF registers */
111         ldr r1, =0xB8003000
112         /*
113         * M3IF Control Register (M3IFCTL)
114         * MRRP[0] = L2CC0 not on priority list (0 << 0) = 0x00000000
115         * MRRP[1] = L2CC1 not on priority list (0 << 0) = 0x00000000
116         * MRRP[2] = MBX not on priority list (0 << 0)   = 0x00000000
117         * MRRP[3] = MAX1 not on priority list (0 << 0)  = 0x00000000
118         * MRRP[4] = SDMA not on priority list (0 << 0)  = 0x00000000
119         * MRRP[5] = MPEG4 not on priority list (0 << 0) = 0x00000000
120         * MRRP[6] = IPU1 on priority list (1 << 6)      = 0x00000040
121         * MRRP[7] = IPU2 not on priority list (0 << 0)  = 0x00000000
122         *                                               ------------
123         *                                                 0x00000040
124         */
125         ldr r0, =0x00000040
126         str r0, [r1]  /* M3IF control reg */
127 .endm /* init_m3if */
128
129 .macro  init_drive_strength
130         /*
131          * Disable maximum drive strength SDRAM/DDR lines by clearing DSE1 bits
132          * in SW_PAD_CTL registers
133          */
134
135         /* SDCLK */
136         ldr r1, =0x43FAC200
137         ldr r0, [r1, #0x6C]
138         bic r0, r0, #(1 << 12)
139         str r0, [r1, #0x6C]
140
141         /* CAS */
142         ldr r0, [r1, #0x70]
143         bic r0, r0, #(1 << 22)
144         str r0, [r1, #0x70]
145
146         /* RAS */
147         ldr r0, [r1, #0x74]
148         bic r0, r0, #(1 << 2)
149         str r0, [r1, #0x74]
150
151         /* CS2 (CSD0) */
152         ldr r0, [r1, #0x7C]
153         bic r0, r0, #(1 << 22)
154         str r0, [r1, #0x7C]
155
156         /* DQM3 */
157         ldr r0, [r1, #0x84]
158         bic r0, r0, #(1 << 22)
159         str r0, [r1, #0x84]
160
161         /* DQM2, DQM1, DQM0, SD31-SD0, A25-A0, MA10 (0x288..0x2DC) */
162         ldr r2, =22     /* (0x2E0 - 0x288) / 4 = 22 */
163 pad_loop:
164         ldr r0, [r1, #0x88]
165         bic r0, r0, #(1 << 22)
166         bic r0, r0, #(1 << 12)
167         bic r0, r0, #(1 << 2)
168         str r0, [r1, #0x88]
169         add r1, r1, #4
170         subs r2, r2, #0x1
171         bne pad_loop
172 .endm /* init_drive_strength */
173
174 .section ".text.init", "x"
175
176 .globl lowlevel_init
177 lowlevel_init:
178
179         ldr r0, =0x40000015        /* start from AIPS 2GB region */
180         mcr p15, 0, r0, c15, c2, 4
181
182         init_aips
183
184         init_max
185
186         init_m3if
187
188         init_drive_strength
189
190         /* Image Processing Unit: */
191         /* Too early to switch display on? */
192         REG     IPU_CONF, IPU_CONF_DI_EN
193         /* Clock Control Module: */
194         REG     CCM_CCMR, 0x074B0BF5    /* Use CKIH, MCU PLL off */
195
196         DELAY 0x40000
197
198         REG     CCM_CCMR, 0x074B0BF5 | CCMR_MPE         /* MCU PLL on */
199         /* Switch to MCU PLL */
200         REG     CCM_CCMR, (0x074B0BF5 | CCMR_MPE) & ~CCMR_MDS
201
202         /* 532-133-66.5 */
203         ldr     r0, =CCM_BASE
204         ldr     r1, =0xFF871D58
205         /* PDR0 */
206         str     r1, [r0, #0x4]
207         ldr     r1, MPCTL_PARAM_532
208         /* MPCTL */
209         str     r1, [r0, #0x10]
210
211         /* Set UPLL=240MHz, USB=60MHz */
212         ldr     r1, =0x49FCFE7F
213         /* PDR1 */
214         str     r1, [r0, #0x8]
215         ldr     r1, UPCTL_PARAM_240
216         /* UPCTL */
217         str     r1, [r0, #0x14]
218         /* default CLKO to 1/8 of the ARM core */
219         mov     r1, #0x000002C0
220         add     r1, r1, #0x00000006
221         /* COSR */
222         str     r1, [r0, #0x1c]
223
224         /* initial CSD0 MDDR */
225         REG     0xB8001004, 0x0075E73A
226         REG     0xB8001010, 0x00000002 /* reset */
227         REG     0xB8001010, 0x00000004
228         DELAY   0x10000
229
230         REG     0xB8001000, 0x92100000
231         REG     0x80000F00, 0x0
232         REG     0xB8001000, 0xA2100000
233         REG     0x80000000, 0x0
234         REG     0xB8001000, 0xB2100000
235         REG8    0x80000033, 0x0
236         REG8    0x81000000, 0xff
237         REG     0xB8001000, 0x82226080
238         REG     0x80000000, 0x0
239         REG     0xB8001010, 0x0000000c
240
241         mov     r13, ip
242         /* copy blocks of total uboot to DDR */
243         b       mxc_nand_load
244
245 MPCTL_PARAM_532:
246         .word (((1-1) << 26) + ((52-1) << 16) + (10 << 10) + (12 << 0))
247 UPCTL_PARAM_240:
248         .word (((2-1) << 26) + ((13-1) << 16) + (9  << 10) + (3  << 0))