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