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 defined(CONFIG_FPGA) && defined(CONFIG_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
, (char *)__FUNCTION__
)) {
54 printf ("%s: Invalid device descriptor\n", __FUNCTION__
);
56 switch (desc
->family
) {
59 #if defined(CONFIG_FPGA_ACEX1K)
60 PRINTF ("%s: Launching the ACEX1K Loader...\n",
62 ret_val
= ACEX1K_load (desc
, buf
, bsize
);
63 #elif defined CONFIG_FPGA_CYCLON2
64 PRINTF ("%s: Launching the CYCLON II Loader...\n",
66 ret_val
= CYC2_load (desc
, buf
, bsize
);
68 printf ("%s: No support for ACEX1K devices.\n",
74 printf ("%s: Unsupported family type, %d\n",
75 __FUNCTION__
, desc
->family
);
82 int altera_dump( Altera_desc
*desc
, void *buf
, size_t bsize
)
84 int ret_val
= FPGA_FAIL
; /* assume a failure */
86 if (!altera_validate (desc
, (char *)__FUNCTION__
)) {
87 printf ("%s: Invalid device descriptor\n", __FUNCTION__
);
89 switch (desc
->family
) {
91 #if defined(CONFIG_FPGA_ACEX)
92 PRINTF ("%s: Launching the ACEX1K Reader...\n",
94 ret_val
= ACEX1K_dump (desc
, buf
, bsize
);
96 printf ("%s: No support for ACEX1K devices.\n",
102 printf ("%s: Unsupported family type, %d\n",
103 __FUNCTION__
, desc
->family
);
110 int altera_info( Altera_desc
*desc
)
112 int ret_val
= FPGA_FAIL
;
114 if (altera_validate (desc
, (char *)__FUNCTION__
)) {
115 printf ("Family: \t");
116 switch (desc
->family
) {
120 /* Add new family types here */
122 printf ("CYCLON II\n");
125 printf ("Unknown family type, %d\n", desc
->family
);
128 printf ("Interface type:\t");
129 switch (desc
->iface
) {
131 printf ("Passive Serial (PS)\n");
133 case passive_parallel_synchronous
:
134 printf ("Passive Parallel Synchronous (PPS)\n");
136 case passive_parallel_asynchronous
:
137 printf ("Passive Parallel Asynchronous (PPA)\n");
139 case passive_serial_asynchronous
:
140 printf ("Passive Serial Asynchronous (PSA)\n");
142 case altera_jtag_mode
: /* Not used */
143 printf ("JTAG Mode\n");
145 /* Add new interface types here */
147 printf ("Unsupported interface type, %d\n", desc
->iface
);
150 printf ("Device Size: \t%d bytes\n"
151 "Cookie: \t0x%x (%d)\n",
152 desc
->size
, desc
->cookie
, desc
->cookie
);
154 if (desc
->iface_fns
) {
155 printf ("Device Function Table @ 0x%p\n", desc
->iface_fns
);
156 switch (desc
->family
) {
159 #if defined(CONFIG_FPGA_ACEX1K)
161 #elif defined(CONFIG_FPGA_CYCLON2)
165 printf ("%s: No support for ACEX1K devices.\n",
169 /* Add new family types here */
171 /* we don't need a message here - we give one up above */
175 printf ("No Device Function Table.\n");
178 ret_val
= FPGA_SUCCESS
;
180 printf ("%s: Invalid device descriptor\n", __FUNCTION__
);
186 int altera_reloc( Altera_desc
*desc
, ulong reloc_offset
)
188 int ret_val
= FPGA_FAIL
; /* assume a failure */
190 if (!altera_validate (desc
, (char *)__FUNCTION__
)) {
191 printf ("%s: Invalid device descriptor\n", __FUNCTION__
);
193 switch (desc
->family
) {
195 #if defined(CONFIG_FPGA_ACEX1K)
196 ret_val
= ACEX1K_reloc (desc
, reloc_offset
);
198 printf ("%s: No support for ACEX devices.\n",
203 #if defined(CONFIG_FPGA_CYCLON2)
204 ret_val
= CYC2_reloc (desc
, reloc_offset
);
206 printf ("%s: No support for CYCLON II devices.\n",
210 /* Add new family types here */
212 printf ("%s: Unsupported family type, %d\n",
213 __FUNCTION__
, desc
->family
);
220 /* ------------------------------------------------------------------------- */
222 static int altera_validate (Altera_desc
* desc
, char *fn
)
227 if ((desc
->family
> min_altera_type
) &&
228 (desc
->family
< max_altera_type
)) {
229 if ((desc
->iface
> min_altera_iface_type
) &&
230 (desc
->iface
< max_altera_iface_type
)) {
234 printf ("%s: NULL part size\n", fn
);
237 printf ("%s: Invalid Interface type, %d\n",
241 printf ("%s: Invalid family type, %d\n", fn
, desc
->family
);
244 printf ("%s: NULL descriptor!\n", fn
);
250 /* ------------------------------------------------------------------------- */
252 #endif /* CONFIG_FPGA & CONFIG_FPGA_ALTERA */