wdenk | 945af8d | 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 | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 5 | * (C) Copyright 2004 |
| 6 | * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com. |
| 7 | * |
wdenk | 945af8d | 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 | 96e48cf | 2003-08-05 18:22:44 +0000 | [diff] [blame] | 29 | #include <pci.h> |
Rafal Jaworowski | b66a938 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 30 | #include <asm/processor.h> |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 31 | |
Stefan Roese | e59581c | 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 | 09e4b0c | 2006-03-17 11:42:53 +0100 | [diff] [blame] | 36 | #if defined(CONFIG_LITE5200B) |
| 37 | #include "mt46v32m16.h" |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 38 | #else |
Wolfgang Denk | 09e4b0c | 2006-03-17 11:42:53 +0100 | [diff] [blame] | 39 | # if defined(CONFIG_MPC5200_DDR) |
| 40 | # include "mt46v16m16-75.h" |
| 41 | # else |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 42 | #include "mt48lc16m16a2-75.h" |
Wolfgang Denk | 09e4b0c | 2006-03-17 11:42:53 +0100 | [diff] [blame] | 43 | # endif |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 44 | #endif |
Domen Puncer | d3832e8 | 2007-04-16 14:00:13 +0200 | [diff] [blame] | 45 | |
| 46 | #ifdef CONFIG_LITE5200B_PM |
| 47 | /* u-boot part of low-power mode implementation */ |
| 48 | #define SAVED_ADDR (*(void **)0x00000000) |
| 49 | #define PSC2_4 0x02 |
| 50 | |
| 51 | void lite5200b_wakeup(void) |
| 52 | { |
| 53 | unsigned char wakeup_pin; |
| 54 | void (*linux_wakeup)(void); |
| 55 | |
| 56 | /* check PSC2_4, if it's down "QT" is signaling we have a wakeup |
| 57 | * from low power mode */ |
| 58 | *(vu_char *)MPC5XXX_WU_GPIO_ENABLE = PSC2_4; |
| 59 | __asm__ volatile ("sync"); |
| 60 | |
| 61 | wakeup_pin = *(vu_char *)MPC5XXX_WU_GPIO_DATA_I; |
| 62 | if (wakeup_pin & PSC2_4) |
| 63 | return; |
| 64 | |
| 65 | /* acknowledge to "QT" |
| 66 | * by holding pin at 1 for 10 uS */ |
| 67 | *(vu_char *)MPC5XXX_WU_GPIO_DIR = PSC2_4; |
| 68 | __asm__ volatile ("sync"); |
| 69 | *(vu_char *)MPC5XXX_WU_GPIO_DATA_O = PSC2_4; |
| 70 | __asm__ volatile ("sync"); |
| 71 | udelay(10); |
| 72 | |
| 73 | /* put ram out of self-refresh */ |
| 74 | *(vu_long *)MPC5XXX_SDRAM_CTRL |= 0x80000000; /* mode_en */ |
| 75 | __asm__ volatile ("sync"); |
| 76 | *(vu_long *)MPC5XXX_SDRAM_CTRL |= 0x50000000; /* cke ref_en */ |
| 77 | __asm__ volatile ("sync"); |
| 78 | *(vu_long *)MPC5XXX_SDRAM_CTRL &= ~0x80000000; /* !mode_en */ |
| 79 | __asm__ volatile ("sync"); |
| 80 | udelay(10); /* wait a bit */ |
| 81 | |
| 82 | /* jump back to linux kernel code */ |
| 83 | linux_wakeup = SAVED_ADDR; |
| 84 | printf("\n\nLooks like we just woke, transferring control to 0x%08lx\n", |
| 85 | linux_wakeup); |
| 86 | linux_wakeup(); |
| 87 | } |
| 88 | #else |
| 89 | #define lite5200b_wakeup() |
| 90 | #endif |
| 91 | |
wdenk | d94f92c | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 92 | #ifndef CFG_RAMBOOT |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 93 | static void sdram_start (int hi_addr) |
| 94 | { |
| 95 | long hi_addr_bit = hi_addr ? 0x01000000 : 0; |
| 96 | |
wdenk | b2001f2 | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 97 | /* unlock mode register */ |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 98 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit; |
| 99 | __asm__ volatile ("sync"); |
wdenk | 5cf91d6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 100 | |
wdenk | b2001f2 | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 101 | /* precharge all banks */ |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 102 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit; |
| 103 | __asm__ volatile ("sync"); |
| 104 | |
| 105 | #if SDRAM_DDR |
wdenk | b2001f2 | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 106 | /* set mode register: extended mode */ |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 107 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE; |
| 108 | __asm__ volatile ("sync"); |
| 109 | |
wdenk | b2001f2 | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 110 | /* set mode register: reset DLL */ |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 111 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000; |
| 112 | __asm__ volatile ("sync"); |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 113 | #endif |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 114 | |
| 115 | /* precharge all banks */ |
| 116 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit; |
| 117 | __asm__ volatile ("sync"); |
| 118 | |
wdenk | f8d813e | 2004-03-02 14:05:39 +0000 | [diff] [blame] | 119 | /* auto refresh */ |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 120 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | hi_addr_bit; |
| 121 | __asm__ volatile ("sync"); |
| 122 | |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 123 | /* set mode register */ |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 124 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE; |
| 125 | __asm__ volatile ("sync"); |
wdenk | 5cf91d6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 126 | |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 127 | /* normal operation */ |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 128 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit; |
| 129 | __asm__ volatile ("sync"); |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 130 | } |
wdenk | d94f92c | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 131 | #endif |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 132 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 133 | /* |
| 134 | * ATTENTION: Although partially referenced initdram does NOT make real use |
| 135 | * use of CFG_SDRAM_BASE. The code does not work if CFG_SDRAM_BASE |
| 136 | * is something else than 0x00000000. |
| 137 | */ |
| 138 | |
| 139 | #if defined(CONFIG_MPC5200) |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 140 | long int initdram (int board_type) |
| 141 | { |
wdenk | d94f92c | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 142 | ulong dramsize = 0; |
wdenk | b2001f2 | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 143 | ulong dramsize2 = 0; |
Rafal Jaworowski | b66a938 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 144 | uint svr, pvr; |
| 145 | |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 146 | #ifndef CFG_RAMBOOT |
wdenk | d94f92c | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 147 | ulong test1, test2; |
wdenk | 5cf91d6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 148 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 149 | /* setup SDRAM chip selects */ |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 150 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;/* 2G at 0x0 */ |
| 151 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;/* disabled */ |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 152 | __asm__ volatile ("sync"); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 153 | |
wdenk | b2001f2 | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 154 | /* setup config registers */ |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 155 | *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1; |
| 156 | *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2; |
| 157 | __asm__ volatile ("sync"); |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 158 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 159 | #if SDRAM_DDR |
| 160 | /* set tap delay */ |
| 161 | *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY; |
| 162 | __asm__ volatile ("sync"); |
wdenk | b2001f2 | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 163 | #endif |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 164 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 165 | /* find RAM size using SDRAM CS0 only */ |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 166 | sdram_start(0); |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 167 | test1 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000); |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 168 | sdram_start(1); |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 169 | test2 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000); |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 170 | if (test1 > test2) { |
| 171 | sdram_start(0); |
| 172 | dramsize = test1; |
| 173 | } else { |
| 174 | dramsize = test2; |
| 175 | } |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 176 | |
| 177 | /* memory smaller than 1MB is impossible */ |
| 178 | if (dramsize < (1 << 20)) { |
| 179 | dramsize = 0; |
| 180 | } |
wdenk | 5cf91d6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 181 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 182 | /* set SDRAM CS0 size according to the amount of RAM found */ |
| 183 | if (dramsize > 0) { |
| 184 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + __builtin_ffs(dramsize >> 20) - 1; |
| 185 | } else { |
| 186 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */ |
| 187 | } |
| 188 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 189 | /* let SDRAM CS1 start right after CS0 */ |
wdenk | b2001f2 | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 190 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;/* 2G */ |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 191 | |
| 192 | /* find RAM size using SDRAM CS1 only */ |
wdenk | 07cc099 | 2005-05-05 00:04:14 +0000 | [diff] [blame] | 193 | if (!dramsize) |
wdenk | a631092 | 2005-04-21 21:10:22 +0000 | [diff] [blame] | 194 | sdram_start(0); |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 195 | test2 = test1 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x80000000); |
wdenk | a631092 | 2005-04-21 21:10:22 +0000 | [diff] [blame] | 196 | if (!dramsize) { |
| 197 | sdram_start(1); |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 198 | test2 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x80000000); |
wdenk | a631092 | 2005-04-21 21:10:22 +0000 | [diff] [blame] | 199 | } |
wdenk | b2001f2 | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 200 | if (test1 > test2) { |
| 201 | sdram_start(0); |
| 202 | dramsize2 = test1; |
| 203 | } else { |
| 204 | dramsize2 = test2; |
| 205 | } |
wdenk | 5cf91d6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 206 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 207 | /* memory smaller than 1MB is impossible */ |
| 208 | if (dramsize2 < (1 << 20)) { |
| 209 | dramsize2 = 0; |
| 210 | } |
wdenk | 5cf91d6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 211 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 212 | /* set SDRAM CS1 size according to the amount of RAM found */ |
| 213 | if (dramsize2 > 0) { |
| 214 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize |
| 215 | | (0x13 + __builtin_ffs(dramsize2 >> 20) - 1); |
| 216 | } else { |
| 217 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */ |
| 218 | } |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 219 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 220 | #else /* CFG_RAMBOOT */ |
| 221 | |
| 222 | /* retrieve size of memory connected to SDRAM CS0 */ |
| 223 | dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF; |
| 224 | if (dramsize >= 0x13) { |
| 225 | dramsize = (1 << (dramsize - 0x13)) << 20; |
| 226 | } else { |
| 227 | dramsize = 0; |
| 228 | } |
| 229 | |
| 230 | /* retrieve size of memory connected to SDRAM CS1 */ |
| 231 | dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF; |
| 232 | if (dramsize2 >= 0x13) { |
| 233 | dramsize2 = (1 << (dramsize2 - 0x13)) << 20; |
| 234 | } else { |
| 235 | dramsize2 = 0; |
| 236 | } |
| 237 | |
wdenk | d94f92c | 2003-08-28 09:41:22 +0000 | [diff] [blame] | 238 | #endif /* CFG_RAMBOOT */ |
wdenk | b2001f2 | 2003-12-20 22:45:10 +0000 | [diff] [blame] | 239 | |
Rafal Jaworowski | b66a938 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 240 | /* |
Wolfgang Denk | cf48eb9 | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 241 | * On MPC5200B we need to set the special configuration delay in the |
| 242 | * DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM |
Rafal Jaworowski | b66a938 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 243 | * Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190: |
| 244 | * |
Wolfgang Denk | cf48eb9 | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 245 | * "The SDelay should be written to a value of 0x00000004. It is |
| 246 | * required to account for changes caused by normal wafer processing |
Rafal Jaworowski | b66a938 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 247 | * parameters." |
Wolfgang Denk | cf48eb9 | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 248 | */ |
Rafal Jaworowski | b66a938 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 249 | svr = get_svr(); |
| 250 | pvr = get_pvr(); |
Wolfgang Denk | cf48eb9 | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 251 | if ((SVR_MJREV(svr) >= 2) && |
Rafal Jaworowski | b66a938 | 2006-03-29 13:17:09 +0200 | [diff] [blame] | 252 | (PVR_MAJ(pvr) == 1) && (PVR_MIN(pvr) == 4)) { |
| 253 | |
| 254 | *(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04; |
| 255 | __asm__ volatile ("sync"); |
| 256 | } |
| 257 | |
Domen Puncer | d3832e8 | 2007-04-16 14:00:13 +0200 | [diff] [blame] | 258 | lite5200b_wakeup(); |
| 259 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 260 | return dramsize + dramsize2; |
| 261 | } |
| 262 | |
| 263 | #elif defined(CONFIG_MGT5100) |
| 264 | |
| 265 | long int initdram (int board_type) |
| 266 | { |
| 267 | ulong dramsize = 0; |
| 268 | #ifndef CFG_RAMBOOT |
| 269 | ulong test1, test2; |
wdenk | 5cf91d6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 270 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 271 | /* setup and enable SDRAM chip selects */ |
| 272 | *(vu_long *)MPC5XXX_SDRAM_START = 0x00000000; |
| 273 | *(vu_long *)MPC5XXX_SDRAM_STOP = 0x0000ffff;/* 2G */ |
| 274 | *(vu_long *)MPC5XXX_ADDECR |= (1 << 22); /* Enable SDRAM */ |
| 275 | __asm__ volatile ("sync"); |
| 276 | |
| 277 | /* setup config registers */ |
| 278 | *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1; |
| 279 | *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2; |
| 280 | |
| 281 | /* address select register */ |
| 282 | *(vu_long *)MPC5XXX_SDRAM_XLBSEL = SDRAM_ADDRSEL; |
| 283 | __asm__ volatile ("sync"); |
| 284 | |
| 285 | /* find RAM size */ |
| 286 | sdram_start(0); |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 287 | test1 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000); |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 288 | sdram_start(1); |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 289 | test2 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000); |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 290 | if (test1 > test2) { |
| 291 | sdram_start(0); |
| 292 | dramsize = test1; |
| 293 | } else { |
| 294 | dramsize = test2; |
| 295 | } |
| 296 | |
| 297 | /* set SDRAM end address according to size */ |
| 298 | *(vu_long *)MPC5XXX_SDRAM_STOP = ((dramsize - 1) >> 15); |
wdenk | 5cf91d6 | 2004-04-23 20:32:05 +0000 | [diff] [blame] | 299 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 300 | #else /* CFG_RAMBOOT */ |
| 301 | |
| 302 | /* Retrieve amount of SDRAM available */ |
| 303 | dramsize = ((*(vu_long *)MPC5XXX_SDRAM_STOP + 1) << 15); |
| 304 | |
| 305 | #endif /* CFG_RAMBOOT */ |
| 306 | |
wdenk | e0ac62d | 2003-08-17 18:55:18 +0000 | [diff] [blame] | 307 | return dramsize; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 308 | } |
| 309 | |
wdenk | e35745b | 2004-04-18 23:32:11 +0000 | [diff] [blame] | 310 | #else |
| 311 | #error Neither CONFIG_MPC5200 or CONFIG_MGT5100 defined |
| 312 | #endif |
| 313 | |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 314 | int checkboard (void) |
| 315 | { |
Wolfgang Denk | 09e4b0c | 2006-03-17 11:42:53 +0100 | [diff] [blame] | 316 | #if defined (CONFIG_LITE5200B) |
| 317 | puts ("Board: Freescale Lite5200B\n"); |
| 318 | #elif defined(CONFIG_MPC5200) |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 319 | puts ("Board: Motorola MPC5200 (IceCube)\n"); |
| 320 | #elif defined(CONFIG_MGT5100) |
| 321 | puts ("Board: Motorola MGT5100 (IceCube)\n"); |
| 322 | #endif |
| 323 | return 0; |
| 324 | } |
| 325 | |
| 326 | void flash_preinit(void) |
| 327 | { |
| 328 | /* |
| 329 | * Now, when we are in RAM, enable flash write |
| 330 | * access for detection process. |
| 331 | * Note that CS_BOOT cannot be cleared when |
| 332 | * executing in flash. |
| 333 | */ |
| 334 | #if defined(CONFIG_MGT5100) |
| 335 | *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25); /* disable CS_BOOT */ |
| 336 | *(vu_long *)MPC5XXX_ADDECR |= (1 << 16); /* enable CS0 */ |
| 337 | #endif |
| 338 | *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */ |
| 339 | } |
wdenk | 96e48cf | 2003-08-05 18:22:44 +0000 | [diff] [blame] | 340 | |
wdenk | 7152b1d | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 341 | void flash_afterinit(ulong size) |
| 342 | { |
| 343 | if (size == 0x800000) { /* adjust mapping */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 344 | *(vu_long *)MPC5XXX_BOOTCS_START = *(vu_long *)MPC5XXX_CS0_START = |
wdenk | 7152b1d | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 345 | START_REG(CFG_BOOTCS_START | size); |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 346 | *(vu_long *)MPC5XXX_BOOTCS_STOP = *(vu_long *)MPC5XXX_CS0_STOP = |
wdenk | 7152b1d | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 347 | STOP_REG(CFG_BOOTCS_START | size, size); |
| 348 | } |
| 349 | } |
| 350 | |
wdenk | 96e48cf | 2003-08-05 18:22:44 +0000 | [diff] [blame] | 351 | #ifdef CONFIG_PCI |
| 352 | static struct pci_controller hose; |
| 353 | |
| 354 | extern void pci_mpc5xxx_init(struct pci_controller *); |
| 355 | |
| 356 | void pci_init_board(void) |
| 357 | { |
| 358 | pci_mpc5xxx_init(&hose); |
| 359 | } |
| 360 | #endif |
wdenk | c3f9d49 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 361 | |
Jon Loeliger | 77a3185 | 2007-07-10 10:39:10 -0500 | [diff] [blame] | 362 | #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET) |
wdenk | c3f9d49 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 363 | |
wdenk | c3f9d49 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 364 | void init_ide_reset (void) |
| 365 | { |
wdenk | 4d13cba | 2004-03-14 14:09:05 +0000 | [diff] [blame] | 366 | debug ("init_ide_reset\n"); |
wdenk | 42dfe7a | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 367 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 368 | /* Configure PSC1_4 as GPIO output for ATA reset */ |
wdenk | c3f9d49 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 369 | *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4; |
wdenk | 4d13cba | 2004-03-14 14:09:05 +0000 | [diff] [blame] | 370 | *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4; |
wdenk | 64f70be | 2004-09-28 20:34:50 +0000 | [diff] [blame] | 371 | /* Deassert reset */ |
Bartlomiej Sieka | dae80f3 | 2006-11-01 01:38:16 +0100 | [diff] [blame] | 372 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4; |
wdenk | c3f9d49 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | void ide_set_reset (int idereset) |
| 376 | { |
wdenk | 4d13cba | 2004-03-14 14:09:05 +0000 | [diff] [blame] | 377 | debug ("ide_reset(%d)\n", idereset); |
| 378 | |
wdenk | c3f9d49 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 379 | if (idereset) { |
Bartlomiej Sieka | dae80f3 | 2006-11-01 01:38:16 +0100 | [diff] [blame] | 380 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4; |
wdenk | 64f70be | 2004-09-28 20:34:50 +0000 | [diff] [blame] | 381 | /* Make a delay. MPC5200 spec says 25 usec min */ |
| 382 | udelay(500000); |
wdenk | c3f9d49 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 383 | } else { |
Bartlomiej Sieka | dae80f3 | 2006-11-01 01:38:16 +0100 | [diff] [blame] | 384 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4; |
wdenk | c3f9d49 | 2004-03-14 00:59:59 +0000 | [diff] [blame] | 385 | } |
| 386 | } |
Jon Loeliger | 77a3185 | 2007-07-10 10:39:10 -0500 | [diff] [blame] | 387 | #endif |
Stefan Roese | e59581c | 2006-11-28 17:55:49 +0100 | [diff] [blame] | 388 | |
| 389 | #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) |
| 390 | void |
| 391 | ft_board_setup(void *blob, bd_t *bd) |
| 392 | { |
| 393 | ft_cpu_setup(blob, bd); |
| 394 | } |
| 395 | #endif |