wdenk | 1cb8e98 | 2003-03-06 21:55:29 +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 |
| 5 | * Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl) |
| 6 | * |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 7 | * Modified for MPL VCMA9 by |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 8 | * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch> |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 9 | * (C) Copyright 2002, 2003, 2004, 2005 |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +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 |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 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 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 31 | #include <config.h> |
| 32 | #include <version.h> |
| 33 | |
| 34 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 35 | /* register definitions */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 36 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 37 | #define PLD_BASE 0x28000000 |
| 38 | #define MISC_REG 0x103 |
| 39 | #define SDRAM_REG 0x106 |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 40 | #define BWSCON 0x48000000 |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 41 | #define CLKBASE 0x4C000000 |
| 42 | #define LOCKTIME 0x0 |
| 43 | #define MPLLCON 0x4 |
| 44 | #define UPLLCON 0x8 |
| 45 | #define GPIOBASE 0x56000000 |
| 46 | #define GSTATUS1 0xB0 |
| 47 | #define FASTCPU 0x02 |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 48 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 49 | /* some parameters for the board */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 50 | /* BWSCON */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 51 | #define DW8 (0x0) |
| 52 | #define DW16 (0x1) |
| 53 | #define DW32 (0x2) |
| 54 | #define WAIT (0x1<<2) |
| 55 | #define UBLB (0x1<<3) |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 56 | |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 57 | /* BANKSIZE */ |
| 58 | #define BURST_EN (0x1<<7) |
| 59 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 60 | /* BANK0CON 200 */ |
| 61 | #define B0_Tacs_200 0x0 /* 0clk (or 0x1 1clk) */ |
| 62 | #define B0_Tcos_200 0x1 /* 1clk (or 0x2 2clk) */ |
| 63 | #define B0_Tacc_200 0x5 /* 8clk (or 0x6 10clk) */ |
| 64 | #define B0_Tcoh_200 0x0 /* 0clk */ |
| 65 | #define B0_Tcah_200 0x3 /* 4clk (or0x01 1clk) */ |
| 66 | #define B0_Tacp_200 0x0 /* page mode is not used */ |
| 67 | #define B0_PMC_200 0x0 /* page mode disabled */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 68 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 69 | /* BANK0CON 250 */ |
| 70 | #define B0_Tacs_250 0x0 /* 0clk (or 0x1 1clk) */ |
| 71 | #define B0_Tcos_250 0x1 /* 1clk (or 0x2 2clk) */ |
| 72 | #define B0_Tacc_250 0x5 /* 8clk (or 0x7 14clk) */ |
| 73 | #define B0_Tcoh_250 0x0 /* 0clk */ |
| 74 | #define B0_Tcah_250 0x3 /* 4clk (or 0x1 1clk) */ |
| 75 | #define B0_Tacp_250 0x0 /* page mode is not used */ |
| 76 | #define B0_PMC_250 0x0 /* page mode disabled */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 77 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 78 | /* BANK0CON 266 */ |
| 79 | #define B0_Tacs_266 0x0 /* 0clk (or 0x1 1clk) */ |
| 80 | #define B0_Tcos_266 0x1 /* 1clk (or 0x2 2clk) */ |
| 81 | #define B0_Tacc_266 0x6 /* 10clk (or 0x7 14clk) */ |
| 82 | #define B0_Tcoh_266 0x0 /* 0clk */ |
| 83 | #define B0_Tcah_266 0x3 /* 4clk (or 0x1 1clk) */ |
| 84 | #define B0_Tacp_266 0x0 /* page mode is not used */ |
| 85 | #define B0_PMC_266 0x0 /* page mode disabled */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 86 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 87 | /* BANK1CON 200 */ |
| 88 | #define B1_Tacs_200 0x0 /* 0clk (or 0x1 1clk) */ |
| 89 | #define B1_Tcos_200 0x1 /* 1clk (or 0x2 2clk) */ |
| 90 | #define B1_Tacc_200 0x5 /* 8clk (or 0x6 10clk) */ |
| 91 | #define B1_Tcoh_200 0x0 /* 0clk */ |
| 92 | #define B1_Tcah_200 0x3 /* 4clk (or 0x1 1clk) */ |
| 93 | #define B1_Tacp_200 0x0 /* page mode is not used */ |
| 94 | #define B1_PMC_200 0x0 /* page mode disabled */ |
| 95 | |
| 96 | /* BANK1CON 250 */ |
| 97 | #define B1_Tacs_250 0x0 /* 0clk (or 0x1 1clk) */ |
| 98 | #define B1_Tcos_250 0x1 /* 1clk (or 0x2 2clk) */ |
| 99 | #define B1_Tacc_250 0x5 /* 8clk (or 0x7 14clk) */ |
| 100 | #define B1_Tcoh_250 0x0 /* 0clk */ |
| 101 | #define B1_Tcah_250 0x3 /* 4clk (or 0x1 1clk) */ |
| 102 | #define B1_Tacp_250 0x0 /* page mode is not used */ |
| 103 | #define B1_PMC_250 0x0 /* page mode disabled */ |
| 104 | |
| 105 | /* BANK1CON 266 */ |
| 106 | #define B1_Tacs_266 0x0 /* 0clk (or 0x1 1clk) */ |
| 107 | #define B1_Tcos_266 0x1 /* 1clk (or 0x2 2clk) */ |
| 108 | #define B1_Tacc_266 0x6 /* 10clk (or 0x7 14clk) */ |
| 109 | #define B1_Tcoh_266 0x0 /* 0clk */ |
| 110 | #define B1_Tcah_266 0x3 /* 4clk (or 0x1 1clk) */ |
| 111 | #define B1_Tacp_266 0x0 /* page mode is not used */ |
| 112 | #define B1_PMC_266 0x0 /* page mode disabled */ |
| 113 | |
| 114 | /* BANK2CON 200 + 250 + 266 */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 115 | #define B2_Tacs 0x3 /* 4clk */ |
| 116 | #define B2_Tcos 0x3 /* 4clk */ |
| 117 | #define B2_Tacc 0x7 /* 14clk */ |
| 118 | #define B2_Tcoh 0x3 /* 4clk */ |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 119 | #define B2_Tcah 0x3 /* 4clk */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 120 | #define B2_Tacp 0x0 /* page mode is not used */ |
| 121 | #define B2_PMC 0x0 /* page mode disabled */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 122 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 123 | /* BANK3CON 200 + 250 + 266 */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 124 | #define B3_Tacs 0x3 /* 4clk */ |
| 125 | #define B3_Tcos 0x3 /* 4clk */ |
| 126 | #define B3_Tacc 0x7 /* 14clk */ |
| 127 | #define B3_Tcoh 0x3 /* 4clk */ |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 128 | #define B3_Tcah 0x3 /* 4clk */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 129 | #define B3_Tacp 0x0 /* page mode is not used */ |
| 130 | #define B3_PMC 0x0 /* page mode disabled */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 131 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 132 | /* BANK4CON 200 */ |
| 133 | #define B4_Tacs_200 0x1 /* 1clk */ |
| 134 | #define B4_Tcos_200 0x3 /* 4clk */ |
| 135 | #define B4_Tacc_200 0x7 /* 14clk */ |
| 136 | #define B4_Tcoh_200 0x3 /* 4clk */ |
| 137 | #define B4_Tcah_200 0x2 /* 2clk */ |
| 138 | #define B4_Tacp_200 0x0 /* page mode is not used */ |
| 139 | #define B4_PMC_200 0x0 /* page mode disabled */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 140 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 141 | /* BANK4CON 250 */ |
| 142 | #define B4_Tacs_250 0x1 /* 1clk */ |
| 143 | #define B4_Tcos_250 0x3 /* 4clk */ |
| 144 | #define B4_Tacc_250 0x7 /* 14clk */ |
| 145 | #define B4_Tcoh_250 0x3 /* 4clk */ |
| 146 | #define B4_Tcah_250 0x2 /* 2clk */ |
| 147 | #define B4_Tacp_250 0x0 /* page mode is not used */ |
| 148 | #define B4_PMC_250 0x0 /* page mode disabled */ |
| 149 | |
| 150 | /* BANK4CON 266 */ |
| 151 | #define B4_Tacs_266 0x1 /* 1clk */ |
| 152 | #define B4_Tcos_266 0x3 /* 4clk */ |
| 153 | #define B4_Tacc_266 0x7 /* 14clk */ |
| 154 | #define B4_Tcoh_266 0x3 /* 4clk */ |
| 155 | #define B4_Tcah_266 0x2 /* 2clk */ |
| 156 | #define B4_Tacp_266 0x0 /* page mode is not used */ |
| 157 | #define B4_PMC_266 0x0 /* page mode disabled */ |
| 158 | |
| 159 | /* BANK5CON 200 */ |
| 160 | #define B5_Tacs_200 0x0 /* 0clk */ |
| 161 | #define B5_Tcos_200 0x3 /* 4clk */ |
| 162 | #define B5_Tacc_200 0x4 /* 6clk */ |
| 163 | #define B5_Tcoh_200 0x3 /* 4clk */ |
| 164 | #define B5_Tcah_200 0x1 /* 1clk */ |
| 165 | #define B5_Tacp_200 0x0 /* page mode is not used */ |
| 166 | #define B5_PMC_200 0x0 /* page mode disabled */ |
| 167 | |
| 168 | /* BANK5CON 250 */ |
| 169 | #define B5_Tacs_250 0x0 /* 0clk */ |
| 170 | #define B5_Tcos_250 0x3 /* 4clk */ |
| 171 | #define B5_Tacc_250 0x5 /* 8clk */ |
| 172 | #define B5_Tcoh_250 0x3 /* 4clk */ |
| 173 | #define B5_Tcah_250 0x1 /* 1clk */ |
| 174 | #define B5_Tacp_250 0x0 /* page mode is not used */ |
| 175 | #define B5_PMC_250 0x0 /* page mode disabled */ |
| 176 | |
| 177 | /* BANK5CON 266 */ |
| 178 | #define B5_Tacs_266 0x0 /* 0clk */ |
| 179 | #define B5_Tcos_266 0x3 /* 4clk */ |
| 180 | #define B5_Tacc_266 0x5 /* 8clk */ |
| 181 | #define B5_Tcoh_266 0x3 /* 4clk */ |
| 182 | #define B5_Tcah_266 0x1 /* 1clk */ |
| 183 | #define B5_Tacp_266 0x0 /* page mode is not used */ |
| 184 | #define B5_PMC_266 0x0 /* page mode disabled */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 185 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 186 | #define B6_MT 0x3 /* SDRAM */ |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 187 | #define B6_Trcd_200 0x0 /* 2clk */ |
| 188 | #define B6_Trcd_250 0x1 /* 3clk */ |
| 189 | #define B6_Trcd_266 0x1 /* 3clk */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 190 | #define B6_SCAN 0x2 /* 10bit */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 191 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 192 | #define B7_MT 0x3 /* SDRAM */ |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 193 | #define B7_Trcd_200 0x0 /* 2clk */ |
| 194 | #define B7_Trcd_250 0x1 /* 3clk */ |
| 195 | #define B7_Trcd_266 0x1 /* 3clk */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 196 | #define B7_SCAN 0x2 /* 10bit */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 197 | |
| 198 | /* REFRESH parameter */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 199 | #define REFEN 0x1 /* Refresh enable */ |
| 200 | #define TREFMD 0x0 /* CBR(CAS before RAS)/Auto refresh */ |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 201 | #define Trp_200 0x0 /* 2clk */ |
| 202 | #define Trp_250 0x1 /* 3clk */ |
| 203 | #define Trp_266 0x1 /* 3clk */ |
| 204 | #define Tsrc_200 0x1 /* 5clk */ |
| 205 | #define Tsrc_250 0x2 /* 6clk */ |
| 206 | #define Tsrc_266 0x3 /* 7clk */ |
| 207 | |
| 208 | /* period=15.6us, HCLK=100Mhz, (2048+1-15.6*100) */ |
| 209 | #define REFCNT_200 489 |
| 210 | /* period=15.6us, HCLK=125Mhz, (2048+1-15.6*125) */ |
| 211 | #define REFCNT_250 99 |
| 212 | /* period=15.6us, HCLK=133Mhz, (2048+1-15.6*133) */ |
| 213 | #define REFCNT_266 0 |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 214 | /**************************************/ |
| 215 | |
| 216 | _TEXT_BASE: |
Wolfgang Denk | 14d0a02 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 217 | .word CONFIG_SYS_TEXT_BASE |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 218 | |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 219 | .globl lowlevel_init |
| 220 | lowlevel_init: |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 221 | /* use r0 to relocate DATA read/write to flash rather than memory ! */ |
| 222 | ldr r0, _TEXT_BASE |
| 223 | ldr r13, =BWSCON |
| 224 | |
| 225 | /* enable minimal access to PLD */ |
| 226 | ldr r1, [r13] /* load default BWSCON */ |
| 227 | orr r1, r1, #(DW8 + UBLB) << 20 /* set necessary CS attrs */ |
| 228 | str r1, [r13] /* set BWSCON */ |
| 229 | ldr r1, =0x7FF0 /* select slowest timing */ |
| 230 | str r1, [r13, #0x18] /* set BANKCON5 */ |
| 231 | |
| 232 | ldr r1, =PLD_BASE |
| 233 | ldr r2, =SETUPDATA |
| 234 | ldrb r1, [r1, #MISC_REG] |
| 235 | sub r2, r2, r0 |
| 236 | tst r1, #FASTCPU /* FASTCPU available ? */ |
| 237 | addeq r2, r2, #SETUPENTRY_SIZE |
| 238 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 239 | /* memory control configuration */ |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 240 | /* r2 = pointer into timing table */ |
| 241 | /* r13 = pointer to MEM controller regs (starting with BWSCON) */ |
| 242 | add r3, r2, #CSDATA_OFFSET |
| 243 | add r4, r3, #CSDATAENTRY_SIZE |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 244 | 0: |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 245 | ldr r1, [r3], #4 |
| 246 | str r1, [r13], #4 |
| 247 | cmp r3, r4 |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 248 | bne 0b |
| 249 | |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 250 | /* PLD access is now possible */ |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 251 | /* r3 = SDRAMDATA |
| 252 | /* r13 = pointer to MEM controller regs */ |
| 253 | ldr r1, =PLD_BASE |
| 254 | mov r4, #SDRAMENTRY_SIZE |
| 255 | ldrb r1, [r1, #SDRAM_REG] |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 256 | /* calculate start and end point */ |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 257 | mla r3, r4, r1, r3 |
| 258 | add r4, r3, r4 |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 259 | 0: |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 260 | ldr r1, [r3], #4 |
| 261 | str r1, [r13], #4 |
| 262 | cmp r3, r4 |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 263 | bne 0b |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 264 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 265 | /* setup MPLL registers */ |
| 266 | ldr r1, =CLKBASE |
| 267 | ldr r4, =0xFFFFFF |
| 268 | add r3, r2, #4 /* r3 points to PLL values */ |
| 269 | str r4, [r1, #LOCKTIME] |
| 270 | ldmia r3, {r4,r5} |
| 271 | str r5, [r1, #UPLLCON] /* writing PLL register */ |
| 272 | /* !! order seems to be important !! */ |
| 273 | /* a little delay */ |
| 274 | ldr r3, =0x4000 |
| 275 | 0: |
| 276 | subs r3, r3, #1 |
| 277 | bne 0b |
| 278 | |
| 279 | str r4, [r1, #MPLLCON] /* writing PLL register */ |
| 280 | /* !! order seems to be important !! */ |
| 281 | /* a little delay */ |
| 282 | ldr r3, =0x4000 |
| 283 | 0: |
| 284 | subs r3, r3, #1 |
| 285 | bne 0b |
| 286 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 287 | /* everything is fine now */ |
| 288 | mov pc, lr |
| 289 | |
| 290 | .ltorg |
| 291 | /* the literal pools origin */ |
| 292 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 293 | #define MK_BWSCON(bws1, bws2, bws3, bws4, bws5, bws6, bws7) \ |
| 294 | ((bws1) << 4) + \ |
| 295 | ((bws2) << 8) + \ |
| 296 | ((bws3) << 12) + \ |
| 297 | ((bws4) << 16) + \ |
| 298 | ((bws5) << 20) + \ |
| 299 | ((bws6) << 24) + \ |
| 300 | ((bws7) << 28) |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 301 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 302 | #define MK_BANKCON(tacs, tcos, tacc, tcoh, tcah, tacp, pmc) \ |
| 303 | ((tacs) << 13) + \ |
| 304 | ((tcos) << 11) + \ |
| 305 | ((tacc) << 8) + \ |
| 306 | ((tcoh) << 6) + \ |
| 307 | ((tcah) << 4) + \ |
| 308 | ((tacp) << 2) + \ |
| 309 | (pmc) |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 310 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 311 | #define MK_BANKCON_SDRAM(trcd, scan) \ |
| 312 | ((0x03) << 15) + \ |
| 313 | ((trcd) << 2) + \ |
| 314 | (scan) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 315 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 316 | #define MK_SDRAM_REFRESH(enable, trefmd, trp, tsrc, cnt) \ |
| 317 | ((enable) << 23) + \ |
| 318 | ((trefmd) << 22) + \ |
| 319 | ((trp) << 20) + \ |
| 320 | ((tsrc) << 18) + \ |
| 321 | (cnt) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 322 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 323 | SETUPDATA: |
| 324 | .word 0x32410002 |
| 325 | /* PLL values (MDIV, PDIV, SDIV) for 250 MHz */ |
| 326 | .word (0x75 << 12) + (0x01 << 4) + (0x01 << 0) |
| 327 | /* PLL values for USB clock */ |
| 328 | .word (0x48 << 12) + (0x03 << 4) + (0x02 << 0) |
| 329 | |
| 330 | /* timing for 250 MHz*/ |
| 331 | 0: |
| 332 | .equiv CSDATA_OFFSET, (. - SETUPDATA) |
| 333 | .word MK_BWSCON(DW16, \ |
| 334 | DW32, \ |
| 335 | DW32, \ |
| 336 | DW16 + WAIT + UBLB, \ |
| 337 | DW8 + UBLB, \ |
| 338 | DW32, \ |
| 339 | DW32) |
| 340 | |
| 341 | .word MK_BANKCON(B0_Tacs_250, \ |
| 342 | B0_Tcos_250, \ |
| 343 | B0_Tacc_250, \ |
| 344 | B0_Tcoh_250, \ |
| 345 | B0_Tcah_250, \ |
| 346 | B0_Tacp_250, \ |
| 347 | B0_PMC_250) |
| 348 | |
| 349 | .word MK_BANKCON(B1_Tacs_250, \ |
| 350 | B1_Tcos_250, \ |
| 351 | B1_Tacc_250, \ |
| 352 | B1_Tcoh_250, \ |
| 353 | B1_Tcah_250, \ |
| 354 | B1_Tacp_250, \ |
| 355 | B1_PMC_250) |
| 356 | |
| 357 | .word MK_BANKCON(B2_Tacs, \ |
| 358 | B2_Tcos, \ |
| 359 | B2_Tacc, \ |
| 360 | B2_Tcoh, \ |
| 361 | B2_Tcah, \ |
| 362 | B2_Tacp, \ |
| 363 | B2_PMC) |
| 364 | |
| 365 | .word MK_BANKCON(B3_Tacs, \ |
| 366 | B3_Tcos, \ |
| 367 | B3_Tacc, \ |
| 368 | B3_Tcoh, \ |
| 369 | B3_Tcah, \ |
| 370 | B3_Tacp, \ |
| 371 | B3_PMC) |
| 372 | |
| 373 | .word MK_BANKCON(B4_Tacs_250, \ |
| 374 | B4_Tcos_250, \ |
| 375 | B4_Tacc_250, \ |
| 376 | B4_Tcoh_250, \ |
| 377 | B4_Tcah_250, \ |
| 378 | B4_Tacp_250, \ |
| 379 | B4_PMC_250) |
| 380 | |
| 381 | .word MK_BANKCON(B5_Tacs_250, \ |
| 382 | B5_Tcos_250, \ |
| 383 | B5_Tacc_250, \ |
| 384 | B5_Tcoh_250, \ |
| 385 | B5_Tcah_250, \ |
| 386 | B5_Tacp_250, \ |
| 387 | B5_PMC_250) |
| 388 | |
| 389 | .equiv CSDATAENTRY_SIZE, (. - 0b) |
| 390 | /* 4Mx8x4 */ |
| 391 | 0: |
| 392 | .word MK_BANKCON_SDRAM(B6_Trcd_250, B6_SCAN) |
| 393 | .word MK_BANKCON_SDRAM(B7_Trcd_250, B7_SCAN) |
| 394 | .word MK_SDRAM_REFRESH(REFEN, TREFMD, Trp_250, Tsrc_250, REFCNT_250) |
| 395 | .word 0x32 + BURST_EN |
| 396 | .word 0x30 |
| 397 | .word 0x30 |
| 398 | .equiv SDRAMENTRY_SIZE, (. - 0b) |
| 399 | |
| 400 | /* 8Mx8x4 */ |
| 401 | .word MK_BANKCON_SDRAM(B6_Trcd_250, B6_SCAN) |
| 402 | .word MK_BANKCON_SDRAM(B7_Trcd_250, B7_SCAN) |
| 403 | .word MK_SDRAM_REFRESH(REFEN, TREFMD, Trp_250, Tsrc_250, REFCNT_250) |
| 404 | .word 0x32 + BURST_EN |
| 405 | .word 0x30 |
| 406 | .word 0x30 |
| 407 | |
| 408 | /* 2Mx8x4 */ |
| 409 | .word MK_BANKCON_SDRAM(B6_Trcd_250, B6_SCAN) |
| 410 | .word MK_BANKCON_SDRAM(B7_Trcd_250, B7_SCAN) |
| 411 | .word MK_SDRAM_REFRESH(REFEN, TREFMD, Trp_250, Tsrc_250, REFCNT_250) |
| 412 | .word 0x32 + BURST_EN |
| 413 | .word 0x30 |
| 414 | .word 0x30 |
| 415 | |
| 416 | /* 4Mx8x2 */ |
| 417 | .word MK_BANKCON_SDRAM(B6_Trcd_250, B6_SCAN) |
| 418 | .word MK_BANKCON_SDRAM(B7_Trcd_250, B7_SCAN) |
| 419 | .word MK_SDRAM_REFRESH(REFEN, TREFMD, Trp_250, Tsrc_250, REFCNT_250) |
| 420 | .word 0x32 + BURST_EN |
| 421 | .word 0x30 |
| 422 | .word 0x30 |
| 423 | |
| 424 | .equiv SETUPENTRY_SIZE, (. - SETUPDATA) |
| 425 | |
| 426 | .word 0x32410000 |
| 427 | /* PLL values (MDIV, PDIV, SDIV) for 200 MHz (Fout = 202.8MHz) */ |
| 428 | .word (0xA1 << 12) + (0x03 << 4) + (0x01 << 0) |
| 429 | /* PLL values for USB clock */ |
| 430 | .word (0x48 << 12) + (0x03 << 4) + (0x02 << 0) |
| 431 | |
| 432 | /* timing for 200 MHz and default*/ |
| 433 | .word MK_BWSCON(DW16, \ |
| 434 | DW32, \ |
| 435 | DW32, \ |
| 436 | DW16 + WAIT + UBLB, \ |
| 437 | DW8 + UBLB, \ |
| 438 | DW32, \ |
| 439 | DW32) |
| 440 | |
| 441 | .word MK_BANKCON(B0_Tacs_200, \ |
| 442 | B0_Tcos_200, \ |
| 443 | B0_Tacc_200, \ |
| 444 | B0_Tcoh_200, \ |
| 445 | B0_Tcah_200, \ |
| 446 | B0_Tacp_200, \ |
| 447 | B0_PMC_200) |
| 448 | |
| 449 | .word MK_BANKCON(B1_Tacs_200, \ |
| 450 | B1_Tcos_200, \ |
| 451 | B1_Tacc_200, \ |
| 452 | B1_Tcoh_200, \ |
| 453 | B1_Tcah_200, \ |
| 454 | B1_Tacp_200, \ |
| 455 | B1_PMC_200) |
| 456 | |
| 457 | .word MK_BANKCON(B2_Tacs, \ |
| 458 | B2_Tcos, \ |
| 459 | B2_Tacc, \ |
| 460 | B2_Tcoh, \ |
| 461 | B2_Tcah, \ |
| 462 | B2_Tacp, \ |
| 463 | B2_PMC) |
| 464 | |
| 465 | .word MK_BANKCON(B3_Tacs, \ |
| 466 | B3_Tcos, \ |
| 467 | B3_Tacc, \ |
| 468 | B3_Tcoh, \ |
| 469 | B3_Tcah, \ |
| 470 | B3_Tacp, \ |
| 471 | B3_PMC) |
| 472 | |
| 473 | .word MK_BANKCON(B4_Tacs_200, \ |
| 474 | B4_Tcos_200, \ |
| 475 | B4_Tacc_200, \ |
| 476 | B4_Tcoh_200, \ |
| 477 | B4_Tcah_200, \ |
| 478 | B4_Tacp_200, \ |
| 479 | B4_PMC_200) |
| 480 | |
| 481 | .word MK_BANKCON(B5_Tacs_200, \ |
| 482 | B5_Tcos_200, \ |
| 483 | B5_Tacc_200, \ |
| 484 | B5_Tcoh_200, \ |
| 485 | B5_Tcah_200, \ |
| 486 | B5_Tacp_200, \ |
| 487 | B5_PMC_200) |
| 488 | |
| 489 | /* 4Mx8x4 */ |
| 490 | .word MK_BANKCON_SDRAM(B6_Trcd_200, B6_SCAN) |
| 491 | .word MK_BANKCON_SDRAM(B7_Trcd_200, B7_SCAN) |
| 492 | .word MK_SDRAM_REFRESH(REFEN, TREFMD, Trp_200, Tsrc_200, REFCNT_200) |
| 493 | .word 0x32 + BURST_EN |
| 494 | .word 0x30 |
| 495 | .word 0x30 |
| 496 | |
| 497 | /* 8Mx8x4 */ |
| 498 | .word MK_BANKCON_SDRAM(B6_Trcd_200, B6_SCAN) |
| 499 | .word MK_BANKCON_SDRAM(B7_Trcd_200, B7_SCAN) |
| 500 | .word MK_SDRAM_REFRESH(REFEN, TREFMD, Trp_200, Tsrc_200, REFCNT_200) |
| 501 | .word 0x32 + BURST_EN |
| 502 | .word 0x30 |
| 503 | .word 0x30 |
| 504 | |
| 505 | /* 2Mx8x4 */ |
| 506 | .word MK_BANKCON_SDRAM(B6_Trcd_200, B6_SCAN) |
| 507 | .word MK_BANKCON_SDRAM(B7_Trcd_200, B7_SCAN) |
| 508 | .word MK_SDRAM_REFRESH(REFEN, TREFMD, Trp_200, Tsrc_200, REFCNT_200) |
| 509 | .word 0x32 + BURST_EN |
| 510 | .word 0x30 |
| 511 | .word 0x30 |
| 512 | |
| 513 | /* 4Mx8x2 */ |
| 514 | .word MK_BANKCON_SDRAM(B6_Trcd_200, B6_SCAN) |
| 515 | .word MK_BANKCON_SDRAM(B7_Trcd_200, B7_SCAN) |
| 516 | .word MK_SDRAM_REFRESH(REFEN, TREFMD, Trp_200, Tsrc_200, REFCNT_200) |
| 517 | .word 0x32 + BURST_EN |
| 518 | .word 0x30 |
| 519 | .word 0x30 |
| 520 | |
| 521 | .equiv SETUPDATA_SIZE, (. - SETUPDATA) |