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 #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ALTERA)
46 /* Local Static Functions */
47 static int altera_validate (Altera_desc * desc, const char *fn);
49 /* ------------------------------------------------------------------------- */
50 int altera_load( Altera_desc *desc, void *buf, size_t bsize )
52 int ret_val = FPGA_FAIL; /* assume a failure */
54 if (!altera_validate (desc, (char *)__FUNCTION__)) {
55 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
57 switch (desc->family) {
60 #if defined(CONFIG_FPGA_ACEX1K)
61 PRINTF ("%s: Launching the ACEX1K Loader...\n",
63 ret_val = ACEX1K_load (desc, buf, bsize);
64 #elif defined(CONFIG_FPGA_CYCLON2)
65 PRINTF ("%s: Launching the CYCLON II Loader...\n",
67 ret_val = CYC2_load (desc, buf, bsize);
69 printf ("%s: No support for ACEX1K devices.\n",
74 #if defined(CONFIG_FPGA_STRATIX_II)
75 case Altera_StratixII:
76 PRINTF ("%s: Launching the Stratix II Loader...\n",
78 ret_val = StratixII_load (desc, buf, bsize);
82 printf ("%s: Unsupported family type, %d\n",
83 __FUNCTION__, desc->family);
90 int altera_dump( Altera_desc *desc, void *buf, size_t bsize )
92 int ret_val = FPGA_FAIL; /* assume a failure */
94 if (!altera_validate (desc, (char *)__FUNCTION__)) {
95 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
97 switch (desc->family) {
99 #if defined(CONFIG_FPGA_ACEX)
100 PRINTF ("%s: Launching the ACEX1K Reader...\n",
102 ret_val = ACEX1K_dump (desc, buf, bsize);
104 printf ("%s: No support for ACEX1K devices.\n",
109 #if defined(CONFIG_FPGA_STRATIX_II)
110 case Altera_StratixII:
111 PRINTF ("%s: Launching the Stratix II Reader...\n",
113 ret_val = StratixII_dump (desc, buf, bsize);
117 printf ("%s: Unsupported family type, %d\n",
118 __FUNCTION__, desc->family);
125 int altera_info( Altera_desc *desc )
127 int ret_val = FPGA_FAIL;
129 if (altera_validate (desc, (char *)__FUNCTION__)) {
130 printf ("Family: \t");
131 switch (desc->family) {
136 printf ("CYCLON II\n");
138 case Altera_StratixII:
139 printf ("Stratix II\n");
141 /* Add new family types here */
143 printf ("Unknown family type, %d\n", desc->family);
146 printf ("Interface type:\t");
147 switch (desc->iface) {
149 printf ("Passive Serial (PS)\n");
151 case passive_parallel_synchronous:
152 printf ("Passive Parallel Synchronous (PPS)\n");
154 case passive_parallel_asynchronous:
155 printf ("Passive Parallel Asynchronous (PPA)\n");
157 case passive_serial_asynchronous:
158 printf ("Passive Serial Asynchronous (PSA)\n");
160 case altera_jtag_mode: /* Not used */
161 printf ("JTAG Mode\n");
163 case fast_passive_parallel:
164 printf ("Fast Passive Parallel (FPP)\n");
166 case fast_passive_parallel_security:
168 ("Fast Passive Parallel with Security (FPPS) \n");
170 /* Add new interface types here */
172 printf ("Unsupported interface type, %d\n", desc->iface);
175 printf ("Device Size: \t%d bytes\n"
176 "Cookie: \t0x%x (%d)\n",
177 desc->size, desc->cookie, desc->cookie);
179 if (desc->iface_fns) {
180 printf ("Device Function Table @ 0x%p\n", desc->iface_fns);
181 switch (desc->family) {
184 #if defined(CONFIG_FPGA_ACEX1K)
186 #elif defined(CONFIG_FPGA_CYCLON2)
190 printf ("%s: No support for ACEX1K devices.\n",
194 #if defined(CONFIG_FPGA_STRATIX_II)
195 case Altera_StratixII:
196 StratixII_info (desc);
199 /* Add new family types here */
201 /* we don't need a message here - we give one up above */
205 printf ("No Device Function Table.\n");
208 ret_val = FPGA_SUCCESS;
210 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
216 int altera_reloc( Altera_desc *desc, ulong reloc_offset)
218 int ret_val = FPGA_FAIL; /* assume a failure */
220 if (!altera_validate (desc, (char *)__FUNCTION__)) {
221 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
223 switch (desc->family) {
225 #if defined(CONFIG_FPGA_ACEX1K)
226 ret_val = ACEX1K_reloc (desc, reloc_offset);
228 printf ("%s: No support for ACEX devices.\n",
232 #if defined(CONFIG_FPGA_STRATIX_II)
233 case Altera_StratixII:
234 ret_val = StratixII_reloc (desc, reloc_offset);
238 #if defined(CONFIG_FPGA_CYCLON2)
239 ret_val = CYC2_reloc (desc, reloc_offset);
241 printf ("%s: No support for CYCLON II devices.\n",
245 /* Add new family types here */
247 printf ("%s: Unsupported family type, %d\n",
248 __FUNCTION__, desc->family);
255 /* ------------------------------------------------------------------------- */
257 static int altera_validate (Altera_desc * desc, const char *fn)
262 if ((desc->family > min_altera_type) &&
263 (desc->family < max_altera_type)) {
264 if ((desc->iface > min_altera_iface_type) &&
265 (desc->iface < max_altera_iface_type)) {
269 printf ("%s: NULL part size\n", fn);
272 printf ("%s: Invalid Interface type, %d\n",
276 printf ("%s: Invalid family type, %d\n", fn, desc->family);
279 printf ("%s: NULL descriptor!\n", fn);
285 /* ------------------------------------------------------------------------- */
287 #endif /* CONFIG_FPGA & CONFIG_FPGA_ALTERA */