]>
Commit | Line | Data |
---|---|---|
2076d0a1 | 1 | /* |
ca0c2d42 | 2 | * (C) Copyright 2005-2008 |
2076d0a1 SR |
3 | * Matthias Fuchs, esd GmbH Germany, matthias.fuchs@esd-electronics.com |
4 | * | |
1a459660 | 5 | * SPDX-License-Identifier: GPL-2.0+ |
2076d0a1 SR |
6 | */ |
7 | ||
8 | #include <common.h> | |
9 | #include <command.h> | |
24b852a7 | 10 | #include <console.h> |
ca0c2d42 MF |
11 | #if !defined(CONFIG_440) |
12 | #include <asm/4xx_pci.h> | |
13 | #endif | |
2076d0a1 | 14 | |
b9307262 | 15 | #if defined(CONFIG_CMD_BSP) |
2076d0a1 SR |
16 | #define ADDRMASK 0xfffff000 |
17 | ||
18 | /* | |
19 | * Command loadpci: wait for signal from host and boot image. | |
20 | */ | |
54841ab5 | 21 | int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
2076d0a1 | 22 | { |
ca0c2d42 | 23 | u32 *ptr = 0; |
2076d0a1 SR |
24 | int count = 0; |
25 | int count2 = 0; | |
26 | char addr[16]; | |
27 | char str[] = "\\|/-"; | |
ca0c2d42 | 28 | u32 la, ptm1la; |
2076d0a1 | 29 | |
ca0c2d42 | 30 | #if defined(CONFIG_440) |
ddc922ff | 31 | ptm1la = in32r(PCIL0_PTM1LA); |
ca0c2d42 MF |
32 | #else |
33 | ptm1la = in32r(PTM1LA); | |
34 | #endif | |
2076d0a1 SR |
35 | while(1) { |
36 | /* | |
37 | * Mark sync address | |
38 | */ | |
ca0c2d42 | 39 | ptr = (u32 *)ptm1la; |
2076d0a1 SR |
40 | memset(ptr, 0, 0x20); |
41 | ||
42 | *ptr = 0xffffffff; | |
43 | puts("\nWaiting for action from pci host -"); | |
44 | ||
45 | /* | |
46 | * Wait for host to write the start address | |
47 | */ | |
48 | while (*ptr == 0xffffffff) { | |
49 | count++; | |
50 | if (!(count % 100)) { | |
51 | count2++; | |
52 | putc(0x08); /* backspace */ | |
53 | putc(str[count2 % 4]); | |
54 | } | |
55 | ||
56 | /* Abort if ctrl-c was pressed */ | |
57 | if (ctrlc()) { | |
58 | puts("\nAbort\n"); | |
59 | return 0; | |
60 | } | |
61 | ||
62 | udelay(1000); | |
63 | } | |
64 | ||
65 | printf("\nGot bootcode %08x: ", *ptr); | |
ca0c2d42 MF |
66 | la = ptm1la + (*ptr & ADDRMASK); |
67 | sprintf(addr, "%08x", la); | |
2076d0a1 SR |
68 | |
69 | switch (*ptr & ~ADDRMASK) { | |
70 | case 0: | |
71 | /* | |
72 | * Boot image via bootm | |
73 | */ | |
74 | printf("booting image at addr 0x%s ...\n", addr); | |
75 | setenv("loadaddr", addr); | |
ca0c2d42 | 76 | do_bootm(cmdtp, 0, 0, NULL); |
2076d0a1 SR |
77 | break; |
78 | ||
79 | case 1: | |
80 | /* | |
74de7aef | 81 | * Boot image via "source" command |
2076d0a1 SR |
82 | */ |
83 | printf("executing script at addr 0x%s ...\n", addr); | |
ec4f5040 | 84 | source(la, NULL); |
2076d0a1 SR |
85 | break; |
86 | ||
87 | case 2: | |
88 | /* | |
89 | * Call run_cmd | |
90 | */ | |
91 | printf("running command at addr 0x%s ...\n", addr); | |
53071532 | 92 | run_command((char *)la, 0); |
2076d0a1 SR |
93 | break; |
94 | ||
95 | default: | |
96 | printf("unhandled boot method\n"); | |
97 | break; | |
98 | } | |
99 | } | |
100 | } | |
101 | ||
102 | U_BOOT_CMD( | |
103 | loadpci, 1, 1, do_loadpci, | |
2fb2604d | 104 | "Wait for pci bootcmd and boot it", |
a89c33db WD |
105 | "" |
106 | ); | |
2076d0a1 SR |
107 | |
108 | #endif |