wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * Keith Outwater, keith_outwater@mvis.com |
| 5 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <virtex2.h> |
| 10 | #include <common.h> |
| 11 | #include <mpc8xx.h> |
| 12 | #include <asm/8xx_immap.h> |
| 13 | #include "beeper.h" |
| 14 | #include "fpga.h" |
| 15 | #include "ioport.h" |
| 16 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 19 | #ifdef CONFIG_STATUS_LED |
| 20 | #include <status_led.h> |
| 21 | #endif |
| 22 | |
Jon Loeliger | 77a3185 | 2007-07-10 10:39:10 -0500 | [diff] [blame] | 23 | #if defined(CONFIG_CMD_MII) && defined(CONFIG_MII) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 24 | #include <net.h> |
| 25 | #endif |
| 26 | |
| 27 | #if 0 |
| 28 | #define GEN860T_DEBUG |
| 29 | #endif |
| 30 | |
| 31 | #ifdef GEN860T_DEBUG |
| 32 | #define PRINTF(fmt,args...) printf (fmt ,##args) |
| 33 | #else |
| 34 | #define PRINTF(fmt,args...) |
| 35 | #endif |
| 36 | |
| 37 | /* |
| 38 | * The following UPM init tables were generated automatically by |
| 39 | * Motorola's MCUINIT program. See the README file for UPM to |
| 40 | * SDRAM pin assignments if you want to type this data into |
| 41 | * MCUINIT in order to reverse engineer the waveforms. |
| 42 | */ |
| 43 | |
| 44 | /* |
| 45 | * UPM initialization tables for MICRON MT48LC16M16A2TG SDRAM devices |
| 46 | * (UPMA) and Virtex FPGA SelectMap interface (UPMB). |
| 47 | * NOTE that unused areas of the table are used to hold NOP, precharge |
| 48 | * and mode register set sequences. |
| 49 | * |
| 50 | */ |
| 51 | #define UPMA_NOP_ADDR 0x5 |
| 52 | #define UPMA_PRECHARGE_ADDR 0x6 |
| 53 | #define UPMA_MRS_ADDR 0x12 |
| 54 | |
| 55 | #define UPM_SINGLE_READ_ADDR 0x00 |
| 56 | #define UPM_BURST_READ_ADDR 0x08 |
| 57 | #define UPM_SINGLE_WRITE_ADDR 0x18 |
| 58 | #define UPM_BURST_WRITE_ADDR 0x20 |
| 59 | #define UPM_REFRESH_ADDR 0x30 |
| 60 | |
| 61 | const uint sdram_upm_table[] = { |
| 62 | /* single read (offset 0x00 in upm ram) */ |
| 63 | 0x0e0fdc04, 0x01adfc04, 0x0fbffc00, 0x1fff5c05, |
| 64 | 0xffffffff, 0x0fffffcd, 0x0fff0fce, 0xefcfffff, |
| 65 | /* burst read (offset 0x08 in upm ram) */ |
| 66 | 0x0f0fdc04, 0x00fdfc04, 0xf0fffc00, 0xf0fffc00, |
| 67 | 0xf1fffc00, 0xfffffc00, 0xfffffc05, 0xffffffff, |
| 68 | 0xffffffff, 0xffffffff, 0x0ffffff4, 0x1f3d5ff4, |
| 69 | 0xfffffff4, 0xfffffff5, 0xffffffff, 0xffffffff, |
| 70 | /* single write (offset 0x18 in upm ram) */ |
| 71 | 0x0f0fdc04, 0x00ad3c00, 0x1fff5c05, 0xffffffff, |
| 72 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 73 | /* burst write (offset 0x20 in upm ram) */ |
| 74 | 0x0f0fdc00, 0x10fd7c00, 0xf0fffc00, 0xf0fffc00, |
| 75 | 0xf1fffc04, 0xfffffc05, 0xffffffff, 0xffffffff, |
| 76 | 0xffffffff, 0xffffffff, 0xffffffff, 0xfffff7ff, |
| 77 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 78 | /* refresh (offset 0x30 in upm ram) */ |
| 79 | 0x1ffddc84, 0xfffffc04, 0xfffffc04, 0xfffffc84, |
| 80 | 0xfffffc05, 0xffffffff, 0xffffffff, 0xffffffff, |
| 81 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 82 | /* exception (offset 0x3C in upm ram) */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 83 | }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 84 | |
| 85 | const uint selectmap_upm_table[] = { |
| 86 | /* single read (offset 0x00 in upm ram) */ |
| 87 | 0x88fffc06, 0x00fff404, 0x00fffc04, 0x33fffc00, |
| 88 | 0xfffffc05, 0xffffffff, 0xffffffff, 0xffffffff, |
| 89 | /* burst read (offset 0x08 in upm ram) */ |
| 90 | 0xfffffc04, 0xfffffc05, 0xffffffff, 0xffffffff, |
| 91 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 92 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 93 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 94 | /* single write (offset 0x18 in upm ram) */ |
| 95 | 0x88fffc04, 0x00fff400, 0x77fffc05, 0xffffffff, |
| 96 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 97 | /* burst write (offset 0x20 in upm ram) */ |
| 98 | 0xfffffc04, 0xfffffc05, 0xffffffff, 0xffffffff, |
| 99 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 100 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 101 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 102 | /* refresh (offset 0x30 in upm ram) */ |
| 103 | 0xfffffc04, 0xfffffc05, 0xffffffff, 0xffffffff, |
| 104 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 105 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 106 | /* exception (offset 0x3C in upm ram) */ |
| 107 | 0xfffffc05, 0xffffffff, 0xffffffff, 0xffffffff |
| 108 | }; |
| 109 | |
| 110 | /* |
| 111 | * Check board identity. Always successful (gives information only) |
| 112 | */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 113 | int checkboard (void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 114 | { |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 115 | char *s; |
| 116 | char buf[64]; |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 117 | int i; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 118 | |
Wolfgang Denk | cdb7497 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 119 | i = getenv_f("board_id", buf, sizeof (buf)); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 120 | s = (i > 0) ? buf : NULL; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 121 | |
| 122 | if (s) { |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 123 | printf ("%s ", s); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 124 | } else { |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 125 | printf ("<unknown> "); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Wolfgang Denk | cdb7497 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 128 | i = getenv_f("serial#", buf, sizeof (buf)); |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 129 | s = (i > 0) ? buf : NULL; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 130 | |
| 131 | if (s) { |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 132 | printf ("S/N %s\n", s); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 133 | } else { |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 134 | printf ("S/N <unknown>\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 135 | } |
| 136 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 137 | printf ("CPU at %s MHz, ", strmhz (buf, gd->cpu_clk)); |
| 138 | printf ("local bus at %s MHz\n", strmhz (buf, gd->bus_clk)); |
| 139 | return (0); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | /* |
| 143 | * Initialize SDRAM |
| 144 | */ |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 145 | phys_size_t initdram (int board_type) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 146 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 147 | volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 148 | volatile memctl8xx_t *memctl = &immr->im_memctl; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 149 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 150 | upmconfig (UPMA, |
| 151 | (uint *) sdram_upm_table, |
| 152 | sizeof (sdram_upm_table) / sizeof (uint) |
| 153 | ); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 154 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 155 | /* |
| 156 | * Setup MAMR register |
| 157 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 158 | memctl->memc_mptpr = CONFIG_SYS_MPTPR_1BK_8K; |
| 159 | memctl->memc_mamr = CONFIG_SYS_MAMR_8COL & (~(MAMR_PTAE)); /* no refresh yet */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 160 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 161 | /* |
| 162 | * Map CS1* to SDRAM bank |
| 163 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 164 | memctl->memc_or1 = CONFIG_SYS_OR1; |
| 165 | memctl->memc_br1 = CONFIG_SYS_BR1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 166 | |
| 167 | /* |
| 168 | * Perform SDRAM initialization sequence: |
| 169 | * 1. Apply at least one NOP command |
| 170 | * 2. 100 uS delay (JEDEC standard says 200 uS) |
| 171 | * 3. Issue 4 precharge commands |
| 172 | * 4. Perform two refresh cycles |
| 173 | * 5. Program mode register |
| 174 | * |
| 175 | * Program SDRAM for standard operation, sequential burst, burst length |
| 176 | * of 4, CAS latency of 2. |
| 177 | */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 178 | memctl->memc_mar = 0x00000000; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 179 | memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 180 | MCR_MLCF (0) | UPMA_NOP_ADDR; |
| 181 | udelay (200); |
| 182 | memctl->memc_mar = 0x00000000; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 183 | memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 184 | MCR_MLCF (4) | UPMA_PRECHARGE_ADDR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 185 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 186 | memctl->memc_mar = 0x00000000; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 187 | memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 188 | MCR_MLCF (2) | UPM_REFRESH_ADDR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 189 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 190 | memctl->memc_mar = 0x00000088; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 191 | memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 192 | MCR_MLCF (1) | UPMA_MRS_ADDR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 193 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 194 | memctl->memc_mar = 0x00000000; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 195 | memctl->memc_mcr = MCR_UPM_A | MCR_OP_RUN | MCR_MB_CS1 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 196 | MCR_MLCF (0) | UPMA_NOP_ADDR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 197 | /* |
| 198 | * Enable refresh |
| 199 | */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 200 | memctl->memc_mamr |= MAMR_PTAE; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 201 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 202 | return (SDRAM_SIZE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | /* |
| 206 | * Disk On Chip (DOC) Millenium initialization. |
| 207 | * The DOC lives in the CS2* space |
| 208 | */ |
Jon Loeliger | c508a4c | 2007-07-09 18:31:28 -0500 | [diff] [blame] | 209 | #if defined(CONFIG_CMD_DOC) |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 210 | void doc_init (void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 211 | { |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 212 | printf ("Probing at 0x%.8x: ", DOC_BASE); |
| 213 | doc_probe (DOC_BASE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 214 | } |
| 215 | #endif |
| 216 | |
| 217 | /* |
| 218 | * Miscellaneous intialization |
| 219 | */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 220 | int misc_init_r (void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 221 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 222 | volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 223 | volatile memctl8xx_t *memctl = &immr->im_memctl; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 224 | |
| 225 | /* |
| 226 | * Set up UPMB to handle the Virtex FPGA SelectMap interface |
| 227 | */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 228 | upmconfig (UPMB, (uint *) selectmap_upm_table, |
| 229 | sizeof (selectmap_upm_table) / sizeof (uint)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 230 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 231 | memctl->memc_mbmr = 0x0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 232 | |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 233 | config_mpc8xx_ioports (immr); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 234 | |
Jon Loeliger | c508a4c | 2007-07-09 18:31:28 -0500 | [diff] [blame] | 235 | #if defined(CONFIG_CMD_MII) |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 236 | mii_init (); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 237 | #endif |
| 238 | |
Matthias Fuchs | 0133502 | 2007-12-27 17:12:34 +0100 | [diff] [blame] | 239 | #if defined(CONFIG_FPGA) |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 240 | gen860t_init_fpga (); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 241 | #endif |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | /* |
| 246 | * Final init hook before entering command loop. |
| 247 | */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 248 | int last_stage_init (void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 249 | { |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 250 | #if !defined(CONFIG_SC) |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 251 | char buf[256]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 252 | int i; |
| 253 | |
| 254 | /* |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 255 | * Turn the beeper volume all the way down in case this is a warm boot. |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 256 | */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 257 | set_beeper_volume (-64); |
| 258 | init_beeper (); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 259 | |
| 260 | /* |
| 261 | * Read the environment to see what to do with the beeper |
| 262 | */ |
Wolfgang Denk | cdb7497 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 263 | i = getenv_f("beeper", buf, sizeof (buf)); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 264 | if (i > 0) { |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 265 | do_beeper (buf); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 266 | } |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 267 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 268 | return 0; |
| 269 | } |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 270 | |
| 271 | /* |
| 272 | * Stub to make POST code happy. Can't self-poweroff, so just hang. |
| 273 | */ |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 274 | void board_poweroff (void) |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 275 | { |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 276 | puts ("### Please power off the board ###\n"); |
| 277 | while (1); |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 278 | } |