Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007, Guennadi Liakhovetski <lg@denx.de> |
| 3 | * |
| 4 | * (C) Copyright 2009 Freescale Semiconductor, Inc. |
| 5 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <config.h> |
| 10 | #include <asm/arch/imx-regs.h> |
Stefano Babic | 2a1f1ac | 2011-09-05 04:32:28 +0000 | [diff] [blame] | 11 | #include <generated/asm-offsets.h> |
Aneesh V | fd8798b | 2012-03-08 07:20:18 +0000 | [diff] [blame] | 12 | #include <linux/linkage.h> |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 13 | |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 14 | .section ".text.init", "x" |
| 15 | |
Fabio Estevam | 52ba932 | 2012-05-07 10:56:00 +0000 | [diff] [blame] | 16 | .macro init_arm_erratum |
| 17 | /* ARM erratum ID #468414 */ |
| 18 | mrc 15, 0, r1, c1, c0, 1 |
| 19 | orr r1, r1, #(1 << 5) /* enable L1NEON bit */ |
| 20 | mcr 15, 0, r1, c1, c0, 1 |
| 21 | .endm |
| 22 | |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 23 | /* |
| 24 | * L2CC Cache setup/invalidation/disable |
| 25 | */ |
| 26 | .macro init_l2cc |
| 27 | /* explicitly disable L2 cache */ |
| 28 | mrc 15, 0, r0, c1, c0, 1 |
| 29 | bic r0, r0, #0x2 |
| 30 | mcr 15, 0, r0, c1, c0, 1 |
| 31 | |
| 32 | /* reconfigure L2 cache aux control reg */ |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 33 | ldr r0, =0xC0 | /* tag RAM */ \ |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 34 | 0x4 | /* data RAM */ \ |
| 35 | 1 << 24 | /* disable write allocate delay */ \ |
| 36 | 1 << 23 | /* disable write allocate combine */ \ |
| 37 | 1 << 22 /* disable write allocate */ |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 38 | |
David Jander | dd6f787 | 2011-07-14 03:58:57 +0000 | [diff] [blame] | 39 | #if defined(CONFIG_MX51) |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 40 | ldr r3, [r4, #ROM_SI_REV] |
David Jander | dd6f787 | 2011-07-14 03:58:57 +0000 | [diff] [blame] | 41 | cmp r3, #0x10 |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 42 | |
| 43 | /* disable write combine for TO 2 and lower revs */ |
Benoît Thébaudeau | 118e0bc | 2012-08-14 05:18:43 +0000 | [diff] [blame] | 44 | orrls r0, r0, #1 << 25 |
David Jander | dd6f787 | 2011-07-14 03:58:57 +0000 | [diff] [blame] | 45 | #endif |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 46 | |
| 47 | mcr 15, 1, r0, c9, c0, 2 |
Fabio Estevam | 2ad8b46 | 2013-09-30 13:16:52 -0300 | [diff] [blame] | 48 | |
| 49 | /* enable L2 cache */ |
| 50 | mrc 15, 0, r0, c1, c0, 1 |
| 51 | orr r0, r0, #2 |
| 52 | mcr 15, 0, r0, c1, c0, 1 |
| 53 | |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 54 | .endm /* init_l2cc */ |
| 55 | |
| 56 | /* AIPS setup - Only setup MPROTx registers. |
| 57 | * The PACR default values are good.*/ |
| 58 | .macro init_aips |
| 59 | /* |
| 60 | * Set all MPROTx to be non-bufferable, trusted for R/W, |
| 61 | * not forced to user-mode. |
| 62 | */ |
| 63 | ldr r0, =AIPS1_BASE_ADDR |
| 64 | ldr r1, =0x77777777 |
| 65 | str r1, [r0, #0x0] |
| 66 | str r1, [r0, #0x4] |
| 67 | ldr r0, =AIPS2_BASE_ADDR |
| 68 | str r1, [r0, #0x0] |
| 69 | str r1, [r0, #0x4] |
| 70 | /* |
| 71 | * Clear the on and off peripheral modules Supervisor Protect bit |
| 72 | * for SDMA to access them. Did not change the AIPS control registers |
| 73 | * (offset 0x20) access type |
| 74 | */ |
| 75 | .endm /* init_aips */ |
| 76 | |
| 77 | /* M4IF setup */ |
| 78 | .macro init_m4if |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 79 | #ifdef CONFIG_MX51 |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 80 | /* VPU and IPU given higher priority (0x4) |
| 81 | * IPU accesses with ID=0x1 given highest priority (=0xA) |
| 82 | */ |
| 83 | ldr r0, =M4IF_BASE_ADDR |
| 84 | |
| 85 | ldr r1, =0x00000203 |
| 86 | str r1, [r0, #0x40] |
| 87 | |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 88 | str r4, [r0, #0x44] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 89 | |
| 90 | ldr r1, =0x00120125 |
| 91 | str r1, [r0, #0x9C] |
| 92 | |
| 93 | ldr r1, =0x001901A3 |
| 94 | str r1, [r0, #0x48] |
| 95 | |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 96 | #endif |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 97 | .endm /* init_m4if */ |
| 98 | |
| 99 | .macro setup_pll pll, freq |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 100 | ldr r0, =\pll |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 101 | adr r2, W_DP_\freq |
| 102 | bl setup_pll_func |
| 103 | .endm |
| 104 | |
| 105 | #define W_DP_OP 0 |
| 106 | #define W_DP_MFD 4 |
| 107 | #define W_DP_MFN 8 |
| 108 | |
| 109 | setup_pll_func: |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 110 | ldr r1, =0x00001232 |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 111 | str r1, [r0, #PLL_DP_CTL] /* Set DPLL ON (set UPEN bit): BRMO=1 */ |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 112 | mov r1, #0x2 |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 113 | str r1, [r0, #PLL_DP_CONFIG] /* Enable auto-restart AREN bit */ |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 114 | |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 115 | ldr r1, [r2, #W_DP_OP] |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 116 | str r1, [r0, #PLL_DP_OP] |
| 117 | str r1, [r0, #PLL_DP_HFS_OP] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 118 | |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 119 | ldr r1, [r2, #W_DP_MFD] |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 120 | str r1, [r0, #PLL_DP_MFD] |
| 121 | str r1, [r0, #PLL_DP_HFS_MFD] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 122 | |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 123 | ldr r1, [r2, #W_DP_MFN] |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 124 | str r1, [r0, #PLL_DP_MFN] |
| 125 | str r1, [r0, #PLL_DP_HFS_MFN] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 126 | |
| 127 | ldr r1, =0x00001232 |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 128 | str r1, [r0, #PLL_DP_CTL] |
| 129 | 1: ldr r1, [r0, #PLL_DP_CTL] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 130 | ands r1, r1, #0x1 |
| 131 | beq 1b |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 132 | |
| 133 | /* r10 saved upper lr */ |
| 134 | mov pc, lr |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 135 | |
David Jander | 088b338 | 2011-07-13 21:11:53 +0000 | [diff] [blame] | 136 | .macro setup_pll_errata pll, freq |
| 137 | ldr r2, =\pll |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 138 | str r4, [r2, #PLL_DP_CONFIG] /* Disable auto-restart AREN bit */ |
David Jander | 088b338 | 2011-07-13 21:11:53 +0000 | [diff] [blame] | 139 | ldr r1, =0x00001236 |
| 140 | str r1, [r2, #PLL_DP_CTL] /* Restart PLL with PLM=1 */ |
| 141 | 1: ldr r1, [r2, #PLL_DP_CTL] /* Wait for lock */ |
| 142 | ands r1, r1, #0x1 |
| 143 | beq 1b |
| 144 | |
| 145 | ldr r5, \freq |
| 146 | str r5, [r2, #PLL_DP_MFN] /* Modify MFN value */ |
| 147 | str r5, [r2, #PLL_DP_HFS_MFN] |
| 148 | |
| 149 | mov r1, #0x1 |
| 150 | str r1, [r2, #PLL_DP_CONFIG] /* Reload MFN value */ |
| 151 | |
| 152 | 2: ldr r1, [r2, #PLL_DP_CONFIG] |
| 153 | tst r1, #1 |
| 154 | bne 2b |
| 155 | |
| 156 | ldr r1, =100 /* Wait at least 4 us */ |
| 157 | 3: subs r1, r1, #1 |
| 158 | bge 3b |
| 159 | |
| 160 | mov r1, #0x2 |
| 161 | str r1, [r2, #PLL_DP_CONFIG] /* Enable auto-restart AREN bit */ |
| 162 | .endm |
| 163 | |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 164 | .macro init_clock |
Fabio Estevam | 3ad50f8 | 2012-10-15 05:37:15 +0000 | [diff] [blame] | 165 | #if defined (CONFIG_MX51) |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 166 | ldr r0, =CCM_BASE_ADDR |
| 167 | |
| 168 | /* Gate of clocks to the peripherals first */ |
| 169 | ldr r1, =0x3FFFFFFF |
| 170 | str r1, [r0, #CLKCTL_CCGR0] |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 171 | str r4, [r0, #CLKCTL_CCGR1] |
| 172 | str r4, [r0, #CLKCTL_CCGR2] |
| 173 | str r4, [r0, #CLKCTL_CCGR3] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 174 | |
| 175 | ldr r1, =0x00030000 |
| 176 | str r1, [r0, #CLKCTL_CCGR4] |
| 177 | ldr r1, =0x00FFF030 |
| 178 | str r1, [r0, #CLKCTL_CCGR5] |
| 179 | ldr r1, =0x00000300 |
| 180 | str r1, [r0, #CLKCTL_CCGR6] |
| 181 | |
| 182 | /* Disable IPU and HSC dividers */ |
| 183 | mov r1, #0x60000 |
| 184 | str r1, [r0, #CLKCTL_CCDR] |
| 185 | |
| 186 | /* Make sure to switch the DDR away from PLL 1 */ |
| 187 | ldr r1, =0x19239145 |
| 188 | str r1, [r0, #CLKCTL_CBCDR] |
| 189 | /* make sure divider effective */ |
| 190 | 1: ldr r1, [r0, #CLKCTL_CDHIPR] |
| 191 | cmp r1, #0x0 |
| 192 | bne 1b |
| 193 | |
| 194 | /* Switch ARM to step clock */ |
| 195 | mov r1, #0x4 |
| 196 | str r1, [r0, #CLKCTL_CCSR] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 197 | |
David Jander | 088b338 | 2011-07-13 21:11:53 +0000 | [diff] [blame] | 198 | #if defined(CONFIG_MX51_PLL_ERRATA) |
| 199 | setup_pll PLL1_BASE_ADDR, 864 |
| 200 | setup_pll_errata PLL1_BASE_ADDR, W_DP_MFN_800_DIT |
| 201 | #else |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 202 | setup_pll PLL1_BASE_ADDR, 800 |
David Jander | 088b338 | 2011-07-13 21:11:53 +0000 | [diff] [blame] | 203 | #endif |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 204 | |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 205 | setup_pll PLL3_BASE_ADDR, 665 |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 206 | |
| 207 | /* Switch peripheral to PLL 3 */ |
| 208 | ldr r0, =CCM_BASE_ADDR |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 209 | ldr r1, =0x000010C0 | CONFIG_SYS_DDR_CLKSEL |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 210 | str r1, [r0, #CLKCTL_CBCMR] |
| 211 | ldr r1, =0x13239145 |
| 212 | str r1, [r0, #CLKCTL_CBCDR] |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 213 | setup_pll PLL2_BASE_ADDR, 665 |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 214 | |
| 215 | /* Switch peripheral to PLL2 */ |
| 216 | ldr r0, =CCM_BASE_ADDR |
| 217 | ldr r1, =0x19239145 |
| 218 | str r1, [r0, #CLKCTL_CBCDR] |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 219 | ldr r1, =0x000020C0 | CONFIG_SYS_DDR_CLKSEL |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 220 | str r1, [r0, #CLKCTL_CBCMR] |
Fabio Estevam | 3ad50f8 | 2012-10-15 05:37:15 +0000 | [diff] [blame] | 221 | |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 222 | setup_pll PLL3_BASE_ADDR, 216 |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 223 | |
| 224 | /* Set the platform clock dividers */ |
| 225 | ldr r0, =ARM_BASE_ADDR |
| 226 | ldr r1, =0x00000725 |
| 227 | str r1, [r0, #0x14] |
| 228 | |
| 229 | ldr r0, =CCM_BASE_ADDR |
| 230 | |
| 231 | /* Run 3.0 at Full speed, for other TO's wait till we increase VDDGP */ |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 232 | ldr r3, [r4, #ROM_SI_REV] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 233 | cmp r3, #0x10 |
| 234 | movls r1, #0x1 |
| 235 | movhi r1, #0 |
Fabio Estevam | 3ad50f8 | 2012-10-15 05:37:15 +0000 | [diff] [blame] | 236 | |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 237 | str r1, [r0, #CLKCTL_CACRR] |
Benoît Thébaudeau | 118e0bc | 2012-08-14 05:18:43 +0000 | [diff] [blame] | 238 | |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 239 | /* Switch ARM back to PLL 1 */ |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 240 | str r4, [r0, #CLKCTL_CCSR] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 241 | |
| 242 | /* setup the rest */ |
| 243 | /* Use lp_apm (24MHz) source for perclk */ |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 244 | ldr r1, =0x000020C2 | CONFIG_SYS_DDR_CLKSEL |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 245 | str r1, [r0, #CLKCTL_CBCMR] |
| 246 | /* ddr clock from PLL 1, all perclk dividers are 1 since using 24MHz */ |
Stefano Babic | 0c3d8ee | 2010-03-28 13:43:26 +0200 | [diff] [blame] | 247 | ldr r1, =CONFIG_SYS_CLKTL_CBCDR |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 248 | str r1, [r0, #CLKCTL_CBCDR] |
| 249 | |
| 250 | /* Restore the default values in the Gate registers */ |
| 251 | ldr r1, =0xFFFFFFFF |
| 252 | str r1, [r0, #CLKCTL_CCGR0] |
| 253 | str r1, [r0, #CLKCTL_CCGR1] |
| 254 | str r1, [r0, #CLKCTL_CCGR2] |
| 255 | str r1, [r0, #CLKCTL_CCGR3] |
| 256 | str r1, [r0, #CLKCTL_CCGR4] |
| 257 | str r1, [r0, #CLKCTL_CCGR5] |
| 258 | str r1, [r0, #CLKCTL_CCGR6] |
| 259 | |
| 260 | /* Use PLL 2 for UART's, get 66.5MHz from it */ |
| 261 | ldr r1, =0xA5A2A020 |
| 262 | str r1, [r0, #CLKCTL_CSCMR1] |
| 263 | ldr r1, =0x00C30321 |
| 264 | str r1, [r0, #CLKCTL_CSCDR1] |
Fabio Estevam | 3ad50f8 | 2012-10-15 05:37:15 +0000 | [diff] [blame] | 265 | /* make sure divider effective */ |
| 266 | 1: ldr r1, [r0, #CLKCTL_CDHIPR] |
| 267 | cmp r1, #0x0 |
| 268 | bne 1b |
| 269 | |
| 270 | str r4, [r0, #CLKCTL_CCDR] |
| 271 | |
| 272 | /* for cko - for ARM div by 8 */ |
| 273 | mov r1, #0x000A0000 |
| 274 | add r1, r1, #0x00000F0 |
| 275 | str r1, [r0, #CLKCTL_CCOSR] |
| 276 | #else /* CONFIG_MX53 */ |
| 277 | ldr r0, =CCM_BASE_ADDR |
| 278 | |
| 279 | /* Gate of clocks to the peripherals first */ |
| 280 | ldr r1, =0x3FFFFFFF |
| 281 | str r1, [r0, #CLKCTL_CCGR0] |
| 282 | str r4, [r0, #CLKCTL_CCGR1] |
| 283 | str r4, [r0, #CLKCTL_CCGR2] |
| 284 | str r4, [r0, #CLKCTL_CCGR3] |
| 285 | str r4, [r0, #CLKCTL_CCGR7] |
| 286 | ldr r1, =0x00030000 |
| 287 | str r1, [r0, #CLKCTL_CCGR4] |
| 288 | ldr r1, =0x00FFF030 |
| 289 | str r1, [r0, #CLKCTL_CCGR5] |
| 290 | ldr r1, =0x0F00030F |
| 291 | str r1, [r0, #CLKCTL_CCGR6] |
| 292 | |
| 293 | /* Switch ARM to step clock */ |
| 294 | mov r1, #0x4 |
| 295 | str r1, [r0, #CLKCTL_CCSR] |
| 296 | |
| 297 | setup_pll PLL1_BASE_ADDR, 800 |
| 298 | |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 299 | setup_pll PLL3_BASE_ADDR, 400 |
Fabio Estevam | 954f1b2 | 2012-10-15 05:37:16 +0000 | [diff] [blame] | 300 | |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 301 | /* Switch peripheral to PLL3 */ |
| 302 | ldr r0, =CCM_BASE_ADDR |
| 303 | ldr r1, =0x00015154 |
| 304 | str r1, [r0, #CLKCTL_CBCMR] |
| 305 | ldr r1, =0x02898945 |
| 306 | str r1, [r0, #CLKCTL_CBCDR] |
| 307 | /* make sure change is effective */ |
Fabio Estevam | 954f1b2 | 2012-10-15 05:37:16 +0000 | [diff] [blame] | 308 | 1: ldr r1, [r0, #CLKCTL_CDHIPR] |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 309 | cmp r1, #0x0 |
| 310 | bne 1b |
Fabio Estevam | 954f1b2 | 2012-10-15 05:37:16 +0000 | [diff] [blame] | 311 | |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 312 | setup_pll PLL2_BASE_ADDR, 400 |
Fabio Estevam | 954f1b2 | 2012-10-15 05:37:16 +0000 | [diff] [blame] | 313 | |
| 314 | /* Switch peripheral to PLL2 */ |
| 315 | ldr r0, =CCM_BASE_ADDR |
Benoît Thébaudeau | 4a53053 | 2013-04-11 09:35:38 +0000 | [diff] [blame] | 316 | ldr r1, =0x00888945 |
Fabio Estevam | 954f1b2 | 2012-10-15 05:37:16 +0000 | [diff] [blame] | 317 | str r1, [r0, #CLKCTL_CBCDR] |
| 318 | |
| 319 | ldr r1, =0x00016154 |
| 320 | str r1, [r0, #CLKCTL_CBCMR] |
| 321 | |
| 322 | /*change uart clk parent to pll2*/ |
| 323 | ldr r1, [r0, #CLKCTL_CSCMR1] |
| 324 | and r1, r1, #0xfcffffff |
| 325 | orr r1, r1, #0x01000000 |
| 326 | str r1, [r0, #CLKCTL_CSCMR1] |
| 327 | |
| 328 | /* make sure change is effective */ |
| 329 | 1: ldr r1, [r0, #CLKCTL_CDHIPR] |
| 330 | cmp r1, #0x0 |
| 331 | bne 1b |
| 332 | |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 333 | setup_pll PLL3_BASE_ADDR, 216 |
Fabio Estevam | 954f1b2 | 2012-10-15 05:37:16 +0000 | [diff] [blame] | 334 | |
| 335 | setup_pll PLL4_BASE_ADDR, 455 |
Fabio Estevam | 3ad50f8 | 2012-10-15 05:37:15 +0000 | [diff] [blame] | 336 | |
| 337 | /* Set the platform clock dividers */ |
| 338 | ldr r0, =ARM_BASE_ADDR |
Fabio Estevam | 954f1b2 | 2012-10-15 05:37:16 +0000 | [diff] [blame] | 339 | ldr r1, =0x00000124 |
Fabio Estevam | 3ad50f8 | 2012-10-15 05:37:15 +0000 | [diff] [blame] | 340 | str r1, [r0, #0x14] |
| 341 | |
| 342 | ldr r0, =CCM_BASE_ADDR |
Fabio Estevam | 3ad50f8 | 2012-10-15 05:37:15 +0000 | [diff] [blame] | 343 | mov r1, #0 |
| 344 | str r1, [r0, #CLKCTL_CACRR] |
| 345 | |
Fabio Estevam | 954f1b2 | 2012-10-15 05:37:16 +0000 | [diff] [blame] | 346 | /* Switch ARM back to PLL 1. */ |
| 347 | mov r1, #0x0 |
| 348 | str r1, [r0, #CLKCTL_CCSR] |
| 349 | |
| 350 | /* make uart div=6 */ |
| 351 | ldr r1, [r0, #CLKCTL_CSCDR1] |
| 352 | and r1, r1, #0xffffffc0 |
| 353 | orr r1, r1, #0x0a |
| 354 | str r1, [r0, #CLKCTL_CSCDR1] |
Fabio Estevam | 3ad50f8 | 2012-10-15 05:37:15 +0000 | [diff] [blame] | 355 | |
| 356 | /* Restore the default values in the Gate registers */ |
| 357 | ldr r1, =0xFFFFFFFF |
| 358 | str r1, [r0, #CLKCTL_CCGR0] |
| 359 | str r1, [r0, #CLKCTL_CCGR1] |
| 360 | str r1, [r0, #CLKCTL_CCGR2] |
| 361 | str r1, [r0, #CLKCTL_CCGR3] |
| 362 | str r1, [r0, #CLKCTL_CCGR4] |
| 363 | str r1, [r0, #CLKCTL_CCGR5] |
| 364 | str r1, [r0, #CLKCTL_CCGR6] |
| 365 | str r1, [r0, #CLKCTL_CCGR7] |
| 366 | |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 367 | mov r1, #0x00000 |
| 368 | str r1, [r0, #CLKCTL_CCDR] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 369 | |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 370 | /* for cko - for ARM div by 8 */ |
| 371 | mov r1, #0x000A0000 |
| 372 | add r1, r1, #0x00000F0 |
| 373 | str r1, [r0, #CLKCTL_CCOSR] |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 374 | |
Fabio Estevam | 3ad50f8 | 2012-10-15 05:37:15 +0000 | [diff] [blame] | 375 | #endif /* CONFIG_MX53 */ |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 376 | .endm |
| 377 | |
Aneesh V | fd8798b | 2012-03-08 07:20:18 +0000 | [diff] [blame] | 378 | ENTRY(lowlevel_init) |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 379 | mov r10, lr |
| 380 | mov r4, #0 /* Fix R4 to 0 */ |
| 381 | |
Benoît Thébaudeau | aa2bcc2 | 2012-11-05 10:07:04 +0000 | [diff] [blame] | 382 | #if defined(CONFIG_SYS_MAIN_PWR_ON) |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 383 | ldr r0, =GPIO1_BASE_ADDR |
| 384 | ldr r1, [r0, #0x0] |
Benoît Thébaudeau | 118e0bc | 2012-08-14 05:18:43 +0000 | [diff] [blame] | 385 | orr r1, r1, #1 << 23 |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 386 | str r1, [r0, #0x0] |
| 387 | ldr r1, [r0, #0x4] |
Benoît Thébaudeau | 118e0bc | 2012-08-14 05:18:43 +0000 | [diff] [blame] | 388 | orr r1, r1, #1 << 23 |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 389 | str r1, [r0, #0x4] |
Liu Hui-R64343 | baa2d78 | 2011-01-03 22:27:35 +0000 | [diff] [blame] | 390 | #endif |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 391 | |
Fabio Estevam | 52ba932 | 2012-05-07 10:56:00 +0000 | [diff] [blame] | 392 | init_arm_erratum |
| 393 | |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 394 | init_l2cc |
| 395 | |
| 396 | init_aips |
| 397 | |
| 398 | init_m4if |
| 399 | |
| 400 | init_clock |
| 401 | |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 402 | mov pc, r10 |
Aneesh V | fd8798b | 2012-03-08 07:20:18 +0000 | [diff] [blame] | 403 | ENDPROC(lowlevel_init) |
Stefano Babic | a521a77 | 2010-01-20 18:19:32 +0100 | [diff] [blame] | 404 | |
| 405 | /* Board level setting value */ |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 406 | #if defined(CONFIG_MX51_PLL_ERRATA) |
| 407 | W_DP_864: .word DP_OP_864 |
| 408 | .word DP_MFD_864 |
| 409 | .word DP_MFN_864 |
Benoît Thébaudeau | 118e0bc | 2012-08-14 05:18:43 +0000 | [diff] [blame] | 410 | W_DP_MFN_800_DIT: .word DP_MFN_800_DIT |
Benoît Thébaudeau | 9d1f282 | 2012-08-14 05:19:12 +0000 | [diff] [blame] | 411 | #else |
| 412 | W_DP_800: .word DP_OP_800 |
| 413 | .word DP_MFD_800 |
| 414 | .word DP_MFN_800 |
| 415 | #endif |
| 416 | #if defined(CONFIG_MX51) |
| 417 | W_DP_665: .word DP_OP_665 |
| 418 | .word DP_MFD_665 |
| 419 | .word DP_MFN_665 |
| 420 | #endif |
| 421 | W_DP_216: .word DP_OP_216 |
| 422 | .word DP_MFD_216 |
| 423 | .word DP_MFN_216 |
Fabio Estevam | 954f1b2 | 2012-10-15 05:37:16 +0000 | [diff] [blame] | 424 | W_DP_400: .word DP_OP_400 |
| 425 | .word DP_MFD_400 |
| 426 | .word DP_MFN_400 |
| 427 | W_DP_455: .word DP_OP_455 |
| 428 | .word DP_MFD_455 |
| 429 | .word DP_MFN_455 |