blob: 6df4c6d9b366df2a6f9a61a29cf5e8083ae1f732 [file] [log] [blame]
Stefan Roese887e2ec2006-09-07 11:51:23 +02001/*
2 * (C) Copyright 2006
Stefan Roese02388982007-01-05 10:38:05 +01003 * Sylvie Gohl, AMCC/IBM, gohl.sylvie@fr.ibm.com
4 * Jacqueline Pira-Ferriol, AMCC/IBM, jpira-ferriol@fr.ibm.com
5 * Thierry Roman, AMCC/IBM, thierry_roman@fr.ibm.com
6 * Alain Saurel, AMCC/IBM, alain.saurel@fr.ibm.com
7 * Robert Snyder, AMCC/IBM, rob.snyder@fr.ibm.com
8 *
Stefan Roese07b7b002007-03-06 07:47:04 +01009 * (C) Copyright 2006-2007
Stefan Roese887e2ec2006-09-07 11:51:23 +020010 * Stefan Roese, DENX Software Engineering, sr@denx.de.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
Stefan Roese02388982007-01-05 10:38:05 +010028/* define DEBUG for debug output */
29#undef DEBUG
30
Stefan Roese887e2ec2006-09-07 11:51:23 +020031#include <common.h>
32#include <asm/processor.h>
Stefan Roese02388982007-01-05 10:38:05 +010033#include <asm/io.h>
Stefan Roese887e2ec2006-09-07 11:51:23 +020034#include <ppc440.h>
35
Stefan Roese02388982007-01-05 10:38:05 +010036/*-----------------------------------------------------------------------------+
Larry Johnsonce3902e2007-12-30 01:00:50 -050037 * Prototypes
38 *-----------------------------------------------------------------------------*/
39extern int denali_wait_for_dlllock(void);
40extern void denali_core_search_data_eye(void);
Stefan Roese02388982007-01-05 10:38:05 +010041
Stefan Roesef544ff62007-05-05 08:29:01 +020042#if defined(CONFIG_NAND_SPL)
43/* Using cpu/ppc4xx/speed.c to calculate the bus frequency is too big
44 * for the 4k NAND boot image so define bus_frequency to 133MHz here
45 * which is save for the refresh counter setup.
46 */
Stefan Roese17c1b0e2009-04-15 11:32:53 +020047#define get_bus_freq(val) 133333333
Stefan Roesef544ff62007-05-05 08:29:01 +020048#endif
49
Stefan Roese887e2ec2006-09-07 11:51:23 +020050/*************************************************************************
51 *
52 * initdram -- 440EPx's DDR controller is a DENALI Core
53 *
54 ************************************************************************/
Becky Bruce9973e3c2008-06-09 16:03:40 -050055phys_size_t initdram (int board_type)
Stefan Roese887e2ec2006-09-07 11:51:23 +020056{
57#if !defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL)
Stefan Roese07b7b002007-03-06 07:47:04 +010058 ulong speed = get_bus_freq(0);
59
Stefan Roese887e2ec2006-09-07 11:51:23 +020060 mtsdram(DDR0_02, 0x00000000);
61
Stefan Roese887e2ec2006-09-07 11:51:23 +020062 mtsdram(DDR0_00, 0x0000190A);
63 mtsdram(DDR0_01, 0x01000000);
64 mtsdram(DDR0_03, 0x02030602);
Stefan Roese07b7b002007-03-06 07:47:04 +010065 mtsdram(DDR0_04, 0x0A020200);
66 mtsdram(DDR0_05, 0x02020308);
67 mtsdram(DDR0_06, 0x0102C812);
Stefan Roese887e2ec2006-09-07 11:51:23 +020068 mtsdram(DDR0_07, 0x000D0100);
Stefan Roese07b7b002007-03-06 07:47:04 +010069 mtsdram(DDR0_08, 0x02430001);
Stefan Roese887e2ec2006-09-07 11:51:23 +020070 mtsdram(DDR0_09, 0x00011D5F);
Mikhail Zolotaryovee86fd12009-03-11 10:54:46 +020071 mtsdram(DDR0_10, 0x00000100);
Stefan Roese887e2ec2006-09-07 11:51:23 +020072 mtsdram(DDR0_11, 0x0027C800);
73 mtsdram(DDR0_12, 0x00000003);
74 mtsdram(DDR0_14, 0x00000000);
75 mtsdram(DDR0_17, 0x19000000);
76 mtsdram(DDR0_18, 0x19191919);
77 mtsdram(DDR0_19, 0x19191919);
78 mtsdram(DDR0_20, 0x0B0B0B0B);
79 mtsdram(DDR0_21, 0x0B0B0B0B);
80 mtsdram(DDR0_22, 0x00267F0B);
81 mtsdram(DDR0_23, 0x00000000);
82 mtsdram(DDR0_24, 0x01010002);
Stefan Roesef544ff62007-05-05 08:29:01 +020083 if (speed > 133333334)
Stefan Roese07b7b002007-03-06 07:47:04 +010084 mtsdram(DDR0_26, 0x5B26050C);
85 else
86 mtsdram(DDR0_26, 0x5B260408);
Stefan Roese887e2ec2006-09-07 11:51:23 +020087 mtsdram(DDR0_27, 0x0000682B);
88 mtsdram(DDR0_28, 0x00000000);
89 mtsdram(DDR0_31, 0x00000000);
90 mtsdram(DDR0_42, 0x01000006);
Stefan Roese07b7b002007-03-06 07:47:04 +010091 mtsdram(DDR0_43, 0x030A0200);
92 mtsdram(DDR0_44, 0x00000003);
Stefan Roese887e2ec2006-09-07 11:51:23 +020093 mtsdram(DDR0_02, 0x00000001);
94
Larry Johnsonce3902e2007-12-30 01:00:50 -050095 denali_wait_for_dlllock();
Stefan Roese887e2ec2006-09-07 11:51:23 +020096#endif /* #ifndef CONFIG_NAND_U_BOOT */
97
Stefan Roese02388982007-01-05 10:38:05 +010098#ifdef CONFIG_DDR_DATA_EYE
99 /* -----------------------------------------------------------+
100 * Perform data eye search if requested.
101 * ----------------------------------------------------------*/
Larry Johnsonce3902e2007-12-30 01:00:50 -0500102 denali_core_search_data_eye();
Stefan Roese02388982007-01-05 10:38:05 +0100103#endif
104
Stefan Roesed5a163d2008-01-11 15:53:58 +0100105 /*
106 * Clear possible errors resulting from data-eye-search.
107 * If not done, then we could get an interrupt later on when
108 * exceptions are enabled.
109 */
110 set_mcsr(get_mcsr());
111
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200112 return (CONFIG_SYS_MBYTES_SDRAM << 20);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200113}