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
19 * See file CREDITS for list of people who contributed to this
22 * Modified for DV-EVM board by Rishi Bhattacharya, Apr 2005
23 * See file CREDITS for list of people who contributed to this
26 * Modified for DV-EVM board by Swaminathan S, Nov 2005
27 * See file CREDITS for list of people who contributed to this
30 * This program is free software; you can redistribute it and/or
31 * modify it under the terms of the GNU General Public License as
32 * published by the Free Software Foundation; either version 2 of
33 * the License, or (at your option) any later version.
35 * This program is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 * GNU General Public License for more details.
40 * You should have received a copy of the GNU General Public License
41 * along with this program; if not, write to the Free Software
42 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
48 #define MDSTAT_STATE 0x3f
53 /*-------------------------------------------------------*
54 * Mask all IRQs by setting all bits in the EINT default *
55 *-------------------------------------------------------*/
62 /*------------------------------------------------------*
63 * Put the GEM in reset *
64 *------------------------------------------------------*/
66 /* Put the GEM in reset */
67 ldr r8, PSC_GEM_FLAG_CLEAR
73 /* Enable the Power Domain Transition Command */
79 /* Check for Transition Complete(PTSTAT) */
84 bne checkStatClkStopGem
86 /* Check for GEM Reset Completion */
91 bne checkGemStatClkStop
93 /* Do this for enabling a WDT initiated reset this is a workaround
94 for a chip bug. Not required under normal situations */
99 /*------------------------------------------------------*
100 * Enable L1 & L2 Memories in Fast mode *
101 *------------------------------------------------------*/
107 ldr r10, MMARG_BRF0_VAL
114 /*------------------------------------------------------*
115 * DDR2 PLL Initialization *
116 *------------------------------------------------------*/
118 /* Select the Clock Mode Depending on the Value written in the Boot Table by the run script */
121 ldr r7, PLL_CLKSRC_MASK
128 /* Select the PLLEN source */
129 ldr r7, PLL_ENSRC_MASK
134 ldr r7, PLL_BYPASS_MASK
138 /* Wait for few cycles to allow PLLEN Mux switch properly to bypass Clock */
145 ldr r7, PLL_RESET_MASK
149 /* Power up the PLL */
150 ldr r7, PLL_PWRUP_MASK
154 /* Enable the PLL from Disable Mode */
155 ldr r7, PLL_DISABLE_ENABLE_MASK
159 /* Program the PLL Multiplier */
161 mov r2, $0x17 /* 162 MHz */
164 /* Program the PLL2 Divisor Value */
169 /* Program the PLL2 Divisor Value */
171 mov r4, $0x0b /* 54 MHz */
175 ldr r8, PLL2_DIV_MASK
184 /* Program the GOSET bit to take new divider values */
198 ldr r8, PLL2_DIV_MASK
207 /* Program the GOSET bit to take new divider values */
220 /* Wait for PLL to Reset Properly */
226 /* Bring PLL out of Reset */
232 /* Wait for PLL to Lock */
233 ldr r10, PLL_LOCK_COUNT
244 /*------------------------------------------------------*
245 * Issue Soft Reset to DDR Module *
246 *------------------------------------------------------*/
248 /* Shut down the DDR2 LPSC Module */
249 ldr r8, PSC_FLAG_CLEAR
256 /* Enable the Power Domain Transition Command */
262 /* Check for Transition Complete(PTSTAT) */
269 /* Check for DDR2 Controller Enable Completion */
273 and r7, r7, $MDSTAT_STATE
275 bne checkDDRStatClkStop
277 /*------------------------------------------------------*
278 * Program DDR2 MMRs for 162MHz Setting *
279 *------------------------------------------------------*/
281 /* Program PHY Control Register */
286 /* Program SDRAM Bank Config Register */
291 /* Program SDRAM TIM-0 Config Register */
293 ldr r7, SDTIM0_VAL_162MHz
296 /* Program SDRAM TIM-1 Config Register */
298 ldr r7, SDTIM1_VAL_162MHz
301 /* Program the SDRAM Bank Config Control Register */
308 /* Program SDRAM SDREF Config Register */
313 /*------------------------------------------------------*
314 * Issue Soft Reset to DDR Module *
315 *------------------------------------------------------*/
317 /* Issue a Dummy DDR2 read/write */
318 ldr r8, DDR2_START_ADDR
323 /* Shut down the DDR2 LPSC Module */
324 ldr r8, PSC_FLAG_CLEAR
331 /* Enable the Power Domain Transition Command */
337 /* Check for Transition Complete(PTSTAT) */
342 bne checkStatClkStop2
344 /* Check for DDR2 Controller Enable Completion */
345 checkDDRStatClkStop2:
348 and r7, r7, $MDSTAT_STATE
350 bne checkDDRStatClkStop2
352 /*------------------------------------------------------*
353 * Turn DDR2 Controller Clocks On *
354 *------------------------------------------------------*/
356 /* Enable the DDR2 LPSC Module */
362 /* Enable the Power Domain Transition Command */
368 /* Check for Transition Complete(PTSTAT) */
375 /* Check for DDR2 Controller Enable Completion */
379 and r7, r7, $MDSTAT_STATE
381 bne checkDDRStatClkEn2
383 /* DDR Writes and Reads */
388 /*------------------------------------------------------*
389 * System PLL Initialization *
390 *------------------------------------------------------*/
392 /* Select the Clock Mode Depending on the Value written in the Boot Table by the run script */
395 ldr r7, PLL_CLKSRC_MASK
402 /* Select the PLLEN source */
403 ldr r7, PLL_ENSRC_MASK
408 ldr r7, PLL_BYPASS_MASK
412 /* Wait for few cycles to allow PLLEN Mux switch properly to bypass Clock */
420 ldr r7, PLL_RESET_MASK
424 /* Disable the PLL */
428 /* Power up the PLL */
429 ldr r7, PLL_PWRUP_MASK
433 /* Enable the PLL from Disable Mode */
434 ldr r7, PLL_DISABLE_ENABLE_MASK
438 /* Program the PLL Multiplier */
440 mov r3, $0x15 /* For 594MHz */
443 /* Wait for PLL to Reset Properly */
450 /* Bring PLL out of Reset */
455 /* Wait for PLL to Lock */
456 ldr r10, PLL_LOCK_COUNT
471 /*------------------------------------------------------*
472 * AEMIF configuration for NOR Flash (double check) *
473 *------------------------------------------------------*/
502 /*--------------------------------------*
503 * VTP manual Calibration *
504 *--------------------------------------*/
513 /* Wait for 33 VTP CLK cycles. VRP operates at 27 MHz */
514 ldr r10, VTP_LOCK_COUNT
535 /* Wait for 33 VTP CLK cycles. VRP operates at 27 MHz */
536 ldr r10, VTP_LOCK_COUNT
551 * Call board-specific lowlevel init.
552 * That MUST be present and THAT returns
553 * back to arch calling code with "mov pc, lr."
560 .word 0x01c40000 /* Device Configuration Registers */
562 .word 0x01c40004 /* Device Configuration Registers */
604 /* DDR2 MMR & CONFIGURATION VALUES, 162 MHZ clock */
618 #elif defined DDR_8BANKS
621 #error "Unknown DDR configuration!!!"
632 .word 0x200000f0 /* VTP IO Control register */
634 .word 0x01c42030 /* DDR VPTR MMR */
654 /* GEM Power Up & LPSC Control Register */
660 /* For WDT reset chip bug */
665 .word 0xfffffeff /* Mask the Clock Mode bit */
667 .word 0xffffffdf /* Select the PLLEN source */
669 .word 0xfffffffe /* Put the PLL in BYPASS */
671 .word 0xfffffff7 /* Put the PLL in Reset Mode */
673 .word 0xfffffffd /* PLL Power up Mask Bit */
674 PLL_DISABLE_ENABLE_MASK:
675 .word 0xffffffef /* Enable the PLL from Disable */
679 /* PLL1-SYSTEM PLL MMRs */
685 /* PLL2-SYSTEM PLL MMRs */
702 .word 0x01c42010 /* BRF margin mode 0 (R/W)*/