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