blob: d8bb96004b9797caf5d43e74bfe84668fe1e74a5 [file] [log] [blame]
wdenk2cbe5712004-10-10 17:05:18 +00001/*
2 * Memory Setup stuff - taken from blob memsetup.S
3 *
4 * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) and
wdenkb6508512004-10-10 18:03:33 +00005 * Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
wdenk2cbe5712004-10-10 17:05:18 +00006 *
7 * Modified for the at91rm9200dk board by
8 * (C) Copyright 2004
wdenk9d5028c2004-11-21 00:06:33 +00009 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
wdenk2cbe5712004-10-10 17:05:18 +000010 *
11 * See file CREDITS for list of people who contributed to this
12 * project.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wdenkb6508512004-10-10 18:03:33 +000021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wdenk2cbe5712004-10-10 17:05:18 +000022 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * MA 02111-1307 USA
28 */
29
30#include <config.h>
31#include <version.h>
32
wdenk8aa1a2d2005-04-04 12:44:11 +000033#ifndef CONFIG_SKIP_LOWLEVEL_INIT
wdenk2cbe5712004-10-10 17:05:18 +000034/*
35 * some parameters for the board
36 *
37 * This is based on rm9200dk.cfg for the BDI2000 from ABATRON which in
wdenk9d5028c2004-11-21 00:06:33 +000038 * turn is based on the boot.bin code from ATMEL
wdenk2cbe5712004-10-10 17:05:18 +000039 *
40 */
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +010041#include <asm/arch/AT91RM9200.h>
wdenk2cbe5712004-10-10 17:05:18 +000042
wdenk9d5028c2004-11-21 00:06:33 +000043_MTEXT_BASE:
44#undef START_FROM_MEM
45#ifdef START_FROM_MEM
46 .word TEXT_BASE-PHYS_FLASH_1
47#else
wdenk2cbe5712004-10-10 17:05:18 +000048 .word TEXT_BASE
wdenk9d5028c2004-11-21 00:06:33 +000049#endif
wdenk2cbe5712004-10-10 17:05:18 +000050
wdenk986ef432005-04-04 12:36:04 +000051.globl lowlevel_init
52lowlevel_init:
wdenkef2807c2005-03-31 23:44:33 +000053 /* Get the CKGR Base Address */
54 ldr r1, =AT91C_BASE_CKGR
55 /* Main oscillator Enable register */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020056#ifdef CONFIG_SYS_USE_MAIN_OSCILLATOR
wdenkef2807c2005-03-31 23:44:33 +000057 ldr r0, =0x0000FF01 /* Enable main oscillator, OSCOUNT = 0xFF */
58#else
59 ldr r0, =0x0000FF00 /* Disable main oscillator, OSCOUNT = 0xFF */
60#endif
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +010061 str r0, [r1, #AT91C_CKGR_MOR]
wdenkef2807c2005-03-31 23:44:33 +000062 /* Add loop to compensate Main Oscillator startup time */
63 ldr r0, =0x00000010
64LoopOsc:
65 subs r0, r0, #1
66 bhi LoopOsc
67
wdenk2cbe5712004-10-10 17:05:18 +000068 /* memory control configuration */
wdenkb6508512004-10-10 18:03:33 +000069 /* this isn't very elegant, but what the heck */
70 ldr r0, =SMRDATA
wdenk9d5028c2004-11-21 00:06:33 +000071 ldr r1, _MTEXT_BASE
wdenk2cbe5712004-10-10 17:05:18 +000072 sub r0, r0, r1
wdenkb6508512004-10-10 18:03:33 +000073 add r2, r0, #80
wdenk2cbe5712004-10-10 17:05:18 +0000740:
75 /* the address */
wdenkb6508512004-10-10 18:03:33 +000076 ldr r1, [r0], #4
wdenk2cbe5712004-10-10 17:05:18 +000077 /* the value */
wdenkb6508512004-10-10 18:03:33 +000078 ldr r3, [r0], #4
79 str r3, [r1]
80 cmp r2, r0
81 bne 0b
wdenk2cbe5712004-10-10 17:05:18 +000082 /* delay - this is all done by guess */
wdenk9d5028c2004-11-21 00:06:33 +000083 ldr r0, =0x00010000
David Brownell06bffc62009-07-16 18:40:55 -070084 /* (vs reading PMC_SR for LOCKA, LOCKB ... or MOSCS earlier) */
wdenk2cbe5712004-10-10 17:05:18 +0000851:
wdenkb6508512004-10-10 18:03:33 +000086 subs r0, r0, #1
87 bhi 1b
88 ldr r0, =SMRDATA1
wdenk9d5028c2004-11-21 00:06:33 +000089 ldr r1, _MTEXT_BASE
wdenk2cbe5712004-10-10 17:05:18 +000090 sub r0, r0, r1
wdenkb6508512004-10-10 18:03:33 +000091 add r2, r0, #176
wdenk2cbe5712004-10-10 17:05:18 +0000922:
93 /* the address */
wdenkb6508512004-10-10 18:03:33 +000094 ldr r1, [r0], #4
wdenk2cbe5712004-10-10 17:05:18 +000095 /* the value */
wdenkb6508512004-10-10 18:03:33 +000096 ldr r3, [r0], #4
97 str r3, [r1]
98 cmp r2, r0
99 bne 2b
wdenk2cbe5712004-10-10 17:05:18 +0000100
Wolfgang Denkc0e82d52005-10-05 02:06:08 +0200101 /* switch from FastBus to Asynchronous clock mode */
Wolfgang Denk3b9dfdd2005-10-05 02:02:25 +0200102 mrc p15, 0, r0, c1, c0, 0
Wolfgang Denkc0e82d52005-10-05 02:06:08 +0200103 orr r0, r0, #0xC0000000 @ set bit 31 (iA) and 30 (nF)
Wolfgang Denk3b9dfdd2005-10-05 02:02:25 +0200104 mcr p15, 0, r0, c1, c0, 0
105
wdenk2cbe5712004-10-10 17:05:18 +0000106 /* everything is fine now */
107 mov pc, lr
108
109 .ltorg
110
111SMRDATA:
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100112 .word AT91C_EBI_CFGR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100113 .word CONFIG_SYS_EBI_CFGR_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100114 .word AT91C_SMC_CSR0
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100115 .word CONFIG_SYS_SMC_CSR0_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100116 .word AT91C_PLLAR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100117 .word CONFIG_SYS_PLLAR_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100118 .word AT91C_PLLBR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100119 .word CONFIG_SYS_PLLBR_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100120 .word AT91C_MCKR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100121 .word CONFIG_SYS_MCKR_VAL
David Brownell06bffc62009-07-16 18:40:55 -0700122 /* here there's a delay */
wdenk2cbe5712004-10-10 17:05:18 +0000123SMRDATA1:
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100124 .word AT91C_PIOC_ASR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100125 .word CONFIG_SYS_PIOC_ASR_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100126 .word AT91C_PIOC_BSR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100127 .word CONFIG_SYS_PIOC_BSR_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100128 .word AT91C_PIOC_PDR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100129 .word CONFIG_SYS_PIOC_PDR_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100130 .word AT91C_EBI_CSA
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100131 .word CONFIG_SYS_EBI_CSA_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100132 .word AT91C_SDRC_CR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100133 .word CONFIG_SYS_SDRC_CR_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100134 .word AT91C_SDRC_MR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100135 .word CONFIG_SYS_SDRC_MR_VAL
136 .word CONFIG_SYS_SDRAM
137 .word CONFIG_SYS_SDRAM_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100138 .word AT91C_SDRC_MR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100139 .word CONFIG_SYS_SDRC_MR_VAL1
140 .word CONFIG_SYS_SDRAM
141 .word CONFIG_SYS_SDRAM_VAL
142 .word CONFIG_SYS_SDRAM
143 .word CONFIG_SYS_SDRAM_VAL
144 .word CONFIG_SYS_SDRAM
145 .word CONFIG_SYS_SDRAM_VAL
146 .word CONFIG_SYS_SDRAM
147 .word CONFIG_SYS_SDRAM_VAL
148 .word CONFIG_SYS_SDRAM
149 .word CONFIG_SYS_SDRAM_VAL
150 .word CONFIG_SYS_SDRAM
151 .word CONFIG_SYS_SDRAM_VAL
152 .word CONFIG_SYS_SDRAM
153 .word CONFIG_SYS_SDRAM_VAL
154 .word CONFIG_SYS_SDRAM
155 .word CONFIG_SYS_SDRAM_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100156 .word AT91C_SDRC_MR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100157 .word CONFIG_SYS_SDRC_MR_VAL2
158 .word CONFIG_SYS_SDRAM1
159 .word CONFIG_SYS_SDRAM_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100160 .word AT91C_SDRC_TR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100161 .word CONFIG_SYS_SDRC_TR_VAL
162 .word CONFIG_SYS_SDRAM
163 .word CONFIG_SYS_SDRAM_VAL
Jean-Christophe PLAGNIOL-VILLARD3dd93952009-01-06 21:41:59 +0100164 .word AT91C_SDRC_MR
Jean-Christophe PLAGNIOL-VILLARDd481c802009-01-03 17:22:25 +0100165 .word CONFIG_SYS_SDRC_MR_VAL3
166 .word CONFIG_SYS_SDRAM
167 .word CONFIG_SYS_SDRAM_VAL
wdenk2cbe5712004-10-10 17:05:18 +0000168 /* SMRDATA1 is 176 bytes long */
wdenk8aa1a2d2005-04-04 12:44:11 +0000169#endif /* CONFIG_SKIP_LOWLEVEL_INIT */