1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <command.h>
26#include <malloc.h>
27#include <asm/arch/ixp425.h>
28
29DECLARE_GLOBAL_DATA_PTR;
30
31
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
36
37static unsigned long old_val = 0;
38
39
40
41
42#include "../common/fpga.c"
43
44
45
46
47int board_init(void)
48{
49
50 gd->bd->bi_arch_number = MACH_TYPE_PDNB3;
51
52
53 gd->bd->bi_boot_params = 0x00000100;
54
55 GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_FPGA_RESET);
56 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_FPGA_RESET);
57
58 GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_SYS_RUNNING);
59 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_SYS_RUNNING);
60
61
62
63
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);
72
73
74
75
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);
84
85
86
87
88 *IXP425_GPIO_GPCLKR = 0x01FF0000;
89 GPIO_OUTPUT_ENABLE(CONFIG_SYS_GPIO_CLK_33M);
90
91
92
93
94 *IXP425_EXP_CS1 = CONFIG_SYS_EXP_CS1;
95
96 return 0;
97}
98
99
100
101
102int checkboard(void)
103{
104 char *s = getenv("serial#");
105
106 puts("Board: PDNB3");
107
108 if (s != NULL) {
109 puts(", serial# ");
110 puts(s);
111 }
112 putc('\n');
113
114 return (0);
115}
116
117int dram_init(void)
118{
119 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
120 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
121
122 return (0);
123}
124
125int do_fpga_boot(unsigned char *fpgadata)
126{
127 unsigned char *dst;
128 int status;
129 int index;
130 int i;
131 ulong len = CONFIG_SYS_MALLOC_LEN;
132
133
134
135
136 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_PRG);
137 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_CLK);
138 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_DATA);
139
140
141
142
143 old_val = *IXP425_GPIO_GPOUTR;
144
145
146
147
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");
151 return -1;
152 }
153
154 status = fpga_boot(dst, len);
155 if (status != 0) {
156 printf("\nFPGA: Booting failed ");
157 switch (status) {
158 case ERROR_FPGA_PRG_INIT_LOW:
159 printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
160 break;
161 case ERROR_FPGA_PRG_INIT_HIGH:
162 printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
163 break;
164 case ERROR_FPGA_PRG_DONE:
165 printf("(Timeout: DONE not high after programming FPGA)\n ");
166 break;
167 }
168
169
170 index = 15;
171 for (i=0; i<4; i++) {
172 len = dst[index];
173 printf("FPGA: %s\n", &(dst[index+1]));
174 index += len+3;
175 }
176 putc ('\n');
177
178 for (i=5; i>0; i--) {
179 printf("Rebooting in %2d seconds \r",i);
180 for (index=0;index<1000;index++)
181 udelay(1000);
182 }
183 putc('\n');
184 do_reset(NULL, 0, 0, NULL);
185 }
186
187 puts("FPGA: ");
188
189
190 index = 15;
191 for (i=0; i<4; i++) {
192 len = dst[index];
193 printf("%s ", &(dst[index+1]));
194 index += len+3;
195 }
196 putc('\n');
197
198 free(dst);
199
200
201
202
203 GPIO_OUTPUT_CLEAR(CONFIG_SYS_GPIO_FPGA_RESET);
204 udelay(10);
205 GPIO_OUTPUT_SET(CONFIG_SYS_GPIO_FPGA_RESET);
206
207 return (0);
208}
209
210int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
211{
212 ulong addr;
213
214 if (argc < 2)
215 return cmd_usage(cmdtp);
216
217 addr = simple_strtoul(argv[1], NULL, 16);
218
219 return do_fpga_boot((unsigned char *)addr);
220}
221
222U_BOOT_CMD(
223 fpga, 2, 0, do_fpga,
224 "boot FPGA",
225 "address size\n - boot FPGA with gzipped image at <address>"
226);
227
228#if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
229extern struct pci_controller hose;
230extern void pci_ixp_init(struct pci_controller * hose);
231
232void pci_init_board(void)
233{
234 extern void pci_ixp_init (struct pci_controller *hose);
235
236 pci_ixp_init(&hose);
237}
238#endif
239