]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - patches/0040-ENGR00116504-1-Sync-clock-and-l2cc-code-with-redboo.patch
imported Ka-Ro specific additions to U-Boot 2009.08 for TX28
[karo-tx-uboot.git] / patches / 0040-ENGR00116504-1-Sync-clock-and-l2cc-code-with-redboo.patch
1 From caeb913349bcff570906d425a6afc2d8b5e0db59 Mon Sep 17 00:00:00 2001
2 From: Terry Lv <r65388@freescale.com>
3 Date: Fri, 18 Sep 2009 10:11:09 +0800
4 Subject: [PATCH] ENGR00116504-1: Sync clock and l2cc code with redboot.
5
6 Syc clock and l2cc code with redboot.
7
8 Signed-off-by: Terry Lv <r65388@freescale.com>
9 (cherry picked from commit f712613010e3bf2c186f05a1b7381483d733b925)
10 ---
11  board/freescale/mx51_bbg/lowlevel_init.S |  171 +++++++++++++++++-------------
12  include/asm-arm/arch-mx51/mx51.h         |    4 +-
13  2 files changed, 102 insertions(+), 73 deletions(-)
14
15 diff --git a/board/freescale/mx51_bbg/lowlevel_init.S b/board/freescale/mx51_bbg/lowlevel_init.S
16 index e974a5f..b8abae4 100644
17 --- a/board/freescale/mx51_bbg/lowlevel_init.S
18 +++ b/board/freescale/mx51_bbg/lowlevel_init.S
19 @@ -36,9 +36,22 @@
20   * L2CC Cache setup/invalidation/disable
21   */
22  .macro init_l2cc
23 -       /* reconfigure L2 cache aux control reg */
24 -       ldr r0, =0x03C000C4
25 -       mcr p15, 1, r0, c9, c0, 2
26 +       /* explicitly disable L2 cache */
27 +        mrc 15, 0, r0, c1, c0, 1
28 +        bic r0, r0, #0x2
29 +        mcr 15, 0, r0, c1, c0, 1
30 +
31 +        /* reconfigure L2 cache aux control reg */
32 +        mov r0, #0xC0                   /* tag RAM */
33 +        add r0, r0, #0x4                /* data RAM */
34 +        orr r0, r0, #(1 << 24)          /* disable write allocate delay */
35 +        orr r0, r0, #(1 << 23)          /* disable write allocate combine */
36 +        orr r0, r0, #(1 << 22)          /* disable write allocate */
37 +
38 +       cmp r3, #0x10    /* r3 contains the silicon rev */
39 +       orrls r0, r0, #(1 << 25)    /* ENGcm09124: disable write combine for TO 2 and lower revs */
40 +
41 +       mcr 15, 1, r0, c9, c0, 2
42  .endm /* init_l2cc */
43  
44  /* AIPS setup - Only setup MPROTx registers.
45 @@ -126,26 +139,52 @@
46  
47  .macro init_clock
48         ldr r0, =CCM_BASE_ADDR
49 -       mov r1, #0x00060000
50 -       str r1, [r0, #CLKCTL_CCDR]
51 +
52 +       /* Gate of clocks to the peripherals first */
53 +       ldr r1, =0x3FFFFFFF
54 +       str r1, [r0, #CLKCTL_CCGR0]
55 +       ldr r1, =0x0
56 +       str r1, [r0, #CLKCTL_CCGR1]
57 +       str r1, [r0, #CLKCTL_CCGR2]
58 +       str r1, [r0, #CLKCTL_CCGR3]
59 +
60 +       ldr r1, =0x00030000
61 +       str r1, [r0, #CLKCTL_CCGR4]
62 +       ldr r1, =0x00FFF030
63 +       str r1, [r0, #CLKCTL_CCGR5]
64 +       ldr r1, =0x00000300
65 +       str r1, [r0, #CLKCTL_CCGR6]
66 +
67 +        /* Disable IPU and HSC dividers */
68 +        mov r1, #0x60000
69 +        str r1, [r0, #CLKCTL_CCDR]
70 +
71 +       /* Make sure to switch the DDR away from PLL 1 */
72 +       ldr r1, =0x19239145
73 +       str r1, [r0, #CLKCTL_CBCDR]
74 +       /* make sure divider effective */
75 +1:     ldr r1, [r0, #CLKCTL_CDHIPR]
76 +       cmp r1, #0x0
77 +       bne 1b
78  
79         /* Switch ARM to step clock */
80         mov r1, #0x4
81         str r1, [r0, #CLKCTL_CCSR]
82 -
83         mov r3, #DP_OP_800
84         mov r4, #DP_MFD_800
85         mov r5, #DP_MFN_800
86         setup_pll PLL1_BASE_ADDR
87 +
88         mov r3, #DP_OP_665
89         mov r4, #DP_MFD_665
90         mov r5, #DP_MFN_665
91         setup_pll PLL3_BASE_ADDR
92  
93         /* Switch peripheral to PLL 3 */
94 -       ldr r1, =0x0000D3C0
95 +       ldr r0, =CCM_BASE_ADDR
96 +        ldr r1, =0x000010C0
97         str r1, [r0, #CLKCTL_CBCMR]
98 -       ldr r1, =0x033B9145
99 +       ldr r1, =0x13239145
100         str r1, [r0, #CLKCTL_CBCDR]
101         mov r3, #DP_OP_665
102         mov r4, #DP_MFD_665
103 @@ -153,9 +192,10 @@
104         setup_pll PLL2_BASE_ADDR
105  
106         /* Switch peripheral to PLL2 */
107 -       ldr r1, =0x013B9145
108 +       ldr r0, =CCM_BASE_ADDR
109 +       ldr r1, =0x19239145
110         str r1, [r0, #CLKCTL_CBCDR]
111 -       ldr r1, =0x0000E3C0
112 +       ldr r1, =0x000020C0
113         str r1, [r0, #CLKCTL_CBCMR]
114  
115         mov r3, #DP_OP_216
116 @@ -163,30 +203,39 @@
117         mov r5, #DP_MFN_216
118         setup_pll PLL3_BASE_ADDR
119  
120 +
121         /* Set the platform clock dividers */
122 -       ldr r2, =ARM_BASE_ADDR
123 +       ldr r0, =ARM_BASE_ADDR
124         ldr r1, =0x00000725
125 -       str r1, [r2, #0x14]
126 +       str r1, [r0, #0x14]
127 +
128 +       ldr r0, =CCM_BASE_ADDR
129 +       mov r1, #0x1
130 +       str r1, [r0, #CLKCTL_CACRR]
131  
132         /* Switch ARM back to PLL 1 */
133         mov r1, #0
134 -       str r1, [r0,  #CLKCTL_CCSR]
135 -       str r1, [r0,  #CLKCTL_CACRR]
136 +       str r1, [r0, #CLKCTL_CCSR]
137  
138 +       /* setup the rest */
139         /* Use lp_apm (24MHz) source for perclk */
140 -       mov r2, #0x48
141 -       ldr r2, [r0]
142 -       cmp r2, #0x10
143 -       ldrhs r1, =0x000020C2
144 -       ldrlo r1, =0x0000E3C2
145 +       ldr r1, =0x000020C2
146         str r1, [r0, #CLKCTL_CBCMR]
147 -       /* TO1.x emi = ahb, all perclk dividers are 1 since using 24MHz */
148 -       /* TO2.x ddr from PLL1, all perclk dividers are 1 since using 24MHz */
149 -       ldrhs r1, =0x59239100
150 -       ldrlo r1, =0x013D9100
151 -       strlo r1, [r0, #CLKCTL_CBCDR]
152 +       /* ddr clock from PLL 1, all perclk dividers are 1 since using 24MHz */
153 +       ldr r1, =0x59E35100
154 +       str r1, [r0, #CLKCTL_CBCDR]
155  
156 -       /* use PLL2 for UART source, get 66.5MHz */
157 +       /* Restore the default values in the Gate registers */
158 +       ldr r1, =0xFFFFFFFF
159 +       str r1, [r0, #CLKCTL_CCGR0]
160 +       str r1, [r0, #CLKCTL_CCGR1]
161 +       str r1, [r0, #CLKCTL_CCGR2]
162 +       str r1, [r0, #CLKCTL_CCGR3]
163 +       str r1, [r0, #CLKCTL_CCGR4]
164 +       str r1, [r0, #CLKCTL_CCGR5]
165 +       str r1, [r0, #CLKCTL_CCGR6]
166 +
167 +       /* Use PLL 2 for UART's, get 66.5MHz from it */
168         ldr r1, =0xA5A2A020
169         str r1, [r0, #CLKCTL_CSCMR1]
170         ldr r1, =0x00C30321
171 @@ -194,11 +243,16 @@
172  
173         /* make sure divider effective */
174  1:     ldr r1, [r0, #CLKCTL_CDHIPR]
175 -       cmp r1, #0
176 +       cmp r1, #0x0
177         bne 1b
178  
179         mov r1, #0x0
180         str r1, [r0, #CLKCTL_CCDR]
181 +
182 +       /* for cko - for ARM div by 8 */
183 +       mov r1, #0x000A0000
184 +       add r1, r1, #0x00000F0
185 +       str r1, [r0, #CLKCTL_CCOSR]
186  .endm
187  
188  .macro setup_wdog
189 @@ -211,48 +265,27 @@
190  
191  .globl lowlevel_init
192  lowlevel_init:
193 -       /* Platform CHIP level init*/
194         ldr r0, =GPIO1_BASE_ADDR
195 -    ldr r1, [r0, #0x0]
196 -    orr r1, r1, #(1 << 23)
197 -    str r1, [r0, #0x0]
198 -    ldr r1, [r0, #0x4]
199 -    orr r1, r1, #(1 << 23)
200 -    str r1, [r0, #0x4]
201 -
202 -#ifdef TURN_OFF_IMPRECISE_ABORT
203 -       mrs r0, cpsr
204 -       bic r0, r0, #0x100
205 -       msr cpsr, r0
206 -#endif
207 -
208 -       mrc 15, 0, r1, c1, c0, 0
209 -
210 -#ifndef BRANCH_PREDICTION_ENABLE
211 -       mrc 15, 0, r0, c1, c0, 1
212 -       bic r0, r0, #7
213 -       mcr 15, 0, r0, c1, c0, 1
214 -#else
215 -       mrc 15, 0, r0, c1, c0, 1
216 -       orr r0, r0, #7
217 -       mcr 15, 0, r0, c1, c0, 1
218 -       orr r1, r1, #(1<<11)
219 -#endif
220 -
221 -#ifdef UNALIGNED_ACCESS_ENABLE
222 -       orr r1, r1, #(1<<22)
223 -#endif
224 -
225 -#ifdef LOW_INT_LATENCY_ENABLE
226 -       orr r1, r1, #(1<<21)
227 -#endif
228 -       mcr 15, 0, r1, c1, c0, 0
229 +       ldr r1, [r0, #0x0]
230 +       orr r1, r1, #(1 << 23)
231 +       str r1, [r0, #0x0]
232 +       ldr r1, [r0, #0x4]
233 +       orr r1, r1, #(1 << 23)
234 +       str r1, [r0, #0x4]
235  
236 -       mov r0, #0
237 -#ifdef BRANCH_PREDICTION_ENABLE
238 -       mcr 15, 0, r0, c15, c2, 4
239 +#ifdef ENABLE_IMPRECISE_ABORT
240 +        mrs r1, spsr            /* save old spsr */
241 +        mrs r0, cpsr            /* read out the cpsr */
242 +       bic r0, r0, #0x100      /* clear the A bit */
243 +       msr spsr, r0            /* update spsr */
244 +       add lr, pc, #0x8        /* update lr */
245 +        movs pc, lr             /* update cpsr */
246 +        nop
247 +        nop
248 +        nop
249 +       nop
250 +       msr spsr, r1            /* restore old spsr */
251  #endif
252 -       mcr 15, 0, r0, c7, c10, 4       /* Drain the write buffer */
253  
254         init_l2cc
255  
256 @@ -264,15 +297,9 @@ lowlevel_init:
257  
258         init_drive_strength
259  
260 -       cmp pc, #PHYS_SDRAM_1
261 -       blo init_clock_start
262 -       cmp pc, #(PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE)
263 -       blo init_clock_start
264 -
265 -init_clock_start:
266         init_clock
267 +
268         init_debug_board
269 -       /*init_sdram*/
270  
271         /* return from mxc_nand_load */
272         /* r12 saved upper lr*/
273 diff --git a/include/asm-arm/arch-mx51/mx51.h b/include/asm-arm/arch-mx51/mx51.h
274 index 1014d41..ec6e60c 100644
275 --- a/include/asm-arm/arch-mx51/mx51.h
276 +++ b/include/asm-arm/arch-mx51/mx51.h
277 @@ -343,6 +343,7 @@
278  #define CLKCTL_CCGR3            0x74
279  #define CLKCTL_CCGR4            0x78
280  #define CLKCTL_CCGR5            0x7C
281 +#define CLKCTL_CCGR6            0x80
282  #define CLKCTL_CMEOR            0x84
283  
284  /* DPLL */
285 @@ -392,7 +393,8 @@
286  #define CHIP_REV_1_0            0x10
287  #define CHIP_REV_1_1            0x11
288  #define CHIP_REV_2_0            0x20
289 -#define CHIP_REV_2_5           0x120
290 +#define CHIP_REV_2_5           0x25
291 +#define CHIP_REV_3_0            0x30
292  
293  #define BOARD_REV_1_0           0x0
294  #define BOARD_REV_2_0           0x1
295 -- 
296 1.5.4.4
297