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,
39 /* Define FPGA_DEBUG to get debug printf's */
41 #define PRINTF(fmt,args...) printf (fmt ,##args)
43 #define PRINTF(fmt,args...)
46 /* Local Static Functions */
47 static int xilinx_validate (Xilinx_desc * desc, char *fn);
49 /* ------------------------------------------------------------------------- */
51 int xilinx_load(Xilinx_desc *desc, const void *buf, size_t bsize)
53 int ret_val = FPGA_FAIL; /* assume a failure */
55 if (!xilinx_validate (desc, (char *)__FUNCTION__)) {
56 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
58 switch (desc->family) {
60 #if defined(CONFIG_FPGA_SPARTAN2)
61 PRINTF ("%s: Launching the Spartan-II Loader...\n",
63 ret_val = Spartan2_load (desc, buf, bsize);
65 printf ("%s: No support for Spartan-II devices.\n",
70 #if defined(CONFIG_FPGA_SPARTAN3)
71 PRINTF ("%s: Launching the Spartan-III Loader...\n",
73 ret_val = Spartan3_load (desc, buf, bsize);
75 printf ("%s: No support for Spartan-III devices.\n",
80 #if defined(CONFIG_FPGA_VIRTEX2)
81 PRINTF ("%s: Launching the Virtex-II Loader...\n",
83 ret_val = Virtex2_load (desc, buf, bsize);
85 printf ("%s: No support for Virtex-II devices.\n",
91 printf ("%s: Unsupported family type, %d\n",
92 __FUNCTION__, desc->family);
98 int xilinx_dump(Xilinx_desc *desc, const void *buf, size_t bsize)
100 int ret_val = FPGA_FAIL; /* assume a failure */
102 if (!xilinx_validate (desc, (char *)__FUNCTION__)) {
103 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
105 switch (desc->family) {
106 case Xilinx_Spartan2:
107 #if defined(CONFIG_FPGA_SPARTAN2)
108 PRINTF ("%s: Launching the Spartan-II Reader...\n",
110 ret_val = Spartan2_dump (desc, buf, bsize);
112 printf ("%s: No support for Spartan-II devices.\n",
116 case Xilinx_Spartan3:
117 #if defined(CONFIG_FPGA_SPARTAN3)
118 PRINTF ("%s: Launching the Spartan-III Reader...\n",
120 ret_val = Spartan3_dump (desc, buf, bsize);
122 printf ("%s: No support for Spartan-III devices.\n",
127 #if defined( CONFIG_FPGA_VIRTEX2)
128 PRINTF ("%s: Launching the Virtex-II Reader...\n",
130 ret_val = Virtex2_dump (desc, buf, bsize);
132 printf ("%s: No support for Virtex-II devices.\n",
138 printf ("%s: Unsupported family type, %d\n",
139 __FUNCTION__, desc->family);
145 int xilinx_info (Xilinx_desc * desc)
147 int ret_val = FPGA_FAIL;
149 if (xilinx_validate (desc, (char *)__FUNCTION__)) {
150 printf ("Family: \t");
151 switch (desc->family) {
152 case Xilinx_Spartan2:
153 printf ("Spartan-II\n");
155 case Xilinx_Spartan3:
156 printf ("Spartan-III\n");
159 printf ("Virtex-II\n");
161 /* Add new family types here */
163 printf ("Unknown family type, %d\n", desc->family);
166 printf ("Interface type:\t");
167 switch (desc->iface) {
169 printf ("Slave Serial\n");
171 case master_serial: /* Not used */
172 printf ("Master Serial\n");
175 printf ("Slave Parallel\n");
177 case jtag_mode: /* Not used */
178 printf ("JTAG Mode\n");
180 case slave_selectmap:
181 printf ("Slave SelectMap Mode\n");
183 case master_selectmap:
184 printf ("Master SelectMap Mode\n");
186 /* Add new interface types here */
188 printf ("Unsupported interface type, %d\n", desc->iface);
191 printf ("Device Size: \t%d bytes\n"
192 "Cookie: \t0x%x (%d)\n",
193 desc->size, desc->cookie, desc->cookie);
195 if (desc->iface_fns) {
196 printf ("Device Function Table @ 0x%p\n", desc->iface_fns);
197 switch (desc->family) {
198 case Xilinx_Spartan2:
199 #if defined(CONFIG_FPGA_SPARTAN2)
200 Spartan2_info (desc);
203 printf ("%s: No support for Spartan-II devices.\n",
207 case Xilinx_Spartan3:
208 #if defined(CONFIG_FPGA_SPARTAN3)
209 Spartan3_info (desc);
212 printf ("%s: No support for Spartan-III devices.\n",
217 #if defined(CONFIG_FPGA_VIRTEX2)
221 printf ("%s: No support for Virtex-II devices.\n",
225 /* Add new family types here */
227 /* we don't need a message here - we give one up above */
231 printf ("No Device Function Table.\n");
233 ret_val = FPGA_SUCCESS;
235 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
241 /* ------------------------------------------------------------------------- */
243 static int xilinx_validate (Xilinx_desc * desc, char *fn)
248 if ((desc->family > min_xilinx_type) &&
249 (desc->family < max_xilinx_type)) {
250 if ((desc->iface > min_xilinx_iface_type) &&
251 (desc->iface < max_xilinx_iface_type)) {
255 printf ("%s: NULL part size\n", fn);
257 printf ("%s: Invalid Interface type, %d\n",
260 printf ("%s: Invalid family type, %d\n", fn, desc->family);
262 printf ("%s: NULL descriptor!\n", fn);