3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
11 #include <asm/arch/ixp425.h>
13 DECLARE_GLOBAL_DATA_PTR;
15 /* predefine these here for FPGA programming (before including fpga.c) */
16 #define SET_FPGA(data) *IXP425_GPIO_GPOUTR = (data)
17 #define FPGA_DONE_STATE (*IXP425_GPIO_GPINR & CONFIG_SYS_FPGA_DONE)
18 #define FPGA_INIT_STATE (*IXP425_GPIO_GPINR & CONFIG_SYS_FPGA_INIT)
19 #define OLD_VAL old_val
21 static unsigned long old_val = 0;
24 * include common fpga code (for prodrive boards)
26 #include "../common/fpga.c"
29 * Miscelaneous platform dependent initialisations
33 /* adress of boot parameters */
34 gd->bd->bi_boot_params = 0x00000100;
36 GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_FPGA_RESET);
37 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_FPGA_RESET);
39 GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_SYS_RUNNING);
40 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_SYS_RUNNING);
43 * Setup GPIO's for FPGA programming
45 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_PRG);
46 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_CLK);
47 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_DATA);
48 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_PRG);
49 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_CLK);
50 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_DATA);
51 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_INIT);
52 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_DONE);
55 * Setup GPIO's for interrupts
57 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_PCI_INTA);
58 GPIO_INT_ACT_LOW_SET(CONFIG_SYS_GPIO_PCI_INTA);
59 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_PCI_INTB);
60 GPIO_INT_ACT_LOW_SET(CONFIG_SYS_GPIO_PCI_INTB);
61 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_RESTORE_INT);
62 GPIO_INT_ACT_LOW_SET(CONFIG_SYS_GPIO_RESTORE_INT);
63 GPIO_OUTPUT_DISABLE(CONFIG_SYS_GPIO_RESTART_INT);
64 GPIO_INT_ACT_LOW_SET(CONFIG_SYS_GPIO_RESTART_INT);
67 * Setup GPIO's for 33MHz clock output
69 *IXP425_GPIO_GPCLKR = 0x01FF0000;
70 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_CLK_33M);
73 * Setup other chip select's
75 *IXP425_EXP_CS1 = CONFIG_SYS_EXP_CS1;
81 * Check Board Identity
86 int i = getenv_f("serial#", buf, sizeof(buf));
101 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
102 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
107 int do_fpga_boot(unsigned char *fpgadata)
113 ulong len = CONFIG_SYS_MALLOC_LEN;
116 * Setup GPIO's for FPGA programming
118 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_PRG);
119 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_CLK);
120 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_DATA);
123 * Save value so no readback is required upon programming
125 old_val = *IXP425_GPIO_GPOUTR;
128 * First try to decompress fpga image (gzip compressed?)
130 dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
131 if (gunzip(dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
132 printf("Error: Image has to be gzipp'ed!\n");
136 status = fpga_boot(dst, len);
138 printf("\nFPGA: Booting failed ");
140 case ERROR_FPGA_PRG_INIT_LOW:
141 printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
143 case ERROR_FPGA_PRG_INIT_HIGH:
144 printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
146 case ERROR_FPGA_PRG_DONE:
147 printf("(Timeout: DONE not high after programming FPGA)\n ");
151 /* display infos on fpgaimage */
153 for (i=0; i<4; i++) {
155 printf("FPGA: %s\n", &(dst[index+1]));
160 for (i=5; i>0; i--) {
161 printf("Rebooting in %2d seconds \r",i);
162 for (index=0;index<1000;index++)
166 do_reset(NULL, 0, 0, NULL);
171 /* display infos on fpgaimage */
173 for (i=0; i<4; i++) {
175 printf("%s ", &(dst[index+1]));
185 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_FPGA_RESET);
187 GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_FPGA_RESET);
192 int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
197 return cmd_usage(cmdtp);
199 addr = simple_strtoul(argv[1], NULL, 16);
201 return do_fpga_boot((unsigned char *)addr);
207 "address size\n - boot FPGA with gzipped image at <address>"
210 #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
211 extern struct pci_controller hose;
212 extern void pci_ixp_init(struct pci_controller * hose);
214 void pci_init_board(void)
216 extern void pci_ixp_init (struct pci_controller *hose);