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