Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2006 |
Stefan Roese | 0238898 | 2007-01-05 10:38:05 +0100 | [diff] [blame] | 3 | * 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 Roese | 07b7b00 | 2007-03-06 07:47:04 +0100 | [diff] [blame] | 9 | * (C) Copyright 2006-2007 |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 10 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 11 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 12 | * SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 13 | */ |
| 14 | |
Stefan Roese | 0238898 | 2007-01-05 10:38:05 +0100 | [diff] [blame] | 15 | /* define DEBUG for debug output */ |
| 16 | #undef DEBUG |
| 17 | |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 18 | #include <common.h> |
| 19 | #include <asm/processor.h> |
Stefan Roese | 0238898 | 2007-01-05 10:38:05 +0100 | [diff] [blame] | 20 | #include <asm/io.h> |
Stefan Roese | b36df56 | 2010-09-09 19:18:00 +0200 | [diff] [blame] | 21 | #include <asm/ppc440.h> |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 22 | |
Stefan Roese | 0238898 | 2007-01-05 10:38:05 +0100 | [diff] [blame] | 23 | /*-----------------------------------------------------------------------------+ |
Larry Johnson | ce3902e | 2007-12-30 01:00:50 -0500 | [diff] [blame] | 24 | * Prototypes |
| 25 | *-----------------------------------------------------------------------------*/ |
| 26 | extern int denali_wait_for_dlllock(void); |
| 27 | extern void denali_core_search_data_eye(void); |
Stefan Roese | 0238898 | 2007-01-05 10:38:05 +0100 | [diff] [blame] | 28 | |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 29 | /************************************************************************* |
| 30 | * |
| 31 | * initdram -- 440EPx's DDR controller is a DENALI Core |
| 32 | * |
| 33 | ************************************************************************/ |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 34 | phys_size_t initdram (int board_type) |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 35 | { |
Stefan Roese | 345b77b | 2014-03-04 15:34:35 +0100 | [diff] [blame] | 36 | #if !defined(CONFIG_SYS_RAMBOOT) |
Stefan Roese | 07b7b00 | 2007-03-06 07:47:04 +0100 | [diff] [blame] | 37 | ulong speed = get_bus_freq(0); |
| 38 | |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 39 | mtsdram(DDR0_02, 0x00000000); |
| 40 | |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 41 | mtsdram(DDR0_00, 0x0000190A); |
| 42 | mtsdram(DDR0_01, 0x01000000); |
| 43 | mtsdram(DDR0_03, 0x02030602); |
Stefan Roese | 07b7b00 | 2007-03-06 07:47:04 +0100 | [diff] [blame] | 44 | mtsdram(DDR0_04, 0x0A020200); |
| 45 | mtsdram(DDR0_05, 0x02020308); |
| 46 | mtsdram(DDR0_06, 0x0102C812); |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 47 | mtsdram(DDR0_07, 0x000D0100); |
Stefan Roese | 07b7b00 | 2007-03-06 07:47:04 +0100 | [diff] [blame] | 48 | mtsdram(DDR0_08, 0x02430001); |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 49 | mtsdram(DDR0_09, 0x00011D5F); |
Mikhail Zolotaryov | ee86fd1 | 2009-03-11 10:54:46 +0200 | [diff] [blame] | 50 | mtsdram(DDR0_10, 0x00000100); |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 51 | mtsdram(DDR0_11, 0x0027C800); |
| 52 | mtsdram(DDR0_12, 0x00000003); |
| 53 | mtsdram(DDR0_14, 0x00000000); |
| 54 | mtsdram(DDR0_17, 0x19000000); |
| 55 | mtsdram(DDR0_18, 0x19191919); |
| 56 | mtsdram(DDR0_19, 0x19191919); |
| 57 | mtsdram(DDR0_20, 0x0B0B0B0B); |
| 58 | mtsdram(DDR0_21, 0x0B0B0B0B); |
| 59 | mtsdram(DDR0_22, 0x00267F0B); |
| 60 | mtsdram(DDR0_23, 0x00000000); |
| 61 | mtsdram(DDR0_24, 0x01010002); |
Stefan Roese | f544ff6 | 2007-05-05 08:29:01 +0200 | [diff] [blame] | 62 | if (speed > 133333334) |
Stefan Roese | 07b7b00 | 2007-03-06 07:47:04 +0100 | [diff] [blame] | 63 | mtsdram(DDR0_26, 0x5B26050C); |
| 64 | else |
| 65 | mtsdram(DDR0_26, 0x5B260408); |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 66 | mtsdram(DDR0_27, 0x0000682B); |
| 67 | mtsdram(DDR0_28, 0x00000000); |
| 68 | mtsdram(DDR0_31, 0x00000000); |
| 69 | mtsdram(DDR0_42, 0x01000006); |
Stefan Roese | 07b7b00 | 2007-03-06 07:47:04 +0100 | [diff] [blame] | 70 | mtsdram(DDR0_43, 0x030A0200); |
| 71 | mtsdram(DDR0_44, 0x00000003); |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 72 | mtsdram(DDR0_02, 0x00000001); |
| 73 | |
Larry Johnson | ce3902e | 2007-12-30 01:00:50 -0500 | [diff] [blame] | 74 | denali_wait_for_dlllock(); |
Stefan Roese | 345b77b | 2014-03-04 15:34:35 +0100 | [diff] [blame] | 75 | #endif /* #ifndef CONFIG_SYS_RAMBOOT */ |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 76 | |
Stefan Roese | 0238898 | 2007-01-05 10:38:05 +0100 | [diff] [blame] | 77 | #ifdef CONFIG_DDR_DATA_EYE |
| 78 | /* -----------------------------------------------------------+ |
| 79 | * Perform data eye search if requested. |
| 80 | * ----------------------------------------------------------*/ |
Larry Johnson | ce3902e | 2007-12-30 01:00:50 -0500 | [diff] [blame] | 81 | denali_core_search_data_eye(); |
Stefan Roese | 0238898 | 2007-01-05 10:38:05 +0100 | [diff] [blame] | 82 | #endif |
| 83 | |
Stefan Roese | d5a163d | 2008-01-11 15:53:58 +0100 | [diff] [blame] | 84 | /* |
| 85 | * Clear possible errors resulting from data-eye-search. |
| 86 | * If not done, then we could get an interrupt later on when |
| 87 | * exceptions are enabled. |
| 88 | */ |
| 89 | set_mcsr(get_mcsr()); |
| 90 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 91 | return (CONFIG_SYS_MBYTES_SDRAM << 20); |
Stefan Roese | 887e2ec | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 92 | } |