wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <config.h> |
| 26 | #include <mpc8xx.h> |
| 27 | #include "fads.h" |
| 28 | |
| 29 | /* ------------------------------------------------------------------------- */ |
| 30 | |
| 31 | #define _NOT_USED_ 0xFFFFFFFF |
| 32 | |
| 33 | #if defined(CONFIG_DRAM_50MHZ) |
| 34 | /* 50MHz tables */ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 35 | static const uint dram_60ns[] = |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 36 | { 0x8fffec24, 0x0fffec04, 0x0cffec04, 0x00ffec04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 37 | 0x00ffec00, 0x37ffec47, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 38 | 0x8fffec24, 0x0fffec04, 0x08ffec04, 0x00ffec0c, |
| 39 | 0x03ffec00, 0x00ffec44, 0x00ffcc08, 0x0cffcc44, |
| 40 | 0x00ffec0c, 0x03ffec00, 0x00ffec44, 0x00ffcc00, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 41 | 0x3fffc847, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 42 | 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x11bfcc47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 43 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 44 | 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x03afcc4c, |
| 45 | 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 46 | 0x0cafcc00, 0x33bfcc4f, _NOT_USED_, _NOT_USED_, |
| 47 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 48 | 0xc0ffcc84, 0x00ffcc04, 0x07ffcc04, 0x3fffcc06, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 49 | 0xffffcc85, 0xffffcc05, _NOT_USED_, _NOT_USED_, |
| 50 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 51 | 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ }; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 52 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 53 | static const uint dram_70ns[] = |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 54 | { 0x8fffcc24, 0x0fffcc04, 0x0cffcc04, 0x00ffcc04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 55 | 0x00ffcc00, 0x37ffcc47, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 56 | 0x8fffcc24, 0x0fffcc04, 0x0cffcc04, 0x00ffcc04, |
| 57 | 0x00ffcc08, 0x0cffcc44, 0x00ffec0c, 0x03ffec00, |
| 58 | 0x00ffec44, 0x00ffcc08, 0x0cffcc44, 0x00ffec04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 59 | 0x00ffec00, 0x3fffec47, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 60 | 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x11bfcc47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 61 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 62 | 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x03afcc4c, |
| 63 | 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 64 | 0x0cafcc00, 0x33bfcc4f, _NOT_USED_, _NOT_USED_, |
| 65 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 66 | 0xe0ffcc84, 0x00ffcc04, 0x00ffcc04, 0x0fffcc04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 67 | 0x7fffcc06, 0xffffcc85, 0xffffcc05, _NOT_USED_, |
| 68 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 69 | 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ }; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 70 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 71 | static const uint edo_60ns[] = |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 72 | { 0x8ffbec24, 0x0ff3ec04, 0x0cf3ec04, 0x00f3ec04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 73 | 0x00f3ec00, 0x37f7ec47, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 74 | 0x8fffec24, 0x0ffbec04, 0x0cf3ec04, 0x00f3ec0c, |
| 75 | 0x0cf3ec00, 0x00f3ec4c, 0x0cf3ec00, 0x00f3ec4c, |
| 76 | 0x0cf3ec00, 0x00f3ec44, 0x03f3ec00, 0x3ff7ec47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 77 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 78 | 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x11bfcc47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 79 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 80 | 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x03afcc4c, |
| 81 | 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 82 | 0x0cafcc00, 0x33bfcc4f, _NOT_USED_, _NOT_USED_, |
| 83 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 84 | 0xc0ffcc84, 0x00ffcc04, 0x07ffcc04, 0x3fffcc06, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 85 | 0xffffcc85, 0xffffcc05, _NOT_USED_, _NOT_USED_, |
| 86 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 87 | 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ }; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 88 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 89 | static const uint edo_70ns[] = |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 90 | { 0x8ffbcc24, 0x0ff3cc04, 0x0cf3cc04, 0x00f3cc04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 91 | 0x00f3cc00, 0x37f7cc47, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 92 | 0x8fffcc24, 0x0ffbcc04, 0x0cf3cc04, 0x00f3cc0c, |
| 93 | 0x03f3cc00, 0x00f3cc44, 0x00f3ec0c, 0x0cf3ec00, |
| 94 | 0x00f3ec4c, 0x03f3ec00, 0x00f3ec44, 0x00f3cc00, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 95 | 0x33f7cc47, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 96 | 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x11bfcc47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 97 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 98 | 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x03afcc4c, |
| 99 | 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 100 | 0x0cafcc00, 0x33bfcc47, _NOT_USED_, _NOT_USED_, |
| 101 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 102 | 0xe0ffcc84, 0x00ffcc04, 0x00ffcc04, 0x0fffcc04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 103 | 0x7fffcc04, 0xffffcc86, 0xffffcc05, _NOT_USED_, |
| 104 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 105 | 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ }; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 106 | |
| 107 | #elif defined(CONFIG_DRAM_25MHZ) |
| 108 | |
| 109 | /* 25MHz tables */ |
| 110 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 111 | static const uint dram_60ns[] = |
| 112 | { 0x0fffcc04, 0x08ffcc00, 0x33ffcc47, _NOT_USED_, |
| 113 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 114 | 0x0fffcc24, 0x0fffcc04, 0x08ffcc00, 0x03ffcc4c, |
| 115 | 0x08ffcc00, 0x03ffcc4c, 0x08ffcc00, 0x03ffcc4c, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 116 | 0x08ffcc00, 0x33ffcc47, _NOT_USED_, _NOT_USED_, |
| 117 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 118 | 0x0fafcc04, 0x08afcc00, 0x3fbfcc47, _NOT_USED_, |
| 119 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 120 | 0x0fafcc04, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00, |
| 121 | 0x01afcc4c, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 122 | 0x31bfcc43, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 123 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 124 | 0x80ffcc84, 0x13ffcc04, 0xffffcc87, 0xffffcc05, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 125 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 126 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 127 | 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ }; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 128 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 129 | static const uint dram_70ns[] = |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 130 | { 0x0fffec04, 0x08ffec04, 0x00ffec00, 0x3fffcc47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 131 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 132 | 0x0fffcc24, 0x0fffcc04, 0x08ffcc00, 0x03ffcc4c, |
| 133 | 0x08ffcc00, 0x03ffcc4c, 0x08ffcc00, 0x03ffcc4c, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 134 | 0x08ffcc00, 0x33ffcc47, _NOT_USED_, _NOT_USED_, |
| 135 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 136 | 0x0fafcc04, 0x08afcc00, 0x3fbfcc47, _NOT_USED_, |
| 137 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 138 | 0x0fafcc04, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00, |
| 139 | 0x01afcc4c, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 140 | 0x31bfcc43, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 141 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 142 | 0xc0ffcc84, 0x01ffcc04, 0x7fffcc86, 0xffffcc05, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 143 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 144 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 145 | 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ }; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 146 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 147 | static const uint edo_60ns[] = |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 148 | { 0x0ffbcc04, 0x0cf3cc04, 0x00f3cc00, 0x33f7cc47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 149 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 150 | 0x0ffbcc04, 0x09f3cc0c, 0x09f3cc0c, 0x09f3cc0c, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 151 | 0x08f3cc00, 0x3ff7cc47, _NOT_USED_, _NOT_USED_, |
| 152 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 153 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 154 | 0x0fefcc04, 0x08afcc04, 0x00afcc00, 0x3fbfcc47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 155 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 156 | 0x0fefcc04, 0x08afcc00, 0x07afcc48, 0x08afcc48, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 157 | 0x08afcc48, 0x39bfcc47, _NOT_USED_, _NOT_USED_, |
| 158 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 159 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 160 | 0x80ffcc84, 0x13ffcc04, 0xffffcc87, 0xffffcc05, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 161 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 162 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 163 | 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ }; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 164 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 165 | static const uint edo_70ns[] = |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 166 | { 0x0ffbcc04, 0x0cf3cc04, 0x00f3cc00, 0x33f7cc47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 167 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 168 | 0x0ffbec04, 0x08f3ec04, 0x03f3ec48, 0x08f3cc00, |
| 169 | 0x0ff3cc4c, 0x08f3cc00, 0x0ff3cc4c, 0x08f3cc00, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 170 | 0x3ff7cc47, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 171 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 172 | 0x0fefcc04, 0x08afcc04, 0x00afcc00, 0x3fbfcc47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 173 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 174 | 0x0fefcc04, 0x08afcc00, 0x07afcc4c, 0x08afcc00, |
| 175 | 0x07afcc4c, 0x08afcc00, 0x07afcc4c, 0x08afcc00, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 176 | 0x37bfcc47, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 177 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 178 | 0xc0ffcc84, 0x01ffcc04, 0x7fffcc86, 0xffffcc05, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 179 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 180 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 181 | 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ }; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 182 | #else |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 183 | #error dram not correctly defined - use CONFIG_DRAM_25MHZ or CONFIG_DRAM_50MHZ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 184 | #endif |
| 185 | |
| 186 | /* ------------------------------------------------------------------------- */ |
| 187 | |
| 188 | |
| 189 | /* |
| 190 | * Check Board Identity: |
| 191 | */ |
| 192 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 193 | #if defined(CONFIG_FADS) && !defined(CONFIG_MPC86xADS) |
| 194 | static void checkdboard(void) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 195 | { |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 196 | /* get db type from BCSR 3 */ |
| 197 | uint k = (*((uint *)BCSR3) >> 24) & 0x3f; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 198 | |
| 199 | printf(" with db "); |
| 200 | |
| 201 | switch(k) { |
| 202 | case 0x03 : |
| 203 | puts ("MPC823"); |
| 204 | break; |
| 205 | case 0x20 : |
| 206 | puts ("MPC801"); |
| 207 | break; |
| 208 | case 0x21 : |
| 209 | puts ("MPC850"); |
| 210 | break; |
| 211 | case 0x22 : |
| 212 | puts ("MPC821, MPC860 / MPC860SAR / MPC860T"); |
| 213 | break; |
| 214 | case 0x23 : |
| 215 | puts ("MPC860SAR"); |
| 216 | break; |
| 217 | case 0x24 : |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 218 | case 0x2A : |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 219 | puts ("MPC860T"); |
| 220 | break; |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 221 | case 0x3F : |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 222 | puts ("MPC850SAR"); |
| 223 | break; |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 224 | default : printf("0x%x", k); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 225 | } |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 226 | } |
| 227 | #endif /* defined(CONFIG_FADS) && !defined(CONFIG_MPC86xADS) */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 228 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 229 | int checkboard (void) |
| 230 | { |
| 231 | /* get revision from BCSR 3 */ |
| 232 | uint r = (((*((uint *) BCSR3) >> 23) & 1) << 3) |
| 233 | | (((*((uint *) BCSR3) >> 19) & 1) << 2) |
| 234 | | (((*((uint *) BCSR3) >> 16) & 3)); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 235 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 236 | puts ("Board: "); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 237 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 238 | #ifdef CONFIG_FADS |
| 239 | # ifdef CONFIG_MPC86xADS |
| 240 | puts ("MPC86xADS"); |
| 241 | # else |
| 242 | puts ("FADS"); |
| 243 | checkdboard (); |
| 244 | # endif /* !CONFIG_MPC86xADS */ |
| 245 | printf (" rev "); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 246 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 247 | switch (r) { |
| 248 | case 0x00: |
| 249 | puts ("ENG\n"); |
| 250 | break; |
| 251 | case 0x01: |
| 252 | puts ("PILOT\n"); |
| 253 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 254 | default: |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 255 | printf ("unknown (0x%x)\n", r); |
| 256 | return (-1); |
| 257 | } |
| 258 | #endif /* CONFIG_FADS */ |
| 259 | |
| 260 | #ifdef CONFIG_ADS |
| 261 | printf ("ADS rev "); |
| 262 | |
| 263 | switch (r) { |
| 264 | case 0x00: |
| 265 | puts ("ENG - this board sucks, check the errata, not supported\n"); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 266 | return -1; |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 267 | case 0x01: |
| 268 | puts ("PILOT - warning, read errata \n"); |
| 269 | break; |
| 270 | case 0x02: |
| 271 | puts ("A - warning, read errata \n"); |
| 272 | break; |
| 273 | case 0x03: |
| 274 | puts ("B \n"); |
| 275 | break; |
| 276 | default: |
| 277 | printf ("unknown revision (0x%x)\n", r); |
| 278 | return (-1); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 279 | } |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 280 | #endif /* CONFIG_ADS */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 281 | |
| 282 | return 0; |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 283 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 284 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 285 | /* ------------------------------------------------------------------------- */ |
| 286 | static long int dram_size (long int *base, long int maxsize) |
| 287 | { |
| 288 | volatile long int *addr=base; |
| 289 | ulong cnt, val; |
| 290 | ulong save[32]; /* to make test non-destructive */ |
| 291 | unsigned char i = 0; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 292 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 293 | for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) { |
| 294 | addr = base + cnt; /* pointer arith! */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 295 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 296 | save[i++] = *addr; |
| 297 | *addr = ~cnt; |
| 298 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 299 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 300 | /* write 0 to base address */ |
| 301 | addr = base; |
| 302 | save[i] = *addr; |
| 303 | *addr = 0; |
| 304 | |
| 305 | /* check at base address */ |
| 306 | if ((val = *addr) != 0) { |
| 307 | *addr = save[i]; |
| 308 | return (0); |
| 309 | } |
| 310 | |
| 311 | for (cnt = 1; cnt <= maxsize / sizeof (long); cnt <<= 1) { |
| 312 | addr = base + cnt; /* pointer arith! */ |
| 313 | |
| 314 | val = *addr; |
| 315 | *addr = save[--i]; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 316 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 317 | if (val != (~cnt)) { |
| 318 | return (cnt * sizeof (long)); |
| 319 | } |
| 320 | } |
| 321 | return (maxsize); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | /* ------------------------------------------------------------------------- */ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 325 | static int _draminit (uint base, uint noMbytes, uint edo, uint delay) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 326 | { |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 327 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 328 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 329 | |
| 330 | /* init upm */ |
| 331 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 332 | switch (delay) { |
| 333 | case 70: |
| 334 | if (edo) { |
| 335 | upmconfig (UPMA, (uint *) edo_70ns, |
| 336 | sizeof (edo_70ns) / sizeof (uint)); |
| 337 | } else { |
| 338 | upmconfig (UPMA, (uint *) dram_70ns, |
| 339 | sizeof (dram_70ns) / sizeof (uint)); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 340 | } |
| 341 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 342 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 343 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 344 | case 60: |
| 345 | if (edo) { |
| 346 | upmconfig (UPMA, (uint *) edo_60ns, |
| 347 | sizeof (edo_60ns) / sizeof (uint)); |
| 348 | } else { |
| 349 | upmconfig (UPMA, (uint *) dram_60ns, |
| 350 | sizeof (dram_60ns) / sizeof (uint)); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 351 | } |
| 352 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 353 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 354 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 355 | default: |
| 356 | return -1; |
| 357 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 358 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 359 | memctl->memc_mptpr = 0x0400; /* divide by 16 */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 360 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 361 | switch (noMbytes) { |
| 362 | case 4: /* 4 Mbyte uses only CS2 */ |
wdenk | 444f22b | 2003-12-07 21:39:28 +0000 | [diff] [blame^] | 363 | #ifdef CONFIG_ADS |
| 364 | memctl->memc_mamr = 0xc0a21114; |
| 365 | #else |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 366 | memctl->memc_mamr = 0x13a01114; /* PTA 0x13 AMA 010 */ |
wdenk | 444f22b | 2003-12-07 21:39:28 +0000 | [diff] [blame^] | 367 | #endif |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 368 | memctl->memc_or2 = 0xffc00800; /* 4M */ |
| 369 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 370 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 371 | case 8: /* 8 Mbyte uses both CS3 and CS2 */ |
| 372 | memctl->memc_mamr = 0x13a01114; /* PTA 0x13 AMA 010 */ |
| 373 | memctl->memc_or3 = 0xffc00800; /* 4M */ |
| 374 | memctl->memc_br3 = 0x00400081 + base; |
| 375 | memctl->memc_or2 = 0xffc00800; /* 4M */ |
| 376 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 377 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 378 | case 16: /* 16 Mbyte uses only CS2 */ |
| 379 | #ifdef CONFIG_ADS /* XXX: why PTA=0x60 only in 16M case? - NTL */ |
| 380 | memctl->memc_mamr = 0x60b21114; /* PTA 0x60 AMA 011 */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 381 | #else |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 382 | memctl->memc_mamr = 0x13b01114; /* PTA 0x13 AMA 011 */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 383 | #endif |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 384 | memctl->memc_or2 = 0xff000800; /* 16M */ |
| 385 | break; |
| 386 | |
| 387 | case 32: /* 32 Mbyte uses both CS3 and CS2 */ |
| 388 | memctl->memc_mamr = 0x13b01114; /* PTA 0x13 AMA 011 */ |
| 389 | memctl->memc_or3 = 0xff000800; /* 16M */ |
| 390 | memctl->memc_br3 = 0x01000081 + base; |
| 391 | memctl->memc_or2 = 0xff000800; /* 16M */ |
| 392 | break; |
| 393 | |
| 394 | default: |
| 395 | return -1; |
| 396 | } |
| 397 | |
| 398 | memctl->memc_br2 = 0x81 + base; /* use upma */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 399 | |
wdenk | 444f22b | 2003-12-07 21:39:28 +0000 | [diff] [blame^] | 400 | *((uint *) BCSR1) &= ~BCSR1_DRAM_EN; /* enable dram */ |
| 401 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 402 | /* if no dimm is inserted, noMbytes is still detected as 8m, so |
| 403 | * sanity check top and bottom of memory */ |
| 404 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 405 | /* check bytes / 2 because dram_size tests at base+bytes, which |
| 406 | * is not mapped */ |
wdenk | 444f22b | 2003-12-07 21:39:28 +0000 | [diff] [blame^] | 407 | if (noMbytes == 8) |
| 408 | if (dram_size ((long *) base, noMbytes << 19) != noMbytes << 19) { |
| 409 | *((uint *) BCSR1) |= BCSR1_DRAM_EN; /* disable dram */ |
| 410 | return -1; |
| 411 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 412 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 413 | return 0; |
| 414 | } |
| 415 | |
| 416 | /* ------------------------------------------------------------------------- */ |
| 417 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 418 | static void _dramdisable(void) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 419 | { |
| 420 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 421 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 422 | |
| 423 | memctl->memc_br2 = 0x00000000; |
| 424 | memctl->memc_br3 = 0x00000000; |
| 425 | |
| 426 | /* maybe we should turn off upma here or something */ |
| 427 | } |
| 428 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 429 | #ifdef CONFIG_FADS |
| 430 | /* SDRAM SUPPORT (FADS ONLY) */ |
| 431 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 432 | #if defined(CONFIG_SDRAM_100MHZ) |
| 433 | |
| 434 | /* ------------------------------------------------------------------------- */ |
| 435 | /* sdram table by Dan Malek */ |
| 436 | |
| 437 | /* This has the stretched early timing so the 50 MHz |
| 438 | * processor can make the 100 MHz timing. This will |
| 439 | * work at all processor speeds. |
| 440 | */ |
| 441 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 442 | #ifdef SDRAM_ALT_INIT_SEQENCE |
| 443 | # define SDRAM_MBMRVALUE0 0xc3802114 /* PTx=195,PTxE,AMx=0,DSx=1,A11,RLFx=1,WLFx=1,TLFx=4 */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 444 | #define SDRAM_MBMRVALUE1 SDRAM_MBMRVALUE0 |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 445 | # define SDRAM_MCRVALUE0 0x80808111 /* run upmb cs4 loop 1 addr 0x11 MRS */ |
| 446 | # define SDRAM_MCRVALUE1 SDRAM_MCRVALUE0 /* ??? why not 0x80808130? */ |
| 447 | #else |
| 448 | # define SDRAM_MxMR_PTx 195 |
| 449 | # define UPM_MRS_ADDR 0x11 |
| 450 | # define UPM_REFRESH_ADDR 0x30 /* or 0x11 if we want to be like above? */ |
| 451 | #endif /* !SDRAM_ALT_INIT_SEQUENCE */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 452 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 453 | static const uint sdram_table[] = |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 454 | { |
| 455 | /* single read. (offset 0 in upm RAM) */ |
| 456 | 0xefebfc24, 0x1f07fc24, 0xeeaefc04, 0x11adfc04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 457 | 0xefbbbc00, 0x1ff77c45, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 458 | |
| 459 | /* burst read. (offset 8 in upm RAM) */ |
| 460 | 0xefebfc24, 0x1f07fc24, 0xeeaefc04, 0x10adfc04, |
| 461 | 0xf0affc00, 0xf0affc00, 0xf1affc00, 0xefbbbc00, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 462 | 0x1ff77c45, |
| 463 | |
| 464 | /* precharge + MRS. (offset 11 in upm RAM) */ |
| 465 | 0xeffbbc04, 0x1ff77c34, 0xefeabc34, |
| 466 | 0x1fb57c35, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 467 | |
| 468 | /* single write. (offset 18 in upm RAM) */ |
| 469 | 0xefebfc24, 0x1f07fc24, 0xeeaebc00, 0x01b93c04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 470 | 0x1ff77c45, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 471 | |
| 472 | /* burst write. (offset 20 in upm RAM) */ |
| 473 | 0xefebfc24, 0x1f07fc24, 0xeeaebc00, 0x10ad7c00, |
| 474 | 0xf0affc00, 0xf0affc00, 0xe1bbbc04, 0x1ff77c45, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 475 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 476 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 477 | |
| 478 | /* refresh. (offset 30 in upm RAM) */ |
| 479 | 0xeffafc84, 0x1ff5fc04, 0xfffffc04, 0xfffffc04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 480 | 0xfffffc84, 0xfffffc07, _NOT_USED_, _NOT_USED_, |
| 481 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 482 | |
| 483 | /* exception. (offset 3c in upm RAM) */ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 484 | 0xeffffc06, 0x1ffffc07, _NOT_USED_, _NOT_USED_ }; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 485 | |
| 486 | #elif defined(CONFIG_SDRAM_50MHZ) |
| 487 | |
| 488 | /* ------------------------------------------------------------------------- */ |
| 489 | /* sdram table stolen from the fads manual */ |
| 490 | /* for chip MB811171622A-100 */ |
| 491 | |
| 492 | /* this table is for 32-50MHz operation */ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 493 | #ifdef SDRAM_ALT_INIT_SEQENCE |
| 494 | # define SDRAM_MBMRVALUE0 0x80802114 /* PTx=128,PTxE,AMx=0,DSx=1,A11,RLFx=1,WLFx=1,TLFx=4 */ |
| 495 | # define SDRAM_MBMRVALUE1 0x80802118 /* PTx=128,PTxE,AMx=0,DSx=1,A11,RLFx=1,WLFx=1,TLFx=8 */ |
| 496 | # define SDRAM_MCRVALUE0 0x80808105 /* run upmb cs4 loop 1 addr 0x5 MRS */ |
| 497 | # define SDRAM_MCRVALUE1 0x80808130 /* run upmb cs4 loop 1 addr 0x30 REFRESH */ |
| 498 | # define SDRAM_MPTRVALUE 0x400 |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 499 | #define SDRAM_MARVALUE 0x88 |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 500 | #else |
| 501 | # define SDRAM_MxMR_PTx 128 |
| 502 | # define UPM_MRS_ADDR 0x5 |
| 503 | # define UPM_REFRESH_ADDR 0x30 |
| 504 | #endif /* !SDRAM_ALT_INIT_SEQUENCE */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 505 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 506 | static const uint sdram_table[] = |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 507 | { |
| 508 | /* single read. (offset 0 in upm RAM) */ |
| 509 | 0x1f07fc04, 0xeeaefc04, 0x11adfc04, 0xefbbbc00, |
| 510 | 0x1ff77c47, |
| 511 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 512 | /* precharge + MRS. (offset 5 in upm RAM) */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 513 | 0x1ff77c34, 0xefeabc34, 0x1fb57c35, |
| 514 | |
| 515 | /* burst read. (offset 8 in upm RAM) */ |
| 516 | 0x1f07fc04, 0xeeaefc04, 0x10adfc04, 0xf0affc00, |
| 517 | 0xf0affc00, 0xf1affc00, 0xefbbbc00, 0x1ff77c47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 518 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 519 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 520 | |
| 521 | /* single write. (offset 18 in upm RAM) */ |
| 522 | 0x1f27fc04, 0xeeaebc00, 0x01b93c04, 0x1ff77c47, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 523 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 524 | |
| 525 | /* burst write. (offset 20 in upm RAM) */ |
| 526 | 0x1f07fc04, 0xeeaebc00, 0x10ad7c00, 0xf0affc00, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 527 | 0xf0affc00, 0xe1bbbc04, 0x1ff77c47, _NOT_USED_, |
| 528 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 529 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 530 | |
| 531 | /* refresh. (offset 30 in upm RAM) */ |
| 532 | 0x1ff5fc84, 0xfffffc04, 0xfffffc04, 0xfffffc04, |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 533 | 0xfffffc84, 0xfffffc07, _NOT_USED_, _NOT_USED_, |
| 534 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 535 | |
| 536 | /* exception. (offset 3c in upm RAM) */ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 537 | 0x7ffffc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ }; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 538 | |
| 539 | /* ------------------------------------------------------------------------- */ |
| 540 | #else |
| 541 | #error SDRAM not correctly configured |
| 542 | #endif |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 543 | /* ------------------------------------------------------------------------- */ |
| 544 | |
| 545 | /* |
| 546 | * Memory Periodic Timer Prescaler |
| 547 | */ |
| 548 | |
| 549 | #define SDRAM_OR4VALUE 0x00000a00 /* SAM,GL5A/S=01,addr mask or'ed on later */ |
| 550 | #define SDRAM_BR4VALUE 0x000000c1 /* UPMB,base addr or'ed on later */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 551 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 552 | /* ------------------------------------------------------------------------- */ |
| 553 | #ifdef SDRAM_ALT_INIT_SEQENCE |
| 554 | /* ------------------------------------------------------------------------- */ |
| 555 | |
| 556 | static int _initsdram(uint base, uint noMbytes) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 557 | { |
| 558 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 559 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 560 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 561 | upmconfig(UPMB, (uint *)sdram_table,sizeof(sdram_table)/sizeof(uint)); |
| 562 | |
| 563 | memctl->memc_mptpr = SDRAM_MPTPRVALUE; |
| 564 | |
| 565 | /* Configure the refresh (mostly). This needs to be |
| 566 | * based upon processor clock speed and optimized to provide |
| 567 | * the highest level of performance. For multiple banks, |
| 568 | * this time has to be divided by the number of banks. |
| 569 | * Although it is not clear anywhere, it appears the |
| 570 | * refresh steps through the chip selects for this UPM |
| 571 | * on each refresh cycle. |
| 572 | * We have to be careful changing |
| 573 | * UPM registers after we ask it to run these commands. |
| 574 | */ |
| 575 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 576 | memctl->memc_mbmr = SDRAM_MBMRVALUE0; /* TLF 4 */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 577 | memctl->memc_mar = SDRAM_MARVALUE; /* MRS code */ |
| 578 | |
| 579 | udelay(200); |
| 580 | |
| 581 | /* Now run the precharge/nop/mrs commands. |
| 582 | */ |
| 583 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 584 | memctl->memc_mcr = 0x80808111; /* run umpb cs4 1 count 1, addr 0x11 ??? (50Mhz) */ |
| 585 | /* run umpb cs4 1 count 1, addr 0x11 precharge+MRS (100Mhz) */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 586 | udelay(200); |
| 587 | |
| 588 | /* Run 8 refresh cycles */ |
| 589 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 590 | memctl->memc_mcr = SDRAM_MCRVALUE0; /* run upmb cs4 loop 1 addr 0x5 precharge+MRS (50 Mhz)*/ |
| 591 | /* run upmb cs4 loop 1 addr 0x11 precharge+MRS (100MHz) */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 592 | |
| 593 | udelay(200); |
| 594 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 595 | memctl->memc_mbmr = SDRAM_MBMRVALUE1; /* TLF 4 (100 Mhz) or TLF 8 (50MHz) */ |
| 596 | memctl->memc_mcr = SDRAM_MCRVALUE1; /* run upmb cs4 loop 1 addr 0x30 refr (50 Mhz) */ |
| 597 | /* run upmb cs4 loop 1 addr 0x11 precharge+MRS ??? (100MHz) */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 598 | |
| 599 | udelay(200); |
| 600 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 601 | memctl->memc_mbmr = SDRAM_MBMRVALUE0; /* TLF 4 */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 602 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 603 | memctl->memc_or4 = SDRAM_OR4VALUE | ~((noMbytes<<20)-1); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 604 | memctl->memc_br4 = SDRAM_BR4VALUE | base; |
| 605 | |
| 606 | return 0; |
| 607 | } |
| 608 | |
| 609 | /* ------------------------------------------------------------------------- */ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 610 | #else /* !SDRAM_ALT_INIT_SEQUENCE */ |
| 611 | /* ------------------------------------------------------------------------- */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 612 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 613 | /* refresh rate 15.6 us (= 64 ms / 4K = 62.4 / quad bursts) for <= 128 MBit */ |
| 614 | # define MPTPR_2BK_4K MPTPR_PTP_DIV16 /* setting for 2 banks */ |
| 615 | # define MPTPR_1BK_4K MPTPR_PTP_DIV32 /* setting for 1 bank */ |
| 616 | |
| 617 | /* refresh rate 7.8 us (= 64 ms / 8K = 31.2 / quad bursts) for 256 MBit */ |
| 618 | # define MPTPR_2BK_8K MPTPR_PTP_DIV8 /* setting for 2 banks */ |
| 619 | # define MPTPR_1BK_8K MPTPR_PTP_DIV16 /* setting for 1 bank */ |
| 620 | |
| 621 | /* |
| 622 | * MxMR settings for SDRAM |
| 623 | */ |
| 624 | |
| 625 | /* 8 column SDRAM */ |
| 626 | # define SDRAM_MxMR_8COL ((SDRAM_MxMR_PTx << MBMR_PTB_SHIFT) | MBMR_PTBE | \ |
| 627 | MBMR_AMB_TYPE_0 | MBMR_DSB_1_CYCL | MBMR_G0CLB_A11 | \ |
| 628 | MBMR_RLFB_1X | MBMR_WLFB_1X | MBMR_TLFB_4X) |
| 629 | /* 9 column SDRAM */ |
| 630 | # define SDRAM_MxMR_9COL ((SDRAM_MxMR_PTx << MBMR_PTB_SHIFT) | MBMR_PTAE | \ |
| 631 | MBMR_AMB_TYPE_1 | MBMR_DSB_1_CYCL | MBMR_G0CLB_A10 | \ |
| 632 | MBMR_RLFB_1X | MBMR_WLFB_1X | MBMR_TLFB_4X) |
| 633 | |
| 634 | static int _initsdram(uint base, uint noMbytes) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 635 | { |
| 636 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 637 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 638 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 639 | upmconfig(UPMB, (uint *)sdram_table,sizeof(sdram_table)/sizeof(uint)); |
| 640 | |
| 641 | memctl->memc_mptpr = MPTPR_2BK_4K; |
| 642 | memctl->memc_mbmr = SDRAM_MxMR_8COL & (~(MBMR_PTBE)); /* no refresh yet */ |
| 643 | |
| 644 | /* map CS 4 */ |
| 645 | memctl->memc_or4 = SDRAM_OR4VALUE | ~((noMbytes<<20)-1); |
| 646 | memctl->memc_br4 = SDRAM_BR4VALUE | base; |
| 647 | |
| 648 | /* Perform SDRAM initilization */ |
| 649 | # ifdef UPM_NOP_ADDR /* not currently in UPM table */ |
| 650 | /* step 1: nop */ |
| 651 | memctl->memc_mar = 0x00000000; |
| 652 | memctl->memc_mcr = MCR_UPM_B | MCR_OP_RUN | MCR_MB_CS4 | |
| 653 | MCR_MLCF(0) | UPM_NOP_ADDR; |
| 654 | # endif |
| 655 | |
| 656 | /* step 2: delay */ |
| 657 | udelay(200); |
| 658 | |
| 659 | # ifdef UPM_PRECHARGE_ADDR /* merged with MRS in UPM table */ |
| 660 | /* step 3: precharge */ |
| 661 | memctl->memc_mar = 0x00000000; |
| 662 | memctl->memc_mcr = MCR_UPM_B | MCR_OP_RUN | MCR_MB_CS4 | |
| 663 | MCR_MLCF(4) | UPM_PRECHARGE_ADDR; |
| 664 | # endif |
| 665 | |
| 666 | /* step 4: refresh */ |
| 667 | memctl->memc_mar = 0x00000000; |
| 668 | memctl->memc_mcr = MCR_UPM_B | MCR_OP_RUN | MCR_MB_CS4 | |
| 669 | MCR_MLCF(2) | UPM_REFRESH_ADDR; |
| 670 | |
| 671 | /* |
| 672 | * note: for some reason, the UPM values we are using include |
| 673 | * precharge with MRS |
| 674 | */ |
| 675 | |
| 676 | /* step 5: mrs */ |
| 677 | memctl->memc_mar = 0x00000088; |
| 678 | memctl->memc_mcr = MCR_UPM_B | MCR_OP_RUN | MCR_MB_CS4 | |
| 679 | MCR_MLCF(1) | UPM_MRS_ADDR; |
| 680 | |
| 681 | # ifdef UPM_NOP_ADDR |
| 682 | memctl->memc_mar = 0x00000000; |
| 683 | memctl->memc_mcr = MCR_UPM_B | MCR_OP_RUN | MCR_MB_CS4 | |
| 684 | MCR_MLCF(0) | UPM_NOP_ADDR; |
| 685 | # endif |
| 686 | /* |
| 687 | * Enable refresh |
| 688 | */ |
| 689 | |
| 690 | memctl->memc_mbmr |= MBMR_PTBE; |
| 691 | return 0; |
| 692 | } |
| 693 | #endif /* !SDRAM_ALT_INIT_SEQUENCE */ |
| 694 | |
| 695 | /* ------------------------------------------------------------------------- */ |
| 696 | |
| 697 | static void _sdramdisable(void) |
| 698 | { |
| 699 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 700 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 701 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 702 | memctl->memc_br4 = 0x00000000; |
| 703 | |
| 704 | /* maybe we should turn off upmb here or something */ |
| 705 | } |
| 706 | |
| 707 | /* ------------------------------------------------------------------------- */ |
| 708 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 709 | static int initsdram(uint base, uint *noMbytes) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 710 | { |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 711 | uint m = CFG_SDRAM_SIZE>>20; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 712 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 713 | /* _initsdram needs access to sdram */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 714 | *((uint *)BCSR1) |= BCSR1_SDRAM_EN; /* enable sdram */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 715 | |
| 716 | if(!_initsdram(base, m)) |
| 717 | { |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 718 | *noMbytes += m; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 719 | return 0; |
| 720 | } |
| 721 | else |
| 722 | { |
| 723 | *((uint *)BCSR1) &= ~BCSR1_SDRAM_EN; /* disable sdram */ |
| 724 | |
| 725 | _sdramdisable(); |
| 726 | |
| 727 | return -1; |
| 728 | } |
| 729 | } |
| 730 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 731 | /* SDRAM SUPPORT (FADS ONLY) */ |
| 732 | #endif /* CONFIG_FADS */ |
| 733 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 734 | long int initdram (int board_type) |
| 735 | { |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 736 | uint sdramsz = 0; /* size of sdram in Mbytes */ |
| 737 | uint base = 0; /* base of dram in bytes */ |
| 738 | uint m = 0; /* size of dram in Mbytes */ |
| 739 | uint k, s; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 740 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 741 | #ifdef CONFIG_FADS |
| 742 | if (!initsdram (0x00000000, &sdramsz)) { |
| 743 | base = sdramsz << 20; |
| 744 | printf ("(%u MB SDRAM) ", sdramsz); |
| 745 | } |
| 746 | #endif |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 747 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 748 | k = (*((uint *) BCSR2) >> 23) & 0x0f; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 749 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 750 | switch (k & 0x3) { |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 751 | /* "MCM36100 / MT8D132X" */ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 752 | case 0x00: |
| 753 | m = 4; |
| 754 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 755 | |
| 756 | /* "MCM36800 / MT16D832X" */ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 757 | case 0x01: |
| 758 | m = 32; |
| 759 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 760 | /* "MCM36400 / MT8D432X" */ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 761 | case 0x02: |
| 762 | m = 16; |
| 763 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 764 | /* "MCM36200 / MT16D832X ?" */ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 765 | case 0x03: |
| 766 | m = 8; |
| 767 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 768 | |
| 769 | } |
| 770 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 771 | switch (k >> 2) { |
| 772 | case 0x02: |
| 773 | k = 70; |
| 774 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 775 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 776 | case 0x03: |
| 777 | k = 60; |
| 778 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 779 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 780 | default: |
| 781 | printf ("unknown dramdelay (0x%x) - defaulting to 70 ns", k); |
| 782 | k = 70; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | #ifdef CONFIG_FADS |
| 786 | /* the FADS is missing this bit, all rams treated as non-edo */ |
| 787 | s = 0; |
| 788 | #else |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 789 | s = (*((uint *) BCSR2) >> 27) & 0x01; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 790 | #endif |
| 791 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 792 | if (!_draminit (base, m, s, k)) { |
| 793 | printf ("%dM %dns %sDRAM: ", m, k, s ? "EDO " : ""); |
| 794 | } else { |
| 795 | _dramdisable (); |
| 796 | m = 0; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 797 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 798 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 799 | m += sdramsz; /* add sdram size to total */ |
| 800 | |
| 801 | if (!m) { |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 802 | /******************************** |
| 803 | *DRAM ERROR, HALT PROCESSOR |
| 804 | *********************************/ |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 805 | while (1); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 806 | return -1; |
| 807 | } |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 808 | |
| 809 | return (m << 20); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 810 | } |
| 811 | |
| 812 | /* ------------------------------------------------------------------------- */ |
| 813 | |
| 814 | int testdram (void) |
| 815 | { |
| 816 | /* TODO: XXX XXX XXX */ |
| 817 | printf ("test: 16 MB - ok\n"); |
| 818 | |
| 819 | return (0); |
| 820 | } |
| 821 | |
| 822 | |
| 823 | #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) |
| 824 | |
| 825 | #ifdef CFG_PCMCIA_MEM_ADDR |
| 826 | volatile unsigned char *pcmcia_mem = (unsigned char*)CFG_PCMCIA_MEM_ADDR; |
| 827 | #endif |
| 828 | |
| 829 | int pcmcia_init(void) |
| 830 | { |
| 831 | volatile pcmconf8xx_t *pcmp; |
| 832 | uint v, slota, slotb; |
| 833 | |
| 834 | /* |
| 835 | ** Enable the PCMCIA for a Flash card. |
| 836 | */ |
| 837 | pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia)); |
| 838 | |
| 839 | #if 0 |
| 840 | pcmp->pcmc_pbr0 = CFG_PCMCIA_MEM_ADDR; |
| 841 | pcmp->pcmc_por0 = 0xc00ff05d; |
| 842 | #endif |
| 843 | |
| 844 | /* Set all slots to zero by default. */ |
| 845 | pcmp->pcmc_pgcra = 0; |
| 846 | pcmp->pcmc_pgcrb = 0; |
| 847 | #ifdef PCMCIA_SLOT_A |
| 848 | pcmp->pcmc_pgcra = 0x40; |
| 849 | #endif |
| 850 | #ifdef PCMCIA_SLOT_B |
| 851 | pcmp->pcmc_pgcrb = 0x40; |
| 852 | #endif |
| 853 | |
| 854 | /* enable PCMCIA buffers */ |
| 855 | *((uint *)BCSR1) &= ~BCSR1_PCCEN; |
| 856 | |
| 857 | /* Check if any PCMCIA card is plugged in. */ |
| 858 | |
| 859 | slota = (pcmp->pcmc_pipr & 0x18000000) == 0 ; |
| 860 | slotb = (pcmp->pcmc_pipr & 0x00001800) == 0 ; |
| 861 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 862 | if (!(slota || slotb)) { |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 863 | printf("No card present\n"); |
| 864 | #ifdef PCMCIA_SLOT_A |
| 865 | pcmp->pcmc_pgcra = 0; |
| 866 | #endif |
| 867 | #ifdef PCMCIA_SLOT_B |
| 868 | pcmp->pcmc_pgcrb = 0; |
| 869 | #endif |
| 870 | return -1; |
| 871 | } |
| 872 | else |
| 873 | printf("Card present ("); |
| 874 | |
| 875 | v = 0; |
| 876 | |
| 877 | /* both the ADS and the FADS have a 5V keyed pcmcia connector (?) |
| 878 | ** |
| 879 | ** Paolo - Yes, but i have to insert some 3.3V card in that slot on |
| 880 | ** my FADS... :-) |
| 881 | */ |
| 882 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 883 | #if defined(CONFIG_MPC86x) |
| 884 | switch ((pcmp->pcmc_pipr >> 30) & 3) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 885 | #elif defined(CONFIG_MPC823) || defined(CONFIG_MPC850) |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 886 | switch ((pcmp->pcmc_pipr >> 14) & 3) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 887 | #endif |
| 888 | { |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 889 | case 0x00 : |
| 890 | printf("5V"); |
| 891 | v = 5; |
| 892 | break; |
| 893 | case 0x01 : |
| 894 | printf("5V and 3V"); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 895 | #ifdef CONFIG_FADS |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 896 | v = 3; /* User lower voltage if supported! */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 897 | #else |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 898 | v = 5; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 899 | #endif |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 900 | break; |
| 901 | case 0x03 : |
| 902 | printf("5V, 3V and x.xV"); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 903 | #ifdef CONFIG_FADS |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 904 | v = 3; /* User lower voltage if supported! */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 905 | #else |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 906 | v = 5; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 907 | #endif |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 908 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 909 | } |
| 910 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 911 | switch (v) { |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 912 | #ifdef CONFIG_FADS |
| 913 | case 3: |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 914 | printf("; using 3V"); |
| 915 | /* |
| 916 | ** Enable 3 volt Vcc. |
| 917 | */ |
| 918 | *((uint *)BCSR1) &= ~BCSR1_PCCVCC1; |
| 919 | *((uint *)BCSR1) |= BCSR1_PCCVCC0; |
| 920 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 921 | #endif |
| 922 | case 5: |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 923 | printf("; using 5V"); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 924 | #ifdef CONFIG_ADS |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 925 | /* |
| 926 | ** Enable 5 volt Vcc. |
| 927 | */ |
| 928 | *((uint *)BCSR1) &= ~BCSR1_PCCVCCON; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 929 | #endif |
| 930 | #ifdef CONFIG_FADS |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 931 | /* |
| 932 | ** Enable 5 volt Vcc. |
| 933 | */ |
| 934 | *((uint *)BCSR1) &= ~BCSR1_PCCVCC0; |
| 935 | *((uint *)BCSR1) |= BCSR1_PCCVCC1; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 936 | #endif |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 937 | break; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 938 | |
| 939 | default: |
| 940 | *((uint *)BCSR1) |= BCSR1_PCCEN; /* disable pcmcia */ |
| 941 | |
| 942 | printf("; unknown voltage"); |
| 943 | return -1; |
| 944 | } |
| 945 | printf(")\n"); |
| 946 | /* disable pcmcia reset after a while */ |
| 947 | |
| 948 | udelay(20); |
| 949 | |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 950 | #ifdef PCMCIA_SLOT_A |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 951 | pcmp->pcmc_pgcra = 0; |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 952 | #elif PCMCIA_SLOT_B |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 953 | pcmp->pcmc_pgcrb = 0; |
| 954 | #endif |
| 955 | |
| 956 | /* If you using a real hd you should give a short |
| 957 | * spin-up time. */ |
| 958 | #ifdef CONFIG_DISK_SPINUP_TIME |
| 959 | udelay(CONFIG_DISK_SPINUP_TIME); |
| 960 | #endif |
| 961 | |
| 962 | return 0; |
| 963 | } |
| 964 | |
| 965 | #endif /* CFG_CMD_PCMCIA */ |
| 966 | |
| 967 | /* ------------------------------------------------------------------------- */ |
| 968 | |
| 969 | #ifdef CFG_PC_IDE_RESET |
| 970 | |
| 971 | void ide_set_reset(int on) |
| 972 | { |
| 973 | volatile immap_t *immr = (immap_t *)CFG_IMMR; |
| 974 | |
| 975 | /* |
| 976 | * Configure PC for IDE Reset Pin |
| 977 | */ |
| 978 | if (on) { /* assert RESET */ |
| 979 | immr->im_ioport.iop_pcdat &= ~(CFG_PC_IDE_RESET); |
| 980 | } else { /* release RESET */ |
| 981 | immr->im_ioport.iop_pcdat |= CFG_PC_IDE_RESET; |
| 982 | } |
| 983 | |
| 984 | /* program port pin as GPIO output */ |
| 985 | immr->im_ioport.iop_pcpar &= ~(CFG_PC_IDE_RESET); |
| 986 | immr->im_ioport.iop_pcso &= ~(CFG_PC_IDE_RESET); |
| 987 | immr->im_ioport.iop_pcdir |= CFG_PC_IDE_RESET; |
| 988 | } |
| 989 | |
| 990 | #endif /* CFG_PC_IDE_RESET */ |
| 991 | /* ------------------------------------------------------------------------- */ |