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 1 to get debug printf's */
21 /* Local Static Functions */
22 static int altera_validate (Altera_desc * desc, const char *fn);
24 /* ------------------------------------------------------------------------- */
25 int altera_load(Altera_desc *desc, const void *buf, size_t bsize)
27 int ret_val = FPGA_FAIL; /* assume a failure */
29 if (!altera_validate(desc, (char *)__func__)) {
30 printf("%s: Invalid device descriptor\n", __func__);
34 switch (desc->family) {
37 #if defined(CONFIG_FPGA_ACEX1K)
38 debug_cond(FPGA_DEBUG,
39 "%s: Launching the ACEX1K Loader...\n",
41 ret_val = ACEX1K_load (desc, buf, bsize);
42 #elif defined(CONFIG_FPGA_CYCLON2)
43 debug_cond(FPGA_DEBUG,
44 "%s: Launching the CYCLONE II Loader...\n",
46 ret_val = CYC2_load (desc, buf, bsize);
48 printf("%s: No support for ACEX1K devices.\n",
53 #if defined(CONFIG_FPGA_STRATIX_II)
54 case Altera_StratixII:
55 debug_cond(FPGA_DEBUG,
56 "%s: Launching the Stratix II Loader...\n",
58 ret_val = StratixII_load (desc, buf, bsize);
62 printf("%s: Unsupported family type, %d\n",
63 __func__, desc->family);
69 int altera_dump(Altera_desc *desc, const void *buf, size_t bsize)
71 int ret_val = FPGA_FAIL; /* assume a failure */
73 if (!altera_validate (desc, (char *)__func__)) {
74 printf("%s: Invalid device descriptor\n", __func__);
78 switch (desc->family) {
80 #if defined(CONFIG_FPGA_ACEX)
81 debug_cond(FPGA_DEBUG,
82 "%s: Launching the ACEX1K Reader...\n",
84 ret_val = ACEX1K_dump (desc, buf, bsize);
86 printf("%s: No support for ACEX1K devices.\n",
91 #if defined(CONFIG_FPGA_STRATIX_II)
92 case Altera_StratixII:
93 debug_cond(FPGA_DEBUG,
94 "%s: Launching the Stratix II Reader...\n",
96 ret_val = StratixII_dump (desc, buf, bsize);
100 printf("%s: Unsupported family type, %d\n",
101 __func__, desc->family);
107 int altera_info(Altera_desc *desc)
109 int ret_val = FPGA_FAIL;
111 if (!altera_validate (desc, (char *)__func__)) {
112 printf("%s: Invalid device descriptor\n", __func__);
116 printf("Family: \t");
117 switch (desc->family) {
122 printf("CYCLON II\n");
124 case Altera_StratixII:
125 printf("Stratix II\n");
127 /* Add new family types here */
129 printf("Unknown family type, %d\n", desc->family);
132 printf("Interface type:\t");
133 switch (desc->iface) {
135 printf("Passive Serial (PS)\n");
137 case passive_parallel_synchronous:
138 printf("Passive Parallel Synchronous (PPS)\n");
140 case passive_parallel_asynchronous:
141 printf("Passive Parallel Asynchronous (PPA)\n");
143 case passive_serial_asynchronous:
144 printf("Passive Serial Asynchronous (PSA)\n");
146 case altera_jtag_mode: /* Not used */
147 printf("JTAG Mode\n");
149 case fast_passive_parallel:
150 printf("Fast Passive Parallel (FPP)\n");
152 case fast_passive_parallel_security:
153 printf("Fast Passive Parallel with Security (FPPS)\n");
155 /* Add new interface types here */
157 printf("Unsupported interface type, %d\n", desc->iface);
160 printf("Device Size: \t%zd bytes\n"
161 "Cookie: \t0x%x (%d)\n",
162 desc->size, desc->cookie, desc->cookie);
164 if (desc->iface_fns) {
165 printf("Device Function Table @ 0x%p\n", desc->iface_fns);
166 switch (desc->family) {
169 #if defined(CONFIG_FPGA_ACEX1K)
171 #elif defined(CONFIG_FPGA_CYCLON2)
175 printf("%s: No support for ACEX1K devices.\n",
179 #if defined(CONFIG_FPGA_STRATIX_II)
180 case Altera_StratixII:
181 StratixII_info(desc);
184 /* Add new family types here */
186 /* we don't need a message here - we give one up above */
190 printf("No Device Function Table.\n");
193 ret_val = FPGA_SUCCESS;
198 /* ------------------------------------------------------------------------- */
200 static int altera_validate(Altera_desc *desc, const char *fn)
203 printf("%s: NULL descriptor!\n", fn);
207 if ((desc->family < min_altera_type) ||
208 (desc->family > max_altera_type)) {
209 printf("%s: Invalid family type, %d\n", fn, desc->family);
213 if ((desc->iface < min_altera_iface_type) ||
214 (desc->iface > max_altera_iface_type)) {
215 printf("%s: Invalid Interface type, %d\n", fn, desc->iface);
220 printf("%s: NULL part size\n", fn);
227 /* ------------------------------------------------------------------------- */