2006-09-07 09:51:23 +00:00
|
|
|
/*
|
2007-01-05 09:38:05 +00:00
|
|
|
* (C) Copyright 2006
|
|
|
|
* Sylvie Gohl, AMCC/IBM, gohl.sylvie@fr.ibm.com
|
|
|
|
* Jacqueline Pira-Ferriol, AMCC/IBM, jpira-ferriol@fr.ibm.com
|
|
|
|
* Thierry Roman, AMCC/IBM, thierry_roman@fr.ibm.com
|
|
|
|
* Alain Saurel, AMCC/IBM, alain.saurel@fr.ibm.com
|
|
|
|
* Robert Snyder, AMCC/IBM, rob.snyder@fr.ibm.com
|
|
|
|
*
|
2007-03-06 06:47:04 +00:00
|
|
|
* (C) Copyright 2006-2007
|
2006-09-07 09:51:23 +00:00
|
|
|
* Stefan Roese, DENX Software Engineering, sr@denx.de.
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2006-09-07 09:51:23 +00:00
|
|
|
*/
|
|
|
|
|
2007-01-05 09:38:05 +00:00
|
|
|
/* define DEBUG for debug output */
|
|
|
|
#undef DEBUG
|
|
|
|
|
2006-09-07 09:51:23 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <asm/processor.h>
|
2007-01-05 09:38:05 +00:00
|
|
|
#include <asm/io.h>
|
2010-09-09 17:18:00 +00:00
|
|
|
#include <asm/ppc440.h>
|
2006-09-07 09:51:23 +00:00
|
|
|
|
2007-01-05 09:38:05 +00:00
|
|
|
/*-----------------------------------------------------------------------------+
|
2007-12-30 06:00:50 +00:00
|
|
|
* Prototypes
|
|
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
extern int denali_wait_for_dlllock(void);
|
|
|
|
extern void denali_core_search_data_eye(void);
|
2007-01-05 09:38:05 +00:00
|
|
|
|
2007-05-05 06:29:01 +00:00
|
|
|
#if defined(CONFIG_NAND_SPL)
|
2010-04-15 14:07:28 +00:00
|
|
|
/* Using arch/powerpc/cpu/ppc4xx/speed.c to calculate the bus frequency is too big
|
2007-05-05 06:29:01 +00:00
|
|
|
* for the 4k NAND boot image so define bus_frequency to 133MHz here
|
|
|
|
* which is save for the refresh counter setup.
|
|
|
|
*/
|
2009-04-15 09:32:53 +00:00
|
|
|
#define get_bus_freq(val) 133333333
|
2007-05-05 06:29:01 +00:00
|
|
|
#endif
|
|
|
|
|
2006-09-07 09:51:23 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* initdram -- 440EPx's DDR controller is a DENALI Core
|
|
|
|
*
|
|
|
|
************************************************************************/
|
2008-06-09 21:03:40 +00:00
|
|
|
phys_size_t initdram (int board_type)
|
2006-09-07 09:51:23 +00:00
|
|
|
{
|
2009-05-11 11:46:14 +00:00
|
|
|
#if !(defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_SYS_RAMBOOT)) || \
|
|
|
|
defined(CONFIG_NAND_SPL)
|
2007-03-06 06:47:04 +00:00
|
|
|
ulong speed = get_bus_freq(0);
|
|
|
|
|
2006-09-07 09:51:23 +00:00
|
|
|
mtsdram(DDR0_02, 0x00000000);
|
|
|
|
|
|
|
|
mtsdram(DDR0_00, 0x0000190A);
|
|
|
|
mtsdram(DDR0_01, 0x01000000);
|
|
|
|
mtsdram(DDR0_03, 0x02030602);
|
2007-03-06 06:47:04 +00:00
|
|
|
mtsdram(DDR0_04, 0x0A020200);
|
|
|
|
mtsdram(DDR0_05, 0x02020308);
|
|
|
|
mtsdram(DDR0_06, 0x0102C812);
|
2006-09-07 09:51:23 +00:00
|
|
|
mtsdram(DDR0_07, 0x000D0100);
|
2007-03-06 06:47:04 +00:00
|
|
|
mtsdram(DDR0_08, 0x02430001);
|
2006-09-07 09:51:23 +00:00
|
|
|
mtsdram(DDR0_09, 0x00011D5F);
|
2009-03-11 08:54:46 +00:00
|
|
|
mtsdram(DDR0_10, 0x00000100);
|
2006-09-07 09:51:23 +00:00
|
|
|
mtsdram(DDR0_11, 0x0027C800);
|
|
|
|
mtsdram(DDR0_12, 0x00000003);
|
|
|
|
mtsdram(DDR0_14, 0x00000000);
|
|
|
|
mtsdram(DDR0_17, 0x19000000);
|
|
|
|
mtsdram(DDR0_18, 0x19191919);
|
|
|
|
mtsdram(DDR0_19, 0x19191919);
|
|
|
|
mtsdram(DDR0_20, 0x0B0B0B0B);
|
|
|
|
mtsdram(DDR0_21, 0x0B0B0B0B);
|
|
|
|
mtsdram(DDR0_22, 0x00267F0B);
|
|
|
|
mtsdram(DDR0_23, 0x00000000);
|
|
|
|
mtsdram(DDR0_24, 0x01010002);
|
2007-05-05 06:29:01 +00:00
|
|
|
if (speed > 133333334)
|
2007-03-06 06:47:04 +00:00
|
|
|
mtsdram(DDR0_26, 0x5B26050C);
|
|
|
|
else
|
|
|
|
mtsdram(DDR0_26, 0x5B260408);
|
2006-09-07 09:51:23 +00:00
|
|
|
mtsdram(DDR0_27, 0x0000682B);
|
|
|
|
mtsdram(DDR0_28, 0x00000000);
|
|
|
|
mtsdram(DDR0_31, 0x00000000);
|
|
|
|
mtsdram(DDR0_42, 0x01000006);
|
2007-03-06 06:47:04 +00:00
|
|
|
mtsdram(DDR0_43, 0x030A0200);
|
|
|
|
mtsdram(DDR0_44, 0x00000003);
|
2006-09-07 09:51:23 +00:00
|
|
|
mtsdram(DDR0_02, 0x00000001);
|
|
|
|
|
2007-12-30 06:00:50 +00:00
|
|
|
denali_wait_for_dlllock();
|
2006-09-07 09:51:23 +00:00
|
|
|
#endif /* #ifndef CONFIG_NAND_U_BOOT */
|
|
|
|
|
2007-01-05 09:38:05 +00:00
|
|
|
#ifdef CONFIG_DDR_DATA_EYE
|
|
|
|
/* -----------------------------------------------------------+
|
|
|
|
* Perform data eye search if requested.
|
|
|
|
* ----------------------------------------------------------*/
|
2007-12-30 06:00:50 +00:00
|
|
|
denali_core_search_data_eye();
|
2007-01-05 09:38:05 +00:00
|
|
|
#endif
|
|
|
|
|
2008-01-11 14:53:58 +00:00
|
|
|
/*
|
|
|
|
* Clear possible errors resulting from data-eye-search.
|
|
|
|
* If not done, then we could get an interrupt later on when
|
|
|
|
* exceptions are enabled.
|
|
|
|
*/
|
|
|
|
set_mcsr(get_mcsr());
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
return (CONFIG_SYS_MBYTES_SDRAM << 20);
|
2006-09-07 09:51:23 +00:00
|
|
|
}
|