]>
Commit | Line | Data |
---|---|---|
d69b100e | 1 | /* |
c2642d14 | 2 | * (C) Copyright 2002-2004 |
d69b100e SR |
3 | * Stefan Roese, esd gmbh germany, [email protected] |
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> | |
8bde7f77 | 25 | #include <command.h> |
d69b100e SR |
26 | #include <malloc.h> |
27 | #include <net.h> | |
28 | #include <asm/io.h> | |
29 | #include <pci.h> | |
3048bcbf | 30 | #include <asm/4xx_pci.h> |
c2642d14 | 31 | #include <asm/processor.h> |
d69b100e SR |
32 | |
33 | #include "pci405.h" | |
34 | ||
b9307262 | 35 | #if defined(CONFIG_CMD_BSP) |
d69b100e SR |
36 | |
37 | extern int do_bootm (cmd_tbl_t *, int, int, char *[]); | |
d69b100e | 38 | |
d69b100e SR |
39 | /* |
40 | * Command loadpci: wait for signal from host and boot image. | |
41 | */ | |
54841ab5 | 42 | int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
d69b100e SR |
43 | { |
44 | unsigned int *ptr = 0; | |
45 | int count = 0; | |
46 | int count2 = 0; | |
47 | int status; | |
48 | int i; | |
49 | char addr[16]; | |
50 | char str[] = "\\|/-"; | |
51 | char *local_args[2]; | |
52 | ||
d69b100e SR |
53 | /* |
54 | * Mark sync address | |
55 | */ | |
56 | ptr = 0; | |
57 | *ptr = 0xffffffff; | |
58 | puts("\nWaiting for image from pci host -"); | |
59 | ||
60 | /* | |
61 | * Wait for host to write the start address | |
62 | */ | |
63 | while (*ptr == 0xffffffff) { | |
64 | count++; | |
65 | if (!(count % 100)) { | |
66 | count2++; | |
67 | putc(0x08); /* backspace */ | |
68 | putc(str[count2 % 4]); | |
69 | } | |
70 | ||
71 | /* Abort if ctrl-c was pressed */ | |
72 | if (ctrlc()) { | |
73 | puts("\nAbort\n"); | |
74 | return 0; | |
75 | } | |
76 | ||
77 | udelay(1000); | |
78 | } | |
79 | ||
80 | if (*ptr == PCI_RECONFIG_MAGIC) { | |
81 | /* | |
82 | * Save own pci configuration in PRAM | |
83 | */ | |
84 | memset((char *)PCI_REGS_ADDR, 0, PCI_REGS_LEN); | |
85 | ptr = (unsigned int *)PCI_REGS_ADDR + 1; | |
86 | for (i=0; i<0x40; i+=4) { | |
87 | pci_read_config_dword(PCIDEVID_405GP, i, ptr++); | |
88 | } | |
89 | ptr = (unsigned int *)PCI_REGS_ADDR; | |
77ddac94 | 90 | *ptr = crc32(0, (uchar *)PCI_REGS_ADDR+4, PCI_REGS_LEN-4); |
d69b100e SR |
91 | |
92 | printf("\nStoring PCI Configuration Regs...\n"); | |
93 | } else { | |
94 | sprintf(addr, "%08x", *ptr); | |
38718425 | 95 | |
c2642d14 SR |
96 | /* |
97 | * Boot image via bootm | |
98 | */ | |
99 | printf("\nBooting Image at addr 0x%s ...\n", addr); | |
d69b100e | 100 | setenv("loadaddr", addr); |
38718425 | 101 | |
d69b100e SR |
102 | local_args[0] = argv[0]; |
103 | local_args[1] = NULL; | |
104 | status = do_bootm (cmdtp, 0, 1, local_args); | |
105 | } | |
106 | ||
107 | return 0; | |
108 | } | |
09433a78 SR |
109 | U_BOOT_CMD( |
110 | loadpci, 1, 1, do_loadpci, | |
2fb2604d | 111 | "Wait for pci-image and boot it", |
a89c33db | 112 | "" |
09433a78 | 113 | ); |
c2642d14 | 114 | #endif |