wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Daniel Engström, Omicron Ceti AB <daniel@omicron.se>. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /* This file is largely based on code obtned from AMD. AMD's original |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 25 | * copyright is included below |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | /* |
| 29 | * ============================================================================= |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 30 | * |
| 31 | * Copyright 1999 Advanced Micro Devices, Inc. |
| 32 | * |
| 33 | * This software is the property of Advanced Micro Devices, Inc (AMD) which |
| 34 | * specifically grants the user the right to modify, use and distribute this |
| 35 | * software provided this COPYRIGHT NOTICE is not removed or altered. All |
| 36 | * other rights are reserved by AMD. |
| 37 | * |
| 38 | * THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY |
| 39 | * OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT OF |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 40 | * THIRD-PARTY INTELLECTUAL PROPERTY, OR FITNESS FOR ANY PARTICULAR PURPOSE. |
| 41 | * IN NO EVENT SHALL AMD OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER |
| 42 | * (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS |
| 43 | * INTERRUPTION, LOSS OF INFORMAITON) ARISING OUT OF THE USE OF OR INABILITY |
| 44 | * TO USE THE MATERIALS, EVEN IF AMD HAS BEEN ADVISED OF THE POSSIBILITY OF |
| 45 | * SUCH DAMAGES. BECAUSE SOME JURSIDICTIONS PROHIBIT THE EXCLUSION OR |
| 46 | * LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE |
| 47 | * LIMITATION MAY NOT APPLY TO YOU. |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 48 | * |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 49 | * AMD does not assume any responsibility for any errors that may appear in |
| 50 | * the Materials nor any responsibility to support or update the Materials. |
| 51 | * AMD retains the right to make changes to its test specifications at any |
| 52 | * time, without notice. |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 53 | * |
| 54 | * So that all may benefit from your experience, please report any problems |
| 55 | * or suggestions about this software back to AMD. Please include your name, |
| 56 | * company, telephone number, AMD product requiring support and question or |
| 57 | * problem encountered. |
| 58 | * |
| 59 | * Advanced Micro Devices, Inc. Worldwide support and contact |
| 60 | * Embedded Processor Division information available at: |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 61 | * Systems Engineering epd.support@amd.com |
| 62 | * 5204 E. Ben White Blvd. -or- |
| 63 | * Austin, TX 78741 http://www.amd.com/html/support/techsup.html |
| 64 | * ============================================================================ |
| 65 | */ |
| 66 | |
| 67 | |
| 68 | /******************************************************************************* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 69 | * AUTHOR : Buddy Fey - Original. |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 70 | ******************************************************************************* |
| 71 | */ |
| 72 | |
| 73 | |
| 74 | /******************************************************************************* |
| 75 | * FUNCTIONAL DESCRIPTION: |
| 76 | * This routine is called to autodetect the geometry of the DRAM. |
| 77 | * |
| 78 | * This routine is called to determine the number of column bits for the DRAM |
| 79 | * devices in this external bank. This routine assumes that the external bank |
| 80 | * has been configured for an 11-bit column and for 4 internal banks. This gives |
| 81 | * us the maximum address reach in memory. By writing a test value to the max |
| 82 | * address and locating where it aliases to, we can determine the number of valid |
| 83 | * column bits. |
| 84 | * |
| 85 | * This routine is called to determine the number of internal banks each DRAM |
| 86 | * device has. The external bank (under test) is configured for maximum reach |
| 87 | * with 11-bit columns and 4 internal banks. This routine will write to a max |
| 88 | * address (BA1 and BA0 = 1) and then read from an address with BA1=0 to see if |
| 89 | * that column is a "don't care". If BA1 does not affect write/read of data, |
| 90 | * then this device has only 2 internal banks. |
| 91 | * |
| 92 | * This routine is called to determine the ending address for this external |
| 93 | * bank of SDRAM. We write to a max address with a data value and then disable |
| 94 | * row address bits looking for "don't care" locations. Each "don't care" bit |
| 95 | * represents a dividing of the maximum density (128M) by 2. By dividing the |
| 96 | * maximum of 32 4M chunks in an external bank down by all the "don't care" bits |
| 97 | * determined during sizing, we set the proper density. |
| 98 | * |
| 99 | * WARNINGS. |
| 100 | * bp must be preserved because it is used for return linkage. |
| 101 | * |
| 102 | * EXIT |
| 103 | * nothing returned - but the memory subsystem is enabled |
| 104 | ******************************************************************************* |
| 105 | */ |
| 106 | |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 107 | #include <config.h> |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 108 | |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 109 | .section .text |
| 110 | .equ DRCCTL, 0x0fffef010 /* DRAM control register */ |
| 111 | .equ DRCTMCTL, 0x0fffef012 /* DRAM timing control register */ |
| 112 | .equ DRCCFG, 0x0fffef014 /* DRAM bank configuration register */ |
| 113 | .equ DRCBENDADR, 0x0fffef018 /* DRAM bank ending address register */ |
| 114 | .equ ECCCTL, 0x0fffef020 /* DRAM ECC control register */ |
Wolfgang Denk | 94568b6 | 2006-08-14 23:23:06 +0200 | [diff] [blame] | 115 | .equ ECCINT, 0x0fffefd18 /* DRAM ECC nmi-INT mapping */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 116 | .equ DBCTL, 0x0fffef040 /* DRAM buffer control register */ |
| 117 | |
| 118 | .equ CACHELINESZ, 0x00000010 /* size of our cache line (read buffer) */ |
| 119 | .equ COL11_ADR, 0x0e001e00 /* 11 col addrs */ |
| 120 | .equ COL10_ADR, 0x0e000e00 /* 10 col addrs */ |
| 121 | .equ COL09_ADR, 0x0e000600 /* 9 col addrs */ |
| 122 | .equ COL08_ADR, 0x0e000200 /* 8 col addrs */ |
| 123 | .equ ROW14_ADR, 0x0f000000 /* 14 row addrs */ |
| 124 | .equ ROW13_ADR, 0x07000000 /* 13 row addrs */ |
| 125 | .equ ROW12_ADR, 0x03000000 /* 12 row addrs */ |
| 126 | .equ ROW11_ADR, 0x01000000 /* 11 row addrs/also bank switch */ |
| 127 | .equ ROW10_ADR, 0x00000000 /* 10 row addrs/also bank switch */ |
| 128 | .equ COL11_DATA, 0x0b0b0b0b /* 11 col addrs */ |
| 129 | .equ COL10_DATA, 0x0a0a0a0a /* 10 col data */ |
| 130 | .equ COL09_DATA, 0x09090909 /* 9 col data */ |
| 131 | .equ COL08_DATA, 0x08080808 /* 8 col data */ |
| 132 | .equ ROW14_DATA, 0x3f3f3f3f /* 14 row data (MASK) */ |
| 133 | .equ ROW13_DATA, 0x1f1f1f1f /* 13 row data (MASK) */ |
| 134 | .equ ROW12_DATA, 0x0f0f0f0f /* 12 row data (MASK) */ |
| 135 | .equ ROW11_DATA, 0x07070707 /* 11 row data/also bank switch (MASK) */ |
| 136 | .equ ROW10_DATA, 0xaaaaaaaa /* 10 row data/also bank switch (MASK) */ |
| 137 | |
| 138 | |
| 139 | /* |
| 140 | * initialize dram controller registers |
| 141 | */ |
| 142 | .globl mem_init |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 143 | mem_init: |
| 144 | xorw %ax,%ax |
| 145 | movl $DBCTL, %edi |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 146 | movb %al, (%edi) /* disable write buffer */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 147 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 148 | movl $ECCCTL, %edi |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 149 | movb %al, (%edi) /* disable ECC */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 150 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 151 | movl $DRCTMCTL, %edi |
| 152 | movb $0x1E,%al /* Set SDRAM timing for slowest */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 153 | movb %al, (%edi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 154 | |
| 155 | /* |
| 156 | * setup loop to do 4 external banks starting with bank 3 |
| 157 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 158 | movl $0xff000000,%eax /* enable last bank and setup */ |
| 159 | movl $DRCBENDADR, %edi /* ending address register */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 160 | movl %eax, (%edi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 161 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 162 | movl $DRCCFG, %edi /* setup */ |
| 163 | movw $0xbbbb,%ax /* dram config register for */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 164 | movw %ax, (%edi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 165 | |
| 166 | /* |
| 167 | * issue a NOP to all DRAMs |
| 168 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 169 | movl $DRCCTL, %edi /* setup DRAM control register with */ |
| 170 | movb $0x1,%al /* Disable refresh,disable write buffer */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 171 | movb %al, (%edi) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 172 | movl $CACHELINESZ, %esi /* just a dummy address to write for */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 173 | movw %ax, (%esi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 174 | /* |
| 175 | * delay for 100 usec? 200? |
| 176 | * ******this is a cludge for now ************* |
| 177 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 178 | movw $100,%cx |
| 179 | sizdelay: |
| 180 | loop sizdelay /* we need 100 usec here */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 181 | /***********************************************/ |
| 182 | |
| 183 | /* |
| 184 | * issue all banks precharge |
| 185 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 186 | movb $0x2,%al /* All banks precharge */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 187 | movb %al, (%edi) |
| 188 | movw %ax, (%esi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 189 | |
| 190 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 191 | * issue 2 auto refreshes to all banks |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 192 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 193 | movb $0x4,%al /* Auto refresh cmd */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 194 | movb %al, (%edi) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 195 | movw $2,%cx |
| 196 | refresh1: |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 197 | movw %ax, (%esi) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 198 | loop refresh1 |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 199 | |
| 200 | /* |
| 201 | * issue LOAD MODE REGISTER command |
| 202 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 203 | movb $0x3,%al /* Load mode register cmd */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 204 | movb %al, (%edi) |
| 205 | movw %ax, (%esi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 206 | |
| 207 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 208 | * issue 8 more auto refreshes to all banks |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 209 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 210 | movb $0x4,%al /* Auto refresh cmd */ |
| 211 | movb %al, (%edi) |
| 212 | movw $8,%cx |
| 213 | refresh2: |
| 214 | movw %ax, (%esi) |
| 215 | loop refresh2 |
| 216 | |
| 217 | /* |
| 218 | * set control register to NORMAL mode |
| 219 | */ |
| 220 | movb $0x0,%al /* Normal mode value */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 221 | movb %al, (%edi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 222 | |
| 223 | /* |
| 224 | * size dram starting with external bank 3 moving to external bank 0 |
| 225 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 226 | movl $0x3,%ecx /* start with external bank 3 */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 227 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 228 | nextbank: |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 229 | |
| 230 | /* |
| 231 | * write col 11 wrap adr |
| 232 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 233 | movl $COL11_ADR, %esi /* set address to max col (11) wrap addr */ |
| 234 | movl $COL11_DATA, %eax /* pattern for max supported columns(11) */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 235 | movl %eax, (%esi) /* write max col pattern at max col adr */ |
| 236 | movl (%esi), %ebx /* optional read */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 237 | cmpl %ebx,%eax /* to verify write */ |
| 238 | jnz bad_ram /* this ram is bad */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 239 | /* |
| 240 | * write col 10 wrap adr |
| 241 | */ |
| 242 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 243 | movl $COL10_ADR, %esi /* set address to 10 col wrap address */ |
| 244 | movl $COL10_DATA, %eax /* pattern for 10 col wrap */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 245 | movl %eax, (%esi) /* write 10 col pattern @ 10 col wrap adr */ |
| 246 | movl (%esi), %ebx /* optional read */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 247 | cmpl %ebx,%eax /* to verify write */ |
| 248 | jnz bad_ram /* this ram is bad */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 249 | /* |
| 250 | * write col 9 wrap adr |
| 251 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 252 | movl $COL09_ADR, %esi /* set address to 9 col wrap address */ |
| 253 | movl $COL09_DATA, %eax /* pattern for 9 col wrap */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 254 | movl %eax, (%esi) /* write 9 col pattern @ 9 col wrap adr */ |
| 255 | movl (%esi), %ebx /* optional read */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 256 | cmpl %ebx,%eax /* to verify write */ |
| 257 | jnz bad_ram /* this ram is bad */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 258 | /* |
| 259 | * write col 8 wrap adr |
| 260 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 261 | movl $COL08_ADR, %esi /* set address to min(8) col wrap address */ |
| 262 | movl $COL08_DATA, %eax /* pattern for min (8) col wrap */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 263 | movl %eax, (%esi) /* write min col pattern @ min col adr */ |
| 264 | movl (%esi), %ebx /* optional read */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 265 | cmpl %ebx,%eax /* to verify write */ |
| 266 | jnz bad_ram /* this ram is bad */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 267 | /* |
| 268 | * write row 14 wrap adr |
| 269 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 270 | movl $ROW14_ADR, %esi /* set address to max row (14) wrap addr */ |
| 271 | movl $ROW14_DATA, %eax /* pattern for max supported rows(14) */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 272 | movl %eax, (%esi) /* write max row pattern at max row adr */ |
| 273 | movl (%esi), %ebx /* optional read */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 274 | cmpl %ebx,%eax /* to verify write */ |
| 275 | jnz bad_ram /* this ram is bad */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 276 | /* |
| 277 | * write row 13 wrap adr |
| 278 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 279 | movl $ROW13_ADR, %esi /* set address to 13 row wrap address */ |
| 280 | movl $ROW13_DATA, %eax /* pattern for 13 row wrap */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 281 | movl %eax, (%esi) /* write 13 row pattern @ 13 row wrap adr */ |
| 282 | movl (%esi), %ebx /* optional read */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 283 | cmpl %ebx,%eax /* to verify write */ |
| 284 | jnz bad_ram /* this ram is bad */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 285 | /* |
| 286 | * write row 12 wrap adr |
| 287 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 288 | movl $ROW12_ADR, %esi /* set address to 12 row wrap address */ |
| 289 | movl $ROW12_DATA, %eax /* pattern for 12 row wrap */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 290 | movl %eax, (%esi) /* write 12 row pattern @ 12 row wrap adr */ |
| 291 | movl (%esi), %ebx /* optional read */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 292 | cmpl %ebx,%eax /* to verify write */ |
| 293 | jnz bad_ram /* this ram is bad */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 294 | /* |
| 295 | * write row 11 wrap adr |
| 296 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 297 | movl $ROW11_ADR, %edi /* set address to 11 row wrap address */ |
| 298 | movl $ROW11_DATA, %eax /* pattern for 11 row wrap */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 299 | movl %eax, (%edi) /* write 11 row pattern @ 11 row wrap adr */ |
| 300 | movl (%edi), %ebx /* optional read */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 301 | cmpl %ebx,%eax /* to verify write */ |
| 302 | jnz bad_ram /* this ram is bad */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 303 | /* |
| 304 | * write row 10 wrap adr --- this write is really to determine number of banks |
| 305 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 306 | movl $ROW10_ADR, %edi /* set address to 10 row wrap address */ |
| 307 | movl $ROW10_DATA, %eax /* pattern for 10 row wrap (AA) */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 308 | movl %eax, (%edi) /* write 10 row pattern @ 10 row wrap adr */ |
| 309 | movl (%edi), %ebx /* optional read */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 310 | cmpl %ebx,%eax /* to verify write */ |
| 311 | jnz bad_ram /* this ram is bad */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 312 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 313 | * read data @ row 12 wrap adr to determine * banks, |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 314 | * and read data @ row 14 wrap adr to determine * rows. |
| 315 | * if data @ row 12 wrap adr is not AA, 11 or 12 we have bad RAM. |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 316 | * if data @ row 12 wrap == AA, we only have 2 banks, NOT 4 |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 317 | * if data @ row 12 wrap == 11 or 12, we have 4 banks, |
| 318 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 319 | xorw %di,%di /* value for 2 banks in DI */ |
| 320 | movl (%esi), %ebx /* read from 12 row wrap to check banks |
| 321 | * (esi is setup from the write to row 12 wrap) */ |
| 322 | cmpl %ebx,%eax /* check for AA pattern (eax holds the aa pattern) */ |
| 323 | jz only2 /* if pattern == AA, we only have 2 banks */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 324 | |
| 325 | /* 4 banks */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 326 | |
| 327 | movw $8,%di /* value for 4 banks in DI (BNK_CNT bit) */ |
| 328 | cmpl $ROW11_DATA, %ebx /* only other legitimate values are 11 */ |
| 329 | jz only2 |
| 330 | cmpl $ROW12_DATA, %ebx /* and 12 */ |
| 331 | jnz bad_ram /* its bad if not 11 or 12! */ |
| 332 | |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 333 | /* fall through */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 334 | only2: |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 335 | /* |
| 336 | * validate row mask |
| 337 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 338 | movl $ROW14_ADR, %esi /* set address back to max row wrap addr */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 339 | movl (%esi), %eax /* read actual number of rows @ row14 adr */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 340 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 341 | cmpl $ROW11_DATA, %eax /* row must be greater than 11 pattern */ |
| 342 | jb bad_ram |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 343 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 344 | cmpl $ROW14_DATA, %eax /* and row must be less than 14 pattern */ |
| 345 | ja bad_ram |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 346 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 347 | cmpb %ah,%al /* verify all 4 bytes of dword same */ |
| 348 | jnz bad_ram |
| 349 | movl %eax,%ebx |
| 350 | shrl $16,%ebx |
| 351 | cmpw %bx,%ax |
| 352 | jnz bad_ram |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 353 | /* |
| 354 | * read col 11 wrap adr for real column data value |
| 355 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 356 | movl $COL11_ADR, %esi /* set address to max col (11) wrap addr */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 357 | movl (%esi), %eax /* read real col number at max col adr */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 358 | /* |
| 359 | * validate column data |
| 360 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 361 | cmpl $COL08_DATA, %eax /* col must be greater than 8 pattern */ |
| 362 | jb bad_ram |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 363 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 364 | cmpl $COL11_DATA, %eax /* and row must be less than 11 pattern */ |
| 365 | ja bad_ram |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 366 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 367 | subl $COL08_DATA, %eax /* normalize column data to zero */ |
| 368 | jc bad_ram |
| 369 | cmpb %ah,%al /* verify all 4 bytes of dword equal */ |
| 370 | jnz bad_ram |
| 371 | movl %eax,%edx |
| 372 | shrl $16,%edx |
| 373 | cmpw %dx,%ax |
| 374 | jnz bad_ram |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 375 | /* |
| 376 | * merge bank and col data together |
| 377 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 378 | addw %di,%dx /* merge of bank and col info in dl */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 379 | /* |
| 380 | * fix ending addr mask based upon col info |
| 381 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 382 | movb $3,%al |
| 383 | subb %dh,%al /* dh contains the overflow from the bank/col merge */ |
| 384 | movb %bl,%dh /* bl contains the row mask (aa, 07, 0f, 1f or 3f) */ |
| 385 | xchgw %cx,%ax /* cx = ax = 3 or 2 depending on 2 or 4 bank device */ |
| 386 | shrb %cl,%dh /* */ |
| 387 | incb %dh /* ending addr is 1 greater than real end */ |
| 388 | xchgw %cx,%ax /* cx is bank number again */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 389 | /* |
| 390 | * issue all banks precharge |
| 391 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 392 | bad_reint: |
| 393 | movl $DRCCTL, %esi /* setup DRAM control register with */ |
| 394 | movb $0x2,%al /* All banks precharge */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 395 | movb %al, (%esi) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 396 | movl $CACHELINESZ, %esi /* address to init read buffer */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 397 | movw %ax, (%esi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 398 | |
| 399 | /* |
| 400 | * update ENDING ADDRESS REGISTER |
| 401 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 402 | movl $DRCBENDADR, %edi /* DRAM ending address register */ |
| 403 | movl %ecx,%ebx |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 404 | addl %ebx, %edi |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 405 | movb %dh, (%edi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 406 | /* |
| 407 | * update CONFIG REGISTER |
| 408 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 409 | xorb %dh,%dh |
| 410 | movw $0x00f,%bx |
| 411 | movw %cx,%ax |
| 412 | shlw $2,%ax |
| 413 | xchgw %cx,%ax |
| 414 | shlw %cl,%dx |
| 415 | shlw %cl,%bx |
| 416 | notw %bx |
| 417 | xchgw %cx,%ax |
| 418 | movl $DRCCFG, %edi |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 419 | mov (%edi), %ax |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 420 | andw %bx,%ax |
| 421 | orw %dx,%ax |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 422 | movw %ax, (%edi) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 423 | jcxz cleanup |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 424 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 425 | decw %cx |
| 426 | movl %ecx,%ebx |
| 427 | movl $DRCBENDADR, %edi /* DRAM ending address register */ |
| 428 | movb $0xff,%al |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 429 | addl %ebx, %edi |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 430 | movb %al, (%edi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 431 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 432 | * set control register to NORMAL mode |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 433 | */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 434 | movl $DRCCTL, %esi /* setup DRAM control register with */ |
| 435 | movb $0x0,%al /* Normal mode value */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 436 | movb %al, (%esi) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 437 | movl $CACHELINESZ, %esi /* address to init read buffer */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 438 | movw %ax, (%esi) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 439 | jmp nextbank |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 440 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 441 | cleanup: |
| 442 | movl $DRCBENDADR, %edi /* DRAM ending address register */ |
| 443 | movw $4,%cx |
| 444 | xorw %ax,%ax |
| 445 | cleanuplp: |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 446 | movb (%edi), %al |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 447 | orb %al,%al |
| 448 | jz emptybank |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 449 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 450 | addb %ah,%al |
| 451 | jns nottoomuch |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 452 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 453 | movb $0x7f,%al |
| 454 | nottoomuch: |
| 455 | movb %al,%ah |
| 456 | orb $0x80,%al |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 457 | movb %al, (%edi) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 458 | emptybank: |
| 459 | incl %edi |
| 460 | loop cleanuplp |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 461 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 462 | #if defined CONFIG_SYS_SDRAM_DRCTMCTL |
Wolfgang Denk | 94568b6 | 2006-08-14 23:23:06 +0200 | [diff] [blame] | 463 | /* just have your hardware desinger _GIVE_ you what you need here! */ |
Wolfgang Denk | 1685091 | 2006-08-27 18:10:01 +0200 | [diff] [blame] | 464 | movl $DRCTMCTL, %edi |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 465 | movb $CONFIG_SYS_SDRAM_DRCTMCTL,%al |
Wolfgang Denk | 94568b6 | 2006-08-14 23:23:06 +0200 | [diff] [blame] | 466 | movb (%edi), %al |
| 467 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 468 | #if defined(CONFIG_SYS_SDRAM_CAS_LATENCY_2T) || defined(CONFIG_SYS_SDRAM_CAS_LATENCY_3T) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 469 | /* set the CAS latency now since it is hard to do |
| 470 | * when we run from the RAM */ |
| 471 | movl $DRCTMCTL, %edi /* DRAM timing register */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 472 | movb (%edi), %al |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 473 | #ifdef CONFIG_SYS_SDRAM_CAS_LATENCY_2T |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 474 | andb $0xef, %al |
| 475 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 476 | #ifdef CONFIG_SYS_SDRAM_CAS_LATENCY_3T |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 477 | orb $0x10, %al |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 478 | #endif |
Wolfgang Denk | 1685091 | 2006-08-27 18:10:01 +0200 | [diff] [blame] | 479 | movb %al, (%edi) |
Wolfgang Denk | 94568b6 | 2006-08-14 23:23:06 +0200 | [diff] [blame] | 480 | #endif |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 481 | #endif |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 482 | movl $DRCCTL, %edi /* DRAM Control register */ |
| 483 | movb $0x3,%al /* Load mode register cmd */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 484 | movb %al, (%edi) |
| 485 | movw %ax, (%esi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 486 | |
| 487 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 488 | movl $DRCCTL, %edi /* DRAM Control register */ |
| 489 | movb $0x18,%al /* Enable refresh and NORMAL mode */ |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 490 | movb %al, (%edi) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 491 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 492 | jmp dram_done |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 493 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 494 | bad_ram: |
| 495 | xorl %edx,%edx |
| 496 | xorl %edi,%edi |
| 497 | jmp bad_reint |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 498 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 499 | dram_done: |
| 500 | |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 501 | /* readback DRCBENDADR and return the number |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 502 | * of available ram bytes in %eax */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 503 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 504 | movl $DRCBENDADR, %edi /* DRAM ending address register */ |
| 505 | |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 506 | movl (%edi), %eax |
| 507 | movl %eax, %ecx |
| 508 | andl $0x80000000, %ecx |
| 509 | jz bank2 |
| 510 | andl $0x7f000000, %eax |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 511 | shrl $2, %eax |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 512 | movl %eax, %ebx |
| 513 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 514 | bank2: movl (%edi), %eax |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 515 | movl %eax, %ecx |
| 516 | andl $0x00800000, %ecx |
| 517 | jz bank1 |
| 518 | andl $0x007f0000, %eax |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 519 | shll $6, %eax |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 520 | movl %eax, %ebx |
| 521 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 522 | bank1: movl (%edi), %eax |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 523 | movl %eax, %ecx |
| 524 | andl $0x00008000, %ecx |
| 525 | jz bank0 |
| 526 | andl $0x00007f00, %eax |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 527 | shll $14, %eax |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 528 | movl %eax, %ebx |
| 529 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 530 | bank0: movl (%edi), %eax |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 531 | movl %eax, %ecx |
| 532 | andl $0x00000080, %ecx |
| 533 | jz done |
| 534 | andl $0x0000007f, %eax |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 535 | shll $22, %eax |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 536 | movl %eax, %ebx |
| 537 | |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 538 | |
Wolfgang Denk | 1685091 | 2006-08-27 18:10:01 +0200 | [diff] [blame] | 539 | done: |
Wolfgang Denk | 94568b6 | 2006-08-14 23:23:06 +0200 | [diff] [blame] | 540 | movl %ebx, %eax |
| 541 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 542 | #if CONFIG_SYS_SDRAM_ECC_ENABLE |
Wolfgang Denk | 94568b6 | 2006-08-14 23:23:06 +0200 | [diff] [blame] | 543 | /* A nominal memory test: just a byte at each address line */ |
| 544 | movl %eax, %ecx |
| 545 | shrl $0x1, %ecx |
| 546 | movl $0x1, %edi |
| 547 | memtest0: |
| 548 | movb $0xa5, (%edi) |
Wolfgang Denk | 1685091 | 2006-08-27 18:10:01 +0200 | [diff] [blame] | 549 | cmpb $0xa5, (%edi) |
Wolfgang Denk | 94568b6 | 2006-08-14 23:23:06 +0200 | [diff] [blame] | 550 | jne out |
| 551 | shrl $1, %ecx |
| 552 | andl %ecx,%ecx |
| 553 | jz set_ecc |
| 554 | shll $1, %edi |
| 555 | jmp memtest0 |
| 556 | |
| 557 | set_ecc: |
| 558 | /* clear all ram with a memset */ |
| 559 | movl %eax, %ecx |
| 560 | xorl %esi, %esi |
| 561 | xorl %edi, %edi |
| 562 | xorl %eax, %eax |
| 563 | shrl $2, %ecx |
| 564 | cld |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 565 | rep stosl |
Wolfgang Denk | 94568b6 | 2006-08-14 23:23:06 +0200 | [diff] [blame] | 566 | /* enable read, write buffers */ |
| 567 | movb $0x11, %al |
| 568 | movl $DBCTL, %edi |
| 569 | movb %al, (%edi) |
| 570 | /* enable NMI mapping for ECC */ |
| 571 | movl $ECCINT, %edi |
| 572 | mov $0x10, %al |
Wolfgang Denk | 1685091 | 2006-08-27 18:10:01 +0200 | [diff] [blame] | 573 | movb %al, (%edi) |
Wolfgang Denk | 94568b6 | 2006-08-14 23:23:06 +0200 | [diff] [blame] | 574 | /* Turn on ECC */ |
| 575 | movl $ECCCTL, %edi |
| 576 | mov $0x05, %al |
Wolfgang Denk | 1685091 | 2006-08-27 18:10:01 +0200 | [diff] [blame] | 577 | movb %al, (%edi) |
Wolfgang Denk | 94568b6 | 2006-08-14 23:23:06 +0200 | [diff] [blame] | 578 | #endif |
| 579 | out: |
| 580 | movl %ebx, %eax |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 581 | jmp *%ebp |