2008-01-17 20:53:56 +09:00
|
|
|
/*
|
|
|
|
*(C) Copyright 2005-2008 Netstal Maschinen AG
|
|
|
|
* Niklaus Giger (Niklaus.Giger@netstal.com)
|
|
|
|
*
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
* and/or modify it in source code form 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <ppc4xx.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include "nm.h"
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
void show_sdram_registers(void)
|
|
|
|
{
|
|
|
|
u32 value;
|
|
|
|
|
|
|
|
printf("SDRAM Controller Registers --\n");
|
2009-09-24 20:59:57 +09:00
|
|
|
mfsdram(SDRAM0_CFG, value);
|
2008-01-17 20:53:56 +09:00
|
|
|
printf(" SDRAM0_CFG : 0x%08x\n", value);
|
2009-09-24 20:59:57 +09:00
|
|
|
mfsdram(SDRAM0_STATUS, value);
|
2008-01-17 20:53:56 +09:00
|
|
|
printf(" SDRAM0_STATUS: 0x%08x\n", value);
|
2009-09-24 20:59:57 +09:00
|
|
|
mfsdram(SDRAM0_B0CR, value);
|
2008-01-17 20:53:56 +09:00
|
|
|
printf(" SDRAM0_B0CR : 0x%08x\n", value);
|
2009-09-24 20:59:57 +09:00
|
|
|
mfsdram(SDRAM0_B1CR, value);
|
2008-01-17 20:53:56 +09:00
|
|
|
printf(" SDRAM0_B1CR : 0x%08x\n", value);
|
2009-09-24 20:59:57 +09:00
|
|
|
mfsdram(SDRAM0_TR, value);
|
2008-01-17 20:53:56 +09:00
|
|
|
printf(" SDRAM0_TR : 0x%08x\n", value);
|
2009-09-24 20:59:57 +09:00
|
|
|
mfsdram(SDRAM0_RTR, value);
|
2008-01-17 20:53:56 +09:00
|
|
|
printf(" SDRAM0_RTR : 0x%08x\n", value);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-02-05 19:31:28 +09:00
|
|
|
long int init_ppc405_sdram(unsigned int dram_size)
|
2008-01-17 20:53:56 +09:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf(__FUNCTION__);
|
|
|
|
#endif
|
|
|
|
/* disable memory controller */
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_CFG, 0x00000000);
|
2008-01-17 20:53:56 +09:00
|
|
|
|
|
|
|
udelay (500);
|
|
|
|
|
|
|
|
/* Clear SDRAM0_BESR0 (Bus Error Syndrome Register) */
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_BESR0, 0xffffffff);
|
2008-01-17 20:53:56 +09:00
|
|
|
|
|
|
|
/* Clear SDRAM0_BESR1 (Bus Error Syndrome Register) */
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_BESR1, 0xffffffff);
|
2008-01-17 20:53:56 +09:00
|
|
|
|
|
|
|
/* Clear SDRAM0_ECCCFG (disable ECC) */
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_ECCCFG, 0x00000000);
|
2008-01-17 20:53:56 +09:00
|
|
|
|
|
|
|
/* Clear SDRAM0_ECCESR (ECC Error Syndrome Register) */
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_ECCESR, 0xffffffff);
|
2008-01-17 20:53:56 +09:00
|
|
|
|
|
|
|
/* Timing register: CASL=2, PTA=2, CTP=2, LDF=1, RFTA=5, RCD=2
|
|
|
|
*/
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_TR, 0x008a4015);
|
2008-01-17 20:53:56 +09:00
|
|
|
|
|
|
|
/* Memory Bank 0 Config == BA=0x00000000, SZ=64M, AM=3, BE=1
|
|
|
|
* and refresh timer
|
|
|
|
*/
|
|
|
|
switch (dram_size >> 20) {
|
|
|
|
case 32:
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_B0CR, 0x00062001);
|
|
|
|
mtsdram(SDRAM0_RTR, 0x07F00000);
|
2008-01-17 20:53:56 +09:00
|
|
|
break;
|
|
|
|
case 64:
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_B0CR, 0x00084001);
|
|
|
|
mtsdram(SDRAM0_RTR, 0x04100000);
|
2008-01-17 20:53:56 +09:00
|
|
|
break;
|
|
|
|
case 128:
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_B0CR, 0x000A4001);
|
|
|
|
mtsdram(SDRAM0_RTR, 0x04100000);
|
2008-01-17 20:53:56 +09:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Invalid memory size of %d MB given\n", dram_size >> 20);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Power management idle timer set to the default. */
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_PMIT, 0x07c00000);
|
2008-01-17 20:53:56 +09:00
|
|
|
|
|
|
|
udelay (500);
|
|
|
|
|
|
|
|
/* Enable banks (DCE=1, BPRF=1, ECCDD=1, EMDUL=1) TODO */
|
2009-09-24 20:59:57 +09:00
|
|
|
mtsdram(SDRAM0_CFG, 0x90800000);
|
2008-01-17 20:53:56 +09:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("%s: done\n", __FUNCTION__);
|
|
|
|
#endif
|
|
|
|
return dram_size;
|
|
|
|
}
|