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