3 * Rich Ireland, Enterasys Networks, rireland@enterasys.com.
4 * Keith Outwater, keith_outwater@mvis.com
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 #if (CONFIG_FPGA & CFG_FPGA_XILINX)
40 /* Define FPGA_DEBUG to get debug printf's */
42 #define PRINTF(fmt,args...) printf (fmt ,##args)
44 #define PRINTF(fmt,args...)
47 /* Local Static Functions */
48 static int xilinx_validate (Xilinx_desc * desc, char *fn);
50 /* ------------------------------------------------------------------------- */
52 int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize)
54 int ret_val = FPGA_FAIL; /* assume a failure */
56 if (!xilinx_validate (desc, __FUNCTION__)) {
57 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
59 switch (desc->family) {
61 #if (CONFIG_FPGA & CFG_SPARTAN2)
62 PRINTF ("%s: Launching the Spartan-II Loader...\n",
64 ret_val = Spartan2_load (desc, buf, bsize);
66 printf ("%s: No support for Spartan-II devices.\n",
71 #if (CONFIG_FPGA & CFG_VIRTEX2)
72 PRINTF ("%s: Launching the Virtex-II Loader...\n",
74 ret_val = Virtex2_load (desc, buf, bsize);
76 printf ("%s: No support for Virtex-II devices.\n",
82 printf ("%s: Unsupported family type, %d\n",
83 __FUNCTION__, desc->family);
89 int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize)
91 int ret_val = FPGA_FAIL; /* assume a failure */
93 if (!xilinx_validate (desc, __FUNCTION__)) {
94 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
96 switch (desc->family) {
98 #if (CONFIG_FPGA & CFG_SPARTAN2)
99 PRINTF ("%s: Launching the Spartan-II Reader...\n",
101 ret_val = Spartan2_dump (desc, buf, bsize);
103 printf ("%s: No support for Spartan-II devices.\n",
108 #if (CONFIG_FPGA & CFG_VIRTEX2)
109 PRINTF ("%s: Launching the Virtex-II Reader...\n",
111 ret_val = Virtex2_dump (desc, buf, bsize);
113 printf ("%s: No support for Virtex-II devices.\n",
119 printf ("%s: Unsupported family type, %d\n",
120 __FUNCTION__, desc->family);
126 int xilinx_info (Xilinx_desc * desc)
128 int ret_val = FPGA_FAIL;
130 if (xilinx_validate (desc, __FUNCTION__)) {
131 printf ("Family: \t");
132 switch (desc->family) {
133 case Xilinx_Spartan2:
134 printf ("Spartan-II\n");
137 printf ("Virtex-II\n");
139 /* Add new family types here */
141 printf ("Unknown family type, %d\n", desc->family);
144 printf ("Interface type:\t");
145 switch (desc->iface) {
147 printf ("Slave Serial\n");
149 case master_serial: /* Not used */
150 printf ("Master Serial\n");
153 printf ("Slave Parallel\n");
155 case jtag_mode: /* Not used */
156 printf ("JTAG Mode\n");
158 case slave_selectmap:
159 printf ("Slave SelectMap Mode\n");
161 case master_selectmap:
162 printf ("Master SelectMap Mode\n");
164 /* Add new interface types here */
166 printf ("Unsupported interface type, %d\n", desc->iface);
169 printf ("Device Size: \t%d bytes\n"
170 "Cookie: \t0x%x (%d)\n",
171 desc->size, desc->cookie, desc->cookie);
173 if (desc->iface_fns) {
174 printf ("Device Function Table @ 0x%p\n", desc->iface_fns);
175 switch (desc->family) {
176 case Xilinx_Spartan2:
177 #if (CONFIG_FPGA & CFG_SPARTAN2)
178 Spartan2_info (desc);
181 printf ("%s: No support for Spartan-II devices.\n",
186 #if (CONFIG_FPGA & CFG_VIRTEX2)
190 printf ("%s: No support for Virtex-II devices.\n",
194 /* Add new family types here */
196 /* we don't need a message here - we give one up above */
199 printf ("No Device Function Table.\n");
201 ret_val = FPGA_SUCCESS;
203 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
209 int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset)
211 int ret_val = FPGA_FAIL; /* assume a failure */
213 if (!xilinx_validate (desc, __FUNCTION__)) {
214 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
216 switch (desc->family) {
217 case Xilinx_Spartan2:
218 #if (CONFIG_FPGA & CFG_SPARTAN2)
219 ret_val = Spartan2_reloc (desc, reloc_offset);
221 printf ("%s: No support for Spartan-II devices.\n",
226 #if (CONFIG_FPGA & CFG_VIRTEX2)
227 ret_val = Virtex2_reloc (desc, reloc_offset);
229 printf ("%s: No support for Virtex-II devices.\n",
233 /* Add new family types here */
235 printf ("%s: Unsupported family type, %d\n",
236 __FUNCTION__, desc->family);
243 /* ------------------------------------------------------------------------- */
245 static int xilinx_validate (Xilinx_desc * desc, char *fn)
250 if ((desc->family > min_xilinx_type) &&
251 (desc->family < max_xilinx_type)) {
252 if ((desc->iface > min_xilinx_iface_type) &&
253 (desc->iface < max_xilinx_iface_type)) {
257 printf ("%s: NULL part size\n", fn);
259 printf ("%s: Invalid Interface type, %d\n",
262 printf ("%s: Invalid family type, %d\n", fn, desc->family);
264 printf ("%s: NULL descriptor!\n", fn);
269 #endif /* CONFIG_FPGA & CFG_FPGA_XILINX */