wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 1 | /* |
| 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 |
wdenk | b650851 | 2004-10-10 18:03:33 +0000 | [diff] [blame] | 5 | * Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl) |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 6 | * |
| 7 | * Modified for the at91rm9200dk board by |
| 8 | * (C) Copyright 2004 |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 9 | * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 10 | * |
| 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 |
wdenk | b650851 | 2004-10-10 18:03:33 +0000 | [diff] [blame] | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 22 | * 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 | |
wdenk | 8aa1a2d | 2005-04-04 12:44:11 +0000 | [diff] [blame] | 33 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 34 | /* |
| 35 | * some parameters for the board |
| 36 | * |
| 37 | * This is based on rm9200dk.cfg for the BDI2000 from ABATRON which in |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 38 | * turn is based on the boot.bin code from ATMEL |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 39 | * |
| 40 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 41 | #include <asm/arch/AT91RM9200.h> |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 42 | |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 43 | _MTEXT_BASE: |
| 44 | #undef START_FROM_MEM |
| 45 | #ifdef START_FROM_MEM |
| 46 | .word TEXT_BASE-PHYS_FLASH_1 |
| 47 | #else |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 48 | .word TEXT_BASE |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 49 | #endif |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 50 | |
wdenk | 986ef43 | 2005-04-04 12:36:04 +0000 | [diff] [blame] | 51 | .globl lowlevel_init |
| 52 | lowlevel_init: |
wdenk | ef2807c | 2005-03-31 23:44:33 +0000 | [diff] [blame] | 53 | /* Get the CKGR Base Address */ |
| 54 | ldr r1, =AT91C_BASE_CKGR |
| 55 | /* Main oscillator Enable register */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 56 | #ifdef CONFIG_SYS_USE_MAIN_OSCILLATOR |
wdenk | ef2807c | 2005-03-31 23:44:33 +0000 | [diff] [blame] | 57 | ldr r0, =0x0000FF01 /* Enable main oscillator, OSCOUNT = 0xFF */ |
| 58 | #else |
| 59 | ldr r0, =0x0000FF00 /* Disable main oscillator, OSCOUNT = 0xFF */ |
| 60 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 61 | str r0, [r1, #AT91C_CKGR_MOR] |
wdenk | ef2807c | 2005-03-31 23:44:33 +0000 | [diff] [blame] | 62 | /* Add loop to compensate Main Oscillator startup time */ |
| 63 | ldr r0, =0x00000010 |
| 64 | LoopOsc: |
| 65 | subs r0, r0, #1 |
| 66 | bhi LoopOsc |
| 67 | |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 68 | /* memory control configuration */ |
wdenk | b650851 | 2004-10-10 18:03:33 +0000 | [diff] [blame] | 69 | /* this isn't very elegant, but what the heck */ |
| 70 | ldr r0, =SMRDATA |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 71 | ldr r1, _MTEXT_BASE |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 72 | sub r0, r0, r1 |
wdenk | b650851 | 2004-10-10 18:03:33 +0000 | [diff] [blame] | 73 | add r2, r0, #80 |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 74 | 0: |
| 75 | /* the address */ |
wdenk | b650851 | 2004-10-10 18:03:33 +0000 | [diff] [blame] | 76 | ldr r1, [r0], #4 |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 77 | /* the value */ |
wdenk | b650851 | 2004-10-10 18:03:33 +0000 | [diff] [blame] | 78 | ldr r3, [r0], #4 |
| 79 | str r3, [r1] |
| 80 | cmp r2, r0 |
| 81 | bne 0b |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 82 | /* delay - this is all done by guess */ |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 83 | ldr r0, =0x00010000 |
David Brownell | 06bffc6 | 2009-07-16 18:40:55 -0700 | [diff] [blame] | 84 | /* (vs reading PMC_SR for LOCKA, LOCKB ... or MOSCS earlier) */ |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 85 | 1: |
wdenk | b650851 | 2004-10-10 18:03:33 +0000 | [diff] [blame] | 86 | subs r0, r0, #1 |
| 87 | bhi 1b |
| 88 | ldr r0, =SMRDATA1 |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 89 | ldr r1, _MTEXT_BASE |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 90 | sub r0, r0, r1 |
wdenk | b650851 | 2004-10-10 18:03:33 +0000 | [diff] [blame] | 91 | add r2, r0, #176 |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 92 | 2: |
| 93 | /* the address */ |
wdenk | b650851 | 2004-10-10 18:03:33 +0000 | [diff] [blame] | 94 | ldr r1, [r0], #4 |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 95 | /* the value */ |
wdenk | b650851 | 2004-10-10 18:03:33 +0000 | [diff] [blame] | 96 | ldr r3, [r0], #4 |
| 97 | str r3, [r1] |
| 98 | cmp r2, r0 |
| 99 | bne 2b |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 100 | |
Wolfgang Denk | c0e82d5 | 2005-10-05 02:06:08 +0200 | [diff] [blame] | 101 | /* switch from FastBus to Asynchronous clock mode */ |
Wolfgang Denk | 3b9dfdd | 2005-10-05 02:02:25 +0200 | [diff] [blame] | 102 | mrc p15, 0, r0, c1, c0, 0 |
Wolfgang Denk | c0e82d5 | 2005-10-05 02:06:08 +0200 | [diff] [blame] | 103 | orr r0, r0, #0xC0000000 @ set bit 31 (iA) and 30 (nF) |
Wolfgang Denk | 3b9dfdd | 2005-10-05 02:02:25 +0200 | [diff] [blame] | 104 | mcr p15, 0, r0, c1, c0, 0 |
| 105 | |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 106 | /* everything is fine now */ |
| 107 | mov pc, lr |
| 108 | |
| 109 | .ltorg |
| 110 | |
| 111 | SMRDATA: |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 112 | .word AT91C_EBI_CFGR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 113 | .word CONFIG_SYS_EBI_CFGR_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 114 | .word AT91C_SMC_CSR0 |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 115 | .word CONFIG_SYS_SMC_CSR0_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 116 | .word AT91C_PLLAR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 117 | .word CONFIG_SYS_PLLAR_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 118 | .word AT91C_PLLBR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 119 | .word CONFIG_SYS_PLLBR_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 120 | .word AT91C_MCKR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 121 | .word CONFIG_SYS_MCKR_VAL |
David Brownell | 06bffc6 | 2009-07-16 18:40:55 -0700 | [diff] [blame] | 122 | /* here there's a delay */ |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 123 | SMRDATA1: |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 124 | .word AT91C_PIOC_ASR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 125 | .word CONFIG_SYS_PIOC_ASR_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 126 | .word AT91C_PIOC_BSR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 127 | .word CONFIG_SYS_PIOC_BSR_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 128 | .word AT91C_PIOC_PDR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 129 | .word CONFIG_SYS_PIOC_PDR_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 130 | .word AT91C_EBI_CSA |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 131 | .word CONFIG_SYS_EBI_CSA_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 132 | .word AT91C_SDRC_CR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 133 | .word CONFIG_SYS_SDRC_CR_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 134 | .word AT91C_SDRC_MR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 135 | .word CONFIG_SYS_SDRC_MR_VAL |
| 136 | .word CONFIG_SYS_SDRAM |
| 137 | .word CONFIG_SYS_SDRAM_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 138 | .word AT91C_SDRC_MR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 139 | .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-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 156 | .word AT91C_SDRC_MR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 157 | .word CONFIG_SYS_SDRC_MR_VAL2 |
| 158 | .word CONFIG_SYS_SDRAM1 |
| 159 | .word CONFIG_SYS_SDRAM_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 160 | .word AT91C_SDRC_TR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 161 | .word CONFIG_SYS_SDRC_TR_VAL |
| 162 | .word CONFIG_SYS_SDRAM |
| 163 | .word CONFIG_SYS_SDRAM_VAL |
Jean-Christophe PLAGNIOL-VILLARD | 3dd9395 | 2009-01-06 21:41:59 +0100 | [diff] [blame] | 164 | .word AT91C_SDRC_MR |
Jean-Christophe PLAGNIOL-VILLARD | d481c80 | 2009-01-03 17:22:25 +0100 | [diff] [blame] | 165 | .word CONFIG_SYS_SDRC_MR_VAL3 |
| 166 | .word CONFIG_SYS_SDRAM |
| 167 | .word CONFIG_SYS_SDRAM_VAL |
wdenk | 2cbe571 | 2004-10-10 17:05:18 +0000 | [diff] [blame] | 168 | /* SMRDATA1 is 176 bytes long */ |
wdenk | 8aa1a2d | 2005-04-04 12:44:11 +0000 | [diff] [blame] | 169 | #endif /* CONFIG_SKIP_LOWLEVEL_INIT */ |