]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/arm/cpu/armv7/mx5/lowlevel_init.S
ARM: mx5: cleanup comments
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / mx5 / lowlevel_init.S
index 529e35b4405aa5f611e5232ad8c6dec49bd4eb91..17a2bdbf1d267d25d652edc32c07ed6ba94c0691 100644 (file)
@@ -3,20 +3,7 @@
  *
  * (C) Copyright 2009 Freescale Semiconductor, Inc.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <config.h>
 
 .section ".text.init", "x"
 
+.macro init_arm_erratum
+       /* ARM erratum ID #468414 */
+       mrc 15, 0, r1, c1, c0, 1
+       orr r1, r1, #(1 << 5)    /* enable L1NEON bit */
+       mcr 15, 0, r1, c1, c0, 1
+.endm
+
 /*
  * L2CC Cache setup/invalidation/disable
  */
@@ -97,7 +91,7 @@
 .endm /* init_m4if */
 
 .macro setup_pll pll, freq
-       ldr r0, =\pll
+       ldr r3, =\pll
        adr r2, W_DP_\freq
        bl setup_pll_func
 .endm
 
 setup_pll_func:
        ldr r1, =0x00001232
-       str r1, [r0, #PLL_DP_CTL] /* Set DPLL ON (set UPEN bit): BRMO=1 */
+       str r1, [r3, #PLL_DP_CTL] /* Set DPLL ON (set UPEN bit): BRMO=1 */
        mov r1, #0x2
-       str r1, [r0, #PLL_DP_CONFIG] /* Enable auto-restart AREN bit */
+       str r1, [r3, #PLL_DP_CONFIG] /* Enable auto-restart AREN bit */
 
        ldr r1, [r2, #W_DP_OP]
-       str r1, [r0, #PLL_DP_OP]
-       str r1, [r0, #PLL_DP_HFS_OP]
+       str r1, [r3, #PLL_DP_OP]
+       str r1, [r3, #PLL_DP_HFS_OP]
 
        ldr r1, [r2, #W_DP_MFD]
-       str r1, [r0, #PLL_DP_MFD]
-       str r1, [r0, #PLL_DP_HFS_MFD]
+       str r1, [r3, #PLL_DP_MFD]
+       str r1, [r3, #PLL_DP_HFS_MFD]
 
        ldr r1, [r2, #W_DP_MFN]
-       str r1, [r0, #PLL_DP_MFN]
-       str r1, [r0, #PLL_DP_HFS_MFN]
+       str r1, [r3, #PLL_DP_MFN]
+       str r1, [r3, #PLL_DP_HFS_MFN]
 
        ldr r1, =0x00001232
-       str r1, [r0, #PLL_DP_CTL]
-1:     ldr r1, [r0, #PLL_DP_CTL]
+       str r1, [r3, #PLL_DP_CTL]
+1:     ldr r1, [r3, #PLL_DP_CTL]
        ands r1, r1, #0x1
        beq 1b
 
@@ -162,10 +156,10 @@ setup_pll_func:
 .endm
 
 .macro init_clock
+#if defined (CONFIG_MX51)
        ldr r0, =CCM_BASE_ADDR
 
-#if defined(CONFIG_MX51)
-       /* Gate of clocks to the peripherals first */
+       /* Gate off clocks to the peripherals first */
        ldr r1, =0x3FFFFFFF
        str r1, [r0, #CLKCTL_CCGR0]
        str r4, [r0, #CLKCTL_CCGR1]
@@ -190,21 +184,6 @@ setup_pll_func:
 1:     ldr r1, [r0, #CLKCTL_CDHIPR]
        cmp r1, #0x0
        bne 1b
-#else
-       ldr r1, =0x3FFFFFFF
-       str r1, [r0, #CLKCTL_CCGR0]
-       str r4, [r0, #CLKCTL_CCGR1]
-       str r4, [r0, #CLKCTL_CCGR2]
-       str r4, [r0, #CLKCTL_CCGR3]
-       str r4, [r0, #CLKCTL_CCGR7]
-
-       ldr r1, =0x00030000
-       str r1, [r0, #CLKCTL_CCGR4]
-       ldr r1, =0x00FFF030
-       str r1, [r0, #CLKCTL_CCGR5]
-       ldr r1, =0x0F00030F
-       str r1, [r0, #CLKCTL_CCGR6]
-#endif
 
        /* Switch ARM to step clock */
        mov r1, #0x4
@@ -217,11 +196,9 @@ setup_pll_func:
        setup_pll PLL1_BASE_ADDR, 800
 #endif
 
-#if defined(CONFIG_MX51)
        setup_pll PLL3_BASE_ADDR, 665
 
        /* Switch peripheral to PLL 3 */
-       ldr r0, =CCM_BASE_ADDR
        ldr r1, =0x000010C0 | CONFIG_SYS_DDR_CLKSEL
        str r1, [r0, #CLKCTL_CBCMR]
        ldr r1, =0x13239145
@@ -229,12 +206,11 @@ setup_pll_func:
        setup_pll PLL2_BASE_ADDR, 665
 
        /* Switch peripheral to PLL2 */
-       ldr r0, =CCM_BASE_ADDR
        ldr r1, =0x19239145
        str r1, [r0, #CLKCTL_CBCDR]
        ldr r1, =0x000020C0 | CONFIG_SYS_DDR_CLKSEL
        str r1, [r0, #CLKCTL_CBCMR]
-#endif
+
        setup_pll PLL3_BASE_ADDR, 216
 
        /* Set the platform clock dividers */
@@ -244,21 +220,17 @@ setup_pll_func:
 
        ldr r0, =CCM_BASE_ADDR
 
-#if defined(CONFIG_MX51)
        /* Run 3.0 at Full speed, for other TO's wait till we increase VDDGP */
        ldr r3, [r4, #ROM_SI_REV]
        cmp r3, #0x10
        movls r1, #0x1
        movhi r1, #0
-#else
-       mov r1, #0
-#endif
+
        str r1, [r0, #CLKCTL_CACRR]
 
        /* Switch ARM back to PLL 1 */
        str r4, [r0, #CLKCTL_CCSR]
 
-#if defined(CONFIG_MX51)
        /* setup the rest */
        /* Use lp_apm (24MHz) source for perclk */
        ldr r1, =0x000020C2 | CONFIG_SYS_DDR_CLKSEL
@@ -266,7 +238,6 @@ setup_pll_func:
        /* ddr clock from PLL 1, all perclk dividers are 1 since using 24MHz */
        ldr r1, =CONFIG_SYS_CLKTL_CBCDR
        str r1, [r0, #CLKCTL_CBCDR]
-#endif
 
        /* Restore the default values in the Gate registers */
        ldr r1, =0xFFFFFFFF
@@ -277,47 +248,119 @@ setup_pll_func:
        str r1, [r0, #CLKCTL_CCGR4]
        str r1, [r0, #CLKCTL_CCGR5]
        str r1, [r0, #CLKCTL_CCGR6]
-#if defined(CONFIG_MX53)
-       str r1, [r0, #CLKCTL_CCGR7]
-#endif
 
-#if defined(CONFIG_MX51)
        /* Use PLL 2 for UART's, get 66.5MHz from it */
        ldr r1, =0xA5A2A020
        str r1, [r0, #CLKCTL_CSCMR1]
        ldr r1, =0x00C30321
        str r1, [r0, #CLKCTL_CSCDR1]
-#elif defined(CONFIG_MX53)
+       /* make sure divider effective */
+1:     ldr r1, [r0, #CLKCTL_CDHIPR]
+       cmp r1, #0x0
+       bne 1b
+
+       str r4, [r0, #CLKCTL_CCDR]
+
+       /* for cko - for ARM div by 8 */
+       mov r1, #0x000A0000
+       add r1, r1, #0x00000F0
+       str r1, [r0, #CLKCTL_CCOSR]
+#else  /* CONFIG_MX53 */
+       /* Gate off clocks to the peripherals first */
+       ldr r1, =0x3FFFFFFF
+       str r1, [r0, #CLKCTL_CCGR0]
+       str r4, [r0, #CLKCTL_CCGR1]
+       str r4, [r0, #CLKCTL_CCGR2]
+       str r4, [r0, #CLKCTL_CCGR3]
+       str r4, [r0, #CLKCTL_CCGR7]
+       ldr r1, =0x00030000
+       str r1, [r0, #CLKCTL_CCGR4]
+       ldr r1, =0x00FFF030
+       str r1, [r0, #CLKCTL_CCGR5]
+       ldr r1, =0x0F00030F
+       str r1, [r0, #CLKCTL_CCGR6]
+
+       /* Switch ARM to step clock */
+       mov r1, #0x4
+       str r1, [r0, #CLKCTL_CCSR]
+
+       setup_pll PLL1_BASE_ADDR, 800
+
+        setup_pll PLL3_BASE_ADDR, 400
+
+        /* Switch peripheral to PLL3 */
+        ldr r1, =0x00015154
+        str r1, [r0, #CLKCTL_CBCMR]
+        ldr r1, =0x02898945
+        str r1, [r0, #CLKCTL_CBCDR]
+        /* make sure change is effective */
+1:      ldr r1, [r0, #CLKCTL_CDHIPR]
+        cmp r1, #0x0
+        bne 1b
+
+        setup_pll PLL2_BASE_ADDR, 400
+
        /* Switch peripheral to PLL2 */
-       ldr r0, =CCM_BASE_ADDR
-       ldr r1, =0x00808145
-       orr r1, r1, #2 << 10
-       orr r1, r1, #1 << 19
+       ldr r1, =0x00888945
        str r1, [r0, #CLKCTL_CBCDR]
 
        ldr r1, =0x00016154
        str r1, [r0, #CLKCTL_CBCMR]
-       /* Change uart clk parent to pll2*/
+
+       /* change uart clk parent to pll2 */
        ldr r1, [r0, #CLKCTL_CSCMR1]
        and r1, r1, #0xfcffffff
        orr r1, r1, #0x01000000
        str r1, [r0, #CLKCTL_CSCMR1]
+
+       /* make sure change is effective */
+1:      ldr r1, [r0, #CLKCTL_CDHIPR]
+       cmp r1, #0x0
+       bne 1b
+
+        setup_pll PLL3_BASE_ADDR, 216
+
+       setup_pll PLL4_BASE_ADDR, 455
+
+       /* Set the platform clock dividers */
+       ldr r0, =ARM_BASE_ADDR
+       ldr r1, =0x00000124
+       str r1, [r0, #0x14]
+
+       ldr r0, =CCM_BASE_ADDR
+       mov r1, #0
+       str r1, [r0, #CLKCTL_CACRR]
+
+       /* Switch ARM back to PLL 1. */
+       mov r1, #0x0
+       str r1, [r0, #CLKCTL_CCSR]
+
+       /* make uart div=6 */
        ldr r1, [r0, #CLKCTL_CSCDR1]
        and r1, r1, #0xffffffc0
        orr r1, r1, #0x0a
        str r1, [r0, #CLKCTL_CSCDR1]
-#endif
-       /* make sure divider effective */
-1:     ldr r1, [r0, #CLKCTL_CDHIPR]
-       cmp r1, #0x0
-       bne 1b
 
-       str r4, [r0, #CLKCTL_CCDR]
+       /* Restore the default values in the Gate registers */
+       ldr r1, =0xFFFFFFFF
+       str r1, [r0, #CLKCTL_CCGR0]
+       str r1, [r0, #CLKCTL_CCGR1]
+       str r1, [r0, #CLKCTL_CCGR2]
+       str r1, [r0, #CLKCTL_CCGR3]
+       str r1, [r0, #CLKCTL_CCGR4]
+       str r1, [r0, #CLKCTL_CCGR5]
+       str r1, [r0, #CLKCTL_CCGR6]
+       str r1, [r0, #CLKCTL_CCGR7]
 
-       /* for cko - for ARM div by 8 */
-       mov r1, #0x000A0000
-       add r1, r1, #0x00000F0
-       str r1, [r0, #CLKCTL_CCOSR]
+        mov r1, #0x00000
+        str r1, [r0, #CLKCTL_CCDR]
+
+        /* for cko - for ARM div by 8 */
+        mov r1, #0x000A0000
+        add r1, r1, #0x00000F0
+        str r1, [r0, #CLKCTL_CCOSR]
+
+#endif /* CONFIG_MX53 */
 .endm
 
 .macro setup_wdog
@@ -330,7 +373,7 @@ ENTRY(lowlevel_init)
        mov r10, lr
        mov r4, #0      /* Fix R4 to 0 */
 
-#if defined(CONFIG_MX51)
+#if defined(CONFIG_SYS_MAIN_PWR_ON)
        ldr r0, =GPIO1_BASE_ADDR
        ldr r1, [r0, #0x0]
        orr r1, r1, #1 << 23
@@ -340,6 +383,8 @@ ENTRY(lowlevel_init)
        str r1, [r0, #0x4]
 #endif
 
+       init_arm_erratum
+
        init_l2cc
 
        init_aips
@@ -370,3 +415,9 @@ W_DP_665:           .word DP_OP_665
 W_DP_216:              .word DP_OP_216
                        .word DP_MFD_216
                        .word DP_MFN_216
+W_DP_400:               .word DP_OP_400
+                       .word DP_MFD_400
+                       .word DP_MFN_400
+W_DP_455:               .word DP_OP_455
+                       .word DP_MFD_455
+                       .word DP_MFN_455