1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <command.h>
26#include <malloc.h>
27#include <net.h>
28#include <asm/io.h>
29#include <pci.h>
30#include <asm/4xx_pci.h>
31#include <asm/processor.h>
32
33#include "pci405.h"
34
35#if defined(CONFIG_CMD_BSP)
36
37extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
38
39
40
41
42int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
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
53
54
55
56 ptr = 0;
57 *ptr = 0xffffffff;
58 puts("\nWaiting for image from pci host -");
59
60
61
62
63 while (*ptr == 0xffffffff) {
64 count++;
65 if (!(count % 100)) {
66 count2++;
67 putc(0x08);
68 putc(str[count2 % 4]);
69 }
70
71
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
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;
90 *ptr = crc32(0, (uchar *)PCI_REGS_ADDR+4, PCI_REGS_LEN-4);
91
92 printf("\nStoring PCI Configuration Regs...\n");
93 } else {
94 sprintf(addr, "%08x", *ptr);
95
96
97
98
99 printf("\nBooting Image at addr 0x%s ...\n", addr);
100 setenv("loadaddr", addr);
101
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}
109U_BOOT_CMD(
110 loadpci, 1, 1, do_loadpci,
111 "Wait for pci-image and boot it",
112 ""
113);
114#endif
115