2006-01-18 19:03:15 +00:00
|
|
|
/*
|
2008-10-28 12:36:57 +00:00
|
|
|
* (C) Copyright 2005-2008
|
2006-01-18 19:03:15 +00:00
|
|
|
* Matthias Fuchs, esd GmbH Germany, matthias.fuchs@esd-electronics.com
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2006-01-18 19:03:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2008-10-28 12:36:57 +00:00
|
|
|
#if !defined(CONFIG_440)
|
|
|
|
#include <asm/4xx_pci.h>
|
|
|
|
#endif
|
2006-01-18 19:03:15 +00:00
|
|
|
|
2007-07-09 23:24:55 +00:00
|
|
|
#if defined(CONFIG_CMD_BSP)
|
2006-01-18 19:03:15 +00:00
|
|
|
#define ADDRMASK 0xfffff000
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Command loadpci: wait for signal from host and boot image.
|
|
|
|
*/
|
2010-06-28 20:00:46 +00:00
|
|
|
int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
2006-01-18 19:03:15 +00:00
|
|
|
{
|
2008-10-28 12:36:57 +00:00
|
|
|
u32 *ptr = 0;
|
2006-01-18 19:03:15 +00:00
|
|
|
int count = 0;
|
|
|
|
int count2 = 0;
|
|
|
|
char addr[16];
|
|
|
|
char str[] = "\\|/-";
|
2008-10-28 12:36:57 +00:00
|
|
|
u32 la, ptm1la;
|
2006-01-18 19:03:15 +00:00
|
|
|
|
2008-10-28 12:36:57 +00:00
|
|
|
#if defined(CONFIG_440)
|
2009-10-04 18:04:20 +00:00
|
|
|
ptm1la = in32r(PCIL0_PTM1LA);
|
2008-10-28 12:36:57 +00:00
|
|
|
#else
|
|
|
|
ptm1la = in32r(PTM1LA);
|
|
|
|
#endif
|
2006-01-18 19:03:15 +00:00
|
|
|
while(1) {
|
|
|
|
/*
|
|
|
|
* Mark sync address
|
|
|
|
*/
|
2008-10-28 12:36:57 +00:00
|
|
|
ptr = (u32 *)ptm1la;
|
2006-01-18 19:03:15 +00:00
|
|
|
memset(ptr, 0, 0x20);
|
|
|
|
|
|
|
|
*ptr = 0xffffffff;
|
|
|
|
puts("\nWaiting for action from pci host -");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for host to write the start address
|
|
|
|
*/
|
|
|
|
while (*ptr == 0xffffffff) {
|
|
|
|
count++;
|
|
|
|
if (!(count % 100)) {
|
|
|
|
count2++;
|
|
|
|
putc(0x08); /* backspace */
|
|
|
|
putc(str[count2 % 4]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Abort if ctrl-c was pressed */
|
|
|
|
if (ctrlc()) {
|
|
|
|
puts("\nAbort\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
udelay(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\nGot bootcode %08x: ", *ptr);
|
2008-10-28 12:36:57 +00:00
|
|
|
la = ptm1la + (*ptr & ADDRMASK);
|
|
|
|
sprintf(addr, "%08x", la);
|
2006-01-18 19:03:15 +00:00
|
|
|
|
|
|
|
switch (*ptr & ~ADDRMASK) {
|
|
|
|
case 0:
|
|
|
|
/*
|
|
|
|
* Boot image via bootm
|
|
|
|
*/
|
|
|
|
printf("booting image at addr 0x%s ...\n", addr);
|
|
|
|
setenv("loadaddr", addr);
|
2008-10-28 12:36:57 +00:00
|
|
|
do_bootm(cmdtp, 0, 0, NULL);
|
2006-01-18 19:03:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
/*
|
2009-04-01 21:34:12 +00:00
|
|
|
* Boot image via "source" command
|
2006-01-18 19:03:15 +00:00
|
|
|
*/
|
|
|
|
printf("executing script at addr 0x%s ...\n", addr);
|
2014-07-21 15:16:07 +00:00
|
|
|
source(la, NULL);
|
2006-01-18 19:03:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
/*
|
|
|
|
* Call run_cmd
|
|
|
|
*/
|
|
|
|
printf("running command at addr 0x%s ...\n", addr);
|
2012-02-14 19:59:21 +00:00
|
|
|
run_command((char *)la, 0);
|
2006-01-18 19:03:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("unhandled boot method\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(
|
|
|
|
loadpci, 1, 1, do_loadpci,
|
2009-01-28 00:03:12 +00:00
|
|
|
"Wait for pci bootcmd and boot it",
|
2009-05-24 15:06:54 +00:00
|
|
|
""
|
|
|
|
);
|
2006-01-18 19:03:15 +00:00
|
|
|
|
|
|
|
#endif
|