wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 1 | /* |
Wolfgang Denk | c98368a | 2006-07-19 17:52:30 +0200 | [diff] [blame] | 2 | * (C) Copyright 2003-2006 |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * (C) Copyright 2004 |
| 6 | * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com. |
| 7 | * |
Wolfgang Denk | c98368a | 2006-07-19 17:52:30 +0200 | [diff] [blame] | 8 | * (C) Copyright 2004-2006 |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 9 | * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de |
| 10 | * |
| 11 | * See file CREDITS for list of people who contributed to this |
| 12 | * project. |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License as |
| 16 | * published by the Free Software Foundation; either version 2 of |
| 17 | * the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wdenk | 7dd1329 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, write to the Free Software |
| 26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 27 | * MA 02111-1307 USA |
| 28 | */ |
| 29 | |
| 30 | #include <common.h> |
| 31 | #include <mpc5xxx.h> |
| 32 | #include <pci.h> |
Wolfgang Denk | c98368a | 2006-07-19 17:52:30 +0200 | [diff] [blame] | 33 | #include <asm/processor.h> |
Grant Likely | 8d1e6e7 | 2007-09-06 09:46:23 -0600 | [diff] [blame] | 34 | #include <libfdt.h> |
Ben Warren | f2c1acb | 2008-08-31 10:03:22 -0700 | [diff] [blame] | 35 | #include <netdev.h> |
Bartlomiej Sieka | 7a432ce | 2007-06-08 14:52:22 +0200 | [diff] [blame] | 36 | |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 37 | #ifdef CONFIG_VIDEO_SM501 |
| 38 | #include <sm501.h> |
| 39 | #endif |
| 40 | |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 41 | #if defined(CONFIG_MPC5200_DDR) |
| 42 | #include "mt46v16m16-75.h" |
| 43 | #else |
| 44 | #include "mt48lc16m16a2-75.h" |
| 45 | #endif |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 46 | |
Martin Krause | 3b09b9d | 2008-02-25 17:52:40 +0100 | [diff] [blame] | 47 | #ifdef CONFIG_OF_LIBFDT |
| 48 | #include <fdt_support.h> |
| 49 | #endif /* CONFIG_OF_LIBFDT */ |
| 50 | |
Wolfgang Denk | d112a2c | 2007-09-15 20:48:41 +0200 | [diff] [blame] | 51 | DECLARE_GLOBAL_DATA_PTR; |
| 52 | |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 53 | #ifdef CONFIG_PS2MULT |
| 54 | void ps2mult_early_init(void); |
| 55 | #endif |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 56 | |
Wolfgang Denk | 3c0d487 | 2010-12-23 19:57:31 +0100 | [diff] [blame] | 57 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) && \ |
| 58 | defined(CONFIG_VIDEO) |
Heiko Schocher | 1ae9144 | 2010-12-04 08:34:04 +0100 | [diff] [blame] | 59 | /* |
| 60 | * EDID block has been generated using Phoenix EDID Designer 1.3. |
| 61 | * This tool creates a text file containing: |
| 62 | * |
| 63 | * EDID BYTES: |
| 64 | * |
| 65 | * 0x 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |
| 66 | * ------------------------------------------------ |
| 67 | * 00 | 00 FF FF FF FF FF FF 00 04 21 00 00 00 00 00 00 |
| 68 | * 10 | 01 00 01 03 00 00 00 00 00 00 00 00 00 00 00 00 |
| 69 | * 20 | 00 00 00 21 00 00 01 01 01 01 01 01 01 01 01 01 |
| 70 | * 30 | 01 01 01 01 01 01 64 00 00 00 00 00 00 00 00 00 |
| 71 | * 40 | 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 |
| 72 | * 50 | 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 |
| 73 | * 60 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 |
| 74 | * 70 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 |
| 75 | * |
| 76 | * Then this data has been manually converted to the char |
| 77 | * array below. |
| 78 | */ |
| 79 | static unsigned char edid_buf[128] = { |
| 80 | 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, |
| 81 | 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 82 | 0x01, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, |
| 83 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 84 | 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x01, 0x01, |
| 85 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
| 86 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x64, 0x00, |
| 87 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 88 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 89 | 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, |
| 90 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 91 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, |
| 92 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 93 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, |
| 94 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 95 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, |
| 96 | }; |
| 97 | #endif |
| 98 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 99 | #ifndef CONFIG_SYS_RAMBOOT |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 100 | static void sdram_start (int hi_addr) |
| 101 | { |
| 102 | long hi_addr_bit = hi_addr ? 0x01000000 : 0; |
| 103 | |
| 104 | /* unlock mode register */ |
| 105 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | |
| 106 | hi_addr_bit; |
| 107 | __asm__ volatile ("sync"); |
| 108 | |
| 109 | /* precharge all banks */ |
| 110 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | |
| 111 | hi_addr_bit; |
| 112 | __asm__ volatile ("sync"); |
| 113 | |
| 114 | #if SDRAM_DDR |
| 115 | /* set mode register: extended mode */ |
| 116 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE; |
| 117 | __asm__ volatile ("sync"); |
| 118 | |
| 119 | /* set mode register: reset DLL */ |
| 120 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000; |
| 121 | __asm__ volatile ("sync"); |
| 122 | #endif |
| 123 | |
| 124 | /* precharge all banks */ |
| 125 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | |
| 126 | hi_addr_bit; |
| 127 | __asm__ volatile ("sync"); |
| 128 | |
| 129 | /* auto refresh */ |
| 130 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | |
| 131 | hi_addr_bit; |
| 132 | __asm__ volatile ("sync"); |
| 133 | |
| 134 | /* set mode register */ |
| 135 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE; |
| 136 | __asm__ volatile ("sync"); |
| 137 | |
| 138 | /* normal operation */ |
| 139 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit; |
| 140 | __asm__ volatile ("sync"); |
| 141 | } |
| 142 | #endif |
| 143 | |
| 144 | /* |
| 145 | * ATTENTION: Although partially referenced initdram does NOT make real use |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 146 | * use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE |
wdenk | 7dd1329 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 147 | * is something else than 0x00000000. |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 148 | */ |
| 149 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 150 | phys_size_t initdram (int board_type) |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 151 | { |
| 152 | ulong dramsize = 0; |
| 153 | ulong dramsize2 = 0; |
Wolfgang Denk | c98368a | 2006-07-19 17:52:30 +0200 | [diff] [blame] | 154 | uint svr, pvr; |
| 155 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 156 | #ifndef CONFIG_SYS_RAMBOOT |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 157 | ulong test1, test2; |
| 158 | |
| 159 | /* setup SDRAM chip selects */ |
| 160 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001c; /* 512MB at 0x0 */ |
| 161 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x40000000; /* disabled */ |
| 162 | __asm__ volatile ("sync"); |
| 163 | |
| 164 | /* setup config registers */ |
| 165 | *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1; |
| 166 | *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2; |
| 167 | __asm__ volatile ("sync"); |
| 168 | |
| 169 | #if SDRAM_DDR |
| 170 | /* set tap delay */ |
| 171 | *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY; |
| 172 | __asm__ volatile ("sync"); |
| 173 | #endif |
| 174 | |
| 175 | /* find RAM size using SDRAM CS0 only */ |
| 176 | sdram_start(0); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 177 | test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000); |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 178 | sdram_start(1); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 179 | test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000); |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 180 | if (test1 > test2) { |
| 181 | sdram_start(0); |
| 182 | dramsize = test1; |
| 183 | } else { |
| 184 | dramsize = test2; |
| 185 | } |
| 186 | |
| 187 | /* memory smaller than 1MB is impossible */ |
| 188 | if (dramsize < (1 << 20)) { |
| 189 | dramsize = 0; |
| 190 | } |
| 191 | |
| 192 | /* set SDRAM CS0 size according to the amount of RAM found */ |
| 193 | if (dramsize > 0) { |
| 194 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + |
| 195 | __builtin_ffs(dramsize >> 20) - 1; |
| 196 | } else { |
| 197 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */ |
| 198 | } |
| 199 | |
| 200 | /* let SDRAM CS1 start right after CS0 */ |
| 201 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001c; /* 512MB */ |
| 202 | |
| 203 | /* find RAM size using SDRAM CS1 only */ |
Martin Krause | c03d80a | 2008-02-25 13:27:52 +0100 | [diff] [blame] | 204 | if (!dramsize) |
| 205 | sdram_start(0); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 206 | test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000); |
Martin Krause | c03d80a | 2008-02-25 13:27:52 +0100 | [diff] [blame] | 207 | if (!dramsize) { |
| 208 | sdram_start(1); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 209 | test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000); |
Martin Krause | c03d80a | 2008-02-25 13:27:52 +0100 | [diff] [blame] | 210 | } |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 211 | if (test1 > test2) { |
| 212 | sdram_start(0); |
| 213 | dramsize2 = test1; |
| 214 | } else { |
| 215 | dramsize2 = test2; |
| 216 | } |
| 217 | |
| 218 | /* memory smaller than 1MB is impossible */ |
| 219 | if (dramsize2 < (1 << 20)) { |
| 220 | dramsize2 = 0; |
| 221 | } |
| 222 | |
| 223 | /* set SDRAM CS1 size according to the amount of RAM found */ |
| 224 | if (dramsize2 > 0) { |
| 225 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize |
| 226 | | (0x13 + __builtin_ffs(dramsize2 >> 20) - 1); |
| 227 | } else { |
| 228 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */ |
| 229 | } |
| 230 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 231 | #else /* CONFIG_SYS_RAMBOOT */ |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 232 | |
| 233 | /* retrieve size of memory connected to SDRAM CS0 */ |
| 234 | dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF; |
| 235 | if (dramsize >= 0x13) { |
| 236 | dramsize = (1 << (dramsize - 0x13)) << 20; |
| 237 | } else { |
| 238 | dramsize = 0; |
| 239 | } |
| 240 | |
| 241 | /* retrieve size of memory connected to SDRAM CS1 */ |
| 242 | dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF; |
| 243 | if (dramsize2 >= 0x13) { |
| 244 | dramsize2 = (1 << (dramsize2 - 0x13)) << 20; |
| 245 | } else { |
| 246 | dramsize2 = 0; |
| 247 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 248 | #endif /* CONFIG_SYS_RAMBOOT */ |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 249 | |
Wolfgang Denk | c98368a | 2006-07-19 17:52:30 +0200 | [diff] [blame] | 250 | /* |
| 251 | * On MPC5200B we need to set the special configuration delay in the |
| 252 | * DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM |
| 253 | * Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190: |
| 254 | * |
| 255 | * "The SDelay should be written to a value of 0x00000004. It is |
| 256 | * required to account for changes caused by normal wafer processing |
| 257 | * parameters." |
| 258 | */ |
| 259 | svr = get_svr(); |
| 260 | pvr = get_pvr(); |
| 261 | if ((SVR_MJREV(svr) >= 2) && |
| 262 | (PVR_MAJ(pvr) == 1) && (PVR_MIN(pvr) == 4)) { |
| 263 | |
| 264 | *(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04; |
| 265 | __asm__ volatile ("sync"); |
| 266 | } |
| 267 | |
| 268 | #if defined(CONFIG_TQM5200_B) |
| 269 | return dramsize + dramsize2; |
| 270 | #else |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 271 | return dramsize; |
Wolfgang Denk | c98368a | 2006-07-19 17:52:30 +0200 | [diff] [blame] | 272 | #endif /* CONFIG_TQM5200_B */ |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 273 | } |
| 274 | |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 275 | int checkboard (void) |
| 276 | { |
Wolfgang Denk | 9975314 | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 277 | #if defined(CONFIG_AEVFIFO) |
Wolfgang Denk | eb95c85 | 2005-08-10 15:14:32 +0200 | [diff] [blame] | 278 | puts ("Board: AEVFIFO\n"); |
| 279 | return 0; |
| 280 | #endif |
Wolfgang Denk | 9975314 | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 281 | |
| 282 | #if defined(CONFIG_TQM5200S) |
| 283 | # define MODULE_NAME "TQM5200S" |
Wolfgang Denk | c98368a | 2006-07-19 17:52:30 +0200 | [diff] [blame] | 284 | #else |
Wolfgang Denk | 9975314 | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 285 | # define MODULE_NAME "TQM5200" |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 286 | #endif |
Wolfgang Denk | 9975314 | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 287 | |
| 288 | #if defined(CONFIG_STK52XX) |
| 289 | # define CARRIER_NAME "STK52xx" |
| 290 | #elif defined(CONFIG_TB5200) |
| 291 | # define CARRIER_NAME "TB5200" |
Wolfgang Denk | 641e357 | 2006-07-22 01:20:03 +0200 | [diff] [blame] | 292 | #elif defined(CONFIG_CAM5200) |
Wolfgang Denk | 0129dcd | 2006-11-23 22:58:58 +0100 | [diff] [blame] | 293 | # define CARRIER_NAME "CAM5200" |
Marian Balakowicz | bcb0cca | 2006-08-18 19:14:46 +0200 | [diff] [blame] | 294 | #elif defined(CONFIG_FO300) |
| 295 | # define CARRIER_NAME "FO300" |
Heiko Schocher | 1ae9144 | 2010-12-04 08:34:04 +0100 | [diff] [blame] | 296 | #elif defined(CONFIG_CHARON) |
| 297 | # define CARRIER_NAME "CHARON" |
Wolfgang Denk | 9975314 | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 298 | #else |
Wolfgang Denk | 9018bc9 | 2006-08-18 23:27:33 +0200 | [diff] [blame] | 299 | # error "UNKNOWN" |
Wolfgang Denk | ba94093 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 300 | #endif |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 301 | |
Wolfgang Denk | 9975314 | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 302 | puts ( "Board: " MODULE_NAME " (TQ-Components GmbH)\n" |
| 303 | " on a " CARRIER_NAME " carrier board\n"); |
| 304 | |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 305 | return 0; |
| 306 | } |
| 307 | |
Wolfgang Denk | 9975314 | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 308 | #undef MODULE_NAME |
| 309 | #undef CARRIER_NAME |
| 310 | |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 311 | void flash_preinit(void) |
| 312 | { |
| 313 | /* |
| 314 | * Now, when we are in RAM, enable flash write |
| 315 | * access for detection process. |
| 316 | * Note that CS_BOOT cannot be cleared when |
| 317 | * executing in flash. |
| 318 | */ |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 319 | *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */ |
| 320 | } |
| 321 | |
| 322 | |
| 323 | #ifdef CONFIG_PCI |
| 324 | static struct pci_controller hose; |
| 325 | |
| 326 | extern void pci_mpc5xxx_init(struct pci_controller *); |
| 327 | |
| 328 | void pci_init_board(void) |
| 329 | { |
| 330 | pci_mpc5xxx_init(&hose); |
| 331 | } |
| 332 | #endif |
| 333 | |
Jon Loeliger | 761ea74 | 2007-07-10 10:48:22 -0500 | [diff] [blame] | 334 | #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET) |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 335 | |
| 336 | #if defined (CONFIG_MINIFAP) |
| 337 | #define SM501_POWER_MODE0_GATE 0x00000040UL |
| 338 | #define SM501_POWER_MODE1_GATE 0x00000048UL |
| 339 | #define POWER_MODE_GATE_GPIO_PWM_I2C 0x00000040UL |
| 340 | #define SM501_GPIO_DATA_DIR_HIGH 0x0001000CUL |
| 341 | #define SM501_GPIO_DATA_HIGH 0x00010004UL |
| 342 | #define SM501_GPIO_51 0x00080000UL |
Bartlomiej Sieka | 79eecbfb | 2006-11-01 01:38:16 +0100 | [diff] [blame] | 343 | #endif /* CONFIG MINIFAP */ |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 344 | |
| 345 | void init_ide_reset (void) |
| 346 | { |
| 347 | debug ("init_ide_reset\n"); |
| 348 | |
| 349 | #if defined (CONFIG_MINIFAP) |
| 350 | /* Configure GPIO_51 of the SM501 grafic controller as ATA reset */ |
| 351 | |
| 352 | /* enable GPIO control (in both power modes) */ |
| 353 | *(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE0_GATE) |= |
| 354 | POWER_MODE_GATE_GPIO_PWM_I2C; |
| 355 | *(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE1_GATE) |= |
| 356 | POWER_MODE_GATE_GPIO_PWM_I2C; |
| 357 | /* configure GPIO51 as output */ |
| 358 | *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_DIR_HIGH) |= |
| 359 | SM501_GPIO_51; |
| 360 | #else |
| 361 | /* Configure PSC1_4 as GPIO output for ATA reset */ |
| 362 | *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4; |
| 363 | *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4; |
Martin Krause | 5f7c6f9 | 2008-04-03 14:29:01 +0200 | [diff] [blame] | 364 | |
| 365 | /* by default the ATA reset is de-asserted */ |
| 366 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 367 | #endif |
| 368 | } |
| 369 | |
| 370 | void ide_set_reset (int idereset) |
| 371 | { |
| 372 | debug ("ide_reset(%d)\n", idereset); |
| 373 | |
| 374 | #if defined (CONFIG_MINIFAP) |
| 375 | if (idereset) { |
| 376 | *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &= |
| 377 | ~SM501_GPIO_51; |
| 378 | } else { |
| 379 | *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |= |
| 380 | SM501_GPIO_51; |
| 381 | } |
| 382 | #else |
| 383 | if (idereset) { |
Bartlomiej Sieka | 79eecbfb | 2006-11-01 01:38:16 +0100 | [diff] [blame] | 384 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 385 | } else { |
Bartlomiej Sieka | 79eecbfb | 2006-11-01 01:38:16 +0100 | [diff] [blame] | 386 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4; |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 387 | } |
| 388 | #endif |
| 389 | } |
Jon Loeliger | 761ea74 | 2007-07-10 10:48:22 -0500 | [diff] [blame] | 390 | #endif |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 391 | |
| 392 | #ifdef CONFIG_POST |
| 393 | /* |
| 394 | * Reads GPIO pin PSC6_3. A keypress is reported, if PSC6_3 is low. If PSC6_3 |
| 395 | * is left open, no keypress is detected. |
| 396 | */ |
| 397 | int post_hotkeys_pressed(void) |
| 398 | { |
Wolfgang Denk | f67272a | 2006-10-09 01:07:53 +0200 | [diff] [blame] | 399 | #ifdef CONFIG_STK52XX |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 400 | struct mpc5xxx_gpio *gpio; |
| 401 | |
| 402 | gpio = (struct mpc5xxx_gpio*) MPC5XXX_GPIO; |
| 403 | |
| 404 | /* |
Detlev Zundel | 3ba0fa7 | 2009-10-07 16:38:05 +0200 | [diff] [blame] | 405 | * Configure PSC6_0 through PSC6_3 as GPIO. |
wdenk | 7dd1329 | 2004-07-11 20:04:51 +0000 | [diff] [blame] | 406 | */ |
Detlev Zundel | 3ba0fa7 | 2009-10-07 16:38:05 +0200 | [diff] [blame] | 407 | gpio->port_config &= ~(0x00700000); |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 408 | |
| 409 | /* Enable GPIO for GPIO_IRDA_1 (IR_USB_CLK pin) = PSC6_3 */ |
| 410 | gpio->simple_gpioe |= 0x20000000; |
| 411 | |
| 412 | /* Configure GPIO_IRDA_1 as input */ |
| 413 | gpio->simple_ddr &= ~(0x20000000); |
| 414 | |
| 415 | return ((gpio->simple_ival & 0x20000000) ? 0 : 1); |
Wolfgang Denk | f67272a | 2006-10-09 01:07:53 +0200 | [diff] [blame] | 416 | #else |
| 417 | return 0; |
| 418 | #endif |
wdenk | 6451936 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 419 | } |
| 420 | #endif |
| 421 | |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 422 | #ifdef CONFIG_BOARD_EARLY_INIT_R |
| 423 | int board_early_init_r (void) |
| 424 | { |
Markus Klotzbuecher | 2f1a4ce | 2008-01-09 13:57:10 +0100 | [diff] [blame] | 425 | |
Wolfgang Denk | 9225411 | 2007-11-18 16:36:27 +0100 | [diff] [blame] | 426 | extern int usb_cpu_init(void); |
| 427 | |
Marian Balakowicz | fa65a4a | 2007-10-24 01:37:36 +0200 | [diff] [blame] | 428 | #ifdef CONFIG_PS2MULT |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 429 | ps2mult_early_init(); |
Marian Balakowicz | fa65a4a | 2007-10-24 01:37:36 +0200 | [diff] [blame] | 430 | #endif /* CONFIG_PS2MULT */ |
| 431 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 432 | #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) |
Marian Balakowicz | fa65a4a | 2007-10-24 01:37:36 +0200 | [diff] [blame] | 433 | /* Low level USB init, required for proper kernel operation */ |
| 434 | usb_cpu_init(); |
| 435 | #endif |
| 436 | |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 437 | return (0); |
| 438 | } |
| 439 | #endif |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 440 | |
Wolfgang Denk | 573a3ad | 2006-09-13 10:47:05 +0200 | [diff] [blame] | 441 | #ifdef CONFIG_FO300 |
| 442 | int silent_boot (void) |
| 443 | { |
| 444 | vu_long timer3_status; |
| 445 | |
| 446 | /* Configure GPT3 as GPIO input */ |
| 447 | *(vu_long *)MPC5XXX_GPT3_ENABLE = 0x00000004; |
| 448 | |
| 449 | /* Read in TIMER_3 pin status */ |
| 450 | timer3_status = *(vu_long *)MPC5XXX_GPT3_STATUS; |
| 451 | |
| 452 | #ifdef FO300_SILENT_CONSOLE_WHEN_S1_CLOSED |
| 453 | /* Force silent console mode if S1 switch |
| 454 | * is in closed position (TIMER_3 pin status is LOW). */ |
| 455 | if (MPC5XXX_GPT_GPIO_PIN(timer3_status) == 0) |
| 456 | return 1; |
| 457 | #else |
| 458 | /* Force silent console mode if S1 switch |
| 459 | * is in open position (TIMER_3 pin status is HIGH). */ |
| 460 | if (MPC5XXX_GPT_GPIO_PIN(timer3_status) == 1) |
| 461 | return 1; |
| 462 | #endif |
| 463 | |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | int board_early_init_f (void) |
| 468 | { |
Wolfgang Denk | 573a3ad | 2006-09-13 10:47:05 +0200 | [diff] [blame] | 469 | if (silent_boot()) |
| 470 | gd->flags |= GD_FLG_SILENT; |
| 471 | |
| 472 | return 0; |
| 473 | } |
| 474 | #endif /* CONFIG_FO300 */ |
| 475 | |
Heiko Schocher | 1ae9144 | 2010-12-04 08:34:04 +0100 | [diff] [blame] | 476 | #if defined(CONFIG_CHARON) |
| 477 | #include <i2c.h> |
| 478 | #include <asm/io.h> |
| 479 | |
| 480 | /* The TFP410 registers */ |
| 481 | #define TFP410_REG_VEN_ID_L 0x00 |
| 482 | #define TFP410_REG_VEN_ID_H 0x01 |
| 483 | #define TFP410_REG_DEV_ID_L 0x02 |
| 484 | #define TFP410_REG_DEV_ID_H 0x03 |
| 485 | #define TFP410_REG_REV_ID 0x04 |
| 486 | |
| 487 | #define TFP410_REG_CTL_1_MODE 0x08 |
| 488 | #define TFP410_REG_CTL_2_MODE 0x09 |
| 489 | #define TFP410_REG_CTL_3_MODE 0x0A |
| 490 | |
| 491 | #define TFP410_REG_CFG 0x0B |
| 492 | |
| 493 | #define TFP410_REG_DE_DLY 0x32 |
| 494 | #define TFP410_REG_DE_CTL 0x33 |
| 495 | #define TFP410_REG_DE_TOP 0x34 |
| 496 | #define TFP410_REG_DE_CNT_L 0x36 |
| 497 | #define TFP410_REG_DE_CNT_H 0x37 |
| 498 | #define TFP410_REG_DE_LIN_L 0x38 |
| 499 | #define TFP410_REG_DE_LIN_H 0x39 |
| 500 | |
| 501 | #define TFP410_REG_H_RES_L 0x3A |
| 502 | #define TFP410_REG_H_RES_H 0x3B |
| 503 | #define TFP410_REG_V_RES_L 0x3C |
| 504 | #define TFP410_REG_V_RES_H 0x3D |
| 505 | |
| 506 | static int tfp410_read_reg(int reg, uchar *buf) |
| 507 | { |
| 508 | if (i2c_read(CONFIG_SYS_TFP410_ADDR, reg, 1, buf, 1) != 0) { |
| 509 | puts ("Error reading the chip.\n"); |
| 510 | return 1; |
| 511 | } |
| 512 | return 0; |
| 513 | } |
| 514 | |
| 515 | static int tfp410_write_reg(int reg, uchar buf) |
| 516 | { |
| 517 | if (i2c_write(CONFIG_SYS_TFP410_ADDR, reg, 1, &buf, 1) != 0) { |
| 518 | puts ("Error writing the chip.\n"); |
| 519 | return 1; |
| 520 | } |
| 521 | return 0; |
| 522 | } |
| 523 | |
| 524 | typedef struct _tfp410_config { |
| 525 | int reg; |
| 526 | uchar val; |
| 527 | }TFP410_CONFIG; |
| 528 | |
| 529 | static TFP410_CONFIG tfp410_configtbl[] = { |
| 530 | {TFP410_REG_CTL_1_MODE, 0x37}, |
| 531 | {TFP410_REG_CTL_2_MODE, 0x20}, |
| 532 | {TFP410_REG_CTL_3_MODE, 0x80}, |
| 533 | {TFP410_REG_DE_DLY, 0x90}, |
| 534 | {TFP410_REG_DE_CTL, 0x00}, |
| 535 | {TFP410_REG_DE_TOP, 0x23}, |
| 536 | {TFP410_REG_DE_CNT_H, 0x02}, |
| 537 | {TFP410_REG_DE_CNT_L, 0x80}, |
| 538 | {TFP410_REG_DE_LIN_H, 0x01}, |
| 539 | {TFP410_REG_DE_LIN_L, 0xe0}, |
| 540 | {-1, 0}, |
| 541 | }; |
| 542 | |
| 543 | static int charon_last_stage_init(void) |
| 544 | { |
| 545 | volatile struct mpc5xxx_lpb *lpb = |
| 546 | (struct mpc5xxx_lpb *) MPC5XXX_LPB; |
| 547 | int oldbus = i2c_get_bus_num(); |
| 548 | uchar buf; |
| 549 | int i = 0; |
| 550 | |
| 551 | i2c_set_bus_num(CONFIG_SYS_TFP410_BUS); |
| 552 | |
| 553 | /* check version */ |
| 554 | if (tfp410_read_reg(TFP410_REG_DEV_ID_H, &buf) != 0) |
| 555 | return -1; |
| 556 | if (!(buf & 0x04)) |
| 557 | return -1; |
| 558 | if (tfp410_read_reg(TFP410_REG_DEV_ID_L, &buf) != 0) |
| 559 | return -1; |
| 560 | if (!(buf & 0x10)) |
| 561 | return -1; |
| 562 | /* OK, now init the chip */ |
| 563 | while (tfp410_configtbl[i].reg != -1) { |
| 564 | int ret; |
| 565 | |
| 566 | ret = tfp410_write_reg(tfp410_configtbl[i].reg, |
| 567 | tfp410_configtbl[i].val); |
| 568 | if (ret != 0) |
| 569 | return -1; |
| 570 | i++; |
| 571 | } |
| 572 | printf("TFP410 initialized.\n"); |
| 573 | i2c_set_bus_num(oldbus); |
| 574 | |
| 575 | /* set deadcycle for cs3 to 0 */ |
| 576 | setbits_be32(&lpb->cs_deadcycle, 0xffffcfff); |
| 577 | return 0; |
| 578 | } |
| 579 | #endif |
| 580 | |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 581 | int last_stage_init (void) |
| 582 | { |
| 583 | /* |
| 584 | * auto scan for really existing devices and re-set chip select |
| 585 | * configuration. |
| 586 | */ |
| 587 | u16 save, tmp; |
| 588 | int restore; |
| 589 | |
| 590 | /* |
| 591 | * Check for SRAM and SRAM size |
| 592 | */ |
| 593 | |
Wolfgang Denk | 7111215 | 2005-08-18 11:55:22 +0200 | [diff] [blame] | 594 | /* save original SRAM content */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 595 | save = *(volatile u16 *)CONFIG_SYS_CS2_START; |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 596 | restore = 1; |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 597 | |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 598 | /* write test pattern to SRAM */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 599 | *(volatile u16 *)CONFIG_SYS_CS2_START = 0xA5A5; |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 600 | __asm__ volatile ("sync"); |
| 601 | /* |
| 602 | * Put a different pattern on the data lines: otherwise they may float |
| 603 | * long enough to read back what we wrote. |
| 604 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 605 | tmp = *(volatile u16 *)CONFIG_SYS_FLASH_BASE; |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 606 | if (tmp == 0xA5A5) |
| 607 | puts ("!! possible error in SRAM detection\n"); |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 608 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 609 | if (*(volatile u16 *)CONFIG_SYS_CS2_START != 0xA5A5) { |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 610 | /* no SRAM at all, disable cs */ |
| 611 | *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 18); |
| 612 | *(vu_long *)MPC5XXX_CS2_START = 0x0000FFFF; |
| 613 | *(vu_long *)MPC5XXX_CS2_STOP = 0x0000FFFF; |
| 614 | restore = 0; |
| 615 | __asm__ volatile ("sync"); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 616 | } else if (*(volatile u16 *)(CONFIG_SYS_CS2_START + (1<<19)) == 0xA5A5) { |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 617 | /* make sure that we access a mirrored address */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 618 | *(volatile u16 *)CONFIG_SYS_CS2_START = 0x1111; |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 619 | __asm__ volatile ("sync"); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 620 | if (*(volatile u16 *)(CONFIG_SYS_CS2_START + (1<<19)) == 0x1111) { |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 621 | /* SRAM size = 512 kByte */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 622 | *(vu_long *)MPC5XXX_CS2_STOP = STOP_REG(CONFIG_SYS_CS2_START, |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 623 | 0x80000); |
| 624 | __asm__ volatile ("sync"); |
| 625 | puts ("SRAM: 512 kB\n"); |
| 626 | } |
| 627 | else |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 628 | puts ("!! possible error in SRAM detection\n"); |
Wolfgang Denk | 7111215 | 2005-08-18 11:55:22 +0200 | [diff] [blame] | 629 | } else { |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 630 | puts ("SRAM: 1 MB\n"); |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 631 | } |
| 632 | /* restore origianl SRAM content */ |
| 633 | if (restore) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 634 | *(volatile u16 *)CONFIG_SYS_CS2_START = save; |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 635 | __asm__ volatile ("sync"); |
| 636 | } |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 637 | |
Martin Krause | 8dcc9f6 | 2007-10-22 16:40:06 +0200 | [diff] [blame] | 638 | #ifndef CONFIG_TQM5200S /* The TQM5200S has no SM501 grafic controller */ |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 639 | /* |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 640 | * Check for Grafic Controller |
| 641 | */ |
| 642 | |
| 643 | /* save origianl FB content */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 644 | save = *(volatile u16 *)CONFIG_SYS_CS1_START; |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 645 | restore = 1; |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 646 | |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 647 | /* write test pattern to FB memory */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 648 | *(volatile u16 *)CONFIG_SYS_CS1_START = 0xA5A5; |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 649 | __asm__ volatile ("sync"); |
| 650 | /* |
| 651 | * Put a different pattern on the data lines: otherwise they may float |
| 652 | * long enough to read back what we wrote. |
| 653 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 654 | tmp = *(volatile u16 *)CONFIG_SYS_FLASH_BASE; |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 655 | if (tmp == 0xA5A5) |
| 656 | puts ("!! possible error in grafic controller detection\n"); |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 657 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 658 | if (*(volatile u16 *)CONFIG_SYS_CS1_START != 0xA5A5) { |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 659 | /* no grafic controller at all, disable cs */ |
| 660 | *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 17); |
| 661 | *(vu_long *)MPC5XXX_CS1_START = 0x0000FFFF; |
| 662 | *(vu_long *)MPC5XXX_CS1_STOP = 0x0000FFFF; |
| 663 | restore = 0; |
| 664 | __asm__ volatile ("sync"); |
Wolfgang Denk | 7111215 | 2005-08-18 11:55:22 +0200 | [diff] [blame] | 665 | } else { |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 666 | puts ("VGA: SMI501 (Voyager) with 8 MB\n"); |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 667 | } |
| 668 | /* restore origianl FB content */ |
| 669 | if (restore) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 670 | *(volatile u16 *)CONFIG_SYS_CS1_START = save; |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 671 | __asm__ volatile ("sync"); |
| 672 | } |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 673 | |
Wolfgang Denk | 573a3ad | 2006-09-13 10:47:05 +0200 | [diff] [blame] | 674 | #ifdef CONFIG_FO300 |
| 675 | if (silent_boot()) { |
| 676 | setenv("bootdelay", "0"); |
| 677 | disable_ctrlc(1); |
| 678 | } |
| 679 | #endif |
Wolfgang Denk | 9225411 | 2007-11-18 16:36:27 +0100 | [diff] [blame] | 680 | #endif /* !CONFIG_TQM5200S */ |
Wolfgang Denk | 573a3ad | 2006-09-13 10:47:05 +0200 | [diff] [blame] | 681 | |
Heiko Schocher | 1ae9144 | 2010-12-04 08:34:04 +0100 | [diff] [blame] | 682 | #if defined(CONFIG_CHARON) |
| 683 | charon_last_stage_init(); |
| 684 | #endif |
wdenk | dc13044 | 2004-12-12 22:06:17 +0000 | [diff] [blame] | 685 | return 0; |
| 686 | } |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 687 | |
| 688 | #ifdef CONFIG_VIDEO_SM501 |
| 689 | |
Marian Balakowicz | bcb0cca | 2006-08-18 19:14:46 +0200 | [diff] [blame] | 690 | #ifdef CONFIG_FO300 |
| 691 | #define DISPLAY_WIDTH 800 |
| 692 | #else |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 693 | #define DISPLAY_WIDTH 640 |
Marian Balakowicz | bcb0cca | 2006-08-18 19:14:46 +0200 | [diff] [blame] | 694 | #endif |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 695 | #define DISPLAY_HEIGHT 480 |
| 696 | |
| 697 | #ifdef CONFIG_VIDEO_SM501_8BPP |
| 698 | #error CONFIG_VIDEO_SM501_8BPP not supported. |
| 699 | #endif /* CONFIG_VIDEO_SM501_8BPP */ |
| 700 | |
| 701 | #ifdef CONFIG_VIDEO_SM501_16BPP |
| 702 | #error CONFIG_VIDEO_SM501_16BPP not supported. |
| 703 | #endif /* CONFIG_VIDEO_SM501_16BPP */ |
| 704 | #ifdef CONFIG_VIDEO_SM501_32BPP |
| 705 | static const SMI_REGS init_regs [] = |
| 706 | { |
| 707 | #if 0 /* CRT only */ |
| 708 | {0x00004, 0x0}, |
| 709 | {0x00048, 0x00021807}, |
| 710 | {0x0004C, 0x10090a01}, |
| 711 | {0x00054, 0x1}, |
| 712 | {0x00040, 0x00021807}, |
| 713 | {0x00044, 0x10090a01}, |
| 714 | {0x00054, 0x0}, |
| 715 | {0x80200, 0x00010000}, |
| 716 | {0x80204, 0x0}, |
| 717 | {0x80208, 0x0A000A00}, |
| 718 | {0x8020C, 0x02fa027f}, |
| 719 | {0x80210, 0x004a028b}, |
| 720 | {0x80214, 0x020c01df}, |
| 721 | {0x80218, 0x000201e9}, |
| 722 | {0x80200, 0x00013306}, |
| 723 | #else /* panel + CRT */ |
Marian Balakowicz | bcb0cca | 2006-08-18 19:14:46 +0200 | [diff] [blame] | 724 | #ifdef CONFIG_FO300 |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 725 | {0x00004, 0x0}, |
| 726 | {0x00048, 0x00021807}, |
Marian Balakowicz | bcb0cca | 2006-08-18 19:14:46 +0200 | [diff] [blame] | 727 | {0x0004C, 0x301a0a01}, |
| 728 | {0x00054, 0x1}, |
| 729 | {0x00040, 0x00021807}, |
| 730 | {0x00044, 0x091a0a01}, |
| 731 | {0x00054, 0x0}, |
| 732 | {0x80000, 0x0f013106}, |
| 733 | {0x80004, 0xc428bb17}, |
| 734 | {0x8000C, 0x00000000}, |
| 735 | {0x80010, 0x0C800C80}, |
| 736 | {0x80014, 0x03200000}, |
| 737 | {0x80018, 0x01e00000}, |
| 738 | {0x8001C, 0x00000000}, |
| 739 | {0x80020, 0x01e00320}, |
| 740 | {0x80024, 0x042a031f}, |
| 741 | {0x80028, 0x0086034a}, |
| 742 | {0x8002C, 0x020c01df}, |
| 743 | {0x80030, 0x000201ea}, |
| 744 | {0x80200, 0x00010000}, |
| 745 | #else |
| 746 | {0x00004, 0x0}, |
| 747 | {0x00048, 0x00021807}, |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 748 | {0x0004C, 0x091a0a01}, |
| 749 | {0x00054, 0x1}, |
| 750 | {0x00040, 0x00021807}, |
| 751 | {0x00044, 0x091a0a01}, |
| 752 | {0x00054, 0x0}, |
| 753 | {0x80000, 0x0f013106}, |
| 754 | {0x80004, 0xc428bb17}, |
| 755 | {0x8000C, 0x00000000}, |
| 756 | {0x80010, 0x0a000a00}, |
| 757 | {0x80014, 0x02800000}, |
| 758 | {0x80018, 0x01e00000}, |
| 759 | {0x8001C, 0x00000000}, |
| 760 | {0x80020, 0x01e00280}, |
| 761 | {0x80024, 0x02fa027f}, |
| 762 | {0x80028, 0x004a028b}, |
| 763 | {0x8002C, 0x020c01df}, |
| 764 | {0x80030, 0x000201e9}, |
| 765 | {0x80200, 0x00010000}, |
Marian Balakowicz | bcb0cca | 2006-08-18 19:14:46 +0200 | [diff] [blame] | 766 | #endif /* #ifdef CONFIG_FO300 */ |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 767 | #endif |
| 768 | {0, 0} |
| 769 | }; |
| 770 | #endif /* CONFIG_VIDEO_SM501_32BPP */ |
| 771 | |
| 772 | #ifdef CONFIG_CONSOLE_EXTRA_INFO |
| 773 | /* |
| 774 | * Return text to be printed besides the logo. |
| 775 | */ |
| 776 | void video_get_info_str (int line_number, char *info) |
| 777 | { |
| 778 | if (line_number == 1) { |
Wolfgang Denk | 3f2f9dd | 2006-06-16 16:11:34 +0200 | [diff] [blame] | 779 | strcpy (info, " Board: TQM5200 (TQ-Components GmbH)"); |
Heiko Schocher | 1ae9144 | 2010-12-04 08:34:04 +0100 | [diff] [blame] | 780 | #if defined (CONFIG_CHARON) || defined (CONFIG_FO300) || \ |
| 781 | defined(CONFIG_STK52XX) || defined(CONFIG_TB5200) |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 782 | } else if (line_number == 2) { |
Heiko Schocher | 1ae9144 | 2010-12-04 08:34:04 +0100 | [diff] [blame] | 783 | #if defined (CONFIG_CHARON) |
| 784 | strcpy (info, " on a CHARON carrier board"); |
| 785 | #endif |
Wolfgang Denk | ba94093 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 786 | #if defined (CONFIG_STK52XX) |
Wolfgang Denk | 9975314 | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 787 | strcpy (info, " on a STK52xx carrier board"); |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 788 | #endif |
Wolfgang Denk | ba94093 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 789 | #if defined (CONFIG_TB5200) |
Wolfgang Denk | 9975314 | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 790 | strcpy (info, " on a TB5200 carrier board"); |
Wolfgang Denk | ba94093 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 791 | #endif |
Marian Balakowicz | bcb0cca | 2006-08-18 19:14:46 +0200 | [diff] [blame] | 792 | #if defined (CONFIG_FO300) |
| 793 | strcpy (info, " on a FO300 carrier board"); |
| 794 | #endif |
Wolfgang Denk | ba94093 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 795 | #endif |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 796 | } |
| 797 | else { |
| 798 | info [0] = '\0'; |
| 799 | } |
| 800 | } |
| 801 | #endif |
| 802 | |
| 803 | /* |
Wolfgang Denk | 7111215 | 2005-08-18 11:55:22 +0200 | [diff] [blame] | 804 | * Returns SM501 register base address. First thing called in the |
| 805 | * driver. Checks if SM501 is physically present. |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 806 | */ |
| 807 | unsigned int board_video_init (void) |
| 808 | { |
Wolfgang Denk | 7111215 | 2005-08-18 11:55:22 +0200 | [diff] [blame] | 809 | u16 save, tmp; |
| 810 | int restore, ret; |
| 811 | |
| 812 | /* |
| 813 | * Check for Grafic Controller |
| 814 | */ |
| 815 | |
| 816 | /* save origianl FB content */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 817 | save = *(volatile u16 *)CONFIG_SYS_CS1_START; |
Wolfgang Denk | 7111215 | 2005-08-18 11:55:22 +0200 | [diff] [blame] | 818 | restore = 1; |
| 819 | |
| 820 | /* write test pattern to FB memory */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 821 | *(volatile u16 *)CONFIG_SYS_CS1_START = 0xA5A5; |
Wolfgang Denk | 7111215 | 2005-08-18 11:55:22 +0200 | [diff] [blame] | 822 | __asm__ volatile ("sync"); |
| 823 | /* |
| 824 | * Put a different pattern on the data lines: otherwise they may float |
| 825 | * long enough to read back what we wrote. |
| 826 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 827 | tmp = *(volatile u16 *)CONFIG_SYS_FLASH_BASE; |
Wolfgang Denk | 7111215 | 2005-08-18 11:55:22 +0200 | [diff] [blame] | 828 | if (tmp == 0xA5A5) |
| 829 | puts ("!! possible error in grafic controller detection\n"); |
| 830 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 831 | if (*(volatile u16 *)CONFIG_SYS_CS1_START != 0xA5A5) { |
Wolfgang Denk | 7111215 | 2005-08-18 11:55:22 +0200 | [diff] [blame] | 832 | /* no grafic controller found */ |
| 833 | restore = 0; |
| 834 | ret = 0; |
| 835 | } else { |
| 836 | ret = SM501_MMIO_BASE; |
| 837 | } |
| 838 | |
| 839 | if (restore) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 840 | *(volatile u16 *)CONFIG_SYS_CS1_START = save; |
Wolfgang Denk | 7111215 | 2005-08-18 11:55:22 +0200 | [diff] [blame] | 841 | __asm__ volatile ("sync"); |
| 842 | } |
| 843 | return ret; |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 844 | } |
| 845 | |
| 846 | /* |
| 847 | * Returns SM501 framebuffer address |
| 848 | */ |
| 849 | unsigned int board_video_get_fb (void) |
| 850 | { |
| 851 | return SM501_FB_BASE; |
| 852 | } |
| 853 | |
| 854 | /* |
| 855 | * Called after initializing the SM501 and before clearing the screen. |
| 856 | */ |
| 857 | void board_validate_screen (unsigned int base) |
| 858 | { |
| 859 | } |
| 860 | |
| 861 | /* |
| 862 | * Return a pointer to the initialization sequence. |
| 863 | */ |
| 864 | const SMI_REGS *board_get_regs (void) |
| 865 | { |
| 866 | return init_regs; |
| 867 | } |
| 868 | |
| 869 | int board_get_width (void) |
| 870 | { |
| 871 | return DISPLAY_WIDTH; |
| 872 | } |
| 873 | |
| 874 | int board_get_height (void) |
| 875 | { |
| 876 | return DISPLAY_HEIGHT; |
| 877 | } |
| 878 | |
| 879 | #endif /* CONFIG_VIDEO_SM501 */ |
Bartlomiej Sieka | 7a432ce | 2007-06-08 14:52:22 +0200 | [diff] [blame] | 880 | |
Grant Likely | 8d1e6e7 | 2007-09-06 09:46:23 -0600 | [diff] [blame] | 881 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
Bartlomiej Sieka | 7a432ce | 2007-06-08 14:52:22 +0200 | [diff] [blame] | 882 | void ft_board_setup(void *blob, bd_t *bd) |
| 883 | { |
| 884 | ft_cpu_setup(blob, bd); |
Heiko Schocher | 1ae9144 | 2010-12-04 08:34:04 +0100 | [diff] [blame] | 885 | #if defined(CONFIG_VIDEO) |
| 886 | fdt_add_edid(blob, "smi,sm501", edid_buf); |
| 887 | #endif |
Bartlomiej Sieka | 7a432ce | 2007-06-08 14:52:22 +0200 | [diff] [blame] | 888 | } |
Grant Likely | 8d1e6e7 | 2007-09-06 09:46:23 -0600 | [diff] [blame] | 889 | #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */ |
Ben Warren | f2c1acb | 2008-08-31 10:03:22 -0700 | [diff] [blame] | 890 | |
Heiko Schocher | 1ae9144 | 2010-12-04 08:34:04 +0100 | [diff] [blame] | 891 | #if defined(CONFIG_RESET_PHY_R) |
| 892 | #include <miiphy.h> |
| 893 | |
| 894 | void reset_phy(void) |
| 895 | { |
| 896 | /* init Micrel KSZ8993 PHY */ |
| 897 | miiphy_write("FEC", CONFIG_PHY_ADDR, 0x01, 0x09); |
| 898 | } |
| 899 | #endif |
| 900 | |
Ben Warren | f2c1acb | 2008-08-31 10:03:22 -0700 | [diff] [blame] | 901 | int board_eth_init(bd_t *bis) |
| 902 | { |
Ben Warren | cba8851 | 2008-08-31 10:39:12 -0700 | [diff] [blame] | 903 | cpu_eth_init(bis); /* Built in FEC comes first */ |
Ben Warren | f2c1acb | 2008-08-31 10:03:22 -0700 | [diff] [blame] | 904 | return pci_eth_init(bis); |
| 905 | } |