wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 1 | /* |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 2 | * (C) Copyright 2000-2008 |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <mpc8xx.h> |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 26 | #ifdef CONFIG_PS2MULT |
| 27 | #include <ps2mult.h> |
| 28 | #endif |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 29 | |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 30 | extern flash_info_t flash_info[]; /* FLASH chips info */ |
| 31 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 32 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 33 | |
| 34 | static long int dram_size (long int, long int *, long int); |
| 35 | |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 36 | #define _NOT_USED_ 0xFFFFFFFF |
| 37 | |
Jens Gehrlein | 22d1a56 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 38 | /* UPM initialization table for SDRAM: 40, 50, 66 MHz CLKOUT @ CAS latency 2, tWR=2 */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 39 | const uint sdram_table[] = |
| 40 | { |
| 41 | /* |
| 42 | * Single Read. (Offset 0 in UPMA RAM) |
| 43 | */ |
| 44 | 0x1F0DFC04, 0xEEAFBC04, 0x11AF7C04, 0xEFBAFC00, |
| 45 | 0x1FF5FC47, /* last */ |
| 46 | /* |
| 47 | * SDRAM Initialization (offset 5 in UPMA RAM) |
| 48 | * |
| 49 | * This is no UPM entry point. The following definition uses |
| 50 | * the remaining space to establish an initialization |
| 51 | * sequence, which is executed by a RUN command. |
| 52 | * |
| 53 | */ |
| 54 | 0x1FF5FC34, 0xEFEABC34, 0x1FB57C35, /* last */ |
| 55 | /* |
| 56 | * Burst Read. (Offset 8 in UPMA RAM) |
| 57 | */ |
| 58 | 0x1F0DFC04, 0xEEAFBC04, 0x10AF7C04, 0xF0AFFC00, |
| 59 | 0xF0AFFC00, 0xF1AFFC00, 0xEFBAFC00, 0x1FF5FC47, /* last */ |
| 60 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 61 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 62 | /* |
| 63 | * Single Write. (Offset 18 in UPMA RAM) |
| 64 | */ |
Jens Gehrlein | 22d1a56 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 65 | 0x1F0DFC04, 0xEEABBC00, 0x11B77C04, 0xEFFAFC44, |
| 66 | 0x1FF5FC47, /* last */ |
| 67 | _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 68 | /* |
| 69 | * Burst Write. (Offset 20 in UPMA RAM) |
| 70 | */ |
| 71 | 0x1F0DFC04, 0xEEABBC00, 0x10A77C00, 0xF0AFFC00, |
Jens Gehrlein | 22d1a56 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 72 | 0xF0AFFC00, 0xF0AFFC04, 0xE1BAFC44, 0x1FF5FC47, /* last */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 73 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 74 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 75 | /* |
| 76 | * Refresh (Offset 30 in UPMA RAM) |
| 77 | */ |
| 78 | 0x1FFD7C84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04, |
| 79 | 0xFFFFFC84, 0xFFFFFC07, /* last */ |
| 80 | _NOT_USED_, _NOT_USED_, |
| 81 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 82 | /* |
| 83 | * Exception. (Offset 3c in UPMA RAM) |
| 84 | */ |
Jens Gehrlein | 22d1a56 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 85 | 0xFFFFFC07, /* last */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 86 | _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 87 | }; |
| 88 | |
| 89 | /* ------------------------------------------------------------------------- */ |
| 90 | |
| 91 | |
| 92 | /* |
| 93 | * Check Board Identity: |
| 94 | * |
| 95 | * Test TQ ID string (TQM8xx...) |
| 96 | * If present, check for "L" type (no second DRAM bank), |
| 97 | * otherwise "L" type is assumed as default. |
| 98 | * |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 99 | * Set board_type to 'L' for "L" type, 'M' for "M" type, 0 else. |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 100 | */ |
| 101 | |
| 102 | int checkboard (void) |
| 103 | { |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 104 | char *s = getenv ("serial#"); |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 105 | |
| 106 | puts ("Board: "); |
| 107 | |
| 108 | if (!s || strncmp (s, "TQM8", 4)) { |
| 109 | puts ("### No HW ID - assuming TQM8xxL\n"); |
| 110 | return (0); |
| 111 | } |
| 112 | |
| 113 | if ((*(s + 6) == 'L')) { /* a TQM8xxL type */ |
| 114 | gd->board_type = 'L'; |
| 115 | } |
| 116 | |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 117 | if ((*(s + 6) == 'M')) { /* a TQM8xxM type */ |
| 118 | gd->board_type = 'M'; |
| 119 | } |
| 120 | |
Markus Klotzbuecher | 090eb73 | 2006-07-12 15:26:01 +0200 | [diff] [blame] | 121 | if ((*(s + 6) == 'D')) { /* a TQM885D type */ |
| 122 | gd->board_type = 'D'; |
| 123 | } |
| 124 | |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 125 | for (; *s; ++s) { |
| 126 | if (*s == ' ') |
| 127 | break; |
| 128 | putc (*s); |
| 129 | } |
Wolfgang Denk | 8cba090 | 2006-05-12 16:15:46 +0200 | [diff] [blame] | 130 | #ifdef CONFIG_VIRTLAB2 |
| 131 | puts (" (Virtlab2)"); |
| 132 | #endif |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 133 | putc ('\n'); |
| 134 | |
| 135 | return (0); |
| 136 | } |
| 137 | |
| 138 | /* ------------------------------------------------------------------------- */ |
| 139 | |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 140 | phys_size_t initdram (int board_type) |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 141 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 142 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 143 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
wdenk | c178d3d | 2004-01-24 20:25:54 +0000 | [diff] [blame] | 144 | long int size8, size9, size10; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 145 | long int size_b0 = 0; |
| 146 | long int size_b1 = 0; |
| 147 | |
| 148 | upmconfig (UPMA, (uint *) sdram_table, |
| 149 | sizeof (sdram_table) / sizeof (uint)); |
| 150 | |
| 151 | /* |
| 152 | * Preliminary prescaler for refresh (depends on number of |
| 153 | * banks): This value is selected for four cycles every 62.4 us |
| 154 | * with two SDRAM banks or four cycles every 31.2 us with one |
| 155 | * bank. It will be adjusted after memory sizing. |
| 156 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 157 | memctl->memc_mptpr = CONFIG_SYS_MPTPR_2BK_8K; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 158 | |
| 159 | /* |
| 160 | * The following value is used as an address (i.e. opcode) for |
| 161 | * the LOAD MODE REGISTER COMMAND during SDRAM initialisation. If |
| 162 | * the port size is 32bit the SDRAM does NOT "see" the lower two |
| 163 | * address lines, i.e. mar=0x00000088 -> opcode=0x00000022 for |
| 164 | * MICRON SDRAMs: |
| 165 | * -> 0 00 010 0 010 |
| 166 | * | | | | +- Burst Length = 4 |
| 167 | * | | | +----- Burst Type = Sequential |
| 168 | * | | +------- CAS Latency = 2 |
| 169 | * | +----------- Operating Mode = Standard |
| 170 | * +-------------- Write Burst Mode = Programmed Burst Length |
| 171 | */ |
| 172 | memctl->memc_mar = 0x00000088; |
| 173 | |
| 174 | /* |
| 175 | * Map controller banks 2 and 3 to the SDRAM banks 2 and 3 at |
| 176 | * preliminary addresses - these have to be modified after the |
| 177 | * SDRAM size has been determined. |
| 178 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 179 | memctl->memc_or2 = CONFIG_SYS_OR2_PRELIM; |
| 180 | memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 181 | |
| 182 | #ifndef CONFIG_CAN_DRIVER |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 183 | if ((board_type != 'L') && |
Markus Klotzbuecher | 090eb73 | 2006-07-12 15:26:01 +0200 | [diff] [blame] | 184 | (board_type != 'M') && |
Martin Krause | 11d9eec | 2007-09-26 17:55:56 +0200 | [diff] [blame] | 185 | (board_type != 'D') ) { /* only one SDRAM bank on L, M and D modules */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 186 | memctl->memc_or3 = CONFIG_SYS_OR3_PRELIM; |
| 187 | memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 188 | } |
| 189 | #endif /* CONFIG_CAN_DRIVER */ |
| 190 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 191 | memctl->memc_mamr = CONFIG_SYS_MAMR_8COL & (~(MAMR_PTAE)); /* no refresh yet */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 192 | |
| 193 | udelay (200); |
| 194 | |
| 195 | /* perform SDRAM initializsation sequence */ |
| 196 | |
| 197 | memctl->memc_mcr = 0x80004105; /* SDRAM bank 0 */ |
| 198 | udelay (1); |
| 199 | memctl->memc_mcr = 0x80004230; /* SDRAM bank 0 - execute twice */ |
| 200 | udelay (1); |
| 201 | |
| 202 | #ifndef CONFIG_CAN_DRIVER |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 203 | if ((board_type != 'L') && |
Markus Klotzbuecher | 090eb73 | 2006-07-12 15:26:01 +0200 | [diff] [blame] | 204 | (board_type != 'M') && |
Wolfgang Denk | fc1840e | 2006-07-21 18:51:56 +0200 | [diff] [blame] | 205 | (board_type != 'D') ) { /* only one SDRAM bank on L, M and D modules */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 206 | memctl->memc_mcr = 0x80006105; /* SDRAM bank 1 */ |
| 207 | udelay (1); |
| 208 | memctl->memc_mcr = 0x80006230; /* SDRAM bank 1 - execute twice */ |
| 209 | udelay (1); |
| 210 | } |
| 211 | #endif /* CONFIG_CAN_DRIVER */ |
| 212 | |
| 213 | memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */ |
| 214 | |
| 215 | udelay (1000); |
| 216 | |
| 217 | /* |
| 218 | * Check Bank 0 Memory Size for re-configuration |
| 219 | * |
| 220 | * try 8 column mode |
| 221 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 222 | size8 = dram_size (CONFIG_SYS_MAMR_8COL, SDRAM_BASE2_PRELIM, SDRAM_MAX_SIZE); |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 223 | debug ("SDRAM Bank 0 in 8 column mode: %ld MB\n", size8 >> 20); |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 224 | |
| 225 | udelay (1000); |
| 226 | |
| 227 | /* |
| 228 | * try 9 column mode |
| 229 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 230 | size9 = dram_size (CONFIG_SYS_MAMR_9COL, SDRAM_BASE2_PRELIM, SDRAM_MAX_SIZE); |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 231 | debug ("SDRAM Bank 0 in 9 column mode: %ld MB\n", size9 >> 20); |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 232 | |
wdenk | c178d3d | 2004-01-24 20:25:54 +0000 | [diff] [blame] | 233 | udelay(1000); |
| 234 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 235 | #if defined(CONFIG_SYS_MAMR_10COL) |
wdenk | c178d3d | 2004-01-24 20:25:54 +0000 | [diff] [blame] | 236 | /* |
| 237 | * try 10 column mode |
| 238 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 239 | size10 = dram_size (CONFIG_SYS_MAMR_10COL, SDRAM_BASE2_PRELIM, SDRAM_MAX_SIZE); |
wdenk | c178d3d | 2004-01-24 20:25:54 +0000 | [diff] [blame] | 240 | debug ("SDRAM Bank 0 in 10 column mode: %ld MB\n", size10 >> 20); |
| 241 | #else |
| 242 | size10 = 0; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 243 | #endif /* CONFIG_SYS_MAMR_10COL */ |
wdenk | c178d3d | 2004-01-24 20:25:54 +0000 | [diff] [blame] | 244 | |
| 245 | if ((size8 < size10) && (size9 < size10)) { |
| 246 | size_b0 = size10; |
| 247 | } else if ((size8 < size9) && (size10 < size9)) { |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 248 | size_b0 = size9; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 249 | memctl->memc_mamr = CONFIG_SYS_MAMR_9COL; |
wdenk | c178d3d | 2004-01-24 20:25:54 +0000 | [diff] [blame] | 250 | udelay (500); |
| 251 | } else { |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 252 | size_b0 = size8; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 253 | memctl->memc_mamr = CONFIG_SYS_MAMR_8COL; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 254 | udelay (500); |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 255 | } |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 256 | debug ("SDRAM Bank 0: %ld MB\n", size_b0 >> 20); |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 257 | |
| 258 | #ifndef CONFIG_CAN_DRIVER |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 259 | if ((board_type != 'L') && |
Markus Klotzbuecher | 090eb73 | 2006-07-12 15:26:01 +0200 | [diff] [blame] | 260 | (board_type != 'M') && |
Martin Krause | 11d9eec | 2007-09-26 17:55:56 +0200 | [diff] [blame] | 261 | (board_type != 'D') ) { /* only one SDRAM bank on L, M and D modules */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 262 | /* |
| 263 | * Check Bank 1 Memory Size |
| 264 | * use current column settings |
| 265 | * [9 column SDRAM may also be used in 8 column mode, |
| 266 | * but then only half the real size will be used.] |
| 267 | */ |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 268 | size_b1 = dram_size (memctl->memc_mamr, (long int *)SDRAM_BASE3_PRELIM, |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 269 | SDRAM_MAX_SIZE); |
| 270 | debug ("SDRAM Bank 1: %ld MB\n", size_b1 >> 20); |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 271 | } else { |
| 272 | size_b1 = 0; |
| 273 | } |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 274 | #endif /* CONFIG_CAN_DRIVER */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 275 | |
| 276 | udelay (1000); |
| 277 | |
| 278 | /* |
| 279 | * Adjust refresh rate depending on SDRAM type, both banks |
| 280 | * For types > 128 MBit leave it at the current (fast) rate |
| 281 | */ |
| 282 | if ((size_b0 < 0x02000000) && (size_b1 < 0x02000000)) { |
| 283 | /* reduce to 15.6 us (62.4 us / quad) */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 284 | memctl->memc_mptpr = CONFIG_SYS_MPTPR_2BK_4K; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 285 | udelay (1000); |
| 286 | } |
| 287 | |
| 288 | /* |
| 289 | * Final mapping: map bigger bank first |
| 290 | */ |
| 291 | if (size_b1 > size_b0) { /* SDRAM Bank 1 is bigger - map first */ |
| 292 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 293 | memctl->memc_or3 = ((-size_b1) & 0xFFFF0000) | CONFIG_SYS_OR_TIMING_SDRAM; |
| 294 | memctl->memc_br3 = (CONFIG_SYS_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 295 | |
| 296 | if (size_b0 > 0) { |
| 297 | /* |
| 298 | * Position Bank 0 immediately above Bank 1 |
| 299 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 300 | memctl->memc_or2 = ((-size_b0) & 0xFFFF0000) | CONFIG_SYS_OR_TIMING_SDRAM; |
| 301 | memctl->memc_br2 = ((CONFIG_SYS_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V) |
wdenk | c178d3d | 2004-01-24 20:25:54 +0000 | [diff] [blame] | 302 | + size_b1; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 303 | } else { |
| 304 | unsigned long reg; |
| 305 | |
| 306 | /* |
| 307 | * No bank 0 |
| 308 | * |
| 309 | * invalidate bank |
| 310 | */ |
| 311 | memctl->memc_br2 = 0; |
| 312 | |
| 313 | /* adjust refresh rate depending on SDRAM type, one bank */ |
| 314 | reg = memctl->memc_mptpr; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 315 | reg >>= 1; /* reduce to CONFIG_SYS_MPTPR_1BK_8K / _4K */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 316 | memctl->memc_mptpr = reg; |
| 317 | } |
| 318 | |
| 319 | } else { /* SDRAM Bank 0 is bigger - map first */ |
| 320 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 321 | memctl->memc_or2 = ((-size_b0) & 0xFFFF0000) | CONFIG_SYS_OR_TIMING_SDRAM; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 322 | memctl->memc_br2 = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 323 | (CONFIG_SYS_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 324 | |
| 325 | if (size_b1 > 0) { |
| 326 | /* |
| 327 | * Position Bank 1 immediately above Bank 0 |
| 328 | */ |
| 329 | memctl->memc_or3 = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 330 | ((-size_b1) & 0xFFFF0000) | CONFIG_SYS_OR_TIMING_SDRAM; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 331 | memctl->memc_br3 = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 332 | ((CONFIG_SYS_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V) |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 333 | + size_b0; |
| 334 | } else { |
| 335 | unsigned long reg; |
| 336 | |
| 337 | #ifndef CONFIG_CAN_DRIVER |
| 338 | /* |
| 339 | * No bank 1 |
| 340 | * |
| 341 | * invalidate bank |
| 342 | */ |
| 343 | memctl->memc_br3 = 0; |
| 344 | #endif /* CONFIG_CAN_DRIVER */ |
| 345 | |
| 346 | /* adjust refresh rate depending on SDRAM type, one bank */ |
| 347 | reg = memctl->memc_mptpr; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 348 | reg >>= 1; /* reduce to CONFIG_SYS_MPTPR_1BK_8K / _4K */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 349 | memctl->memc_mptpr = reg; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | udelay (10000); |
| 354 | |
| 355 | #ifdef CONFIG_CAN_DRIVER |
Jens Gehrlein | 9d29250 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 356 | /* UPM initialization for CAN @ CLKOUT <= 66 MHz */ |
| 357 | |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 358 | /* Initialize OR3 / BR3 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 359 | memctl->memc_or3 = CONFIG_SYS_OR3_CAN; |
| 360 | memctl->memc_br3 = CONFIG_SYS_BR3_CAN; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 361 | |
| 362 | /* Initialize MBMR */ |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 363 | memctl->memc_mbmr = MBMR_GPL_B4DIS; /* GPL_B4 ouput line Disable */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 364 | |
| 365 | /* Initialize UPMB for CAN: single read */ |
Jens Gehrlein | 9d29250 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 366 | memctl->memc_mdr = 0xFFFFCC04; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 367 | memctl->memc_mcr = 0x0100 | UPMB; |
| 368 | |
| 369 | memctl->memc_mdr = 0x0FFFD004; |
| 370 | memctl->memc_mcr = 0x0101 | UPMB; |
| 371 | |
| 372 | memctl->memc_mdr = 0x0FFFC000; |
| 373 | memctl->memc_mcr = 0x0102 | UPMB; |
| 374 | |
| 375 | memctl->memc_mdr = 0x3FFFC004; |
| 376 | memctl->memc_mcr = 0x0103 | UPMB; |
| 377 | |
Jens Gehrlein | 9d29250 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 378 | memctl->memc_mdr = 0xFFFFDC07; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 379 | memctl->memc_mcr = 0x0104 | UPMB; |
| 380 | |
| 381 | /* Initialize UPMB for CAN: single write */ |
Jens Gehrlein | 9d29250 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 382 | memctl->memc_mdr = 0xFFFCCC04; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 383 | memctl->memc_mcr = 0x0118 | UPMB; |
| 384 | |
Jens Gehrlein | 9d29250 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 385 | memctl->memc_mdr = 0xCFFCDC04; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 386 | memctl->memc_mcr = 0x0119 | UPMB; |
| 387 | |
Jens Gehrlein | 9d29250 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 388 | memctl->memc_mdr = 0x3FFCC000; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 389 | memctl->memc_mcr = 0x011A | UPMB; |
| 390 | |
Jens Gehrlein | 9d29250 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 391 | memctl->memc_mdr = 0xFFFCC004; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 392 | memctl->memc_mcr = 0x011B | UPMB; |
| 393 | |
Jens Gehrlein | 9d29250 | 2007-09-26 17:55:54 +0200 | [diff] [blame] | 394 | memctl->memc_mdr = 0xFFFDC405; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 395 | memctl->memc_mcr = 0x011C | UPMB; |
| 396 | #endif /* CONFIG_CAN_DRIVER */ |
| 397 | |
wdenk | bdccc4f | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 398 | #ifdef CONFIG_ISP1362_USB |
| 399 | /* Initialize OR5 / BR5 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 400 | memctl->memc_or5 = CONFIG_SYS_OR5_ISP1362; |
| 401 | memctl->memc_br5 = CONFIG_SYS_BR5_ISP1362; |
wdenk | bdccc4f | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 402 | #endif /* CONFIG_ISP1362_USB */ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 403 | return (size_b0 + size_b1); |
| 404 | } |
| 405 | |
| 406 | /* ------------------------------------------------------------------------- */ |
| 407 | |
| 408 | /* |
| 409 | * Check memory range for valid RAM. A simple memory test determines |
| 410 | * the actually available RAM size between addresses `base' and |
| 411 | * `base + maxsize'. Some (not all) hardware errors are detected: |
| 412 | * - short between address lines |
| 413 | * - short between data lines |
| 414 | */ |
| 415 | |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 416 | static long int dram_size (long int mamr_value, long int *base, long int maxsize) |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 417 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 418 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 419 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 420 | |
| 421 | memctl->memc_mamr = mamr_value; |
| 422 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 423 | return (get_ram_size(base, maxsize)); |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | /* ------------------------------------------------------------------------- */ |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 427 | |
| 428 | #ifdef CONFIG_PS2MULT |
| 429 | |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 430 | #ifdef CONFIG_HMI10 |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 431 | #define BASE_BAUD ( 1843200 / 16 ) |
| 432 | struct serial_state rs_table[] = { |
| 433 | { BASE_BAUD, 4, (void*)0xec140000 }, |
| 434 | { BASE_BAUD, 2, (void*)0xec150000 }, |
| 435 | { BASE_BAUD, 6, (void*)0xec160000 }, |
| 436 | { BASE_BAUD, 10, (void*)0xec170000 }, |
| 437 | }; |
wdenk | c837dcb | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 438 | |
| 439 | #ifdef CONFIG_BOARD_EARLY_INIT_R |
| 440 | int board_early_init_r (void) |
| 441 | { |
| 442 | ps2mult_early_init(); |
| 443 | return (0); |
| 444 | } |
| 445 | #endif |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 446 | #endif /* CONFIG_HMI10 */ |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 447 | |
| 448 | #endif /* CONFIG_PS2MULT */ |
| 449 | |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 450 | |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 451 | #ifdef CONFIG_MISC_INIT_R |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 452 | int misc_init_r (void) |
| 453 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 454 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 455 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 456 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 457 | #ifdef CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 458 | int scy, trlx, flash_or_timing, clk_diff; |
| 459 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 460 | scy = (CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ & OR_SCY_MSK) >> 4; |
| 461 | if (CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ & OR_TRLX) { |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 462 | trlx = OR_TRLX; |
| 463 | scy *= 2; |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 464 | } else { |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 465 | trlx = 0; |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 466 | } |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 467 | |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 468 | /* |
| 469 | * We assume that each 10MHz of bus clock require 1-clk SCY |
| 470 | * adjustment. |
| 471 | */ |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 472 | clk_diff = (gd->bus_clk / 1000000) - 50; |
| 473 | |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 474 | /* |
| 475 | * We need proper rounding here. This is what the "+5" and "-5" |
| 476 | * are here for. |
| 477 | */ |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 478 | if (clk_diff >= 0) |
| 479 | scy += (clk_diff + 5) / 10; |
| 480 | else |
| 481 | scy += (clk_diff - 5) / 10; |
| 482 | |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 483 | /* |
| 484 | * For bus frequencies above 50MHz, we want to use relaxed timing |
| 485 | * (OR_TRLX). |
| 486 | */ |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 487 | if (gd->bus_clk >= 50000000) |
| 488 | trlx = OR_TRLX; |
| 489 | else |
| 490 | trlx = 0; |
| 491 | |
| 492 | if (trlx) |
| 493 | scy /= 2; |
| 494 | |
| 495 | if (scy > 0xf) |
| 496 | scy = 0xf; |
| 497 | if (scy < 1) |
| 498 | scy = 1; |
| 499 | |
| 500 | flash_or_timing = (scy << 4) | trlx | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 501 | (CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ & ~(OR_TRLX | OR_SCY_MSK)); |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 502 | |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 503 | memctl->memc_or0 = |
| 504 | flash_or_timing | (-flash_info[0].size & OR_AM_MSK); |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 505 | #else |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 506 | memctl->memc_or0 = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 507 | CONFIG_SYS_OR_TIMING_FLASH | (-flash_info[0].size & OR_AM_MSK); |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 508 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 509 | memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) | BR_MS_GPCM | BR_V; |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 510 | |
| 511 | debug ("## BR0: 0x%08x OR0: 0x%08x\n", |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 512 | memctl->memc_br0, memctl->memc_or0); |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 513 | |
| 514 | if (flash_info[1].size) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 515 | #ifdef CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 516 | memctl->memc_or1 = flash_or_timing | |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 517 | (-flash_info[1].size & 0xFFFF8000); |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 518 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 519 | memctl->memc_or1 = CONFIG_SYS_OR_TIMING_FLASH | |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 520 | (-flash_info[1].size & 0xFFFF8000); |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 521 | #endif |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 522 | memctl->memc_br1 = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 523 | ((CONFIG_SYS_FLASH_BASE + |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 524 | flash_info[0]. |
| 525 | size) & BR_BA_MSK) | BR_MS_GPCM | BR_V; |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 526 | |
| 527 | debug ("## BR1: 0x%08x OR1: 0x%08x\n", |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 528 | memctl->memc_br1, memctl->memc_or1); |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 529 | } else { |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 530 | memctl->memc_br1 = 0; /* invalidate bank */ |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 531 | |
| 532 | debug ("## DISABLE BR1: 0x%08x OR1: 0x%08x\n", |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 533 | memctl->memc_br1, memctl->memc_or1); |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | # ifdef CONFIG_IDE_LED |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 537 | /* Configure PA15 as output port */ |
| 538 | immap->im_ioport.iop_padir |= 0x0001; |
| 539 | immap->im_ioport.iop_paodr |= 0x0001; |
| 540 | immap->im_ioport.iop_papar &= ~0x0001; |
| 541 | immap->im_ioport.iop_padat &= ~0x0001; /* turn it off */ |
wdenk | cfca5e6 | 2004-08-01 13:09:47 +0000 | [diff] [blame] | 542 | # endif |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 543 | |
| 544 | #ifdef CONFIG_NSCU |
| 545 | /* wake up ethernet module */ |
Wolfgang Denk | 87b4ef5 | 2008-09-17 10:17:55 +0200 | [diff] [blame] | 546 | immap->im_ioport.iop_pcpar &= ~0x0004; /* GPIO pin */ |
| 547 | immap->im_ioport.iop_pcdir |= 0x0004; /* output */ |
| 548 | immap->im_ioport.iop_pcso &= ~0x0004; /* for clarity */ |
| 549 | immap->im_ioport.iop_pcdat |= 0x0004; /* enable */ |
| 550 | #endif /* CONFIG_NSCU */ |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 551 | |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 552 | return (0); |
| 553 | } |
Wolfgang Denk | 7c803be | 2008-09-16 18:02:19 +0200 | [diff] [blame] | 554 | #endif /* CONFIG_MISC_INIT_R */ |
| 555 | |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 556 | |
wdenk | cfca5e6 | 2004-08-01 13:09:47 +0000 | [diff] [blame] | 557 | # ifdef CONFIG_IDE_LED |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 558 | void ide_led (uchar led, uchar status) |
| 559 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 560 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 1c43771 | 2004-01-16 00:30:56 +0000 | [diff] [blame] | 561 | |
| 562 | /* We have one led for both pcmcia slots */ |
| 563 | if (status) { /* led on */ |
| 564 | immap->im_ioport.iop_padat |= 0x0001; |
| 565 | } else { |
| 566 | immap->im_ioport.iop_padat &= ~0x0001; |
| 567 | } |
| 568 | } |
wdenk | cfca5e6 | 2004-08-01 13:09:47 +0000 | [diff] [blame] | 569 | # endif |
wdenk | cfca5e6 | 2004-08-01 13:09:47 +0000 | [diff] [blame] | 570 | |
Haavard Skinnemoen | 6b59e03 | 2008-09-01 16:21:22 +0200 | [diff] [blame^] | 571 | #ifdef CONFIG_LCD_INFO |
| 572 | #include <lcd.h> |
| 573 | |
| 574 | void lcd_show_board_info(void) |
| 575 | { |
| 576 | lcd_printf ("%s (%s - %s)\n", U_BOOT_VERSION, __DATE__, __TIME__); |
| 577 | lcd_printf ("(C) 2008 DENX Software Engineering GmbH\n"); |
| 578 | lcd_printf (" Wolfgang DENK, wd@denx.de\n"); |
| 579 | #ifdef CONFIG_LCD_INFO_BELOW_LOGO |
| 580 | lcd_printf ("MPC823 CPU at %s MHz\n", |
| 581 | strmhz(temp, gd->cpu_clk)); |
| 582 | lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3, |
| 583 | info, strlen(info)); |
| 584 | lcd_printf (" %ld MB RAM, %ld MB Flash\n", |
| 585 | gd->ram_size >> 20, |
| 586 | gd->bd->bi_flashsize >> 20 ); |
| 587 | #else |
| 588 | /* leave one blank line */ |
| 589 | lcd_printf ("\nMPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash\n", |
| 590 | strmhz(temp, gd->cpu_clk), |
| 591 | gd->ram_size >> 20, |
| 592 | gd->bd->bi_flashsize >> 20 ); |
| 593 | #endif /* CONFIG_LCD_INFO_BELOW_LOGO */ |
| 594 | } |
| 595 | #endif /* CONFIG_LCD_INFO */ |
| 596 | |
Guennadi Liakhovetski | efc6f44 | 2008-01-10 17:59:07 +0100 | [diff] [blame] | 597 | /* ---------------------------------------------------------------------------- */ |
| 598 | /* TK885D specific initializaion */ |
| 599 | /* ---------------------------------------------------------------------------- */ |
| 600 | #ifdef CONFIG_TK885D |
| 601 | #include <miiphy.h> |
| 602 | int last_stage_init(void) |
| 603 | { |
| 604 | const unsigned char phy[] = {CONFIG_FEC1_PHY, CONFIG_FEC2_PHY}; |
| 605 | unsigned short reg; |
| 606 | int ret, i = 100; |
| 607 | char *s; |
| 608 | |
| 609 | mii_init(); |
| 610 | /* Without this delay 0xff is read from the UART buffer later in |
| 611 | * abortboot() and autoboot is aborted */ |
| 612 | udelay(10000); |
| 613 | while (tstc() && i--) |
| 614 | (void)getc(); |
| 615 | |
| 616 | /* Check if auto-negotiation is prohibited */ |
| 617 | s = getenv("phy_auto_nego"); |
| 618 | |
| 619 | if (!s || !strcmp(s, "on")) |
| 620 | /* Nothing to do - autonegotiation by default */ |
| 621 | return 0; |
| 622 | |
| 623 | for (i = 0; i < 2; i++) { |
| 624 | ret = miiphy_read("FEC ETHERNET", phy[i], PHY_BMCR, ®); |
| 625 | if (ret) { |
| 626 | printf("Cannot read BMCR on PHY %d\n", phy[i]); |
| 627 | return 0; |
| 628 | } |
| 629 | /* Auto-negotiation off, hard set full duplex, 100Mbps */ |
| 630 | ret = miiphy_write("FEC ETHERNET", phy[i], |
| 631 | PHY_BMCR, (reg | PHY_BMCR_100MB | |
| 632 | PHY_BMCR_DPLX) & ~PHY_BMCR_AUTON); |
| 633 | if (ret) { |
| 634 | printf("Cannot write BMCR on PHY %d\n", phy[i]); |
| 635 | return 0; |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | return 0; |
| 640 | } |
Guennadi Liakhovetski | efc6f44 | 2008-01-10 17:59:07 +0100 | [diff] [blame] | 641 | #endif |