1*601fbec7SMasahiro Yamada/* 2*601fbec7SMasahiro Yamada * Low-level board setup code for TI DaVinci SoC based boards. 3*601fbec7SMasahiro Yamada * 4*601fbec7SMasahiro Yamada * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net> 5*601fbec7SMasahiro Yamada * 6*601fbec7SMasahiro Yamada * Partially based on TI sources, original copyrights follow: 7*601fbec7SMasahiro Yamada */ 8*601fbec7SMasahiro Yamada 9*601fbec7SMasahiro Yamada/* 10*601fbec7SMasahiro Yamada * Board specific setup info 11*601fbec7SMasahiro Yamada * 12*601fbec7SMasahiro Yamada * (C) Copyright 2003 13*601fbec7SMasahiro Yamada * Texas Instruments, <www.ti.com> 14*601fbec7SMasahiro Yamada * Kshitij Gupta <Kshitij@ti.com> 15*601fbec7SMasahiro Yamada * 16*601fbec7SMasahiro Yamada * Modified for OMAP 1610 H2 board by Nishant Kamat, Jan 2004 17*601fbec7SMasahiro Yamada * 18*601fbec7SMasahiro Yamada * Modified for OMAP 5912 OSK board by Rishi Bhattacharya, Apr 2004 19*601fbec7SMasahiro Yamada * 20*601fbec7SMasahiro Yamada * Modified for DV-EVM board by Rishi Bhattacharya, Apr 2005 21*601fbec7SMasahiro Yamada * 22*601fbec7SMasahiro Yamada * Modified for DV-EVM board by Swaminathan S, Nov 2005 23*601fbec7SMasahiro Yamada * 24*601fbec7SMasahiro Yamada * SPDX-License-Identifier: GPL-2.0+ 25*601fbec7SMasahiro Yamada */ 26*601fbec7SMasahiro Yamada 27*601fbec7SMasahiro Yamada#include <config.h> 28*601fbec7SMasahiro Yamada 29*601fbec7SMasahiro Yamada#define MDSTAT_STATE 0x3f 30*601fbec7SMasahiro Yamada 31*601fbec7SMasahiro Yamada.globl lowlevel_init 32*601fbec7SMasahiro Yamadalowlevel_init: 33*601fbec7SMasahiro Yamada#ifdef CONFIG_SOC_DM644X 34*601fbec7SMasahiro Yamada 35*601fbec7SMasahiro Yamada /*-------------------------------------------------------* 36*601fbec7SMasahiro Yamada * Mask all IRQs by setting all bits in the EINT default * 37*601fbec7SMasahiro Yamada *-------------------------------------------------------*/ 38*601fbec7SMasahiro Yamada mov r1, $0 39*601fbec7SMasahiro Yamada ldr r0, =EINT_ENABLE0 40*601fbec7SMasahiro Yamada str r1, [r0] 41*601fbec7SMasahiro Yamada ldr r0, =EINT_ENABLE1 42*601fbec7SMasahiro Yamada str r1, [r0] 43*601fbec7SMasahiro Yamada 44*601fbec7SMasahiro Yamada /*------------------------------------------------------* 45*601fbec7SMasahiro Yamada * Put the GEM in reset * 46*601fbec7SMasahiro Yamada *------------------------------------------------------*/ 47*601fbec7SMasahiro Yamada 48*601fbec7SMasahiro Yamada /* Put the GEM in reset */ 49*601fbec7SMasahiro Yamada ldr r8, PSC_GEM_FLAG_CLEAR 50*601fbec7SMasahiro Yamada ldr r6, MDCTL_GEM 51*601fbec7SMasahiro Yamada ldr r7, [r6] 52*601fbec7SMasahiro Yamada and r7, r7, r8 53*601fbec7SMasahiro Yamada str r7, [r6] 54*601fbec7SMasahiro Yamada 55*601fbec7SMasahiro Yamada /* Enable the Power Domain Transition Command */ 56*601fbec7SMasahiro Yamada ldr r6, PTCMD 57*601fbec7SMasahiro Yamada ldr r7, [r6] 58*601fbec7SMasahiro Yamada orr r7, r7, $0x02 59*601fbec7SMasahiro Yamada str r7, [r6] 60*601fbec7SMasahiro Yamada 61*601fbec7SMasahiro Yamada /* Check for Transition Complete(PTSTAT) */ 62*601fbec7SMasahiro YamadacheckStatClkStopGem: 63*601fbec7SMasahiro Yamada ldr r6, PTSTAT 64*601fbec7SMasahiro Yamada ldr r7, [r6] 65*601fbec7SMasahiro Yamada ands r7, r7, $0x02 66*601fbec7SMasahiro Yamada bne checkStatClkStopGem 67*601fbec7SMasahiro Yamada 68*601fbec7SMasahiro Yamada /* Check for GEM Reset Completion */ 69*601fbec7SMasahiro YamadacheckGemStatClkStop: 70*601fbec7SMasahiro Yamada ldr r6, MDSTAT_GEM 71*601fbec7SMasahiro Yamada ldr r7, [r6] 72*601fbec7SMasahiro Yamada ands r7, r7, $0x100 73*601fbec7SMasahiro Yamada bne checkGemStatClkStop 74*601fbec7SMasahiro Yamada 75*601fbec7SMasahiro Yamada /* Do this for enabling a WDT initiated reset this is a workaround 76*601fbec7SMasahiro Yamada for a chip bug. Not required under normal situations */ 77*601fbec7SMasahiro Yamada ldr r6, P1394 78*601fbec7SMasahiro Yamada mov r10, $0 79*601fbec7SMasahiro Yamada str r10, [r6] 80*601fbec7SMasahiro Yamada 81*601fbec7SMasahiro Yamada /*------------------------------------------------------* 82*601fbec7SMasahiro Yamada * Enable L1 & L2 Memories in Fast mode * 83*601fbec7SMasahiro Yamada *------------------------------------------------------*/ 84*601fbec7SMasahiro Yamada ldr r6, DFT_ENABLE 85*601fbec7SMasahiro Yamada mov r10, $0x01 86*601fbec7SMasahiro Yamada str r10, [r6] 87*601fbec7SMasahiro Yamada 88*601fbec7SMasahiro Yamada ldr r6, MMARG_BRF0 89*601fbec7SMasahiro Yamada ldr r10, MMARG_BRF0_VAL 90*601fbec7SMasahiro Yamada str r10, [r6] 91*601fbec7SMasahiro Yamada 92*601fbec7SMasahiro Yamada ldr r6, DFT_ENABLE 93*601fbec7SMasahiro Yamada mov r10, $0 94*601fbec7SMasahiro Yamada str r10, [r6] 95*601fbec7SMasahiro Yamada 96*601fbec7SMasahiro Yamada /*------------------------------------------------------* 97*601fbec7SMasahiro Yamada * DDR2 PLL Initialization * 98*601fbec7SMasahiro Yamada *------------------------------------------------------*/ 99*601fbec7SMasahiro Yamada 100*601fbec7SMasahiro Yamada /* Select the Clock Mode Depending on the Value written in the Boot Table by the run script */ 101*601fbec7SMasahiro Yamada mov r10, $0 102*601fbec7SMasahiro Yamada ldr r6, PLL2_CTL 103*601fbec7SMasahiro Yamada ldr r7, PLL_CLKSRC_MASK 104*601fbec7SMasahiro Yamada ldr r8, [r6] 105*601fbec7SMasahiro Yamada and r8, r8, r7 106*601fbec7SMasahiro Yamada mov r9, r10, lsl $8 107*601fbec7SMasahiro Yamada orr r8, r8, r9 108*601fbec7SMasahiro Yamada str r8, [r6] 109*601fbec7SMasahiro Yamada 110*601fbec7SMasahiro Yamada /* Select the PLLEN source */ 111*601fbec7SMasahiro Yamada ldr r7, PLL_ENSRC_MASK 112*601fbec7SMasahiro Yamada and r8, r8, r7 113*601fbec7SMasahiro Yamada str r8, [r6] 114*601fbec7SMasahiro Yamada 115*601fbec7SMasahiro Yamada /* Bypass the PLL */ 116*601fbec7SMasahiro Yamada ldr r7, PLL_BYPASS_MASK 117*601fbec7SMasahiro Yamada and r8, r8, r7 118*601fbec7SMasahiro Yamada str r8, [r6] 119*601fbec7SMasahiro Yamada 120*601fbec7SMasahiro Yamada /* Wait for few cycles to allow PLLEN Mux switch properly to bypass Clock */ 121*601fbec7SMasahiro Yamada mov r10, $0x20 122*601fbec7SMasahiro YamadaWaitPPL2Loop: 123*601fbec7SMasahiro Yamada subs r10, r10, $1 124*601fbec7SMasahiro Yamada bne WaitPPL2Loop 125*601fbec7SMasahiro Yamada 126*601fbec7SMasahiro Yamada /* Reset the PLL */ 127*601fbec7SMasahiro Yamada ldr r7, PLL_RESET_MASK 128*601fbec7SMasahiro Yamada and r8, r8, r7 129*601fbec7SMasahiro Yamada str r8, [r6] 130*601fbec7SMasahiro Yamada 131*601fbec7SMasahiro Yamada /* Power up the PLL */ 132*601fbec7SMasahiro Yamada ldr r7, PLL_PWRUP_MASK 133*601fbec7SMasahiro Yamada and r8, r8, r7 134*601fbec7SMasahiro Yamada str r8, [r6] 135*601fbec7SMasahiro Yamada 136*601fbec7SMasahiro Yamada /* Enable the PLL from Disable Mode */ 137*601fbec7SMasahiro Yamada ldr r7, PLL_DISABLE_ENABLE_MASK 138*601fbec7SMasahiro Yamada and r8, r8, r7 139*601fbec7SMasahiro Yamada str r8, [r6] 140*601fbec7SMasahiro Yamada 141*601fbec7SMasahiro Yamada /* Program the PLL Multiplier */ 142*601fbec7SMasahiro Yamada ldr r6, PLL2_PLLM 143*601fbec7SMasahiro Yamada mov r2, $0x17 /* 162 MHz */ 144*601fbec7SMasahiro Yamada str r2, [r6] 145*601fbec7SMasahiro Yamada 146*601fbec7SMasahiro Yamada /* Program the PLL2 Divisor Value */ 147*601fbec7SMasahiro Yamada ldr r6, PLL2_DIV2 148*601fbec7SMasahiro Yamada mov r3, $0x01 149*601fbec7SMasahiro Yamada str r3, [r6] 150*601fbec7SMasahiro Yamada 151*601fbec7SMasahiro Yamada /* Program the PLL2 Divisor Value */ 152*601fbec7SMasahiro Yamada ldr r6, PLL2_DIV1 153*601fbec7SMasahiro Yamada mov r4, $0x0b /* 54 MHz */ 154*601fbec7SMasahiro Yamada str r4, [r6] 155*601fbec7SMasahiro Yamada 156*601fbec7SMasahiro Yamada /* PLL2 DIV2 MMR */ 157*601fbec7SMasahiro Yamada ldr r8, PLL2_DIV_MASK 158*601fbec7SMasahiro Yamada ldr r6, PLL2_DIV2 159*601fbec7SMasahiro Yamada ldr r9, [r6] 160*601fbec7SMasahiro Yamada and r8, r8, r9 161*601fbec7SMasahiro Yamada mov r9, $0x01 162*601fbec7SMasahiro Yamada mov r9, r9, lsl $15 163*601fbec7SMasahiro Yamada orr r8, r8, r9 164*601fbec7SMasahiro Yamada str r8, [r6] 165*601fbec7SMasahiro Yamada 166*601fbec7SMasahiro Yamada /* Program the GOSET bit to take new divider values */ 167*601fbec7SMasahiro Yamada ldr r6, PLL2_PLLCMD 168*601fbec7SMasahiro Yamada ldr r7, [r6] 169*601fbec7SMasahiro Yamada orr r7, r7, $0x01 170*601fbec7SMasahiro Yamada str r7, [r6] 171*601fbec7SMasahiro Yamada 172*601fbec7SMasahiro Yamada /* Wait for Done */ 173*601fbec7SMasahiro Yamada ldr r6, PLL2_PLLSTAT 174*601fbec7SMasahiro YamadadoneLoop_0: 175*601fbec7SMasahiro Yamada ldr r7, [r6] 176*601fbec7SMasahiro Yamada ands r7, r7, $0x01 177*601fbec7SMasahiro Yamada bne doneLoop_0 178*601fbec7SMasahiro Yamada 179*601fbec7SMasahiro Yamada /* PLL2 DIV1 MMR */ 180*601fbec7SMasahiro Yamada ldr r8, PLL2_DIV_MASK 181*601fbec7SMasahiro Yamada ldr r6, PLL2_DIV1 182*601fbec7SMasahiro Yamada ldr r9, [r6] 183*601fbec7SMasahiro Yamada and r8, r8, r9 184*601fbec7SMasahiro Yamada mov r9, $0x01 185*601fbec7SMasahiro Yamada mov r9, r9, lsl $15 186*601fbec7SMasahiro Yamada orr r8, r8, r9 187*601fbec7SMasahiro Yamada str r8, [r6] 188*601fbec7SMasahiro Yamada 189*601fbec7SMasahiro Yamada /* Program the GOSET bit to take new divider values */ 190*601fbec7SMasahiro Yamada ldr r6, PLL2_PLLCMD 191*601fbec7SMasahiro Yamada ldr r7, [r6] 192*601fbec7SMasahiro Yamada orr r7, r7, $0x01 193*601fbec7SMasahiro Yamada str r7, [r6] 194*601fbec7SMasahiro Yamada 195*601fbec7SMasahiro Yamada /* Wait for Done */ 196*601fbec7SMasahiro Yamada ldr r6, PLL2_PLLSTAT 197*601fbec7SMasahiro YamadadoneLoop: 198*601fbec7SMasahiro Yamada ldr r7, [r6] 199*601fbec7SMasahiro Yamada ands r7, r7, $0x01 200*601fbec7SMasahiro Yamada bne doneLoop 201*601fbec7SMasahiro Yamada 202*601fbec7SMasahiro Yamada /* Wait for PLL to Reset Properly */ 203*601fbec7SMasahiro Yamada mov r10, $0x218 204*601fbec7SMasahiro YamadaResetPPL2Loop: 205*601fbec7SMasahiro Yamada subs r10, r10, $1 206*601fbec7SMasahiro Yamada bne ResetPPL2Loop 207*601fbec7SMasahiro Yamada 208*601fbec7SMasahiro Yamada /* Bring PLL out of Reset */ 209*601fbec7SMasahiro Yamada ldr r6, PLL2_CTL 210*601fbec7SMasahiro Yamada ldr r8, [r6] 211*601fbec7SMasahiro Yamada orr r8, r8, $0x08 212*601fbec7SMasahiro Yamada str r8, [r6] 213*601fbec7SMasahiro Yamada 214*601fbec7SMasahiro Yamada /* Wait for PLL to Lock */ 215*601fbec7SMasahiro Yamada ldr r10, PLL_LOCK_COUNT 216*601fbec7SMasahiro YamadaPLL2Lock: 217*601fbec7SMasahiro Yamada subs r10, r10, $1 218*601fbec7SMasahiro Yamada bne PLL2Lock 219*601fbec7SMasahiro Yamada 220*601fbec7SMasahiro Yamada /* Enable the PLL */ 221*601fbec7SMasahiro Yamada ldr r6, PLL2_CTL 222*601fbec7SMasahiro Yamada ldr r8, [r6] 223*601fbec7SMasahiro Yamada orr r8, r8, $0x01 224*601fbec7SMasahiro Yamada str r8, [r6] 225*601fbec7SMasahiro Yamada 226*601fbec7SMasahiro Yamada /*------------------------------------------------------* 227*601fbec7SMasahiro Yamada * Issue Soft Reset to DDR Module * 228*601fbec7SMasahiro Yamada *------------------------------------------------------*/ 229*601fbec7SMasahiro Yamada 230*601fbec7SMasahiro Yamada /* Shut down the DDR2 LPSC Module */ 231*601fbec7SMasahiro Yamada ldr r8, PSC_FLAG_CLEAR 232*601fbec7SMasahiro Yamada ldr r6, MDCTL_DDR2 233*601fbec7SMasahiro Yamada ldr r7, [r6] 234*601fbec7SMasahiro Yamada and r7, r7, r8 235*601fbec7SMasahiro Yamada orr r7, r7, $0x03 236*601fbec7SMasahiro Yamada str r7, [r6] 237*601fbec7SMasahiro Yamada 238*601fbec7SMasahiro Yamada /* Enable the Power Domain Transition Command */ 239*601fbec7SMasahiro Yamada ldr r6, PTCMD 240*601fbec7SMasahiro Yamada ldr r7, [r6] 241*601fbec7SMasahiro Yamada orr r7, r7, $0x01 242*601fbec7SMasahiro Yamada str r7, [r6] 243*601fbec7SMasahiro Yamada 244*601fbec7SMasahiro Yamada /* Check for Transition Complete(PTSTAT) */ 245*601fbec7SMasahiro YamadacheckStatClkStop: 246*601fbec7SMasahiro Yamada ldr r6, PTSTAT 247*601fbec7SMasahiro Yamada ldr r7, [r6] 248*601fbec7SMasahiro Yamada ands r7, r7, $0x01 249*601fbec7SMasahiro Yamada bne checkStatClkStop 250*601fbec7SMasahiro Yamada 251*601fbec7SMasahiro Yamada /* Check for DDR2 Controller Enable Completion */ 252*601fbec7SMasahiro YamadacheckDDRStatClkStop: 253*601fbec7SMasahiro Yamada ldr r6, MDSTAT_DDR2 254*601fbec7SMasahiro Yamada ldr r7, [r6] 255*601fbec7SMasahiro Yamada and r7, r7, $MDSTAT_STATE 256*601fbec7SMasahiro Yamada cmp r7, $0x03 257*601fbec7SMasahiro Yamada bne checkDDRStatClkStop 258*601fbec7SMasahiro Yamada 259*601fbec7SMasahiro Yamada /*------------------------------------------------------* 260*601fbec7SMasahiro Yamada * Program DDR2 MMRs for 162MHz Setting * 261*601fbec7SMasahiro Yamada *------------------------------------------------------*/ 262*601fbec7SMasahiro Yamada 263*601fbec7SMasahiro Yamada /* Program PHY Control Register */ 264*601fbec7SMasahiro Yamada ldr r6, DDRCTL 265*601fbec7SMasahiro Yamada ldr r7, DDRCTL_VAL 266*601fbec7SMasahiro Yamada str r7, [r6] 267*601fbec7SMasahiro Yamada 268*601fbec7SMasahiro Yamada /* Program SDRAM Bank Config Register */ 269*601fbec7SMasahiro Yamada ldr r6, SDCFG 270*601fbec7SMasahiro Yamada ldr r7, SDCFG_VAL 271*601fbec7SMasahiro Yamada str r7, [r6] 272*601fbec7SMasahiro Yamada 273*601fbec7SMasahiro Yamada /* Program SDRAM TIM-0 Config Register */ 274*601fbec7SMasahiro Yamada ldr r6, SDTIM0 275*601fbec7SMasahiro Yamada ldr r7, SDTIM0_VAL_162MHz 276*601fbec7SMasahiro Yamada str r7, [r6] 277*601fbec7SMasahiro Yamada 278*601fbec7SMasahiro Yamada /* Program SDRAM TIM-1 Config Register */ 279*601fbec7SMasahiro Yamada ldr r6, SDTIM1 280*601fbec7SMasahiro Yamada ldr r7, SDTIM1_VAL_162MHz 281*601fbec7SMasahiro Yamada str r7, [r6] 282*601fbec7SMasahiro Yamada 283*601fbec7SMasahiro Yamada /* Program the SDRAM Bank Config Control Register */ 284*601fbec7SMasahiro Yamada ldr r10, MASK_VAL 285*601fbec7SMasahiro Yamada ldr r8, SDCFG 286*601fbec7SMasahiro Yamada ldr r9, SDCFG_VAL 287*601fbec7SMasahiro Yamada and r9, r9, r10 288*601fbec7SMasahiro Yamada str r9, [r8] 289*601fbec7SMasahiro Yamada 290*601fbec7SMasahiro Yamada /* Program SDRAM SDREF Config Register */ 291*601fbec7SMasahiro Yamada ldr r6, SDREF 292*601fbec7SMasahiro Yamada ldr r7, SDREF_VAL 293*601fbec7SMasahiro Yamada str r7, [r6] 294*601fbec7SMasahiro Yamada 295*601fbec7SMasahiro Yamada /*------------------------------------------------------* 296*601fbec7SMasahiro Yamada * Issue Soft Reset to DDR Module * 297*601fbec7SMasahiro Yamada *------------------------------------------------------*/ 298*601fbec7SMasahiro Yamada 299*601fbec7SMasahiro Yamada /* Issue a Dummy DDR2 read/write */ 300*601fbec7SMasahiro Yamada ldr r8, DDR2_START_ADDR 301*601fbec7SMasahiro Yamada ldr r7, DUMMY_VAL 302*601fbec7SMasahiro Yamada str r7, [r8] 303*601fbec7SMasahiro Yamada ldr r7, [r8] 304*601fbec7SMasahiro Yamada 305*601fbec7SMasahiro Yamada /* Shut down the DDR2 LPSC Module */ 306*601fbec7SMasahiro Yamada ldr r8, PSC_FLAG_CLEAR 307*601fbec7SMasahiro Yamada ldr r6, MDCTL_DDR2 308*601fbec7SMasahiro Yamada ldr r7, [r6] 309*601fbec7SMasahiro Yamada and r7, r7, r8 310*601fbec7SMasahiro Yamada orr r7, r7, $0x01 311*601fbec7SMasahiro Yamada str r7, [r6] 312*601fbec7SMasahiro Yamada 313*601fbec7SMasahiro Yamada /* Enable the Power Domain Transition Command */ 314*601fbec7SMasahiro Yamada ldr r6, PTCMD 315*601fbec7SMasahiro Yamada ldr r7, [r6] 316*601fbec7SMasahiro Yamada orr r7, r7, $0x01 317*601fbec7SMasahiro Yamada str r7, [r6] 318*601fbec7SMasahiro Yamada 319*601fbec7SMasahiro Yamada /* Check for Transition Complete(PTSTAT) */ 320*601fbec7SMasahiro YamadacheckStatClkStop2: 321*601fbec7SMasahiro Yamada ldr r6, PTSTAT 322*601fbec7SMasahiro Yamada ldr r7, [r6] 323*601fbec7SMasahiro Yamada ands r7, r7, $0x01 324*601fbec7SMasahiro Yamada bne checkStatClkStop2 325*601fbec7SMasahiro Yamada 326*601fbec7SMasahiro Yamada /* Check for DDR2 Controller Enable Completion */ 327*601fbec7SMasahiro YamadacheckDDRStatClkStop2: 328*601fbec7SMasahiro Yamada ldr r6, MDSTAT_DDR2 329*601fbec7SMasahiro Yamada ldr r7, [r6] 330*601fbec7SMasahiro Yamada and r7, r7, $MDSTAT_STATE 331*601fbec7SMasahiro Yamada cmp r7, $0x01 332*601fbec7SMasahiro Yamada bne checkDDRStatClkStop2 333*601fbec7SMasahiro Yamada 334*601fbec7SMasahiro Yamada /*------------------------------------------------------* 335*601fbec7SMasahiro Yamada * Turn DDR2 Controller Clocks On * 336*601fbec7SMasahiro Yamada *------------------------------------------------------*/ 337*601fbec7SMasahiro Yamada 338*601fbec7SMasahiro Yamada /* Enable the DDR2 LPSC Module */ 339*601fbec7SMasahiro Yamada ldr r6, MDCTL_DDR2 340*601fbec7SMasahiro Yamada ldr r7, [r6] 341*601fbec7SMasahiro Yamada orr r7, r7, $0x03 342*601fbec7SMasahiro Yamada str r7, [r6] 343*601fbec7SMasahiro Yamada 344*601fbec7SMasahiro Yamada /* Enable the Power Domain Transition Command */ 345*601fbec7SMasahiro Yamada ldr r6, PTCMD 346*601fbec7SMasahiro Yamada ldr r7, [r6] 347*601fbec7SMasahiro Yamada orr r7, r7, $0x01 348*601fbec7SMasahiro Yamada str r7, [r6] 349*601fbec7SMasahiro Yamada 350*601fbec7SMasahiro Yamada /* Check for Transition Complete(PTSTAT) */ 351*601fbec7SMasahiro YamadacheckStatClkEn2: 352*601fbec7SMasahiro Yamada ldr r6, PTSTAT 353*601fbec7SMasahiro Yamada ldr r7, [r6] 354*601fbec7SMasahiro Yamada ands r7, r7, $0x01 355*601fbec7SMasahiro Yamada bne checkStatClkEn2 356*601fbec7SMasahiro Yamada 357*601fbec7SMasahiro Yamada /* Check for DDR2 Controller Enable Completion */ 358*601fbec7SMasahiro YamadacheckDDRStatClkEn2: 359*601fbec7SMasahiro Yamada ldr r6, MDSTAT_DDR2 360*601fbec7SMasahiro Yamada ldr r7, [r6] 361*601fbec7SMasahiro Yamada and r7, r7, $MDSTAT_STATE 362*601fbec7SMasahiro Yamada cmp r7, $0x03 363*601fbec7SMasahiro Yamada bne checkDDRStatClkEn2 364*601fbec7SMasahiro Yamada 365*601fbec7SMasahiro Yamada /* DDR Writes and Reads */ 366*601fbec7SMasahiro Yamada ldr r6, CFGTEST 367*601fbec7SMasahiro Yamada mov r3, $0x01 368*601fbec7SMasahiro Yamada str r3, [r6] 369*601fbec7SMasahiro Yamada 370*601fbec7SMasahiro Yamada /*------------------------------------------------------* 371*601fbec7SMasahiro Yamada * System PLL Initialization * 372*601fbec7SMasahiro Yamada *------------------------------------------------------*/ 373*601fbec7SMasahiro Yamada 374*601fbec7SMasahiro Yamada /* Select the Clock Mode Depending on the Value written in the Boot Table by the run script */ 375*601fbec7SMasahiro Yamada mov r2, $0 376*601fbec7SMasahiro Yamada ldr r6, PLL1_CTL 377*601fbec7SMasahiro Yamada ldr r7, PLL_CLKSRC_MASK 378*601fbec7SMasahiro Yamada ldr r8, [r6] 379*601fbec7SMasahiro Yamada and r8, r8, r7 380*601fbec7SMasahiro Yamada mov r9, r2, lsl $8 381*601fbec7SMasahiro Yamada orr r8, r8, r9 382*601fbec7SMasahiro Yamada str r8, [r6] 383*601fbec7SMasahiro Yamada 384*601fbec7SMasahiro Yamada /* Select the PLLEN source */ 385*601fbec7SMasahiro Yamada ldr r7, PLL_ENSRC_MASK 386*601fbec7SMasahiro Yamada and r8, r8, r7 387*601fbec7SMasahiro Yamada str r8, [r6] 388*601fbec7SMasahiro Yamada 389*601fbec7SMasahiro Yamada /* Bypass the PLL */ 390*601fbec7SMasahiro Yamada ldr r7, PLL_BYPASS_MASK 391*601fbec7SMasahiro Yamada and r8, r8, r7 392*601fbec7SMasahiro Yamada str r8, [r6] 393*601fbec7SMasahiro Yamada 394*601fbec7SMasahiro Yamada /* Wait for few cycles to allow PLLEN Mux switch properly to bypass Clock */ 395*601fbec7SMasahiro Yamada mov r10, $0x20 396*601fbec7SMasahiro Yamada 397*601fbec7SMasahiro YamadaWaitLoop: 398*601fbec7SMasahiro Yamada subs r10, r10, $1 399*601fbec7SMasahiro Yamada bne WaitLoop 400*601fbec7SMasahiro Yamada 401*601fbec7SMasahiro Yamada /* Reset the PLL */ 402*601fbec7SMasahiro Yamada ldr r7, PLL_RESET_MASK 403*601fbec7SMasahiro Yamada and r8, r8, r7 404*601fbec7SMasahiro Yamada str r8, [r6] 405*601fbec7SMasahiro Yamada 406*601fbec7SMasahiro Yamada /* Disable the PLL */ 407*601fbec7SMasahiro Yamada orr r8, r8, $0x10 408*601fbec7SMasahiro Yamada str r8, [r6] 409*601fbec7SMasahiro Yamada 410*601fbec7SMasahiro Yamada /* Power up the PLL */ 411*601fbec7SMasahiro Yamada ldr r7, PLL_PWRUP_MASK 412*601fbec7SMasahiro Yamada and r8, r8, r7 413*601fbec7SMasahiro Yamada str r8, [r6] 414*601fbec7SMasahiro Yamada 415*601fbec7SMasahiro Yamada /* Enable the PLL from Disable Mode */ 416*601fbec7SMasahiro Yamada ldr r7, PLL_DISABLE_ENABLE_MASK 417*601fbec7SMasahiro Yamada and r8, r8, r7 418*601fbec7SMasahiro Yamada str r8, [r6] 419*601fbec7SMasahiro Yamada 420*601fbec7SMasahiro Yamada /* Program the PLL Multiplier */ 421*601fbec7SMasahiro Yamada ldr r6, PLL1_PLLM 422*601fbec7SMasahiro Yamada mov r3, $0x15 /* For 594MHz */ 423*601fbec7SMasahiro Yamada str r3, [r6] 424*601fbec7SMasahiro Yamada 425*601fbec7SMasahiro Yamada /* Wait for PLL to Reset Properly */ 426*601fbec7SMasahiro Yamada mov r10, $0xff 427*601fbec7SMasahiro Yamada 428*601fbec7SMasahiro YamadaResetLoop: 429*601fbec7SMasahiro Yamada subs r10, r10, $1 430*601fbec7SMasahiro Yamada bne ResetLoop 431*601fbec7SMasahiro Yamada 432*601fbec7SMasahiro Yamada /* Bring PLL out of Reset */ 433*601fbec7SMasahiro Yamada ldr r6, PLL1_CTL 434*601fbec7SMasahiro Yamada orr r8, r8, $0x08 435*601fbec7SMasahiro Yamada str r8, [r6] 436*601fbec7SMasahiro Yamada 437*601fbec7SMasahiro Yamada /* Wait for PLL to Lock */ 438*601fbec7SMasahiro Yamada ldr r10, PLL_LOCK_COUNT 439*601fbec7SMasahiro Yamada 440*601fbec7SMasahiro YamadaPLL1Lock: 441*601fbec7SMasahiro Yamada subs r10, r10, $1 442*601fbec7SMasahiro Yamada bne PLL1Lock 443*601fbec7SMasahiro Yamada 444*601fbec7SMasahiro Yamada /* Enable the PLL */ 445*601fbec7SMasahiro Yamada orr r8, r8, $0x01 446*601fbec7SMasahiro Yamada str r8, [r6] 447*601fbec7SMasahiro Yamada 448*601fbec7SMasahiro Yamada nop 449*601fbec7SMasahiro Yamada nop 450*601fbec7SMasahiro Yamada nop 451*601fbec7SMasahiro Yamada nop 452*601fbec7SMasahiro Yamada 453*601fbec7SMasahiro Yamada /*------------------------------------------------------* 454*601fbec7SMasahiro Yamada * AEMIF configuration for NOR Flash (double check) * 455*601fbec7SMasahiro Yamada *------------------------------------------------------*/ 456*601fbec7SMasahiro Yamada ldr r0, _PINMUX0 457*601fbec7SMasahiro Yamada ldr r1, _DEV_SETTING 458*601fbec7SMasahiro Yamada str r1, [r0] 459*601fbec7SMasahiro Yamada 460*601fbec7SMasahiro Yamada ldr r0, WAITCFG 461*601fbec7SMasahiro Yamada ldr r1, WAITCFG_VAL 462*601fbec7SMasahiro Yamada ldr r2, [r0] 463*601fbec7SMasahiro Yamada orr r2, r2, r1 464*601fbec7SMasahiro Yamada str r2, [r0] 465*601fbec7SMasahiro Yamada 466*601fbec7SMasahiro Yamada ldr r0, ACFG3 467*601fbec7SMasahiro Yamada ldr r1, ACFG3_VAL 468*601fbec7SMasahiro Yamada ldr r2, [r0] 469*601fbec7SMasahiro Yamada and r1, r2, r1 470*601fbec7SMasahiro Yamada str r1, [r0] 471*601fbec7SMasahiro Yamada 472*601fbec7SMasahiro Yamada ldr r0, ACFG4 473*601fbec7SMasahiro Yamada ldr r1, ACFG4_VAL 474*601fbec7SMasahiro Yamada ldr r2, [r0] 475*601fbec7SMasahiro Yamada and r1, r2, r1 476*601fbec7SMasahiro Yamada str r1, [r0] 477*601fbec7SMasahiro Yamada 478*601fbec7SMasahiro Yamada ldr r0, ACFG5 479*601fbec7SMasahiro Yamada ldr r1, ACFG5_VAL 480*601fbec7SMasahiro Yamada ldr r2, [r0] 481*601fbec7SMasahiro Yamada and r1, r2, r1 482*601fbec7SMasahiro Yamada str r1, [r0] 483*601fbec7SMasahiro Yamada 484*601fbec7SMasahiro Yamada /*--------------------------------------* 485*601fbec7SMasahiro Yamada * VTP manual Calibration * 486*601fbec7SMasahiro Yamada *--------------------------------------*/ 487*601fbec7SMasahiro Yamada ldr r0, VTPIOCR 488*601fbec7SMasahiro Yamada ldr r1, VTP_MMR0 489*601fbec7SMasahiro Yamada str r1, [r0] 490*601fbec7SMasahiro Yamada 491*601fbec7SMasahiro Yamada ldr r0, VTPIOCR 492*601fbec7SMasahiro Yamada ldr r1, VTP_MMR1 493*601fbec7SMasahiro Yamada str r1, [r0] 494*601fbec7SMasahiro Yamada 495*601fbec7SMasahiro Yamada /* Wait for 33 VTP CLK cycles. VRP operates at 27 MHz */ 496*601fbec7SMasahiro Yamada ldr r10, VTP_LOCK_COUNT 497*601fbec7SMasahiro YamadaVTPLock: 498*601fbec7SMasahiro Yamada subs r10, r10, $1 499*601fbec7SMasahiro Yamada bne VTPLock 500*601fbec7SMasahiro Yamada 501*601fbec7SMasahiro Yamada ldr r6, DFT_ENABLE 502*601fbec7SMasahiro Yamada mov r10, $0x01 503*601fbec7SMasahiro Yamada str r10, [r6] 504*601fbec7SMasahiro Yamada 505*601fbec7SMasahiro Yamada ldr r6, DDRVTPR 506*601fbec7SMasahiro Yamada ldr r7, [r6] 507*601fbec7SMasahiro Yamada mov r8, r7, LSL #32-10 508*601fbec7SMasahiro Yamada mov r8, r8, LSR #32-10 /* grab low 10 bits */ 509*601fbec7SMasahiro Yamada ldr r7, VTP_RECAL 510*601fbec7SMasahiro Yamada orr r8, r7, r8 511*601fbec7SMasahiro Yamada ldr r7, VTP_EN 512*601fbec7SMasahiro Yamada orr r8, r7, r8 513*601fbec7SMasahiro Yamada str r8, [r0] 514*601fbec7SMasahiro Yamada 515*601fbec7SMasahiro Yamada 516*601fbec7SMasahiro Yamada /* Wait for 33 VTP CLK cycles. VRP operates at 27 MHz */ 517*601fbec7SMasahiro Yamada ldr r10, VTP_LOCK_COUNT 518*601fbec7SMasahiro YamadaVTP1Lock: 519*601fbec7SMasahiro Yamada subs r10, r10, $1 520*601fbec7SMasahiro Yamada bne VTP1Lock 521*601fbec7SMasahiro Yamada 522*601fbec7SMasahiro Yamada ldr r1, [r0] 523*601fbec7SMasahiro Yamada ldr r2, VTP_MASK 524*601fbec7SMasahiro Yamada and r2, r1, r2 525*601fbec7SMasahiro Yamada str r2, [r0] 526*601fbec7SMasahiro Yamada 527*601fbec7SMasahiro Yamada ldr r6, DFT_ENABLE 528*601fbec7SMasahiro Yamada mov r10, $0 529*601fbec7SMasahiro Yamada str r10, [r6] 530*601fbec7SMasahiro Yamada 531*601fbec7SMasahiro Yamada /* 532*601fbec7SMasahiro Yamada * Call board-specific lowlevel init. 533*601fbec7SMasahiro Yamada * That MUST be present and THAT returns 534*601fbec7SMasahiro Yamada * back to arch calling code with "mov pc, lr." 535*601fbec7SMasahiro Yamada */ 536*601fbec7SMasahiro Yamada b dv_board_init 537*601fbec7SMasahiro Yamada 538*601fbec7SMasahiro Yamada.ltorg 539*601fbec7SMasahiro Yamada 540*601fbec7SMasahiro Yamada_PINMUX0: 541*601fbec7SMasahiro Yamada .word 0x01c40000 /* Device Configuration Registers */ 542*601fbec7SMasahiro Yamada_PINMUX1: 543*601fbec7SMasahiro Yamada .word 0x01c40004 /* Device Configuration Registers */ 544*601fbec7SMasahiro Yamada 545*601fbec7SMasahiro Yamada_DEV_SETTING: 546*601fbec7SMasahiro Yamada .word 0x00000c1f 547*601fbec7SMasahiro Yamada 548*601fbec7SMasahiro YamadaWAITCFG: 549*601fbec7SMasahiro Yamada .word 0x01e00004 550*601fbec7SMasahiro YamadaWAITCFG_VAL: 551*601fbec7SMasahiro Yamada .word 0 552*601fbec7SMasahiro YamadaACFG3: 553*601fbec7SMasahiro Yamada .word 0x01e00014 554*601fbec7SMasahiro YamadaACFG3_VAL: 555*601fbec7SMasahiro Yamada .word 0x3ffffffd 556*601fbec7SMasahiro YamadaACFG4: 557*601fbec7SMasahiro Yamada .word 0x01e00018 558*601fbec7SMasahiro YamadaACFG4_VAL: 559*601fbec7SMasahiro Yamada .word 0x3ffffffd 560*601fbec7SMasahiro YamadaACFG5: 561*601fbec7SMasahiro Yamada .word 0x01e0001c 562*601fbec7SMasahiro YamadaACFG5_VAL: 563*601fbec7SMasahiro Yamada .word 0x3ffffffd 564*601fbec7SMasahiro Yamada 565*601fbec7SMasahiro YamadaMDCTL_DDR2: 566*601fbec7SMasahiro Yamada .word 0x01c41a34 567*601fbec7SMasahiro YamadaMDSTAT_DDR2: 568*601fbec7SMasahiro Yamada .word 0x01c41834 569*601fbec7SMasahiro Yamada 570*601fbec7SMasahiro YamadaPTCMD: 571*601fbec7SMasahiro Yamada .word 0x01c41120 572*601fbec7SMasahiro YamadaPTSTAT: 573*601fbec7SMasahiro Yamada .word 0x01c41128 574*601fbec7SMasahiro Yamada 575*601fbec7SMasahiro YamadaEINT_ENABLE0: 576*601fbec7SMasahiro Yamada .word 0x01c48018 577*601fbec7SMasahiro YamadaEINT_ENABLE1: 578*601fbec7SMasahiro Yamada .word 0x01c4801c 579*601fbec7SMasahiro Yamada 580*601fbec7SMasahiro YamadaPSC_FLAG_CLEAR: 581*601fbec7SMasahiro Yamada .word 0xffffffe0 582*601fbec7SMasahiro YamadaPSC_GEM_FLAG_CLEAR: 583*601fbec7SMasahiro Yamada .word 0xfffffeff 584*601fbec7SMasahiro Yamada 585*601fbec7SMasahiro Yamada/* DDR2 MMR & CONFIGURATION VALUES, 162 MHZ clock */ 586*601fbec7SMasahiro YamadaDDRCTL: 587*601fbec7SMasahiro Yamada .word 0x200000e4 588*601fbec7SMasahiro YamadaDDRCTL_VAL: 589*601fbec7SMasahiro Yamada .word 0x50006405 590*601fbec7SMasahiro YamadaSDREF: 591*601fbec7SMasahiro Yamada .word 0x2000000c 592*601fbec7SMasahiro YamadaSDREF_VAL: 593*601fbec7SMasahiro Yamada .word 0x000005c3 594*601fbec7SMasahiro YamadaSDCFG: 595*601fbec7SMasahiro Yamada .word 0x20000008 596*601fbec7SMasahiro YamadaSDCFG_VAL: 597*601fbec7SMasahiro Yamada#ifdef DDR_4BANKS 598*601fbec7SMasahiro Yamada .word 0x00178622 599*601fbec7SMasahiro Yamada#elif defined DDR_8BANKS 600*601fbec7SMasahiro Yamada .word 0x00178632 601*601fbec7SMasahiro Yamada#else 602*601fbec7SMasahiro Yamada#error "Unknown DDR configuration!!!" 603*601fbec7SMasahiro Yamada#endif 604*601fbec7SMasahiro YamadaSDTIM0: 605*601fbec7SMasahiro Yamada .word 0x20000010 606*601fbec7SMasahiro YamadaSDTIM0_VAL_162MHz: 607*601fbec7SMasahiro Yamada .word 0x28923211 608*601fbec7SMasahiro YamadaSDTIM1: 609*601fbec7SMasahiro Yamada .word 0x20000014 610*601fbec7SMasahiro YamadaSDTIM1_VAL_162MHz: 611*601fbec7SMasahiro Yamada .word 0x0016c722 612*601fbec7SMasahiro YamadaVTPIOCR: 613*601fbec7SMasahiro Yamada .word 0x200000f0 /* VTP IO Control register */ 614*601fbec7SMasahiro YamadaDDRVTPR: 615*601fbec7SMasahiro Yamada .word 0x01c42030 /* DDR VPTR MMR */ 616*601fbec7SMasahiro YamadaVTP_MMR0: 617*601fbec7SMasahiro Yamada .word 0x201f 618*601fbec7SMasahiro YamadaVTP_MMR1: 619*601fbec7SMasahiro Yamada .word 0xa01f 620*601fbec7SMasahiro YamadaDFT_ENABLE: 621*601fbec7SMasahiro Yamada .word 0x01c4004c 622*601fbec7SMasahiro YamadaVTP_LOCK_COUNT: 623*601fbec7SMasahiro Yamada .word 0x5b0 624*601fbec7SMasahiro YamadaVTP_MASK: 625*601fbec7SMasahiro Yamada .word 0xffffdfff 626*601fbec7SMasahiro YamadaVTP_RECAL: 627*601fbec7SMasahiro Yamada .word 0x08000 628*601fbec7SMasahiro YamadaVTP_EN: 629*601fbec7SMasahiro Yamada .word 0x02000 630*601fbec7SMasahiro YamadaCFGTEST: 631*601fbec7SMasahiro Yamada .word 0x80010000 632*601fbec7SMasahiro YamadaMASK_VAL: 633*601fbec7SMasahiro Yamada .word 0x00000fff 634*601fbec7SMasahiro Yamada 635*601fbec7SMasahiro Yamada/* GEM Power Up & LPSC Control Register */ 636*601fbec7SMasahiro YamadaMDCTL_GEM: 637*601fbec7SMasahiro Yamada .word 0x01c41a9c 638*601fbec7SMasahiro YamadaMDSTAT_GEM: 639*601fbec7SMasahiro Yamada .word 0x01c4189c 640*601fbec7SMasahiro Yamada 641*601fbec7SMasahiro Yamada/* For WDT reset chip bug */ 642*601fbec7SMasahiro YamadaP1394: 643*601fbec7SMasahiro Yamada .word 0x01c41a20 644*601fbec7SMasahiro Yamada 645*601fbec7SMasahiro YamadaPLL_CLKSRC_MASK: 646*601fbec7SMasahiro Yamada .word 0xfffffeff /* Mask the Clock Mode bit */ 647*601fbec7SMasahiro YamadaPLL_ENSRC_MASK: 648*601fbec7SMasahiro Yamada .word 0xffffffdf /* Select the PLLEN source */ 649*601fbec7SMasahiro YamadaPLL_BYPASS_MASK: 650*601fbec7SMasahiro Yamada .word 0xfffffffe /* Put the PLL in BYPASS */ 651*601fbec7SMasahiro YamadaPLL_RESET_MASK: 652*601fbec7SMasahiro Yamada .word 0xfffffff7 /* Put the PLL in Reset Mode */ 653*601fbec7SMasahiro YamadaPLL_PWRUP_MASK: 654*601fbec7SMasahiro Yamada .word 0xfffffffd /* PLL Power up Mask Bit */ 655*601fbec7SMasahiro YamadaPLL_DISABLE_ENABLE_MASK: 656*601fbec7SMasahiro Yamada .word 0xffffffef /* Enable the PLL from Disable */ 657*601fbec7SMasahiro YamadaPLL_LOCK_COUNT: 658*601fbec7SMasahiro Yamada .word 0x2000 659*601fbec7SMasahiro Yamada 660*601fbec7SMasahiro Yamada/* PLL1-SYSTEM PLL MMRs */ 661*601fbec7SMasahiro YamadaPLL1_CTL: 662*601fbec7SMasahiro Yamada .word 0x01c40900 663*601fbec7SMasahiro YamadaPLL1_PLLM: 664*601fbec7SMasahiro Yamada .word 0x01c40910 665*601fbec7SMasahiro Yamada 666*601fbec7SMasahiro Yamada/* PLL2-SYSTEM PLL MMRs */ 667*601fbec7SMasahiro YamadaPLL2_CTL: 668*601fbec7SMasahiro Yamada .word 0x01c40d00 669*601fbec7SMasahiro YamadaPLL2_PLLM: 670*601fbec7SMasahiro Yamada .word 0x01c40d10 671*601fbec7SMasahiro YamadaPLL2_DIV1: 672*601fbec7SMasahiro Yamada .word 0x01c40d18 673*601fbec7SMasahiro YamadaPLL2_DIV2: 674*601fbec7SMasahiro Yamada .word 0x01c40d1c 675*601fbec7SMasahiro YamadaPLL2_PLLCMD: 676*601fbec7SMasahiro Yamada .word 0x01c40d38 677*601fbec7SMasahiro YamadaPLL2_PLLSTAT: 678*601fbec7SMasahiro Yamada .word 0x01c40d3c 679*601fbec7SMasahiro YamadaPLL2_DIV_MASK: 680*601fbec7SMasahiro Yamada .word 0xffff7fff 681*601fbec7SMasahiro Yamada 682*601fbec7SMasahiro YamadaMMARG_BRF0: 683*601fbec7SMasahiro Yamada .word 0x01c42010 /* BRF margin mode 0 (R/W)*/ 684*601fbec7SMasahiro YamadaMMARG_BRF0_VAL: 685*601fbec7SMasahiro Yamada .word 0x00444400 686*601fbec7SMasahiro Yamada 687*601fbec7SMasahiro YamadaDDR2_START_ADDR: 688*601fbec7SMasahiro Yamada .word 0x80000000 689*601fbec7SMasahiro YamadaDUMMY_VAL: 690*601fbec7SMasahiro Yamada .word 0xa55aa55a 691*601fbec7SMasahiro Yamada#else /* CONFIG_SOC_DM644X */ 692*601fbec7SMasahiro Yamada mov pc, lr 693*601fbec7SMasahiro Yamada#endif 694