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