2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* (C) Copyright 2002
|
|
|
|
|
* Daniel Engstr<EFBFBD>m, Omicron Ceti AB <daniel@omicron.se>.
|
|
|
|
|
*
|
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
|
* project.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* This file is largely based on code obtned from AMD. AMD's original
|
2003-06-27 21:31:46 +00:00
|
|
|
|
* copyright is included below
|
2002-11-18 00:14:45 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* =============================================================================
|
2003-06-27 21:31:46 +00:00
|
|
|
|
*
|
|
|
|
|
* Copyright 1999 Advanced Micro Devices, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This software is the property of Advanced Micro Devices, Inc (AMD) which
|
|
|
|
|
* specifically grants the user the right to modify, use and distribute this
|
|
|
|
|
* software provided this COPYRIGHT NOTICE is not removed or altered. All
|
|
|
|
|
* other rights are reserved by AMD.
|
|
|
|
|
*
|
|
|
|
|
* THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY
|
|
|
|
|
* OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT OF
|
2002-11-18 00:14:45 +00:00
|
|
|
|
* THIRD-PARTY INTELLECTUAL PROPERTY, OR FITNESS FOR ANY PARTICULAR PURPOSE.
|
|
|
|
|
* IN NO EVENT SHALL AMD OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER
|
|
|
|
|
* (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS
|
|
|
|
|
* INTERRUPTION, LOSS OF INFORMAITON) ARISING OUT OF THE USE OF OR INABILITY
|
|
|
|
|
* TO USE THE MATERIALS, EVEN IF AMD HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGES. BECAUSE SOME JURSIDICTIONS PROHIBIT THE EXCLUSION OR
|
|
|
|
|
* LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE
|
|
|
|
|
* LIMITATION MAY NOT APPLY TO YOU.
|
2003-06-27 21:31:46 +00:00
|
|
|
|
*
|
2002-11-18 00:14:45 +00:00
|
|
|
|
* AMD does not assume any responsibility for any errors that may appear in
|
|
|
|
|
* the Materials nor any responsibility to support or update the Materials.
|
|
|
|
|
* AMD retains the right to make changes to its test specifications at any
|
|
|
|
|
* time, without notice.
|
2003-06-27 21:31:46 +00:00
|
|
|
|
*
|
|
|
|
|
* So that all may benefit from your experience, please report any problems
|
|
|
|
|
* or suggestions about this software back to AMD. Please include your name,
|
|
|
|
|
* company, telephone number, AMD product requiring support and question or
|
|
|
|
|
* problem encountered.
|
|
|
|
|
*
|
|
|
|
|
* Advanced Micro Devices, Inc. Worldwide support and contact
|
|
|
|
|
* Embedded Processor Division information available at:
|
2002-11-18 00:14:45 +00:00
|
|
|
|
* Systems Engineering epd.support@amd.com
|
|
|
|
|
* 5204 E. Ben White Blvd. -or-
|
|
|
|
|
* Austin, TX 78741 http://www.amd.com/html/support/techsup.html
|
|
|
|
|
* ============================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
2003-06-27 21:31:46 +00:00
|
|
|
|
* AUTHOR : Buddy Fey - Original.
|
2002-11-18 00:14:45 +00:00
|
|
|
|
*******************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
* FUNCTIONAL DESCRIPTION:
|
|
|
|
|
* This routine is called to autodetect the geometry of the DRAM.
|
|
|
|
|
*
|
|
|
|
|
* This routine is called to determine the number of column bits for the DRAM
|
|
|
|
|
* devices in this external bank. This routine assumes that the external bank
|
|
|
|
|
* has been configured for an 11-bit column and for 4 internal banks. This gives
|
|
|
|
|
* us the maximum address reach in memory. By writing a test value to the max
|
|
|
|
|
* address and locating where it aliases to, we can determine the number of valid
|
|
|
|
|
* column bits.
|
|
|
|
|
*
|
|
|
|
|
* This routine is called to determine the number of internal banks each DRAM
|
|
|
|
|
* device has. The external bank (under test) is configured for maximum reach
|
|
|
|
|
* with 11-bit columns and 4 internal banks. This routine will write to a max
|
|
|
|
|
* address (BA1 and BA0 = 1) and then read from an address with BA1=0 to see if
|
|
|
|
|
* that column is a "don't care". If BA1 does not affect write/read of data,
|
|
|
|
|
* then this device has only 2 internal banks.
|
|
|
|
|
*
|
|
|
|
|
* This routine is called to determine the ending address for this external
|
|
|
|
|
* bank of SDRAM. We write to a max address with a data value and then disable
|
|
|
|
|
* row address bits looking for "don't care" locations. Each "don't care" bit
|
|
|
|
|
* represents a dividing of the maximum density (128M) by 2. By dividing the
|
|
|
|
|
* maximum of 32 4M chunks in an external bank down by all the "don't care" bits
|
|
|
|
|
* determined during sizing, we set the proper density.
|
|
|
|
|
*
|
|
|
|
|
* WARNINGS.
|
|
|
|
|
* bp must be preserved because it is used for return linkage.
|
|
|
|
|
*
|
|
|
|
|
* EXIT
|
|
|
|
|
* nothing returned - but the memory subsystem is enabled
|
|
|
|
|
*******************************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
2003-05-31 18:35:21 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
#ifdef CONFIG_SC520
|
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
|
.section .text
|
|
|
|
|
.equ DRCCTL, 0x0fffef010 /* DRAM control register */
|
|
|
|
|
.equ DRCTMCTL, 0x0fffef012 /* DRAM timing control register */
|
|
|
|
|
.equ DRCCFG, 0x0fffef014 /* DRAM bank configuration register */
|
|
|
|
|
.equ DRCBENDADR, 0x0fffef018 /* DRAM bank ending address register */
|
|
|
|
|
.equ ECCCTL, 0x0fffef020 /* DRAM ECC control register */
|
2006-08-14 21:23:06 +00:00
|
|
|
|
.equ ECCINT, 0x0fffefd18 /* DRAM ECC nmi-INT mapping */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
.equ DBCTL, 0x0fffef040 /* DRAM buffer control register */
|
|
|
|
|
|
|
|
|
|
.equ CACHELINESZ, 0x00000010 /* size of our cache line (read buffer) */
|
|
|
|
|
.equ COL11_ADR, 0x0e001e00 /* 11 col addrs */
|
|
|
|
|
.equ COL10_ADR, 0x0e000e00 /* 10 col addrs */
|
|
|
|
|
.equ COL09_ADR, 0x0e000600 /* 9 col addrs */
|
|
|
|
|
.equ COL08_ADR, 0x0e000200 /* 8 col addrs */
|
|
|
|
|
.equ ROW14_ADR, 0x0f000000 /* 14 row addrs */
|
|
|
|
|
.equ ROW13_ADR, 0x07000000 /* 13 row addrs */
|
|
|
|
|
.equ ROW12_ADR, 0x03000000 /* 12 row addrs */
|
|
|
|
|
.equ ROW11_ADR, 0x01000000 /* 11 row addrs/also bank switch */
|
|
|
|
|
.equ ROW10_ADR, 0x00000000 /* 10 row addrs/also bank switch */
|
|
|
|
|
.equ COL11_DATA, 0x0b0b0b0b /* 11 col addrs */
|
|
|
|
|
.equ COL10_DATA, 0x0a0a0a0a /* 10 col data */
|
|
|
|
|
.equ COL09_DATA, 0x09090909 /* 9 col data */
|
|
|
|
|
.equ COL08_DATA, 0x08080808 /* 8 col data */
|
|
|
|
|
.equ ROW14_DATA, 0x3f3f3f3f /* 14 row data (MASK) */
|
|
|
|
|
.equ ROW13_DATA, 0x1f1f1f1f /* 13 row data (MASK) */
|
|
|
|
|
.equ ROW12_DATA, 0x0f0f0f0f /* 12 row data (MASK) */
|
|
|
|
|
.equ ROW11_DATA, 0x07070707 /* 11 row data/also bank switch (MASK) */
|
|
|
|
|
.equ ROW10_DATA, 0xaaaaaaaa /* 10 row data/also bank switch (MASK) */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* initialize dram controller registers
|
|
|
|
|
*/
|
|
|
|
|
.globl mem_init
|
2003-06-27 21:31:46 +00:00
|
|
|
|
mem_init:
|
|
|
|
|
xorw %ax,%ax
|
|
|
|
|
movl $DBCTL, %edi
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi) /* disable write buffer */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $ECCCTL, %edi
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi) /* disable ECC */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $DRCTMCTL, %edi
|
|
|
|
|
movb $0x1E,%al /* Set SDRAM timing for slowest */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* setup loop to do 4 external banks starting with bank 3
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $0xff000000,%eax /* enable last bank and setup */
|
|
|
|
|
movl $DRCBENDADR, %edi /* ending address register */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl %eax, (%edi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $DRCCFG, %edi /* setup */
|
|
|
|
|
movw $0xbbbb,%ax /* dram config register for */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movw %ax, (%edi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* issue a NOP to all DRAMs
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $DRCCTL, %edi /* setup DRAM control register with */
|
|
|
|
|
movb $0x1,%al /* Disable refresh,disable write buffer */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $CACHELINESZ, %esi /* just a dummy address to write for */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movw %ax, (%esi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* delay for 100 usec? 200?
|
|
|
|
|
* ******this is a cludge for now *************
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw $100,%cx
|
|
|
|
|
sizdelay:
|
|
|
|
|
loop sizdelay /* we need 100 usec here */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/***********************************************/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* issue all banks precharge
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movb $0x2,%al /* All banks precharge */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
|
|
|
|
movw %ax, (%esi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2003-06-27 21:31:46 +00:00
|
|
|
|
* issue 2 auto refreshes to all banks
|
2002-11-18 00:14:45 +00:00
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movb $0x4,%al /* Auto refresh cmd */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw $2,%cx
|
|
|
|
|
refresh1:
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movw %ax, (%esi)
|
2003-06-27 21:31:46 +00:00
|
|
|
|
loop refresh1
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* issue LOAD MODE REGISTER command
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movb $0x3,%al /* Load mode register cmd */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
|
|
|
|
movw %ax, (%esi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2003-06-27 21:31:46 +00:00
|
|
|
|
* issue 8 more auto refreshes to all banks
|
|
|
|
|
*/
|
|
|
|
|
movb $0x4,%al /* Auto refresh cmd */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw $8,%cx
|
|
|
|
|
refresh2:
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movw %ax, (%esi)
|
2003-06-27 21:31:46 +00:00
|
|
|
|
loop refresh2
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2003-06-27 21:31:46 +00:00
|
|
|
|
* set control register to NORMAL mode
|
2002-11-18 00:14:45 +00:00
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movb $0x0,%al /* Normal mode value */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* size dram starting with external bank 3 moving to external bank 0
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $0x3,%ecx /* start with external bank 3 */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
nextbank:
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* write col 11 wrap adr
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $COL11_ADR, %esi /* set address to max col (11) wrap addr */
|
|
|
|
|
movl $COL11_DATA, %eax /* pattern for max supported columns(11) */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl %eax, (%esi) /* write max col pattern at max col adr */
|
|
|
|
|
movl (%esi), %ebx /* optional read */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl %ebx,%eax /* to verify write */
|
|
|
|
|
jnz bad_ram /* this ram is bad */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* write col 10 wrap adr
|
|
|
|
|
*/
|
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $COL10_ADR, %esi /* set address to 10 col wrap address */
|
|
|
|
|
movl $COL10_DATA, %eax /* pattern for 10 col wrap */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl %eax, (%esi) /* write 10 col pattern @ 10 col wrap adr */
|
|
|
|
|
movl (%esi), %ebx /* optional read */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl %ebx,%eax /* to verify write */
|
|
|
|
|
jnz bad_ram /* this ram is bad */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* write col 9 wrap adr
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $COL09_ADR, %esi /* set address to 9 col wrap address */
|
|
|
|
|
movl $COL09_DATA, %eax /* pattern for 9 col wrap */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl %eax, (%esi) /* write 9 col pattern @ 9 col wrap adr */
|
|
|
|
|
movl (%esi), %ebx /* optional read */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl %ebx,%eax /* to verify write */
|
|
|
|
|
jnz bad_ram /* this ram is bad */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* write col 8 wrap adr
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $COL08_ADR, %esi /* set address to min(8) col wrap address */
|
|
|
|
|
movl $COL08_DATA, %eax /* pattern for min (8) col wrap */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl %eax, (%esi) /* write min col pattern @ min col adr */
|
|
|
|
|
movl (%esi), %ebx /* optional read */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl %ebx,%eax /* to verify write */
|
|
|
|
|
jnz bad_ram /* this ram is bad */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* write row 14 wrap adr
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $ROW14_ADR, %esi /* set address to max row (14) wrap addr */
|
|
|
|
|
movl $ROW14_DATA, %eax /* pattern for max supported rows(14) */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl %eax, (%esi) /* write max row pattern at max row adr */
|
|
|
|
|
movl (%esi), %ebx /* optional read */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl %ebx,%eax /* to verify write */
|
|
|
|
|
jnz bad_ram /* this ram is bad */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* write row 13 wrap adr
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $ROW13_ADR, %esi /* set address to 13 row wrap address */
|
|
|
|
|
movl $ROW13_DATA, %eax /* pattern for 13 row wrap */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl %eax, (%esi) /* write 13 row pattern @ 13 row wrap adr */
|
|
|
|
|
movl (%esi), %ebx /* optional read */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl %ebx,%eax /* to verify write */
|
|
|
|
|
jnz bad_ram /* this ram is bad */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* write row 12 wrap adr
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $ROW12_ADR, %esi /* set address to 12 row wrap address */
|
|
|
|
|
movl $ROW12_DATA, %eax /* pattern for 12 row wrap */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl %eax, (%esi) /* write 12 row pattern @ 12 row wrap adr */
|
|
|
|
|
movl (%esi), %ebx /* optional read */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl %ebx,%eax /* to verify write */
|
|
|
|
|
jnz bad_ram /* this ram is bad */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* write row 11 wrap adr
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $ROW11_ADR, %edi /* set address to 11 row wrap address */
|
|
|
|
|
movl $ROW11_DATA, %eax /* pattern for 11 row wrap */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl %eax, (%edi) /* write 11 row pattern @ 11 row wrap adr */
|
|
|
|
|
movl (%edi), %ebx /* optional read */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl %ebx,%eax /* to verify write */
|
|
|
|
|
jnz bad_ram /* this ram is bad */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* write row 10 wrap adr --- this write is really to determine number of banks
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $ROW10_ADR, %edi /* set address to 10 row wrap address */
|
|
|
|
|
movl $ROW10_DATA, %eax /* pattern for 10 row wrap (AA) */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl %eax, (%edi) /* write 10 row pattern @ 10 row wrap adr */
|
|
|
|
|
movl (%edi), %ebx /* optional read */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl %ebx,%eax /* to verify write */
|
|
|
|
|
jnz bad_ram /* this ram is bad */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
2003-06-27 21:31:46 +00:00
|
|
|
|
* read data @ row 12 wrap adr to determine * banks,
|
2002-11-18 00:14:45 +00:00
|
|
|
|
* and read data @ row 14 wrap adr to determine * rows.
|
|
|
|
|
* if data @ row 12 wrap adr is not AA, 11 or 12 we have bad RAM.
|
2003-06-27 21:31:46 +00:00
|
|
|
|
* if data @ row 12 wrap == AA, we only have 2 banks, NOT 4
|
2002-11-18 00:14:45 +00:00
|
|
|
|
* if data @ row 12 wrap == 11 or 12, we have 4 banks,
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
xorw %di,%di /* value for 2 banks in DI */
|
|
|
|
|
movl (%esi), %ebx /* read from 12 row wrap to check banks
|
|
|
|
|
* (esi is setup from the write to row 12 wrap) */
|
|
|
|
|
cmpl %ebx,%eax /* check for AA pattern (eax holds the aa pattern) */
|
|
|
|
|
jz only2 /* if pattern == AA, we only have 2 banks */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/* 4 banks */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
|
|
|
|
|
movw $8,%di /* value for 4 banks in DI (BNK_CNT bit) */
|
|
|
|
|
cmpl $ROW11_DATA, %ebx /* only other legitimate values are 11 */
|
|
|
|
|
jz only2
|
|
|
|
|
cmpl $ROW12_DATA, %ebx /* and 12 */
|
|
|
|
|
jnz bad_ram /* its bad if not 11 or 12! */
|
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/* fall through */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
only2:
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* validate row mask
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $ROW14_ADR, %esi /* set address back to max row wrap addr */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl (%esi), %eax /* read actual number of rows @ row14 adr */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl $ROW11_DATA, %eax /* row must be greater than 11 pattern */
|
|
|
|
|
jb bad_ram
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl $ROW14_DATA, %eax /* and row must be less than 14 pattern */
|
|
|
|
|
ja bad_ram
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpb %ah,%al /* verify all 4 bytes of dword same */
|
|
|
|
|
jnz bad_ram
|
|
|
|
|
movl %eax,%ebx
|
|
|
|
|
shrl $16,%ebx
|
|
|
|
|
cmpw %bx,%ax
|
|
|
|
|
jnz bad_ram
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* read col 11 wrap adr for real column data value
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $COL11_ADR, %esi /* set address to max col (11) wrap addr */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movl (%esi), %eax /* read real col number at max col adr */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* validate column data
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl $COL08_DATA, %eax /* col must be greater than 8 pattern */
|
|
|
|
|
jb bad_ram
|
|
|
|
|
|
|
|
|
|
cmpl $COL11_DATA, %eax /* and row must be less than 11 pattern */
|
|
|
|
|
ja bad_ram
|
|
|
|
|
|
|
|
|
|
subl $COL08_DATA, %eax /* normalize column data to zero */
|
|
|
|
|
jc bad_ram
|
|
|
|
|
cmpb %ah,%al /* verify all 4 bytes of dword equal */
|
|
|
|
|
jnz bad_ram
|
|
|
|
|
movl %eax,%edx
|
|
|
|
|
shrl $16,%edx
|
|
|
|
|
cmpw %dx,%ax
|
|
|
|
|
jnz bad_ram
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* merge bank and col data together
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
addw %di,%dx /* merge of bank and col info in dl */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* fix ending addr mask based upon col info
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movb $3,%al
|
|
|
|
|
subb %dh,%al /* dh contains the overflow from the bank/col merge */
|
|
|
|
|
movb %bl,%dh /* bl contains the row mask (aa, 07, 0f, 1f or 3f) */
|
|
|
|
|
xchgw %cx,%ax /* cx = ax = 3 or 2 depending on 2 or 4 bank device */
|
|
|
|
|
shrb %cl,%dh /* */
|
|
|
|
|
incb %dh /* ending addr is 1 greater than real end */
|
|
|
|
|
xchgw %cx,%ax /* cx is bank number again */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* issue all banks precharge
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
bad_reint:
|
|
|
|
|
movl $DRCCTL, %esi /* setup DRAM control register with */
|
|
|
|
|
movb $0x2,%al /* All banks precharge */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%esi)
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $CACHELINESZ, %esi /* address to init read buffer */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movw %ax, (%esi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* update ENDING ADDRESS REGISTER
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $DRCBENDADR, %edi /* DRAM ending address register */
|
|
|
|
|
movl %ecx,%ebx
|
2002-11-18 00:14:45 +00:00
|
|
|
|
addl %ebx, %edi
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %dh, (%edi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* update CONFIG REGISTER
|
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
xorb %dh,%dh
|
|
|
|
|
movw $0x00f,%bx
|
|
|
|
|
movw %cx,%ax
|
|
|
|
|
shlw $2,%ax
|
|
|
|
|
xchgw %cx,%ax
|
|
|
|
|
shlw %cl,%dx
|
|
|
|
|
shlw %cl,%bx
|
|
|
|
|
notw %bx
|
|
|
|
|
xchgw %cx,%ax
|
|
|
|
|
movl $DRCCFG, %edi
|
2003-05-31 18:35:21 +00:00
|
|
|
|
mov (%edi), %ax
|
2003-06-27 21:31:46 +00:00
|
|
|
|
andw %bx,%ax
|
|
|
|
|
orw %dx,%ax
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movw %ax, (%edi)
|
2003-06-27 21:31:46 +00:00
|
|
|
|
jcxz cleanup
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
decw %cx
|
|
|
|
|
movl %ecx,%ebx
|
|
|
|
|
movl $DRCBENDADR, %edi /* DRAM ending address register */
|
|
|
|
|
movb $0xff,%al
|
2002-11-18 00:14:45 +00:00
|
|
|
|
addl %ebx, %edi
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
2003-06-27 21:31:46 +00:00
|
|
|
|
* set control register to NORMAL mode
|
2002-11-18 00:14:45 +00:00
|
|
|
|
*/
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $DRCCTL, %esi /* setup DRAM control register with */
|
|
|
|
|
movb $0x0,%al /* Normal mode value */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%esi)
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $CACHELINESZ, %esi /* address to init read buffer */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movw %ax, (%esi)
|
2003-06-27 21:31:46 +00:00
|
|
|
|
jmp nextbank
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cleanup:
|
|
|
|
|
movl $DRCBENDADR, %edi /* DRAM ending address register */
|
|
|
|
|
movw $4,%cx
|
|
|
|
|
xorw %ax,%ax
|
|
|
|
|
cleanuplp:
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb (%edi), %al
|
2003-06-27 21:31:46 +00:00
|
|
|
|
orb %al,%al
|
|
|
|
|
jz emptybank
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
addb %ah,%al
|
|
|
|
|
jns nottoomuch
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movb $0x7f,%al
|
|
|
|
|
nottoomuch:
|
|
|
|
|
movb %al,%ah
|
|
|
|
|
orb $0x80,%al
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
2003-06-27 21:31:46 +00:00
|
|
|
|
emptybank:
|
|
|
|
|
incl %edi
|
|
|
|
|
loop cleanuplp
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2006-08-14 21:23:06 +00:00
|
|
|
|
#if defined CFG_SDRAM_DRCTMCTL
|
|
|
|
|
/* just have your hardware desinger _GIVE_ you what you need here! */
|
2006-08-27 16:10:01 +00:00
|
|
|
|
movl $DRCTMCTL, %edi
|
2006-08-14 21:23:06 +00:00
|
|
|
|
movb $CFG_SDRAM_DRCTMCTL,%al
|
|
|
|
|
movb (%edi), %al
|
|
|
|
|
#else
|
2002-11-18 00:14:45 +00:00
|
|
|
|
#if defined(CFG_SDRAM_CAS_LATENCY_2T) || defined(CFG_SDRAM_CAS_LATENCY_3T)
|
|
|
|
|
/* set the CAS latency now since it is hard to do
|
|
|
|
|
* when we run from the RAM */
|
|
|
|
|
movl $DRCTMCTL, %edi /* DRAM timing register */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movb (%edi), %al
|
2002-11-18 00:14:45 +00:00
|
|
|
|
#ifdef CFG_SDRAM_CAS_LATENCY_2T
|
|
|
|
|
andb $0xef, %al
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef CFG_SDRAM_CAS_LATENCY_3T
|
|
|
|
|
orb $0x10, %al
|
2003-06-27 21:31:46 +00:00
|
|
|
|
#endif
|
2006-08-27 16:10:01 +00:00
|
|
|
|
movb %al, (%edi)
|
2006-08-14 21:23:06 +00:00
|
|
|
|
#endif
|
2002-11-18 00:14:45 +00:00
|
|
|
|
#endif
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $DRCCTL, %edi /* DRAM Control register */
|
|
|
|
|
movb $0x3,%al /* Load mode register cmd */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
|
|
|
|
movw %ax, (%esi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movl $DRCCTL, %edi /* DRAM Control register */
|
|
|
|
|
movb $0x18,%al /* Enable refresh and NORMAL mode */
|
2003-05-31 18:35:21 +00:00
|
|
|
|
movb %al, (%edi)
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
jmp dram_done
|
|
|
|
|
|
|
|
|
|
bad_ram:
|
|
|
|
|
xorl %edx,%edx
|
|
|
|
|
xorl %edi,%edi
|
|
|
|
|
jmp bad_reint
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
dram_done:
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/* readback DRCBENDADR and return the number
|
2003-06-27 21:31:46 +00:00
|
|
|
|
* of available ram bytes in %eax */
|
|
|
|
|
|
|
|
|
|
movl $DRCBENDADR, %edi /* DRAM ending address register */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
movl (%edi), %eax
|
|
|
|
|
movl %eax, %ecx
|
|
|
|
|
andl $0x80000000, %ecx
|
|
|
|
|
jz bank2
|
|
|
|
|
andl $0x7f000000, %eax
|
2003-06-27 21:31:46 +00:00
|
|
|
|
shrl $2, %eax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl %eax, %ebx
|
|
|
|
|
|
2008-05-20 14:00:29 +00:00
|
|
|
|
bank2: movl (%edi), %eax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl %eax, %ecx
|
|
|
|
|
andl $0x00800000, %ecx
|
|
|
|
|
jz bank1
|
|
|
|
|
andl $0x007f0000, %eax
|
2003-06-27 21:31:46 +00:00
|
|
|
|
shll $6, %eax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl %eax, %ebx
|
|
|
|
|
|
2008-05-20 14:00:29 +00:00
|
|
|
|
bank1: movl (%edi), %eax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl %eax, %ecx
|
|
|
|
|
andl $0x00008000, %ecx
|
|
|
|
|
jz bank0
|
|
|
|
|
andl $0x00007f00, %eax
|
2003-06-27 21:31:46 +00:00
|
|
|
|
shll $14, %eax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl %eax, %ebx
|
|
|
|
|
|
2008-05-20 14:00:29 +00:00
|
|
|
|
bank0: movl (%edi), %eax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl %eax, %ecx
|
|
|
|
|
andl $0x00000080, %ecx
|
|
|
|
|
jz done
|
|
|
|
|
andl $0x0000007f, %eax
|
2003-06-27 21:31:46 +00:00
|
|
|
|
shll $22, %eax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl %eax, %ebx
|
|
|
|
|
|
|
|
|
|
|
2006-08-27 16:10:01 +00:00
|
|
|
|
done:
|
2006-08-14 21:23:06 +00:00
|
|
|
|
movl %ebx, %eax
|
|
|
|
|
|
|
|
|
|
#if CFG_SDRAM_ECC_ENABLE
|
|
|
|
|
/* A nominal memory test: just a byte at each address line */
|
|
|
|
|
movl %eax, %ecx
|
|
|
|
|
shrl $0x1, %ecx
|
|
|
|
|
movl $0x1, %edi
|
|
|
|
|
memtest0:
|
|
|
|
|
movb $0xa5, (%edi)
|
2006-08-27 16:10:01 +00:00
|
|
|
|
cmpb $0xa5, (%edi)
|
2006-08-14 21:23:06 +00:00
|
|
|
|
jne out
|
|
|
|
|
shrl $1, %ecx
|
|
|
|
|
andl %ecx,%ecx
|
|
|
|
|
jz set_ecc
|
|
|
|
|
shll $1, %edi
|
|
|
|
|
jmp memtest0
|
|
|
|
|
|
|
|
|
|
set_ecc:
|
|
|
|
|
/* clear all ram with a memset */
|
|
|
|
|
movl %eax, %ecx
|
|
|
|
|
xorl %esi, %esi
|
|
|
|
|
xorl %edi, %edi
|
|
|
|
|
xorl %eax, %eax
|
|
|
|
|
shrl $2, %ecx
|
|
|
|
|
cld
|
2008-05-20 14:00:29 +00:00
|
|
|
|
rep stosl
|
2006-08-14 21:23:06 +00:00
|
|
|
|
/* enable read, write buffers */
|
|
|
|
|
movb $0x11, %al
|
|
|
|
|
movl $DBCTL, %edi
|
|
|
|
|
movb %al, (%edi)
|
|
|
|
|
/* enable NMI mapping for ECC */
|
|
|
|
|
movl $ECCINT, %edi
|
|
|
|
|
mov $0x10, %al
|
2006-08-27 16:10:01 +00:00
|
|
|
|
movb %al, (%edi)
|
2006-08-14 21:23:06 +00:00
|
|
|
|
/* Turn on ECC */
|
|
|
|
|
movl $ECCCTL, %edi
|
|
|
|
|
mov $0x05, %al
|
2006-08-27 16:10:01 +00:00
|
|
|
|
movb %al, (%edi)
|
2006-08-14 21:23:06 +00:00
|
|
|
|
#endif
|
|
|
|
|
out:
|
|
|
|
|
movl %ebx, %eax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
jmp *%ebp
|
2003-05-31 18:35:21 +00:00
|
|
|
|
|
|
|
|
|
#endif /* CONFIG_SC520 */
|