3 * Steven Scholz, imc Measurement & Control, steven.scholz@imc-berlin.de
6 * Rich Ireland, Enterasys Networks, rireland@enterasys.com.
8 * SPDX-License-Identifier: GPL-2.0+
16 #include <stratixII.h>
18 /* Define FPGA_DEBUG to get debug printf's */
19 /* #define FPGA_DEBUG */
22 #define PRINTF(fmt,args...) printf (fmt ,##args)
24 #define PRINTF(fmt,args...)
27 /* Local Static Functions */
28 static int altera_validate (Altera_desc * desc, const char *fn);
30 /* ------------------------------------------------------------------------- */
31 int altera_load(Altera_desc *desc, const void *buf, size_t bsize)
33 int ret_val = FPGA_FAIL; /* assume a failure */
35 if (!altera_validate (desc, (char *)__FUNCTION__)) {
36 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
38 switch (desc->family) {
41 #if defined(CONFIG_FPGA_ACEX1K)
42 PRINTF ("%s: Launching the ACEX1K Loader...\n",
44 ret_val = ACEX1K_load (desc, buf, bsize);
45 #elif defined(CONFIG_FPGA_CYCLON2)
46 PRINTF ("%s: Launching the CYCLONE II Loader...\n",
48 ret_val = CYC2_load (desc, buf, bsize);
50 printf ("%s: No support for ACEX1K devices.\n",
55 #if defined(CONFIG_FPGA_STRATIX_II)
56 case Altera_StratixII:
57 PRINTF ("%s: Launching the Stratix II Loader...\n",
59 ret_val = StratixII_load (desc, buf, bsize);
63 printf ("%s: Unsupported family type, %d\n",
64 __FUNCTION__, desc->family);
71 int altera_dump(Altera_desc *desc, const void *buf, size_t bsize)
73 int ret_val = FPGA_FAIL; /* assume a failure */
75 if (!altera_validate (desc, (char *)__FUNCTION__)) {
76 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
78 switch (desc->family) {
80 #if defined(CONFIG_FPGA_ACEX)
81 PRINTF ("%s: Launching the ACEX1K Reader...\n",
83 ret_val = ACEX1K_dump (desc, buf, bsize);
85 printf ("%s: No support for ACEX1K devices.\n",
90 #if defined(CONFIG_FPGA_STRATIX_II)
91 case Altera_StratixII:
92 PRINTF ("%s: Launching the Stratix II Reader...\n",
94 ret_val = StratixII_dump (desc, buf, bsize);
98 printf ("%s: Unsupported family type, %d\n",
99 __FUNCTION__, desc->family);
106 int altera_info( Altera_desc *desc )
108 int ret_val = FPGA_FAIL;
110 if (altera_validate (desc, (char *)__FUNCTION__)) {
111 printf ("Family: \t");
112 switch (desc->family) {
117 printf ("CYCLON II\n");
119 case Altera_StratixII:
120 printf ("Stratix II\n");
122 /* Add new family types here */
124 printf ("Unknown family type, %d\n", desc->family);
127 printf ("Interface type:\t");
128 switch (desc->iface) {
130 printf ("Passive Serial (PS)\n");
132 case passive_parallel_synchronous:
133 printf ("Passive Parallel Synchronous (PPS)\n");
135 case passive_parallel_asynchronous:
136 printf ("Passive Parallel Asynchronous (PPA)\n");
138 case passive_serial_asynchronous:
139 printf ("Passive Serial Asynchronous (PSA)\n");
141 case altera_jtag_mode: /* Not used */
142 printf ("JTAG Mode\n");
144 case fast_passive_parallel:
145 printf ("Fast Passive Parallel (FPP)\n");
147 case fast_passive_parallel_security:
149 ("Fast Passive Parallel with Security (FPPS) \n");
151 /* Add new interface types here */
153 printf ("Unsupported interface type, %d\n", desc->iface);
156 printf("Device Size: \t%zd bytes\n"
157 "Cookie: \t0x%x (%d)\n",
158 desc->size, desc->cookie, desc->cookie);
160 if (desc->iface_fns) {
161 printf ("Device Function Table @ 0x%p\n", desc->iface_fns);
162 switch (desc->family) {
165 #if defined(CONFIG_FPGA_ACEX1K)
167 #elif defined(CONFIG_FPGA_CYCLON2)
171 printf ("%s: No support for ACEX1K devices.\n",
175 #if defined(CONFIG_FPGA_STRATIX_II)
176 case Altera_StratixII:
177 StratixII_info (desc);
180 /* Add new family types here */
182 /* we don't need a message here - we give one up above */
186 printf ("No Device Function Table.\n");
189 ret_val = FPGA_SUCCESS;
191 printf ("%s: Invalid device descriptor\n", __FUNCTION__);
197 /* ------------------------------------------------------------------------- */
199 static int altera_validate (Altera_desc * desc, const char *fn)
204 if ((desc->family > min_altera_type) &&
205 (desc->family < max_altera_type)) {
206 if ((desc->iface > min_altera_iface_type) &&
207 (desc->iface < max_altera_iface_type)) {
211 printf ("%s: NULL part size\n", fn);
214 printf ("%s: Invalid Interface type, %d\n",
218 printf ("%s: Invalid family type, %d\n", fn, desc->family);
221 printf ("%s: NULL descriptor!\n", fn);
227 /* ------------------------------------------------------------------------- */