2 * Low-level board setup code for TI DaVinci SoC based boards.
4 * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
6 * Partially based on TI sources, original copyrights follow:
10 * Board specific setup info
13 * Texas Instruments, <www.ti.com>
14 * Kshitij Gupta <Kshitij@ti.com>
16 * Modified for OMAP 1610 H2 board by Nishant Kamat, Jan 2004
18 * Modified for OMAP 5912 OSK board by Rishi Bhattacharya, Apr 2004
20 * Modified for DV-EVM board by Rishi Bhattacharya, Apr 2005
22 * Modified for DV-EVM board by Swaminathan S, Nov 2005
24 * SPDX-License-Identifier: GPL-2.0+
29 #define MDSTAT_STATE 0x3f
33 #ifdef CONFIG_SOC_DM644X
35 /*-------------------------------------------------------*
36 * Mask all IRQs by setting all bits in the EINT default *
37 *-------------------------------------------------------*/
44 /*------------------------------------------------------*
45 * Put the GEM in reset *
46 *------------------------------------------------------*/
48 /* Put the GEM in reset */
49 ldr r8, PSC_GEM_FLAG_CLEAR
55 /* Enable the Power Domain Transition Command */
61 /* Check for Transition Complete(PTSTAT) */
66 bne checkStatClkStopGem
68 /* Check for GEM Reset Completion */
73 bne checkGemStatClkStop
75 /* Do this for enabling a WDT initiated reset this is a workaround
76 for a chip bug. Not required under normal situations */
81 /*------------------------------------------------------*
82 * Enable L1 & L2 Memories in Fast mode *
83 *------------------------------------------------------*/
89 ldr r10, MMARG_BRF0_VAL
96 /*------------------------------------------------------*
97 * DDR2 PLL Initialization *
98 *------------------------------------------------------*/
100 /* Select the Clock Mode Depending on the Value written in the Boot Table by the run script */
103 ldr r7, PLL_CLKSRC_MASK
110 /* Select the PLLEN source */
111 ldr r7, PLL_ENSRC_MASK
116 ldr r7, PLL_BYPASS_MASK
120 /* Wait for few cycles to allow PLLEN Mux switch properly to bypass Clock */
127 ldr r7, PLL_RESET_MASK
131 /* Power up the PLL */
132 ldr r7, PLL_PWRUP_MASK
136 /* Enable the PLL from Disable Mode */
137 ldr r7, PLL_DISABLE_ENABLE_MASK
141 /* Program the PLL Multiplier */
143 mov r2, $0x17 /* 162 MHz */
146 /* Program the PLL2 Divisor Value */
151 /* Program the PLL2 Divisor Value */
153 mov r4, $0x0b /* 54 MHz */
157 ldr r8, PLL2_DIV_MASK
166 /* Program the GOSET bit to take new divider values */
180 ldr r8, PLL2_DIV_MASK
189 /* Program the GOSET bit to take new divider values */
202 /* Wait for PLL to Reset Properly */
208 /* Bring PLL out of Reset */
214 /* Wait for PLL to Lock */
215 ldr r10, PLL_LOCK_COUNT
226 /*------------------------------------------------------*
227 * Issue Soft Reset to DDR Module *
228 *------------------------------------------------------*/
230 /* Shut down the DDR2 LPSC Module */
231 ldr r8, PSC_FLAG_CLEAR
238 /* Enable the Power Domain Transition Command */
244 /* Check for Transition Complete(PTSTAT) */
251 /* Check for DDR2 Controller Enable Completion */
255 and r7, r7, $MDSTAT_STATE
257 bne checkDDRStatClkStop
259 /*------------------------------------------------------*
260 * Program DDR2 MMRs for 162MHz Setting *
261 *------------------------------------------------------*/
263 /* Program PHY Control Register */
268 /* Program SDRAM Bank Config Register */
273 /* Program SDRAM TIM-0 Config Register */
275 ldr r7, SDTIM0_VAL_162MHz
278 /* Program SDRAM TIM-1 Config Register */
280 ldr r7, SDTIM1_VAL_162MHz
283 /* Program the SDRAM Bank Config Control Register */
290 /* Program SDRAM SDREF Config Register */
295 /*------------------------------------------------------*
296 * Issue Soft Reset to DDR Module *
297 *------------------------------------------------------*/
299 /* Issue a Dummy DDR2 read/write */
300 ldr r8, DDR2_START_ADDR
305 /* Shut down the DDR2 LPSC Module */
306 ldr r8, PSC_FLAG_CLEAR
313 /* Enable the Power Domain Transition Command */
319 /* Check for Transition Complete(PTSTAT) */
324 bne checkStatClkStop2
326 /* Check for DDR2 Controller Enable Completion */
327 checkDDRStatClkStop2:
330 and r7, r7, $MDSTAT_STATE
332 bne checkDDRStatClkStop2
334 /*------------------------------------------------------*
335 * Turn DDR2 Controller Clocks On *
336 *------------------------------------------------------*/
338 /* Enable the DDR2 LPSC Module */
344 /* Enable the Power Domain Transition Command */
350 /* Check for Transition Complete(PTSTAT) */
357 /* Check for DDR2 Controller Enable Completion */
361 and r7, r7, $MDSTAT_STATE
363 bne checkDDRStatClkEn2
365 /* DDR Writes and Reads */
370 /*------------------------------------------------------*
371 * System PLL Initialization *
372 *------------------------------------------------------*/
374 /* Select the Clock Mode Depending on the Value written in the Boot Table by the run script */
377 ldr r7, PLL_CLKSRC_MASK
384 /* Select the PLLEN source */
385 ldr r7, PLL_ENSRC_MASK
390 ldr r7, PLL_BYPASS_MASK
394 /* Wait for few cycles to allow PLLEN Mux switch properly to bypass Clock */
402 ldr r7, PLL_RESET_MASK
406 /* Disable the PLL */
410 /* Power up the PLL */
411 ldr r7, PLL_PWRUP_MASK
415 /* Enable the PLL from Disable Mode */
416 ldr r7, PLL_DISABLE_ENABLE_MASK
420 /* Program the PLL Multiplier */
422 mov r3, $0x15 /* For 594MHz */
425 /* Wait for PLL to Reset Properly */
432 /* Bring PLL out of Reset */
437 /* Wait for PLL to Lock */
438 ldr r10, PLL_LOCK_COUNT
453 /*------------------------------------------------------*
454 * AEMIF configuration for NOR Flash (double check) *
455 *------------------------------------------------------*/
484 /*--------------------------------------*
485 * VTP manual Calibration *
486 *--------------------------------------*/
495 /* Wait for 33 VTP CLK cycles. VRP operates at 27 MHz */
496 ldr r10, VTP_LOCK_COUNT
507 mov r8, r7, LSL #32-10
508 mov r8, r8, LSR #32-10 /* grab low 10 bits */
516 /* Wait for 33 VTP CLK cycles. VRP operates at 27 MHz */
517 ldr r10, VTP_LOCK_COUNT
532 * Call board-specific lowlevel init.
533 * That MUST be present and THAT returns
534 * back to arch calling code with "mov pc, lr."
541 .word 0x01c40000 /* Device Configuration Registers */
543 .word 0x01c40004 /* Device Configuration Registers */
585 /* DDR2 MMR & CONFIGURATION VALUES, 162 MHZ clock */
599 #elif defined DDR_8BANKS
602 #error "Unknown DDR configuration!!!"
613 .word 0x200000f0 /* VTP IO Control register */
615 .word 0x01c42030 /* DDR VPTR MMR */
635 /* GEM Power Up & LPSC Control Register */
641 /* For WDT reset chip bug */
646 .word 0xfffffeff /* Mask the Clock Mode bit */
648 .word 0xffffffdf /* Select the PLLEN source */
650 .word 0xfffffffe /* Put the PLL in BYPASS */
652 .word 0xfffffff7 /* Put the PLL in Reset Mode */
654 .word 0xfffffffd /* PLL Power up Mask Bit */
655 PLL_DISABLE_ENABLE_MASK:
656 .word 0xffffffef /* Enable the PLL from Disable */
660 /* PLL1-SYSTEM PLL MMRs */
666 /* PLL2-SYSTEM PLL MMRs */
683 .word 0x01c42010 /* BRF margin mode 0 (R/W)*/
691 #else /* CONFIG_SOC_DM644X */