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,
34 /* Define FPGA_DEBUG to get debug printf's */
35 /* #define FPGA_DEBUG */
38 #define PRINTF(fmt,args...) printf (fmt ,##args)
40 #define PRINTF(fmt,args...)
43 #if (CONFIG_FPGA & CFG_FPGA_ALTERA)
45 /* Local Static Functions */
46 static int altera_validate (Altera_desc
* desc
, char *fn
);
48 /* ------------------------------------------------------------------------- */
49 int altera_load( Altera_desc
*desc
, void *buf
, size_t bsize
)
51 int ret_val
= FPGA_FAIL
; /* assume a failure */
53 if (!altera_validate (desc
, __FUNCTION__
)) {
54 printf ("%s: Invalid device descriptor\n", __FUNCTION__
);
56 switch (desc
->family
) {
58 #if (CONFIG_FPGA & CFG_ACEX1K)
59 PRINTF ("%s: Launching the ACEX1K Loader...\n",
61 ret_val
= ACEX1K_load (desc
, buf
, bsize
);
63 printf ("%s: No support for ACEX1K devices.\n",
69 printf ("%s: Unsupported family type, %d\n",
70 __FUNCTION__
, desc
->family
);
77 int altera_dump( Altera_desc
*desc
, void *buf
, size_t bsize
)
79 int ret_val
= FPGA_FAIL
; /* assume a failure */
81 if (!altera_validate (desc
, __FUNCTION__
)) {
82 printf ("%s: Invalid device descriptor\n", __FUNCTION__
);
84 switch (desc
->family
) {
86 #if (CONFIG_FPGA & CFG_ACEX)
87 PRINTF ("%s: Launching the ACEX1K Reader...\n",
89 ret_val
= ACEX1K_dump (desc
, buf
, bsize
);
91 printf ("%s: No support for ACEX1K devices.\n",
97 printf ("%s: Unsupported family type, %d\n",
98 __FUNCTION__
, desc
->family
);
105 int altera_info( Altera_desc
*desc
)
107 int ret_val
= FPGA_FAIL
;
109 if (altera_validate (desc
, __FUNCTION__
)) {
110 printf ("Family: \t");
111 switch (desc
->family
) {
115 /* Add new family types here */
117 printf ("Unknown family type, %d\n", desc
->family
);
120 printf ("Interface type:\t");
121 switch (desc
->iface
) {
123 printf ("Passive Serial (PS)\n");
125 case passive_parallel_synchronous
:
126 printf ("Passive Parallel Synchronous (PPS)\n");
128 case passive_parallel_asynchronous
:
129 printf ("Passive Parallel Asynchronous (PPA)\n");
131 case passive_serial_asynchronous
:
132 printf ("Passive Serial Asynchronous (PSA)\n");
134 case altera_jtag_mode
: /* Not used */
135 printf ("JTAG Mode\n");
137 /* Add new interface types here */
139 printf ("Unsupported interface type, %d\n", desc
->iface
);
142 printf ("Device Size: \t%d bytes\n"
143 "Cookie: \t0x%x (%d)\n",
144 desc
->size
, desc
->cookie
, desc
->cookie
);
146 if (desc
->iface_fns
) {
147 printf ("Device Function Table @ 0x%p\n", desc
->iface_fns
);
148 switch (desc
->family
) {
150 #if (CONFIG_FPGA & CFG_ACEX1K)
154 printf ("%s: No support for ACEX1K devices.\n",
158 /* Add new family types here */
160 /* we don't need a message here - we give one up above */
164 printf ("No Device Function Table.\n");
167 ret_val
= FPGA_SUCCESS
;
169 printf ("%s: Invalid device descriptor\n", __FUNCTION__
);
175 int altera_reloc( Altera_desc
*desc
, ulong reloc_offset
)
177 int ret_val
= FPGA_FAIL
; /* assume a failure */
179 if (!altera_validate (desc
, __FUNCTION__
)) {
180 printf ("%s: Invalid device descriptor\n", __FUNCTION__
);
182 switch (desc
->family
) {
184 #if (CONFIG_FPGA & CFG_ACEX1K)
185 ret_val
= ACEX1K_reloc (desc
, reloc_offset
);
187 printf ("%s: No support for ACEX devices.\n",
191 /* Add new family types here */
193 printf ("%s: Unsupported family type, %d\n",
194 __FUNCTION__
, desc
->family
);
201 /* ------------------------------------------------------------------------- */
203 static int altera_validate (Altera_desc
* desc
, char *fn
)
208 if ((desc
->family
> min_altera_type
) &&
209 (desc
->family
< max_altera_type
)) {
210 if ((desc
->iface
> min_altera_iface_type
) &&
211 (desc
->iface
< max_altera_iface_type
)) {
215 printf ("%s: NULL part size\n", fn
);
218 printf ("%s: Invalid Interface type, %d\n",
222 printf ("%s: Invalid family type, %d\n", fn
, desc
->family
);
225 printf ("%s: NULL descriptor!\n", fn
);
231 /* ------------------------------------------------------------------------- */
233 #endif /* CONFIG_FPGA & CFG_FPGA_ALTERA */