3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
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,
27 #include <asm/arch/ixp425.h>
29 DECLARE_GLOBAL_DATA_PTR;
31 /* predefine these here for FPGA programming (before including fpga.c) */
32 #define SET_FPGA(data) *IXP425_GPIO_GPOUTR = (data)
33 #define FPGA_DONE_STATE (*IXP425_GPIO_GPINR & CONFIG_SYS_FPGA_DONE)
34 #define FPGA_INIT_STATE (*IXP425_GPIO_GPINR & CONFIG_SYS_FPGA_INIT)
35 #define OLD_VAL old_val
37 static unsigned long old_val = 0;
40 * include common fpga code (for prodrive boards)
42 #include "../common/fpga.c"
45 * Miscelaneous platform dependent initialisations
49 /* arch number of PDNB3 */
50 gd->bd->bi_arch_number = MACH_TYPE_PDNB3;
52 /* adress of boot parameters */
53 gd->bd->bi_boot_params = 0x00000100;
55 GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_FPGA_RESET);
56 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_FPGA_RESET);
58 GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_SYS_RUNNING);
59 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_SYS_RUNNING);
62 * Setup GPIO's for FPGA programming
64 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_PRG);
65 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_CLK);
66 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_DATA);
67 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_PRG);
68 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_CLK);
69 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_DATA);
70 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_INIT);
71 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_DONE);
74 * Setup GPIO's for interrupts
76 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_PCI_INTA);
77 GPIO_INT_ACT_LOW_SET(CONFIG_SYS_GPIO_PCI_INTA);
78 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_PCI_INTB);
79 GPIO_INT_ACT_LOW_SET(CONFIG_SYS_GPIO_PCI_INTB);
80 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_RESTORE_INT);
81 GPIO_INT_ACT_LOW_SET(CONFIG_SYS_GPIO_RESTORE_INT);
82 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_RESTART_INT);
83 GPIO_INT_ACT_LOW_SET(CONFIG_SYS_GPIO_RESTART_INT);
86 * Setup GPIO's for 33MHz clock output
88 *IXP425_GPIO_GPCLKR = 0x01FF0000;
89 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_CLK_33M);
92 * Setup other chip select's
94 *IXP425_EXP_CS1 = CONFIG_SYS_EXP_CS1;
100 * Check Board Identity
104 char *s = getenv("serial#");
106 puts("Board: PDNB3");
119 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
120 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
125 int do_fpga_boot(unsigned char *fpgadata)
131 ulong len = CONFIG_SYS_MALLOC_LEN;
134 * Setup GPIO's for FPGA programming
136 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_PRG);
137 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_CLK);
138 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_DATA);
141 * Save value so no readback is required upon programming
143 old_val = *IXP425_GPIO_GPOUTR;
146 * First try to decompress fpga image (gzip compressed?)
148 dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
149 if (gunzip(dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
150 printf("Error: Image has to be gzipp'ed!\n");
154 status = fpga_boot(dst, len);
156 printf("\nFPGA: Booting failed ");
158 case ERROR_FPGA_PRG_INIT_LOW:
159 printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
161 case ERROR_FPGA_PRG_INIT_HIGH:
162 printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
164 case ERROR_FPGA_PRG_DONE:
165 printf("(Timeout: DONE not high after programming FPGA)\n ");
169 /* display infos on fpgaimage */
171 for (i=0; i<4; i++) {
173 printf("FPGA: %s\n", &(dst[index+1]));
178 for (i=5; i>0; i--) {
179 printf("Rebooting in %2d seconds \r",i);
180 for (index=0;index<1000;index++)
184 do_reset(NULL, 0, 0, NULL);
189 /* display infos on fpgaimage */
191 for (i=0; i<4; i++) {
193 printf("%s ", &(dst[index+1]));
203 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_FPGA_RESET);
205 GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_FPGA_RESET);
210 int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
215 return cmd_usage(cmdtp);
217 addr = simple_strtoul(argv[1], NULL, 16);
219 return do_fpga_boot((unsigned char *)addr);
225 "address size\n - boot FPGA with gzipped image at <address>"
228 #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
229 extern struct pci_controller hose;
230 extern void pci_ixp_init(struct pci_controller * hose);
232 void pci_init_board(void)
234 extern void pci_ixp_init (struct pci_controller *hose);