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.
6 Syc clock and l2cc code with redboot.
8 Signed-off-by: Terry Lv <r65388@freescale.com>
9 (cherry picked from commit f712613010e3bf2c186f05a1b7381483d733b925)
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(-)
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
20 * L2CC Cache setup/invalidation/disable
23 - /* reconfigure L2 cache aux control reg */
25 - mcr p15, 1, r0, c9, c0, 2
26 + /* explicitly disable L2 cache */
27 + mrc 15, 0, r0, c1, c0, 1
29 + mcr 15, 0, r0, c1, c0, 1
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 */
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 */
41 + mcr 15, 1, r0, c9, c0, 2
44 /* AIPS setup - Only setup MPROTx registers.
48 ldr r0, =CCM_BASE_ADDR
50 - str r1, [r0, #CLKCTL_CCDR]
52 + /* Gate of clocks to the peripherals first */
54 + str r1, [r0, #CLKCTL_CCGR0]
56 + str r1, [r0, #CLKCTL_CCGR1]
57 + str r1, [r0, #CLKCTL_CCGR2]
58 + str r1, [r0, #CLKCTL_CCGR3]
61 + str r1, [r0, #CLKCTL_CCGR4]
63 + str r1, [r0, #CLKCTL_CCGR5]
65 + str r1, [r0, #CLKCTL_CCGR6]
67 + /* Disable IPU and HSC dividers */
69 + str r1, [r0, #CLKCTL_CCDR]
71 + /* Make sure to switch the DDR away from PLL 1 */
73 + str r1, [r0, #CLKCTL_CBCDR]
74 + /* make sure divider effective */
75 +1: ldr r1, [r0, #CLKCTL_CDHIPR]
79 /* Switch ARM to step clock */
81 str r1, [r0, #CLKCTL_CCSR]
86 setup_pll PLL1_BASE_ADDR
91 setup_pll PLL3_BASE_ADDR
93 /* Switch peripheral to PLL 3 */
95 + ldr r0, =CCM_BASE_ADDR
97 str r1, [r0, #CLKCTL_CBCMR]
100 str r1, [r0, #CLKCTL_CBCDR]
104 setup_pll PLL2_BASE_ADDR
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]
116 @@ -163,30 +203,39 @@
118 setup_pll PLL3_BASE_ADDR
121 /* Set the platform clock dividers */
122 - ldr r2, =ARM_BASE_ADDR
123 + ldr r0, =ARM_BASE_ADDR
125 - str r1, [r2, #0x14]
126 + str r1, [r0, #0x14]
128 + ldr r0, =CCM_BASE_ADDR
130 + str r1, [r0, #CLKCTL_CACRR]
132 /* Switch ARM back to PLL 1 */
134 - str r1, [r0, #CLKCTL_CCSR]
135 - str r1, [r0, #CLKCTL_CACRR]
136 + str r1, [r0, #CLKCTL_CCSR]
138 + /* setup the rest */
139 /* Use lp_apm (24MHz) source for perclk */
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]
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]
167 + /* Use PLL 2 for UART's, get 66.5MHz from it */
169 str r1, [r0, #CLKCTL_CSCMR1]
171 @@ -194,11 +243,16 @@
173 /* make sure divider effective */
174 1: ldr r1, [r0, #CLKCTL_CDHIPR]
180 str r1, [r0, #CLKCTL_CCDR]
182 + /* for cko - for ARM div by 8 */
183 + mov r1, #0x000A0000
184 + add r1, r1, #0x00000F0
185 + str r1, [r0, #CLKCTL_CCOSR]
189 @@ -211,48 +265,27 @@
193 - /* Platform CHIP level init*/
194 ldr r0, =GPIO1_BASE_ADDR
196 - orr r1, r1, #(1 << 23)
199 - orr r1, r1, #(1 << 23)
202 -#ifdef TURN_OFF_IMPRECISE_ABORT
208 - mrc 15, 0, r1, c1, c0, 0
210 -#ifndef BRANCH_PREDICTION_ENABLE
211 - mrc 15, 0, r0, c1, c0, 1
213 - mcr 15, 0, r0, c1, c0, 1
215 - mrc 15, 0, r0, c1, c0, 1
217 - mcr 15, 0, r0, c1, c0, 1
218 - orr r1, r1, #(1<<11)
221 -#ifdef UNALIGNED_ACCESS_ENABLE
222 - orr r1, r1, #(1<<22)
225 -#ifdef LOW_INT_LATENCY_ENABLE
226 - orr r1, r1, #(1<<21)
228 - mcr 15, 0, r1, c1, c0, 0
230 + orr r1, r1, #(1 << 23)
233 + orr r1, r1, #(1 << 23)
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 */
250 + msr spsr, r1 /* restore old spsr */
252 - mcr 15, 0, r0, c7, c10, 4 /* Drain the write buffer */
256 @@ -264,15 +297,9 @@ lowlevel_init:
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
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
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
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
293 #define BOARD_REV_1_0 0x0
294 #define BOARD_REV_2_0 0x1