3 * Steven Scholz, imc Measurement & Control, steven.scholz@imc-berlin.de
6 * Rich Ireland, Enterasys Networks, rireland@enterasys.com.
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 #include <stratixII.h>
35 /* Define FPGA_DEBUG to get debug printf's */
36 /* #define FPGA_DEBUG */
39 #define PRINTF(fmt,args...) printf (fmt ,##args)
41 #define PRINTF(fmt,args...)
44 /* Local Static Functions */
45 static int altera_validate (Altera_desc * desc, const char *fn);
47 /* ------------------------------------------------------------------------- */
48 int altera_load(Altera_desc *desc, const void *buf, size_t bsize)
50 int ret_val = FPGA_FAIL; /* assume a failure */
52 if (!altera_validate (desc, (char *)__FUNCTION__)) {
53 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
55 switch (desc->family) {
58 #if defined(CONFIG_FPGA_ACEX1K)
59 PRINTF ("%s: Launching the ACEX1K Loader...\n",
61 ret_val = ACEX1K_load (desc, buf, bsize);
62 #elif defined(CONFIG_FPGA_CYCLON2)
63 PRINTF ("%s: Launching the CYCLONE II Loader...\n",
65 ret_val = CYC2_load (desc, buf, bsize);
67 printf ("%s: No support for ACEX1K devices.\n",
72 #if defined(CONFIG_FPGA_STRATIX_II)
73 case Altera_StratixII:
74 PRINTF ("%s: Launching the Stratix II Loader...\n",
76 ret_val = StratixII_load (desc, buf, bsize);
80 printf ("%s: Unsupported family type, %d\n",
81 __FUNCTION__, desc->family);
88 int altera_dump(Altera_desc *desc, const void *buf, size_t bsize)
90 int ret_val = FPGA_FAIL; /* assume a failure */
92 if (!altera_validate (desc, (char *)__FUNCTION__)) {
93 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
95 switch (desc->family) {
97 #if defined(CONFIG_FPGA_ACEX)
98 PRINTF ("%s: Launching the ACEX1K Reader...\n",
100 ret_val = ACEX1K_dump (desc, buf, bsize);
102 printf ("%s: No support for ACEX1K devices.\n",
107 #if defined(CONFIG_FPGA_STRATIX_II)
108 case Altera_StratixII:
109 PRINTF ("%s: Launching the Stratix II Reader...\n",
111 ret_val = StratixII_dump (desc, buf, bsize);
115 printf ("%s: Unsupported family type, %d\n",
116 __FUNCTION__, desc->family);
123 int altera_info( Altera_desc *desc )
125 int ret_val = FPGA_FAIL;
127 if (altera_validate (desc, (char *)__FUNCTION__)) {
128 printf ("Family: \t");
129 switch (desc->family) {
134 printf ("CYCLON II\n");
136 case Altera_StratixII:
137 printf ("Stratix 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 ("Passive Serial (PS)\n");
149 case passive_parallel_synchronous:
150 printf ("Passive Parallel Synchronous (PPS)\n");
152 case passive_parallel_asynchronous:
153 printf ("Passive Parallel Asynchronous (PPA)\n");
155 case passive_serial_asynchronous:
156 printf ("Passive Serial Asynchronous (PSA)\n");
158 case altera_jtag_mode: /* Not used */
159 printf ("JTAG Mode\n");
161 case fast_passive_parallel:
162 printf ("Fast Passive Parallel (FPP)\n");
164 case fast_passive_parallel_security:
166 ("Fast Passive Parallel with Security (FPPS) \n");
168 /* Add new interface types here */
170 printf ("Unsupported interface type, %d\n", desc->iface);
173 printf ("Device Size: \t%d bytes\n"
174 "Cookie: \t0x%x (%d)\n",
175 desc->size, desc->cookie, desc->cookie);
177 if (desc->iface_fns) {
178 printf ("Device Function Table @ 0x%p\n", desc->iface_fns);
179 switch (desc->family) {
182 #if defined(CONFIG_FPGA_ACEX1K)
184 #elif defined(CONFIG_FPGA_CYCLON2)
188 printf ("%s: No support for ACEX1K devices.\n",
192 #if defined(CONFIG_FPGA_STRATIX_II)
193 case Altera_StratixII:
194 StratixII_info (desc);
197 /* Add new family types here */
199 /* we don't need a message here - we give one up above */
203 printf ("No Device Function Table.\n");
206 ret_val = FPGA_SUCCESS;
208 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
214 /* ------------------------------------------------------------------------- */
216 static int altera_validate (Altera_desc * desc, const char *fn)
221 if ((desc->family > min_altera_type) &&
222 (desc->family < max_altera_type)) {
223 if ((desc->iface > min_altera_iface_type) &&
224 (desc->iface < max_altera_iface_type)) {
228 printf ("%s: NULL part size\n", fn);
231 printf ("%s: Invalid Interface type, %d\n",
235 printf ("%s: Invalid family type, %d\n", fn, desc->family);
238 printf ("%s: NULL descriptor!\n", fn);
244 /* ------------------------------------------------------------------------- */