u-boot/board/esd/pci405/cmd_pci405.c

115 lines
2.6 KiB
C
Raw Normal View History

2003-03-25 14:41:35 +00:00
/*
2004-12-16 18:38:22 +00:00
* (C) Copyright 2002-2004
2003-03-25 14:41:35 +00:00
* Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <command.h>
2003-03-25 14:41:35 +00:00
#include <malloc.h>
#include <net.h>
#include <asm/io.h>
#include <pci.h>
#include <asm/4xx_pci.h>
2004-12-16 18:38:22 +00:00
#include <asm/processor.h>
2003-03-25 14:41:35 +00:00
#include "pci405.h"
#if defined(CONFIG_CMD_BSP)
2003-03-25 14:41:35 +00:00
extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
/*
* Command loadpci: wait for signal from host and boot image.
*/
int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
2003-03-25 14:41:35 +00:00
{
unsigned int *ptr = 0;
int count = 0;
int count2 = 0;
int status;
int i;
char addr[16];
char str[] = "\\|/-";
char *local_args[2];
/*
* Mark sync address
*/
ptr = 0;
*ptr = 0xffffffff;
puts("\nWaiting for image 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);
}
if (*ptr == PCI_RECONFIG_MAGIC) {
/*
* Save own pci configuration in PRAM
*/
memset((char *)PCI_REGS_ADDR, 0, PCI_REGS_LEN);
ptr = (unsigned int *)PCI_REGS_ADDR + 1;
for (i=0; i<0x40; i+=4) {
pci_read_config_dword(PCIDEVID_405GP, i, ptr++);
}
ptr = (unsigned int *)PCI_REGS_ADDR;
2005-10-13 14:45:02 +00:00
*ptr = crc32(0, (uchar *)PCI_REGS_ADDR+4, PCI_REGS_LEN-4);
2003-03-25 14:41:35 +00:00
printf("\nStoring PCI Configuration Regs...\n");
} else {
sprintf(addr, "%08x", *ptr);
2003-05-23 11:35:09 +00:00
2004-12-16 18:38:22 +00:00
/*
* Boot image via bootm
*/
printf("\nBooting Image at addr 0x%s ...\n", addr);
2003-03-25 14:41:35 +00:00
setenv("loadaddr", addr);
2003-05-23 11:35:09 +00:00
2003-03-25 14:41:35 +00:00
local_args[0] = argv[0];
local_args[1] = NULL;
status = do_bootm (cmdtp, 0, 1, local_args);
}
return 0;
}
2003-09-12 08:46:10 +00:00
U_BOOT_CMD(
loadpci, 1, 1, do_loadpci,
"Wait for pci-image and boot it",
""
2003-09-12 08:46:10 +00:00
);
2004-12-16 18:38:22 +00:00
#endif