stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 1 | /* |
stroese | c2642d1 | 2004-12-16 18:38:22 +0000 | [diff] [blame] | 2 | * (C) Copyright 2002-2004 |
stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 3 | * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com |
| 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> |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 25 | #include <command.h> |
stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 26 | #include <malloc.h> |
| 27 | #include <net.h> |
| 28 | #include <asm/io.h> |
| 29 | #include <pci.h> |
Stefan Roese | 3048bcb | 2007-10-03 15:01:02 +0200 | [diff] [blame] | 30 | #include <asm/4xx_pci.h> |
stroese | c2642d1 | 2004-12-16 18:38:22 +0000 | [diff] [blame] | 31 | #include <asm/processor.h> |
stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 32 | |
| 33 | #include "pci405.h" |
| 34 | |
Jon Loeliger | b930726 | 2007-07-09 18:24:55 -0500 | [diff] [blame] | 35 | #if defined(CONFIG_CMD_BSP) |
stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 36 | |
stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 37 | /* |
| 38 | * Command loadpci: wait for signal from host and boot image. |
| 39 | */ |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 40 | int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 41 | { |
| 42 | unsigned int *ptr = 0; |
| 43 | int count = 0; |
| 44 | int count2 = 0; |
| 45 | int status; |
| 46 | int i; |
| 47 | char addr[16]; |
| 48 | char str[] = "\\|/-"; |
| 49 | char *local_args[2]; |
| 50 | |
stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 51 | /* |
| 52 | * Mark sync address |
| 53 | */ |
| 54 | ptr = 0; |
| 55 | *ptr = 0xffffffff; |
| 56 | puts("\nWaiting for image from pci host -"); |
| 57 | |
| 58 | /* |
| 59 | * Wait for host to write the start address |
| 60 | */ |
| 61 | while (*ptr == 0xffffffff) { |
| 62 | count++; |
| 63 | if (!(count % 100)) { |
| 64 | count2++; |
| 65 | putc(0x08); /* backspace */ |
| 66 | putc(str[count2 % 4]); |
| 67 | } |
| 68 | |
| 69 | /* Abort if ctrl-c was pressed */ |
| 70 | if (ctrlc()) { |
| 71 | puts("\nAbort\n"); |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | udelay(1000); |
| 76 | } |
| 77 | |
| 78 | if (*ptr == PCI_RECONFIG_MAGIC) { |
| 79 | /* |
| 80 | * Save own pci configuration in PRAM |
| 81 | */ |
| 82 | memset((char *)PCI_REGS_ADDR, 0, PCI_REGS_LEN); |
| 83 | ptr = (unsigned int *)PCI_REGS_ADDR + 1; |
| 84 | for (i=0; i<0x40; i+=4) { |
| 85 | pci_read_config_dword(PCIDEVID_405GP, i, ptr++); |
| 86 | } |
| 87 | ptr = (unsigned int *)PCI_REGS_ADDR; |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 88 | *ptr = crc32(0, (uchar *)PCI_REGS_ADDR+4, PCI_REGS_LEN-4); |
stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 89 | |
| 90 | printf("\nStoring PCI Configuration Regs...\n"); |
| 91 | } else { |
| 92 | sprintf(addr, "%08x", *ptr); |
stroese | 3871842 | 2003-05-23 11:35:09 +0000 | [diff] [blame] | 93 | |
stroese | c2642d1 | 2004-12-16 18:38:22 +0000 | [diff] [blame] | 94 | /* |
| 95 | * Boot image via bootm |
| 96 | */ |
| 97 | printf("\nBooting Image at addr 0x%s ...\n", addr); |
stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 98 | setenv("loadaddr", addr); |
stroese | 3871842 | 2003-05-23 11:35:09 +0000 | [diff] [blame] | 99 | |
stroese | d69b100 | 2003-03-25 14:41:35 +0000 | [diff] [blame] | 100 | local_args[0] = argv[0]; |
| 101 | local_args[1] = NULL; |
| 102 | status = do_bootm (cmdtp, 0, 1, local_args); |
| 103 | } |
| 104 | |
| 105 | return 0; |
| 106 | } |
stroese | 09433a7 | 2003-09-12 08:46:10 +0000 | [diff] [blame] | 107 | U_BOOT_CMD( |
| 108 | loadpci, 1, 1, do_loadpci, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 109 | "Wait for pci-image and boot it", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 110 | "" |
stroese | 09433a7 | 2003-09-12 08:46:10 +0000 | [diff] [blame] | 111 | ); |
stroese | c2642d1 | 2004-12-16 18:38:22 +0000 | [diff] [blame] | 112 | #endif |