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