wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000, 2001 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * Ulrich Lutz, Speech Design GmbH, ulutz@datalab.de. |
| 5 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <mpc8xx.h> |
| 11 | #include <commproc.h> |
| 12 | |
| 13 | #ifdef CONFIG_STATUS_LED |
| 14 | # include <status_led.h> |
| 15 | #endif |
| 16 | |
| 17 | /* ------------------------------------------------------------------------- */ |
| 18 | |
| 19 | static long int dram_size (long int, long int *, long int); |
| 20 | |
| 21 | /* ------------------------------------------------------------------------- */ |
| 22 | |
| 23 | #define _NOT_USED_ 0xFFFFFFFF |
| 24 | |
| 25 | /* |
| 26 | * 50 MHz SHARC access using UPM A |
| 27 | */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 28 | const uint sharc_table[] = { |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 29 | /* |
| 30 | * Single Read. (Offset 0 in UPM RAM) |
| 31 | */ |
| 32 | 0x0FF3FC04, 0x0FF3EC00, 0x7FFFEC04, 0xFFFFEC04, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 33 | 0xFFFFEC05, /* last */ |
| 34 | _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 35 | /* |
| 36 | * Burst Read. (Offset 8 in UPM RAM) |
| 37 | */ |
| 38 | /* last */ |
| 39 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 40 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 41 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 42 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 43 | /* |
| 44 | * Single Write. (Offset 18 in UPM RAM) |
| 45 | */ |
| 46 | 0x0FAFFC04, 0x0FAFEC00, 0x7FFFEC04, 0xFFFFEC04, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 47 | 0xFFFFEC05, /* last */ |
| 48 | _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 49 | /* |
| 50 | * Burst Write. (Offset 20 in UPM RAM) |
| 51 | */ |
| 52 | /* last */ |
| 53 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 54 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 55 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 56 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 57 | /* |
| 58 | * Refresh (Offset 30 in UPM RAM) |
| 59 | */ |
| 60 | /* last */ |
| 61 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 62 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 63 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 64 | /* |
| 65 | * Exception. (Offset 3c in UPM RAM) |
| 66 | */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 67 | 0x7FFFFC07, /* last */ |
| 68 | _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | |
| 72 | /* |
| 73 | * 50 MHz SDRAM access using UPM B |
| 74 | */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 75 | const uint sdram_table[] = { |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 76 | /* |
| 77 | * Single Read. (Offset 0 in UPM RAM) |
| 78 | */ |
| 79 | 0x0E26FC04, 0x11ADFC04, 0xEFBBBC00, 0x1FF77C45, /* last */ |
| 80 | _NOT_USED_, |
| 81 | /* |
| 82 | * SDRAM Initialization (offset 5 in UPM RAM) |
| 83 | * |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 84 | * This is no UPM entry point. The following definition uses |
| 85 | * the remaining space to establish an initialization |
| 86 | * sequence, which is executed by a RUN command. |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 87 | * |
| 88 | */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 89 | 0x1FF77C35, 0xEFEABC34, 0x1FB57C35, /* last */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 90 | /* |
| 91 | * Burst Read. (Offset 8 in UPM RAM) |
| 92 | */ |
| 93 | 0x0E26FC04, 0x10ADFC04, 0xF0AFFC00, 0xF0AFFC00, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 94 | 0xF1AFFC00, 0xEFBBBC00, 0x1FF77C45, /* last */ |
| 95 | _NOT_USED_, |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 96 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 97 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 98 | /* |
| 99 | * Single Write. (Offset 18 in UPM RAM) |
| 100 | */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 101 | 0x1F27FC04, 0xEEAEBC04, 0x01B93C00, 0x1FF77C45, /* last */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 102 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 103 | /* |
| 104 | * Burst Write. (Offset 20 in UPM RAM) |
| 105 | */ |
| 106 | 0x0E26BC00, 0x10AD7C00, 0xF0AFFC00, 0xF0AFFC00, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 107 | 0xE1BBBC04, 0x1FF77C45, /* last */ |
| 108 | _NOT_USED_, _NOT_USED_, |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 109 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 110 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 111 | /* |
| 112 | * Refresh (Offset 30 in UPM RAM) |
| 113 | */ |
| 114 | 0x1FF5FC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC84, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 115 | 0xFFFFFC05, /* last */ |
| 116 | _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 117 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 118 | /* |
| 119 | * Exception. (Offset 3c in UPM RAM) |
| 120 | */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 121 | 0x7FFFFC07, /* last */ |
| 122 | _NOT_USED_, _NOT_USED_, _NOT_USED_, |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | /* ------------------------------------------------------------------------- */ |
| 126 | |
| 127 | |
| 128 | /* |
| 129 | * Check Board Identity: |
| 130 | * |
| 131 | */ |
| 132 | |
| 133 | int checkboard (void) |
| 134 | { |
| 135 | #ifdef CONFIG_IVMS8 |
| 136 | puts ("Board: IVMS8\n"); |
| 137 | #endif |
| 138 | #ifdef CONFIG_IVML24 |
| 139 | puts ("Board: IVM-L8/24\n"); |
| 140 | #endif |
| 141 | return (0); |
| 142 | } |
| 143 | |
| 144 | /* ------------------------------------------------------------------------- */ |
| 145 | |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 146 | phys_size_t initdram (int board_type) |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 147 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 148 | volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 149 | volatile memctl8xx_t *memctl = &immr->im_memctl; |
| 150 | long int size_b0; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 151 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 152 | /* enable SDRAM clock ("switch on" SDRAM) */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 153 | immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_SDRAM_CLKE); /* GPIO */ |
| 154 | immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_SDRAM_CLKE); /* active output */ |
| 155 | immr->im_cpm.cp_pbdir |= CONFIG_SYS_PB_SDRAM_CLKE; /* output */ |
| 156 | immr->im_cpm.cp_pbdat |= CONFIG_SYS_PB_SDRAM_CLKE; /* assert SDRAM CLKE */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 157 | udelay (1); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 158 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 159 | /* |
| 160 | * Map controller bank 1 for ELIC SACCO |
| 161 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 162 | memctl->memc_or1 = CONFIG_SYS_OR1; |
| 163 | memctl->memc_br1 = CONFIG_SYS_BR1; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 164 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 165 | /* |
| 166 | * Map controller bank 2 for ELIC EPIC |
| 167 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 168 | memctl->memc_or2 = CONFIG_SYS_OR2; |
| 169 | memctl->memc_br2 = CONFIG_SYS_BR2; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 170 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 171 | /* |
| 172 | * Configure UPMA for SHARC |
| 173 | */ |
| 174 | upmconfig (UPMA, (uint *) sharc_table, |
| 175 | sizeof (sharc_table) / sizeof (uint)); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 176 | |
| 177 | #if defined(CONFIG_IVML24) |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 178 | /* |
| 179 | * Map controller bank 4 for HDLC Address space |
| 180 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 181 | memctl->memc_or4 = CONFIG_SYS_OR4; |
| 182 | memctl->memc_br4 = CONFIG_SYS_BR4; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 183 | #endif |
| 184 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 185 | /* |
| 186 | * Map controller bank 5 for SHARC |
| 187 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 188 | memctl->memc_or5 = CONFIG_SYS_OR5; |
| 189 | memctl->memc_br5 = CONFIG_SYS_BR5; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 190 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 191 | memctl->memc_mamr = 0x00001000; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 192 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 193 | /* |
| 194 | * Configure UPMB for SDRAM |
| 195 | */ |
| 196 | upmconfig (UPMB, (uint *) sdram_table, |
| 197 | sizeof (sdram_table) / sizeof (uint)); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 198 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 199 | memctl->memc_mptpr = CONFIG_SYS_MPTPR_1BK_8K; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 200 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 201 | memctl->memc_mar = 0x00000088; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 202 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 203 | /* |
| 204 | * Map controller bank 3 to the SDRAM bank at preliminary address. |
| 205 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 206 | memctl->memc_or3 = CONFIG_SYS_OR3_PRELIM; |
| 207 | memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 208 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 209 | memctl->memc_mbmr = CONFIG_SYS_MBMR_8COL; /* refresh not enabled yet */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 210 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 211 | udelay (200); |
| 212 | memctl->memc_mcr = 0x80806105; /* precharge */ |
| 213 | udelay (1); |
| 214 | memctl->memc_mcr = 0x80806106; /* load mode register */ |
| 215 | udelay (1); |
| 216 | memctl->memc_mcr = 0x80806130; /* autorefresh */ |
| 217 | udelay (1); |
| 218 | memctl->memc_mcr = 0x80806130; /* autorefresh */ |
| 219 | udelay (1); |
| 220 | memctl->memc_mcr = 0x80806130; /* autorefresh */ |
| 221 | udelay (1); |
| 222 | memctl->memc_mcr = 0x80806130; /* autorefresh */ |
| 223 | udelay (1); |
| 224 | memctl->memc_mcr = 0x80806130; /* autorefresh */ |
| 225 | udelay (1); |
| 226 | memctl->memc_mcr = 0x80806130; /* autorefresh */ |
| 227 | udelay (1); |
| 228 | memctl->memc_mcr = 0x80806130; /* autorefresh */ |
| 229 | udelay (1); |
| 230 | memctl->memc_mcr = 0x80806130; /* autorefresh */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 231 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 232 | memctl->memc_mbmr |= MBMR_PTBE; /* refresh enabled */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 233 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 234 | /* |
| 235 | * Check Bank 0 Memory Size for re-configuration |
| 236 | */ |
| 237 | size_b0 = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 238 | dram_size (CONFIG_SYS_MBMR_8COL, (long *) SDRAM_BASE3_PRELIM, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 239 | SDRAM_MAX_SIZE); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 240 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 241 | memctl->memc_mbmr = CONFIG_SYS_MBMR_8COL | MBMR_PTBE; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 242 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 243 | return (size_b0); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | /* ------------------------------------------------------------------------- */ |
| 247 | |
| 248 | /* |
| 249 | * Check memory range for valid RAM. A simple memory test determines |
| 250 | * the actually available RAM size between addresses `base' and |
| 251 | * `base + maxsize'. Some (not all) hardware errors are detected: |
| 252 | * - short between address lines |
| 253 | * - short between data lines |
| 254 | */ |
| 255 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 256 | static long int dram_size (long int mamr_value, long int *base, |
| 257 | long int maxsize) |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 258 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 259 | volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 260 | volatile memctl8xx_t *memctl = &immr->im_memctl; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 261 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 262 | memctl->memc_mbmr = mamr_value; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 263 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 264 | return (get_ram_size (base, maxsize)); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | /* ------------------------------------------------------------------------- */ |
| 268 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 269 | void reset_phy (void) |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 270 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 271 | immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 272 | |
| 273 | /* De-assert Ethernet Powerdown */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 274 | immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_ETH_POWERDOWN); /* GPIO */ |
| 275 | immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_ETH_POWERDOWN); /* active output */ |
| 276 | immr->im_cpm.cp_pbdir |= CONFIG_SYS_PB_ETH_POWERDOWN; /* output */ |
| 277 | immr->im_cpm.cp_pbdat &= ~(CONFIG_SYS_PB_ETH_POWERDOWN); /* Enable PHY power */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 278 | udelay (1000); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 279 | |
| 280 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 281 | * RESET is implemented by a positive pulse of at least 1 us |
| 282 | * at the reset pin. |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 283 | * |
| 284 | * Configure RESET pins for NS DP83843 PHY, and RESET chip. |
| 285 | * |
| 286 | * Note: The RESET pin is high active, but there is an |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 287 | * inverter on the SPD823TS board... |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 288 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 289 | immr->im_ioport.iop_pcpar &= ~(CONFIG_SYS_PC_ETH_RESET); |
| 290 | immr->im_ioport.iop_pcdir |= CONFIG_SYS_PC_ETH_RESET; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 291 | /* assert RESET signal of PHY */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 292 | immr->im_ioport.iop_pcdat &= ~(CONFIG_SYS_PC_ETH_RESET); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 293 | udelay (10); |
| 294 | /* de-assert RESET signal of PHY */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 295 | immr->im_ioport.iop_pcdat |= CONFIG_SYS_PC_ETH_RESET; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 296 | udelay (10); |
| 297 | } |
| 298 | |
| 299 | /* ------------------------------------------------------------------------- */ |
| 300 | |
| 301 | void show_boot_progress (int status) |
| 302 | { |
| 303 | #if defined(CONFIG_STATUS_LED) |
| 304 | # if defined(STATUS_LED_YELLOW) |
| 305 | status_led_set (STATUS_LED_YELLOW, |
| 306 | (status < 0) ? STATUS_LED_ON : STATUS_LED_OFF); |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 307 | # endif /* STATUS_LED_YELLOW */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 308 | # if defined(STATUS_LED_BOOT) |
Simon Glass | 5dc8871 | 2012-01-14 15:24:47 +0000 | [diff] [blame] | 309 | if (status == BOOTSTAGE_ID_DECOMP_IMAGE) |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 310 | status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF); |
| 311 | # endif /* STATUS_LED_BOOT */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 312 | #endif /* CONFIG_STATUS_LED */ |
| 313 | } |
| 314 | |
| 315 | /* ------------------------------------------------------------------------- */ |
| 316 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 317 | void ide_set_reset (int on) |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 318 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 319 | volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
Pavel Herrmann | e4148c1 | 2012-10-07 05:56:07 +0000 | [diff] [blame] | 320 | int i; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 321 | |
| 322 | /* |
| 323 | * Configure PC for IDE Reset Pin |
| 324 | */ |
| 325 | if (on) { /* assert RESET */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 326 | immr->im_ioport.iop_pcdat &= ~(CONFIG_SYS_PC_IDE_RESET); |
Pavel Herrmann | e4148c1 | 2012-10-07 05:56:07 +0000 | [diff] [blame] | 327 | |
| 328 | #ifdef CONFIG_SYS_PB_12V_ENABLE |
| 329 | /* 12V Enable output OFF */ |
| 330 | immr->im_cpm.cp_pbdat &= ~(CONFIG_SYS_PB_12V_ENABLE); |
| 331 | |
| 332 | immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_12V_ENABLE); |
| 333 | immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_12V_ENABLE); |
| 334 | immr->im_cpm.cp_pbdir |= CONFIG_SYS_PB_12V_ENABLE; |
| 335 | |
| 336 | /* wait 500 ms for the voltage to stabilize */ |
| 337 | for (i = 0; i < 500; ++i) |
| 338 | udelay(1000); |
| 339 | #endif /* CONFIG_SYS_PB_12V_ENABLE */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 340 | } else { /* release RESET */ |
Pavel Herrmann | e4148c1 | 2012-10-07 05:56:07 +0000 | [diff] [blame] | 341 | #ifdef CONFIG_SYS_PB_12V_ENABLE |
| 342 | /* 12V Enable output ON */ |
| 343 | immr->im_cpm.cp_pbdat |= CONFIG_SYS_PB_12V_ENABLE; |
| 344 | #endif /* CONFIG_SYS_PB_12V_ENABLE */ |
| 345 | |
| 346 | #ifdef CONFIG_SYS_PB_IDE_MOTOR |
| 347 | /* configure IDE Motor voltage monitor pin as input */ |
| 348 | immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_IDE_MOTOR); |
| 349 | immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_IDE_MOTOR); |
| 350 | immr->im_cpm.cp_pbdir &= ~(CONFIG_SYS_PB_IDE_MOTOR); |
| 351 | |
| 352 | /* wait up to 1 s for the motor voltage to stabilize */ |
| 353 | for (i = 0; i < 1000; ++i) { |
| 354 | if ((immr->im_cpm.cp_pbdat |
| 355 | & CONFIG_SYS_PB_IDE_MOTOR) != 0) |
| 356 | break; |
| 357 | udelay(1000); |
| 358 | } |
| 359 | |
| 360 | if (i == 1000) { /* Timeout */ |
| 361 | printf("\nWarning: 5V for IDE Motor missing\n"); |
| 362 | #ifdef CONFIG_STATUS_LED |
| 363 | #ifdef STATUS_LED_YELLOW |
| 364 | status_led_set(STATUS_LED_YELLOW, STATUS_LED_ON); |
| 365 | #endif |
| 366 | #ifdef STATUS_LED_GREEN |
| 367 | status_led_set(STATUS_LED_GREEN, STATUS_LED_OFF); |
| 368 | #endif |
| 369 | #endif /* CONFIG_STATUS_LED */ |
| 370 | } |
| 371 | #endif /* CONFIG_SYS_PB_IDE_MOTOR */ |
| 372 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 373 | immr->im_ioport.iop_pcdat |= CONFIG_SYS_PC_IDE_RESET; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | /* program port pin as GPIO output */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 377 | immr->im_ioport.iop_pcpar &= ~(CONFIG_SYS_PC_IDE_RESET); |
| 378 | immr->im_ioport.iop_pcso &= ~(CONFIG_SYS_PC_IDE_RESET); |
| 379 | immr->im_ioport.iop_pcdir |= CONFIG_SYS_PC_IDE_RESET; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | /* ------------------------------------------------------------------------- */ |