3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 #include <405gp_pci.h>
35 #if (CONFIG_COMMANDS & CFG_CMD_BSP)
37 extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
40 #include "../common/fpga.c"
41 void error_print(void)
44 volatile unsigned char *ptr;
45 volatile unsigned long *ptr2;
47 printf("\n 2nd SJA1000:\n");
49 for (i=0; i<0x20; i++) {
50 printf("%02x ", *ptr++);
54 printf("\nTimestamp = %x\n", *ptr2);
56 printf("Timestamp = %x\n", *ptr2);
58 printf("Timestamp = %x\n", *ptr2);
62 * Reset FPGA via FPGA_DATA pin
64 printf("Resetting FPGA...\n");
65 SET_FPGA(FPGA_PRG | FPGA_CLK);
66 udelay(1000); /* wait 1ms */
67 SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
68 udelay(1000); /* wait 1ms */
70 do_loadpci(NULL, 0,0, NULL);
77 volatile unsigned char *ptr;
78 volatile unsigned char val;
79 volatile unsigned long *ptr2;
81 printf("\nread loop on 1st sja1000...");
84 /* printf("\n1st SJA1000:\n");*/
85 for (i=0; i<0x20; i++) {
88 /* printf("%02x ", val);*/
91 /* Abort if ctrl-c was pressed */
100 * Command loadpci: wait for signal from host and boot image.
102 int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
104 unsigned int *ptr = 0;
110 char str[] = "\\|/-";
113 #if 0 /* test-only */
114 puts("\nStarting sja1000 test...");
117 volatile unsigned char *ptr;
118 volatile unsigned char val;
119 volatile unsigned char val2;
121 #if 1 /* write test */
130 #if 0 /* write test */
135 #if 1 /* read test */
137 for (i=1; i<11; i++) {
142 val = *ptr; /* trigger las */
147 printf("\nERROR: count=%d: soll=%x ist=%x -> staring read loop on 1st sja1000...\n", count, i, val);
149 printf("soll=%x ist=%x -> staring read loop on 1st sja1000...\n", 1, val2);
151 return 0; /* test-only */
161 /* Abort if ctrl-c was pressed */
167 if (!(count % 100000)) {
178 puts("\nWaiting for image from pci host -");
181 * Wait for host to write the start address
183 while (*ptr == 0xffffffff) {
185 if (!(count % 100)) {
187 putc(0x08); /* backspace */
188 putc(str[count2 % 4]);
191 /* Abort if ctrl-c was pressed */
200 if (*ptr == PCI_RECONFIG_MAGIC) {
202 * Save own pci configuration in PRAM
204 memset((char *)PCI_REGS_ADDR, 0, PCI_REGS_LEN);
205 ptr = (unsigned int *)PCI_REGS_ADDR + 1;
206 for (i=0; i<0x40; i+=4) {
207 pci_read_config_dword(PCIDEVID_405GP, i, ptr++);
209 ptr = (unsigned int *)PCI_REGS_ADDR;
210 *ptr = crc32(0, (char *)PCI_REGS_ADDR+4, PCI_REGS_LEN-4);
212 printf("\nStoring PCI Configuration Regs...\n");
214 sprintf(addr, "%08x", *ptr);
219 printf("\nBooting image at addr 0x%s ...\n", addr);
220 setenv("loadaddr", addr);
222 local_args[0] = argv[0];
223 local_args[1] = NULL;
224 status = do_bootm (cmdtp, 0, 1, local_args);