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,
35 #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX)
41 /* Define FPGA_DEBUG to get debug printf's */
43 #define PRINTF(fmt,args...) printf (fmt ,##args)
45 #define PRINTF(fmt,args...)
48 /* Local Static Functions */
49 static int xilinx_validate (Xilinx_desc * desc, char *fn);
51 /* ------------------------------------------------------------------------- */
53 int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize)
55 int ret_val = FPGA_FAIL; /* assume a failure */
57 if (!xilinx_validate (desc, (char *)__FUNCTION__)) {
58 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
60 switch (desc->family) {
62 #if defined(CONFIG_FPGA_SPARTAN2)
63 PRINTF ("%s: Launching the Spartan-II Loader...\n",
65 ret_val = Spartan2_load (desc, buf, bsize);
67 printf ("%s: No support for Spartan-II devices.\n",
72 #if defined(CONFIG_FPGA_SPARTAN3)
73 PRINTF ("%s: Launching the Spartan-III Loader...\n",
75 ret_val = Spartan3_load (desc, buf, bsize);
77 printf ("%s: No support for Spartan-III devices.\n",
82 #if defined(CONFIG_FPGA_VIRTEX2)
83 PRINTF ("%s: Launching the Virtex-II Loader...\n",
85 ret_val = Virtex2_load (desc, buf, bsize);
87 printf ("%s: No support for Virtex-II devices.\n",
93 printf ("%s: Unsupported family type, %d\n",
94 __FUNCTION__, desc->family);
100 int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize)
102 int ret_val = FPGA_FAIL; /* assume a failure */
104 if (!xilinx_validate (desc, (char *)__FUNCTION__)) {
105 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
107 switch (desc->family) {
108 case Xilinx_Spartan2:
109 #if defined(CONFIG_FPGA_SPARTAN2)
110 PRINTF ("%s: Launching the Spartan-II Reader...\n",
112 ret_val = Spartan2_dump (desc, buf, bsize);
114 printf ("%s: No support for Spartan-II devices.\n",
118 case Xilinx_Spartan3:
119 #if defined(CONFIG_FPGA_SPARTAN3)
120 PRINTF ("%s: Launching the Spartan-III Reader...\n",
122 ret_val = Spartan3_dump (desc, buf, bsize);
124 printf ("%s: No support for Spartan-III devices.\n",
129 #if defined( CONFIG_FPGA_VIRTEX2)
130 PRINTF ("%s: Launching the Virtex-II Reader...\n",
132 ret_val = Virtex2_dump (desc, buf, bsize);
134 printf ("%s: No support for Virtex-II devices.\n",
140 printf ("%s: Unsupported family type, %d\n",
141 __FUNCTION__, desc->family);
147 int xilinx_info (Xilinx_desc * desc)
149 int ret_val = FPGA_FAIL;
151 if (xilinx_validate (desc, (char *)__FUNCTION__)) {
152 printf ("Family: \t");
153 switch (desc->family) {
154 case Xilinx_Spartan2:
155 printf ("Spartan-II\n");
157 case Xilinx_Spartan3:
158 printf ("Spartan-III\n");
161 printf ("Virtex-II\n");
163 /* Add new family types here */
165 printf ("Unknown family type, %d\n", desc->family);
168 printf ("Interface type:\t");
169 switch (desc->iface) {
171 printf ("Slave Serial\n");
173 case master_serial: /* Not used */
174 printf ("Master Serial\n");
177 printf ("Slave Parallel\n");
179 case jtag_mode: /* Not used */
180 printf ("JTAG Mode\n");
182 case slave_selectmap:
183 printf ("Slave SelectMap Mode\n");
185 case master_selectmap:
186 printf ("Master SelectMap Mode\n");
188 /* Add new interface types here */
190 printf ("Unsupported interface type, %d\n", desc->iface);
193 printf ("Device Size: \t%d bytes\n"
194 "Cookie: \t0x%x (%d)\n",
195 desc->size, desc->cookie, desc->cookie);
197 if (desc->iface_fns) {
198 printf ("Device Function Table @ 0x%p\n", desc->iface_fns);
199 switch (desc->family) {
200 case Xilinx_Spartan2:
201 #if defined(CONFIG_FPGA_SPARTAN2)
202 Spartan2_info (desc);
205 printf ("%s: No support for Spartan-II devices.\n",
209 case Xilinx_Spartan3:
210 #if defined(CONFIG_FPGA_SPARTAN3)
211 Spartan3_info (desc);
214 printf ("%s: No support for Spartan-III devices.\n",
219 #if defined(CONFIG_FPGA_VIRTEX2)
223 printf ("%s: No support for Virtex-II devices.\n",
227 /* Add new family types here */
229 /* we don't need a message here - we give one up above */
233 printf ("No Device Function Table.\n");
235 ret_val = FPGA_SUCCESS;
237 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
243 int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset)
245 int ret_val = FPGA_FAIL; /* assume a failure */
247 if (!xilinx_validate (desc, (char *)__FUNCTION__)) {
248 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
250 switch (desc->family) {
251 case Xilinx_Spartan2:
252 #if defined(CONFIG_FPGA_SPARTAN2)
253 ret_val = Spartan2_reloc (desc, reloc_offset);
255 printf ("%s: No support for Spartan-II devices.\n",
259 case Xilinx_Spartan3:
260 #if defined(CONFIG_FPGA_SPARTAN3)
261 ret_val = Spartan3_reloc (desc, reloc_offset);
263 printf ("%s: No support for Spartan-III devices.\n",
268 #if defined(CONFIG_FPGA_VIRTEX2)
269 ret_val = Virtex2_reloc (desc, reloc_offset);
271 printf ("%s: No support for Virtex-II devices.\n",
275 /* Add new family types here */
277 printf ("%s: Unsupported family type, %d\n",
278 __FUNCTION__, desc->family);
285 /* ------------------------------------------------------------------------- */
287 static int xilinx_validate (Xilinx_desc * desc, char *fn)
292 if ((desc->family > min_xilinx_type) &&
293 (desc->family < max_xilinx_type)) {
294 if ((desc->iface > min_xilinx_iface_type) &&
295 (desc->iface < max_xilinx_iface_type)) {
299 printf ("%s: NULL part size\n", fn);
301 printf ("%s: Invalid Interface type, %d\n",
304 printf ("%s: Invalid family type, %d\n", fn, desc->family);
306 printf ("%s: NULL descriptor!\n", fn);
311 #endif /* CONFIG_FPGA && CONFIG_FPGA_XILINX */