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