blob: 0913284e793ab8a00c03900fa962a54941303d40 [file] [log] [blame]
wdenk70ae5b42004-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
wdenkcbb52882004-10-10 18:03:33 +00005 * Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
wdenk70ae5b42004-10-10 17:05:18 +00006 *
7 * Modified for the at91rm9200dk board by
8 * (C) Copyright 2004
wdenk20dd2fa2004-11-21 00:06:33 +00009 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
wdenk70ae5b42004-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
wdenkcbb52882004-10-10 18:03:33 +000021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wdenk70ae5b42004-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
wdenk3d3d99f2005-04-04 12:44:11 +000033#ifndef CONFIG_SKIP_LOWLEVEL_INIT
wdenk70ae5b42004-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
wdenk20dd2fa2004-11-21 00:06:33 +000038 * turn is based on the boot.bin code from ATMEL
wdenk70ae5b42004-10-10 17:05:18 +000039 *
40 */
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +010041#include <asm/arch/AT91RM9200.h>
wdenk70ae5b42004-10-10 17:05:18 +000042
wdenk20dd2fa2004-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
wdenk70ae5b42004-10-10 17:05:18 +000048 .word TEXT_BASE
wdenk20dd2fa2004-11-21 00:06:33 +000049#endif
wdenk70ae5b42004-10-10 17:05:18 +000050
wdenkdf33b662005-04-04 12:36:04 +000051.globl lowlevel_init
52lowlevel_init:
wdenk0af9d012005-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-VILLARD03836942008-10-16 15:01:15 +020056#ifdef CONFIG_SYS_USE_MAIN_OSCILLATOR
wdenk0af9d012005-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-VILLARD8c45a9e2009-01-06 21:41:59 +010061 str r0, [r1, #AT91C_CKGR_MOR]
wdenk0af9d012005-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
wdenk70ae5b42004-10-10 17:05:18 +000068 /* memory control configuration */
wdenkcbb52882004-10-10 18:03:33 +000069 /* this isn't very elegant, but what the heck */
70 ldr r0, =SMRDATA
wdenk20dd2fa2004-11-21 00:06:33 +000071 ldr r1, _MTEXT_BASE
wdenk70ae5b42004-10-10 17:05:18 +000072 sub r0, r0, r1
wdenkcbb52882004-10-10 18:03:33 +000073 add r2, r0, #80
wdenk70ae5b42004-10-10 17:05:18 +0000740:
75 /* the address */
wdenkcbb52882004-10-10 18:03:33 +000076 ldr r1, [r0], #4
wdenk70ae5b42004-10-10 17:05:18 +000077 /* the value */
wdenkcbb52882004-10-10 18:03:33 +000078 ldr r3, [r0], #4
79 str r3, [r1]
80 cmp r2, r0
81 bne 0b
wdenk70ae5b42004-10-10 17:05:18 +000082 /* delay - this is all done by guess */
wdenk20dd2fa2004-11-21 00:06:33 +000083 ldr r0, =0x00010000
wdenk70ae5b42004-10-10 17:05:18 +0000841:
wdenkcbb52882004-10-10 18:03:33 +000085 subs r0, r0, #1
86 bhi 1b
87 ldr r0, =SMRDATA1
wdenk20dd2fa2004-11-21 00:06:33 +000088 ldr r1, _MTEXT_BASE
wdenk70ae5b42004-10-10 17:05:18 +000089 sub r0, r0, r1
wdenkcbb52882004-10-10 18:03:33 +000090 add r2, r0, #176
wdenk70ae5b42004-10-10 17:05:18 +0000912:
92 /* the address */
wdenkcbb52882004-10-10 18:03:33 +000093 ldr r1, [r0], #4
wdenk70ae5b42004-10-10 17:05:18 +000094 /* the value */
wdenkcbb52882004-10-10 18:03:33 +000095 ldr r3, [r0], #4
96 str r3, [r1]
97 cmp r2, r0
98 bne 2b
wdenk70ae5b42004-10-10 17:05:18 +000099
Wolfgang Denk1d281202005-10-05 02:06:08 +0200100 /* switch from FastBus to Asynchronous clock mode */
Wolfgang Denk7aea95a2005-10-05 02:02:25 +0200101 mrc p15, 0, r0, c1, c0, 0
Wolfgang Denk1d281202005-10-05 02:06:08 +0200102 orr r0, r0, #0xC0000000 @ set bit 31 (iA) and 30 (nF)
Wolfgang Denk7aea95a2005-10-05 02:02:25 +0200103 mcr p15, 0, r0, c1, c0, 0
104
wdenk70ae5b42004-10-10 17:05:18 +0000105 /* everything is fine now */
106 mov pc, lr
107
108 .ltorg
109
110SMRDATA:
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100111 .word AT91C_MC_PUIA
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100112 .word CONFIG_SYS_MC_PUIA_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100113 .word AT91C_MC_PUP
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100114 .word CONFIG_SYS_MC_PUP_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100115 .word AT91C_MC_PUER
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100116 .word CONFIG_SYS_MC_PUER_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100117 .word AT91C_MC_ASR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100118 .word CONFIG_SYS_MC_ASR_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100119 .word AT91C_MC_AASR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100120 .word CONFIG_SYS_MC_AASR_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100121 .word AT91C_EBI_CFGR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100122 .word CONFIG_SYS_EBI_CFGR_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100123 .word AT91C_SMC_CSR0
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100124 .word CONFIG_SYS_SMC_CSR0_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100125 .word AT91C_PLLAR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100126 .word CONFIG_SYS_PLLAR_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100127 .word AT91C_PLLBR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100128 .word CONFIG_SYS_PLLBR_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100129 .word AT91C_MCKR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100130 .word CONFIG_SYS_MCKR_VAL
wdenk70ae5b42004-10-10 17:05:18 +0000131 /* SMRDATA is 80 bytes long */
132 /* here there's a delay of 100 */
133SMRDATA1:
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100134 .word AT91C_PIOC_ASR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100135 .word CONFIG_SYS_PIOC_ASR_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100136 .word AT91C_PIOC_BSR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100137 .word CONFIG_SYS_PIOC_BSR_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100138 .word AT91C_PIOC_PDR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100139 .word CONFIG_SYS_PIOC_PDR_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100140 .word AT91C_EBI_CSA
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100141 .word CONFIG_SYS_EBI_CSA_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100142 .word AT91C_SDRC_CR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100143 .word CONFIG_SYS_SDRC_CR_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100144 .word AT91C_SDRC_MR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100145 .word CONFIG_SYS_SDRC_MR_VAL
146 .word CONFIG_SYS_SDRAM
147 .word CONFIG_SYS_SDRAM_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100148 .word AT91C_SDRC_MR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100149 .word CONFIG_SYS_SDRC_MR_VAL1
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
156 .word CONFIG_SYS_SDRAM
157 .word CONFIG_SYS_SDRAM_VAL
158 .word CONFIG_SYS_SDRAM
159 .word CONFIG_SYS_SDRAM_VAL
160 .word CONFIG_SYS_SDRAM
161 .word CONFIG_SYS_SDRAM_VAL
162 .word CONFIG_SYS_SDRAM
163 .word CONFIG_SYS_SDRAM_VAL
164 .word CONFIG_SYS_SDRAM
165 .word CONFIG_SYS_SDRAM_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100166 .word AT91C_SDRC_MR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100167 .word CONFIG_SYS_SDRC_MR_VAL2
168 .word CONFIG_SYS_SDRAM1
169 .word CONFIG_SYS_SDRAM_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100170 .word AT91C_SDRC_TR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100171 .word CONFIG_SYS_SDRC_TR_VAL
172 .word CONFIG_SYS_SDRAM
173 .word CONFIG_SYS_SDRAM_VAL
Jean-Christophe PLAGNIOL-VILLARD8c45a9e2009-01-06 21:41:59 +0100174 .word AT91C_SDRC_MR
Jean-Christophe PLAGNIOL-VILLARDa16842e2009-01-03 17:22:25 +0100175 .word CONFIG_SYS_SDRC_MR_VAL3
176 .word CONFIG_SYS_SDRAM
177 .word CONFIG_SYS_SDRAM_VAL
wdenk70ae5b42004-10-10 17:05:18 +0000178 /* SMRDATA1 is 176 bytes long */
wdenk3d3d99f2005-04-04 12:44:11 +0000179#endif /* CONFIG_SKIP_LOWLEVEL_INIT */