Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 Freescale Semiconductor. |
Jon Loeliger | c934f65 | 2006-05-31 13:55:35 -0500 | [diff] [blame] | 3 | * Jeff Brown |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 4 | * Srikanth Srinivasan (srikanth.srinivasan@freescale.com) |
| 5 | * |
| 6 | * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com> |
| 7 | * |
| 8 | * See file CREDITS for list of people who contributed to this |
| 9 | * project. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <common.h> |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 28 | #include <command.h> |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 29 | #include <pci.h> |
| 30 | #include <asm/processor.h> |
| 31 | #include <asm/immap_86xx.h> |
| 32 | #include <spd.h> |
| 33 | |
| 34 | #if defined(CONFIG_OF_FLAT_TREE) |
| 35 | #include <ft_build.h> |
| 36 | extern void ft_cpu_setup(void *blob, bd_t *bd); |
| 37 | #endif |
| 38 | |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 39 | #include "pixis.h" |
| 40 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 41 | #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
| 42 | extern void ddr_enable_ecc(unsigned int dram_size); |
| 43 | #endif |
| 44 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 45 | #if defined(CONFIG_SPD_EEPROM) |
| 46 | #include "spd_sdram.h" |
| 47 | #endif |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 48 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 49 | void sdram_init(void); |
| 50 | long int fixed_sdram(void); |
| 51 | |
| 52 | |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 53 | int board_early_init_f(void) |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 54 | { |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 55 | return 0; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 56 | } |
| 57 | |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 58 | int checkboard(void) |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 59 | { |
| 60 | puts("Board: MPC8641HPCN\n"); |
| 61 | |
| 62 | #ifdef CONFIG_PCI |
| 63 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 64 | volatile immap_t *immap = (immap_t *) CFG_CCSRBAR; |
| 65 | volatile ccsr_gur_t *gur = &immap->im_gur; |
| 66 | volatile ccsr_pex_t *pex1 = &immap->im_pex1; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 67 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 68 | uint devdisr = gur->devdisr; |
| 69 | uint io_sel = (gur->pordevsr & MPC86xx_PORDEVSR_IO_SEL) >> 16; |
| 70 | uint host1_agent = (gur->porbmsr & MPC86xx_PORBMSR_HA) >> 17; |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 71 | uint pex1_agent = (host1_agent == 0) || (host1_agent == 1); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 72 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 73 | if ((io_sel == 2 || io_sel == 3 || io_sel == 5 |
| 74 | || io_sel == 6 || io_sel == 7 || io_sel == 0xF) |
| 75 | && !(devdisr & MPC86xx_DEVDISR_PCIEX1)) { |
| 76 | debug("PCI-EXPRESS 1: %s \n", pex1_agent ? "Agent" : "Host"); |
| 77 | debug("0x%08x=0x%08x ", &pex1->pme_msg_det, pex1->pme_msg_det); |
| 78 | if (pex1->pme_msg_det) { |
| 79 | pex1->pme_msg_det = 0xffffffff; |
| 80 | debug(" with errors. Clearing. Now 0x%08x", |
| 81 | pex1->pme_msg_det); |
| 82 | } |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 83 | debug("\n"); |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 84 | } else { |
| 85 | puts("PCI-EXPRESS 1: Disabled\n"); |
| 86 | } |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 87 | |
| 88 | #else |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 89 | puts("PCI-EXPRESS1: Disabled\n"); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 90 | #endif |
| 91 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | |
| 96 | long int |
| 97 | initdram(int board_type) |
| 98 | { |
| 99 | long dram_size = 0; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 100 | |
| 101 | #if defined(CONFIG_SPD_EEPROM) |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 102 | dram_size = spd_sdram(); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 103 | #else |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 104 | dram_size = fixed_sdram(); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 105 | #endif |
| 106 | |
| 107 | #if defined(CFG_RAMBOOT) |
| 108 | puts(" DDR: "); |
| 109 | return dram_size; |
| 110 | #endif |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 111 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 112 | #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
| 113 | /* |
| 114 | * Initialize and enable DDR ECC. |
| 115 | */ |
| 116 | ddr_enable_ecc(dram_size); |
| 117 | #endif |
| 118 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 119 | puts(" DDR: "); |
| 120 | return dram_size; |
| 121 | } |
| 122 | |
| 123 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 124 | #if defined(CFG_DRAM_TEST) |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 125 | int |
| 126 | testdram(void) |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 127 | { |
| 128 | uint *pstart = (uint *) CFG_MEMTEST_START; |
| 129 | uint *pend = (uint *) CFG_MEMTEST_END; |
| 130 | uint *p; |
| 131 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 132 | puts("SDRAM test phase 1:\n"); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 133 | for (p = pstart; p < pend; p++) |
| 134 | *p = 0xaaaaaaaa; |
| 135 | |
| 136 | for (p = pstart; p < pend; p++) { |
| 137 | if (*p != 0xaaaaaaaa) { |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 138 | printf("SDRAM test fails at: %08x\n", (uint) p); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 139 | return 1; |
| 140 | } |
| 141 | } |
| 142 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 143 | puts("SDRAM test phase 2:\n"); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 144 | for (p = pstart; p < pend; p++) |
| 145 | *p = 0x55555555; |
| 146 | |
| 147 | for (p = pstart; p < pend; p++) { |
| 148 | if (*p != 0x55555555) { |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 149 | printf("SDRAM test fails at: %08x\n", (uint) p); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 150 | return 1; |
| 151 | } |
| 152 | } |
| 153 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 154 | puts("SDRAM test passed.\n"); |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 155 | return 0; |
| 156 | } |
| 157 | #endif |
| 158 | |
| 159 | |
| 160 | #if !defined(CONFIG_SPD_EEPROM) |
Jon Loeliger | 5c9efb3 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 161 | /* |
| 162 | * Fixed sdram init -- doesn't use serial presence detect. |
| 163 | */ |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 164 | long int |
| 165 | fixed_sdram(void) |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 166 | { |
| 167 | #if !defined(CFG_RAMBOOT) |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 168 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
| 169 | volatile ccsr_ddr_t *ddr = &immap->im_ddr1; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 170 | |
| 171 | ddr->cs0_bnds = CFG_DDR_CS0_BNDS; |
| 172 | ddr->cs0_config = CFG_DDR_CS0_CONFIG; |
| 173 | ddr->ext_refrec = CFG_DDR_EXT_REFRESH; |
| 174 | ddr->timing_cfg_0 = CFG_DDR_TIMING_0; |
| 175 | ddr->timing_cfg_1 = CFG_DDR_TIMING_1; |
| 176 | ddr->timing_cfg_2 = CFG_DDR_TIMING_2; |
| 177 | ddr->sdram_mode_1 = CFG_DDR_MODE_1; |
| 178 | ddr->sdram_mode_2 = CFG_DDR_MODE_2; |
| 179 | ddr->sdram_interval = CFG_DDR_INTERVAL; |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 180 | ddr->sdram_data_init = CFG_DDR_DATA_INIT; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 181 | ddr->sdram_clk_cntl = CFG_DDR_CLK_CTRL; |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 182 | ddr->sdram_ocd_cntl = CFG_DDR_OCD_CTRL; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 183 | ddr->sdram_ocd_status = CFG_DDR_OCD_STATUS; |
| 184 | |
| 185 | #if defined (CONFIG_DDR_ECC) |
| 186 | ddr->err_disable = 0x0000008D; |
| 187 | ddr->err_sbe = 0x00ff0000; |
| 188 | #endif |
| 189 | asm("sync;isync"); |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 190 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 191 | udelay(500); |
| 192 | |
| 193 | #if defined (CONFIG_DDR_ECC) |
| 194 | /* Enable ECC checking */ |
| 195 | ddr->sdram_cfg_1 = (CFG_DDR_CONTROL | 0x20000000); |
| 196 | #else |
| 197 | ddr->sdram_cfg_1 = CFG_DDR_CONTROL; |
| 198 | ddr->sdram_cfg_2 = CFG_DDR_CONTROL2; |
| 199 | #endif |
| 200 | asm("sync; isync"); |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 201 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 202 | udelay(500); |
| 203 | #endif |
| 204 | return CFG_SDRAM_SIZE * 1024 * 1024; |
| 205 | } |
| 206 | #endif /* !defined(CONFIG_SPD_EEPROM) */ |
| 207 | |
| 208 | |
| 209 | #if defined(CONFIG_PCI) |
| 210 | /* |
| 211 | * Initialize PCI Devices, report devices found. |
| 212 | */ |
| 213 | |
| 214 | #ifndef CONFIG_PCI_PNP |
| 215 | static struct pci_config_table pci_fsl86xxads_config_table[] = { |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 216 | {PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, |
| 217 | PCI_IDSEL_NUMBER, PCI_ANY_ID, |
| 218 | pci_cfgfunc_config_device, {PCI_ENET0_IOADDR, |
| 219 | PCI_ENET0_MEMADDR, |
| 220 | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER}}, |
| 221 | {} |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 222 | }; |
| 223 | #endif |
| 224 | |
| 225 | |
| 226 | static struct pci_controller hose = { |
| 227 | #ifndef CONFIG_PCI_PNP |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 228 | config_table:pci_mpc86xxcts_config_table, |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 229 | #endif |
| 230 | }; |
| 231 | |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 232 | #endif /* CONFIG_PCI */ |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 233 | |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 234 | void pci_init_board(void) |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 235 | { |
| 236 | #ifdef CONFIG_PCI |
| 237 | extern void pci_mpc86xx_init(struct pci_controller *hose); |
| 238 | |
| 239 | pci_mpc86xx_init(&hose); |
| 240 | #endif /* CONFIG_PCI */ |
| 241 | } |
| 242 | |
| 243 | #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) |
| 244 | void |
| 245 | ft_board_setup(void *blob, bd_t *bd) |
| 246 | { |
| 247 | u32 *p; |
| 248 | int len; |
| 249 | |
| 250 | ft_cpu_setup(blob, bd); |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 251 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 252 | p = ft_get_prop(blob, "/memory/reg", &len); |
| 253 | if (p != NULL) { |
| 254 | *p++ = cpu_to_be32(bd->bi_memstart); |
| 255 | *p = cpu_to_be32(bd->bi_memsize); |
| 256 | } |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 257 | } |
| 258 | #endif |
| 259 | |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 260 | |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 261 | void |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 262 | mpc8641_reset_board(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 263 | { |
| 264 | char cmd; |
| 265 | ulong val; |
| 266 | ulong corepll; |
Jon Loeliger | debb735 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 267 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 268 | /* |
| 269 | * No args is a simple reset request. |
| 270 | */ |
Jon Loeliger | 684623c | 2006-06-22 08:51:46 -0500 | [diff] [blame] | 271 | if (argc <= 1) { |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 272 | out8(PIXIS_BASE + PIXIS_RST, 0); |
| 273 | /* not reached */ |
| 274 | } |
| 275 | |
| 276 | cmd = argv[1][1]; |
| 277 | switch (cmd) { |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 278 | case 'f': /* reset with frequency changed */ |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 279 | if (argc < 5) |
| 280 | goto my_usage; |
| 281 | read_from_px_regs(0); |
| 282 | |
| 283 | val = set_px_sysclk(simple_strtoul(argv[2], NULL, 10)); |
| 284 | |
| 285 | corepll = strfractoint(argv[3]); |
| 286 | val = val + set_px_corepll(corepll); |
| 287 | val = val + set_px_mpxpll(simple_strtoul(argv[4], NULL, 10)); |
| 288 | if (val == 3) { |
| 289 | puts("Setting registers VCFGEN0 and VCTL\n"); |
| 290 | read_from_px_regs(1); |
| 291 | puts("Resetting board with values from VSPEED0, VSPEED1, VCLKH, and VCLKL ....\n"); |
| 292 | set_px_go(); |
| 293 | } else |
| 294 | goto my_usage; |
| 295 | |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 296 | while (1) ; /* Not reached */ |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 297 | |
| 298 | case 'l': |
| 299 | if (argv[2][1] == 'f') { |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 300 | read_from_px_regs(0); |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 301 | read_from_px_regs_altbank(0); |
| 302 | /* reset with frequency changed */ |
| 303 | val = set_px_sysclk(simple_strtoul(argv[3], NULL, 10)); |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 304 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 305 | corepll = strfractoint(argv[4]); |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 306 | val = val + set_px_corepll(corepll); |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 307 | val = val + set_px_mpxpll(simple_strtoul(argv[5], |
| 308 | NULL, 10)); |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 309 | if (val == 3) { |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 310 | puts("Setting registers VCFGEN0, VCFGEN1, VBOOT, and VCTL\n"); |
| 311 | set_altbank(); |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 312 | read_from_px_regs(1); |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 313 | read_from_px_regs_altbank(1); |
| 314 | puts("Enabling watchdog timer on the FPGA and resetting board with values from VSPEED0, VSPEED1, VCLKH, and VCLKL to boot from the other bank ....\n"); |
| 315 | set_px_go_with_watchdog(); |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 316 | } else |
| 317 | goto my_usage; |
| 318 | |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 319 | while (1) ; /* Not reached */ |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 320 | |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 321 | } else if (argv[2][1] == 'd') { |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 322 | /* |
| 323 | * Reset from alternate bank without changing |
| 324 | * frequencies but with watchdog timer enabled. |
| 325 | */ |
| 326 | read_from_px_regs(0); |
| 327 | read_from_px_regs_altbank(0); |
| 328 | puts("Setting registers VCFGEN1, VBOOT, and VCTL\n"); |
| 329 | set_altbank(); |
| 330 | read_from_px_regs_altbank(1); |
| 331 | puts("Enabling watchdog timer on the FPGA and resetting board to boot from the other bank....\n"); |
| 332 | set_px_go_with_watchdog(); |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 333 | while (1) ; /* Not reached */ |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 334 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 335 | } else { |
| 336 | /* |
| 337 | * Reset from next bank without changing |
| 338 | * frequency and without watchdog timer enabled. |
| 339 | */ |
| 340 | read_from_px_regs(0); |
| 341 | read_from_px_regs_altbank(0); |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 342 | if (argc > 2) |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 343 | goto my_usage; |
| 344 | puts("Setting registers VCFGNE1, VBOOT, and VCTL\n"); |
| 345 | set_altbank(); |
| 346 | read_from_px_regs_altbank(1); |
| 347 | puts("Resetting board to boot from the other bank....\n"); |
| 348 | set_px_go(); |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 349 | } |
| 350 | |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 351 | default: |
| 352 | goto my_usage; |
| 353 | } |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 354 | |
Jon Loeliger | c934f65 | 2006-05-31 13:55:35 -0500 | [diff] [blame] | 355 | my_usage: |
Jon Loeliger | cb5965f | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 356 | puts("\nUsage: reset cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>\n"); |
| 357 | puts(" reset altbank [cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>]\n"); |
| 358 | puts(" reset altbank [wd]\n"); |
| 359 | puts("For example: reset cf 40 2.5 10\n"); |
| 360 | puts("See MPC8641HPCN Design Workbook for valid values of command line parameters.\n"); |
Jon Loeliger | 4d3d729 | 2006-05-31 11:24:28 -0500 | [diff] [blame] | 361 | } |
Haiying Wang | 239db37 | 2006-07-28 12:41:18 -0400 | [diff] [blame] | 362 | |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 363 | |
Haiying Wang | 239db37 | 2006-07-28 12:41:18 -0400 | [diff] [blame] | 364 | /* |
| 365 | * get_board_sys_clk |
| 366 | * Reads the FPGA on board for CONFIG_SYS_CLK_FREQ |
| 367 | */ |
| 368 | |
Jon Loeliger | 80e955c | 2006-08-22 12:25:27 -0500 | [diff] [blame] | 369 | unsigned long |
| 370 | get_board_sys_clk(ulong dummy) |
Haiying Wang | 239db37 | 2006-07-28 12:41:18 -0400 | [diff] [blame] | 371 | { |
| 372 | u8 i, go_bit, rd_clks; |
| 373 | ulong val = 0; |
| 374 | |
| 375 | go_bit = in8(PIXIS_BASE + PIXIS_VCTL); |
| 376 | go_bit &= 0x01; |
| 377 | |
| 378 | rd_clks = in8(PIXIS_BASE + PIXIS_VCFGEN0); |
| 379 | rd_clks &= 0x1C; |
| 380 | |
| 381 | /* |
| 382 | * Only if both go bit and the SCLK bit in VCFGEN0 are set |
| 383 | * should we be using the AUX register. Remember, we also set the |
| 384 | * GO bit to boot from the alternate bank on the on-board flash |
| 385 | */ |
| 386 | |
| 387 | if (go_bit) { |
| 388 | if (rd_clks == 0x1c) |
| 389 | i = in8(PIXIS_BASE + PIXIS_AUX); |
| 390 | else |
| 391 | i = in8(PIXIS_BASE + PIXIS_SPD); |
| 392 | } else { |
| 393 | i = in8(PIXIS_BASE + PIXIS_SPD); |
| 394 | } |
| 395 | |
| 396 | i &= 0x07; |
| 397 | |
| 398 | switch (i) { |
| 399 | case 0: |
| 400 | val = 33000000; |
| 401 | break; |
| 402 | case 1: |
| 403 | val = 40000000; |
| 404 | break; |
| 405 | case 2: |
| 406 | val = 50000000; |
| 407 | break; |
| 408 | case 3: |
| 409 | val = 66000000; |
| 410 | break; |
| 411 | case 4: |
| 412 | val = 83000000; |
| 413 | break; |
| 414 | case 5: |
| 415 | val = 100000000; |
| 416 | break; |
| 417 | case 6: |
| 418 | val = 134000000; |
| 419 | break; |
| 420 | case 7: |
| 421 | val = 166000000; |
| 422 | break; |
| 423 | } |
| 424 | |
| 425 | return val; |
| 426 | } |