wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 5 | * (C) Copyright 2004 |
| 6 | * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com. |
| 7 | * |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 8 | * See file CREDITS for list of people who contributed to this |
| 9 | * project. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <common.h> |
| 28 | #include <mpc5xxx.h> |
wdenk | 0237902 | 2003-08-05 18:22:44 +0000 | [diff] [blame] | 29 | #include <pci.h> |
Rafal Jaworowski | 0b892e8 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 30 | #include <asm/processor.h> |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 31 | |
Stefan Roese | fb34787 | 2006-11-28 17:55:49 +0100 | [diff] [blame] | 32 | #if defined(CONFIG_OF_FLAT_TREE) |
| 33 | #include <ft_build.h> |
| 34 | #endif |
| 35 | |
Wolfgang Denk | 315b46a | 2006-03-17 11:42:53 +0100 | [diff] [blame] | 36 | #if defined(CONFIG_LITE5200B) |
| 37 | #include "mt46v32m16.h" |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 38 | #else |
Wolfgang Denk | 315b46a | 2006-03-17 11:42:53 +0100 | [diff] [blame] | 39 | # if defined(CONFIG_MPC5200_DDR) |
| 40 | # include "mt46v16m16-75.h" |
| 41 | # else |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 42 | #include "mt48lc16m16a2-75.h" |
Wolfgang Denk | 315b46a | 2006-03-17 11:42:53 +0100 | [diff] [blame] | 43 | # endif |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 44 | #endif |
wdenk | b10ba6b | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 45 | #ifndef CFG_RAMBOOT |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 46 | static void sdram_start (int hi_addr) |
| 47 | { |
| 48 | long hi_addr_bit = hi_addr ? 0x01000000 : 0; |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 49 | |
wdenk | 236d3fc | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 50 | /* unlock mode register */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 51 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit; |
| 52 | __asm__ volatile ("sync"); |
wdenk | 20c98a6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 53 | |
wdenk | 236d3fc | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 54 | /* precharge all banks */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 55 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit; |
| 56 | __asm__ volatile ("sync"); |
| 57 | |
| 58 | #if SDRAM_DDR |
wdenk | 236d3fc | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 59 | /* set mode register: extended mode */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 60 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE; |
| 61 | __asm__ volatile ("sync"); |
| 62 | |
wdenk | 236d3fc | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 63 | /* set mode register: reset DLL */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 64 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000; |
| 65 | __asm__ volatile ("sync"); |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 66 | #endif |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 67 | |
| 68 | /* precharge all banks */ |
| 69 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit; |
| 70 | __asm__ volatile ("sync"); |
| 71 | |
wdenk | 0e2874cb | 2004-03-02 14:05:39 +0000 | [diff] [blame] | 72 | /* auto refresh */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 73 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | hi_addr_bit; |
| 74 | __asm__ volatile ("sync"); |
| 75 | |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 76 | /* set mode register */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 77 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE; |
| 78 | __asm__ volatile ("sync"); |
wdenk | 20c98a6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 79 | |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 80 | /* normal operation */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 81 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit; |
| 82 | __asm__ volatile ("sync"); |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 83 | } |
wdenk | b10ba6b | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 84 | #endif |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 85 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 86 | /* |
| 87 | * ATTENTION: Although partially referenced initdram does NOT make real use |
| 88 | * use of CFG_SDRAM_BASE. The code does not work if CFG_SDRAM_BASE |
| 89 | * is something else than 0x00000000. |
| 90 | */ |
| 91 | |
| 92 | #if defined(CONFIG_MPC5200) |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 93 | long int initdram (int board_type) |
| 94 | { |
wdenk | b10ba6b | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 95 | ulong dramsize = 0; |
wdenk | 236d3fc | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 96 | ulong dramsize2 = 0; |
Rafal Jaworowski | 0b892e8 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 97 | uint svr, pvr; |
| 98 | |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 99 | #ifndef CFG_RAMBOOT |
wdenk | b10ba6b | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 100 | ulong test1, test2; |
wdenk | 20c98a6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 101 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 102 | /* setup SDRAM chip selects */ |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 103 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;/* 2G at 0x0 */ |
| 104 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;/* disabled */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 105 | __asm__ volatile ("sync"); |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 106 | |
wdenk | 236d3fc | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 107 | /* setup config registers */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 108 | *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1; |
| 109 | *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2; |
| 110 | __asm__ volatile ("sync"); |
wdenk | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 111 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 112 | #if SDRAM_DDR |
| 113 | /* set tap delay */ |
| 114 | *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY; |
| 115 | __asm__ volatile ("sync"); |
wdenk | 236d3fc | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 116 | #endif |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 117 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 118 | /* find RAM size using SDRAM CS0 only */ |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 119 | sdram_start(0); |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 120 | test1 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000); |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 121 | sdram_start(1); |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 122 | test2 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000); |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 123 | if (test1 > test2) { |
| 124 | sdram_start(0); |
| 125 | dramsize = test1; |
| 126 | } else { |
| 127 | dramsize = test2; |
| 128 | } |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 129 | |
| 130 | /* memory smaller than 1MB is impossible */ |
| 131 | if (dramsize < (1 << 20)) { |
| 132 | dramsize = 0; |
| 133 | } |
wdenk | 20c98a6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 134 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 135 | /* set SDRAM CS0 size according to the amount of RAM found */ |
| 136 | if (dramsize > 0) { |
| 137 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + __builtin_ffs(dramsize >> 20) - 1; |
| 138 | } else { |
| 139 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */ |
| 140 | } |
| 141 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 142 | /* let SDRAM CS1 start right after CS0 */ |
wdenk | 236d3fc | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 143 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;/* 2G */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 144 | |
| 145 | /* find RAM size using SDRAM CS1 only */ |
wdenk | e84ec90 | 2005-05-05 00:04:14 +0000 | [diff] [blame] | 146 | if (!dramsize) |
wdenk | faaa602 | 2005-04-21 21:10:22 +0000 | [diff] [blame] | 147 | sdram_start(0); |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 148 | test2 = test1 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x80000000); |
wdenk | faaa602 | 2005-04-21 21:10:22 +0000 | [diff] [blame] | 149 | if (!dramsize) { |
| 150 | sdram_start(1); |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 151 | test2 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x80000000); |
wdenk | faaa602 | 2005-04-21 21:10:22 +0000 | [diff] [blame] | 152 | } |
wdenk | 236d3fc | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 153 | if (test1 > test2) { |
| 154 | sdram_start(0); |
| 155 | dramsize2 = test1; |
| 156 | } else { |
| 157 | dramsize2 = test2; |
| 158 | } |
wdenk | 20c98a6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 159 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 160 | /* memory smaller than 1MB is impossible */ |
| 161 | if (dramsize2 < (1 << 20)) { |
| 162 | dramsize2 = 0; |
| 163 | } |
wdenk | 20c98a6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 164 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 165 | /* set SDRAM CS1 size according to the amount of RAM found */ |
| 166 | if (dramsize2 > 0) { |
| 167 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize |
| 168 | | (0x13 + __builtin_ffs(dramsize2 >> 20) - 1); |
| 169 | } else { |
| 170 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */ |
| 171 | } |
| 172 | |
| 173 | #else /* CFG_RAMBOOT */ |
| 174 | |
| 175 | /* retrieve size of memory connected to SDRAM CS0 */ |
| 176 | dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF; |
| 177 | if (dramsize >= 0x13) { |
| 178 | dramsize = (1 << (dramsize - 0x13)) << 20; |
| 179 | } else { |
| 180 | dramsize = 0; |
| 181 | } |
| 182 | |
| 183 | /* retrieve size of memory connected to SDRAM CS1 */ |
| 184 | dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF; |
| 185 | if (dramsize2 >= 0x13) { |
| 186 | dramsize2 = (1 << (dramsize2 - 0x13)) << 20; |
| 187 | } else { |
| 188 | dramsize2 = 0; |
| 189 | } |
| 190 | |
| 191 | #endif /* CFG_RAMBOOT */ |
| 192 | |
Rafal Jaworowski | 0b892e8 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 193 | /* |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 194 | * On MPC5200B we need to set the special configuration delay in the |
| 195 | * DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM |
Rafal Jaworowski | 0b892e8 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 196 | * Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190: |
| 197 | * |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 198 | * "The SDelay should be written to a value of 0x00000004. It is |
| 199 | * required to account for changes caused by normal wafer processing |
Rafal Jaworowski | 0b892e8 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 200 | * parameters." |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 201 | */ |
Rafal Jaworowski | 0b892e8 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 202 | svr = get_svr(); |
| 203 | pvr = get_pvr(); |
Wolfgang Denk | ebd3deb | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 204 | if ((SVR_MJREV(svr) >= 2) && |
Rafal Jaworowski | 0b892e8 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 205 | (PVR_MAJ(pvr) == 1) && (PVR_MIN(pvr) == 4)) { |
| 206 | |
| 207 | *(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04; |
| 208 | __asm__ volatile ("sync"); |
| 209 | } |
| 210 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 211 | return dramsize + dramsize2; |
| 212 | } |
| 213 | |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 214 | #elif defined(CONFIG_MGT5100) |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 215 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 216 | long int initdram (int board_type) |
| 217 | { |
| 218 | ulong dramsize = 0; |
| 219 | #ifndef CFG_RAMBOOT |
| 220 | ulong test1, test2; |
wdenk | 20c98a6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 221 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 222 | /* setup and enable SDRAM chip selects */ |
| 223 | *(vu_long *)MPC5XXX_SDRAM_START = 0x00000000; |
| 224 | *(vu_long *)MPC5XXX_SDRAM_STOP = 0x0000ffff;/* 2G */ |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 225 | *(vu_long *)MPC5XXX_ADDECR |= (1 << 22); /* Enable SDRAM */ |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 226 | __asm__ volatile ("sync"); |
| 227 | |
| 228 | /* setup config registers */ |
| 229 | *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1; |
| 230 | *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2; |
| 231 | |
| 232 | /* address select register */ |
| 233 | *(vu_long *)MPC5XXX_SDRAM_XLBSEL = SDRAM_ADDRSEL; |
| 234 | __asm__ volatile ("sync"); |
| 235 | |
| 236 | /* find RAM size */ |
| 237 | sdram_start(0); |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 238 | test1 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000); |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 239 | sdram_start(1); |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 240 | test2 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000); |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 241 | if (test1 > test2) { |
| 242 | sdram_start(0); |
| 243 | dramsize = test1; |
| 244 | } else { |
| 245 | dramsize = test2; |
| 246 | } |
| 247 | |
| 248 | /* set SDRAM end address according to size */ |
| 249 | *(vu_long *)MPC5XXX_SDRAM_STOP = ((dramsize - 1) >> 15); |
wdenk | 20c98a6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 250 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 251 | #else /* CFG_RAMBOOT */ |
| 252 | |
| 253 | /* Retrieve amount of SDRAM available */ |
wdenk | b10ba6b | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 254 | dramsize = ((*(vu_long *)MPC5XXX_SDRAM_STOP + 1) << 15); |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 255 | |
wdenk | b10ba6b | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 256 | #endif /* CFG_RAMBOOT */ |
wdenk | 236d3fc | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 257 | |
wdenk | 5d84173 | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 258 | return dramsize; |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 259 | } |
| 260 | |
wdenk | e44b911 | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 261 | #else |
| 262 | #error Neither CONFIG_MPC5200 or CONFIG_MGT5100 defined |
| 263 | #endif |
| 264 | |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 265 | int checkboard (void) |
| 266 | { |
Wolfgang Denk | 315b46a | 2006-03-17 11:42:53 +0100 | [diff] [blame] | 267 | #if defined (CONFIG_LITE5200B) |
| 268 | puts ("Board: Freescale Lite5200B\n"); |
| 269 | #elif defined(CONFIG_MPC5200) |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 270 | puts ("Board: Motorola MPC5200 (IceCube)\n"); |
| 271 | #elif defined(CONFIG_MGT5100) |
| 272 | puts ("Board: Motorola MGT5100 (IceCube)\n"); |
| 273 | #endif |
| 274 | return 0; |
| 275 | } |
| 276 | |
| 277 | void flash_preinit(void) |
| 278 | { |
| 279 | /* |
| 280 | * Now, when we are in RAM, enable flash write |
| 281 | * access for detection process. |
| 282 | * Note that CS_BOOT cannot be cleared when |
| 283 | * executing in flash. |
| 284 | */ |
| 285 | #if defined(CONFIG_MGT5100) |
| 286 | *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25); /* disable CS_BOOT */ |
| 287 | *(vu_long *)MPC5XXX_ADDECR |= (1 << 16); /* enable CS0 */ |
| 288 | #endif |
| 289 | *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */ |
| 290 | } |
wdenk | 0237902 | 2003-08-05 18:22:44 +0000 | [diff] [blame] | 291 | |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 292 | void flash_afterinit(ulong size) |
| 293 | { |
| 294 | if (size == 0x800000) { /* adjust mapping */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 295 | *(vu_long *)MPC5XXX_BOOTCS_START = *(vu_long *)MPC5XXX_CS0_START = |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 296 | START_REG(CFG_BOOTCS_START | size); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 297 | *(vu_long *)MPC5XXX_BOOTCS_STOP = *(vu_long *)MPC5XXX_CS0_STOP = |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 298 | STOP_REG(CFG_BOOTCS_START | size, size); |
| 299 | } |
| 300 | } |
| 301 | |
wdenk | 0237902 | 2003-08-05 18:22:44 +0000 | [diff] [blame] | 302 | #ifdef CONFIG_PCI |
| 303 | static struct pci_controller hose; |
| 304 | |
| 305 | extern void pci_mpc5xxx_init(struct pci_controller *); |
| 306 | |
| 307 | void pci_init_board(void) |
| 308 | { |
| 309 | pci_mpc5xxx_init(&hose); |
| 310 | } |
| 311 | #endif |
wdenk | acd9b10 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 312 | |
| 313 | #if defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) |
| 314 | |
wdenk | acd9b10 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 315 | void init_ide_reset (void) |
| 316 | { |
wdenk | 369d43d | 2004-03-14 14:09:05 +0000 | [diff] [blame] | 317 | debug ("init_ide_reset\n"); |
wdenk | c35ba4e | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 318 | |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 319 | /* Configure PSC1_4 as GPIO output for ATA reset */ |
wdenk | acd9b10 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 320 | *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4; |
wdenk | 369d43d | 2004-03-14 14:09:05 +0000 | [diff] [blame] | 321 | *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4; |
wdenk | e2d6d74 | 2004-09-28 20:34:50 +0000 | [diff] [blame] | 322 | /* Deassert reset */ |
Bartlomiej Sieka | 79eecbfb | 2006-11-01 01:38:16 +0100 | [diff] [blame] | 323 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4; |
wdenk | acd9b10 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | void ide_set_reset (int idereset) |
| 327 | { |
wdenk | 369d43d | 2004-03-14 14:09:05 +0000 | [diff] [blame] | 328 | debug ("ide_reset(%d)\n", idereset); |
| 329 | |
wdenk | acd9b10 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 330 | if (idereset) { |
Bartlomiej Sieka | 79eecbfb | 2006-11-01 01:38:16 +0100 | [diff] [blame] | 331 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4; |
wdenk | e2d6d74 | 2004-09-28 20:34:50 +0000 | [diff] [blame] | 332 | /* Make a delay. MPC5200 spec says 25 usec min */ |
| 333 | udelay(500000); |
wdenk | acd9b10 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 334 | } else { |
Bartlomiej Sieka | 79eecbfb | 2006-11-01 01:38:16 +0100 | [diff] [blame] | 335 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4; |
wdenk | acd9b10 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 336 | } |
| 337 | } |
| 338 | #endif /* defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) */ |
Stefan Roese | fb34787 | 2006-11-28 17:55:49 +0100 | [diff] [blame] | 339 | |
| 340 | #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) |
| 341 | void |
| 342 | ft_board_setup(void *blob, bd_t *bd) |
| 343 | { |
| 344 | ft_cpu_setup(blob, bd); |
| 345 | } |
| 346 | #endif |