mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-30 19:11:37 +00:00
fpga: altera: Clean up the printing and debug
Clean up the printf() statements and get rid of the PRINTF() macro by replacing it with debug_cond(). Signed-off-by: Marek Vasut <marex@denx.de> Cc: Chin Liang See <clsee@altera.com> Cc: Dinh Nguyen <dinguyen@altera.com> Cc: Albert Aribaud <albert.u.boot@aribaud.net> Cc: Tom Rini <trini@ti.com> Cc: Wolfgang Denk <wd@denx.de> Cc: Pavel Machek <pavel@denx.de> Acked-by: Pavel Machek <pavel@denx.de>
This commit is contained in:
parent
be9f643ae6
commit
0ae16cbb40
1 changed files with 58 additions and 59 deletions
|
@ -15,14 +15,8 @@
|
||||||
#include <ACEX1K.h>
|
#include <ACEX1K.h>
|
||||||
#include <stratixII.h>
|
#include <stratixII.h>
|
||||||
|
|
||||||
/* Define FPGA_DEBUG to get debug printf's */
|
/* Define FPGA_DEBUG to 1 to get debug printf's */
|
||||||
/* #define FPGA_DEBUG */
|
#define FPGA_DEBUG 0
|
||||||
|
|
||||||
#ifdef FPGA_DEBUG
|
|
||||||
#define PRINTF(fmt,args...) printf (fmt ,##args)
|
|
||||||
#else
|
|
||||||
#define PRINTF(fmt,args...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Local Static Functions */
|
/* Local Static Functions */
|
||||||
static int altera_validate (Altera_desc * desc, const char *fn);
|
static int altera_validate (Altera_desc * desc, const char *fn);
|
||||||
|
@ -32,36 +26,39 @@ int altera_load(Altera_desc *desc, const void *buf, size_t bsize)
|
||||||
{
|
{
|
||||||
int ret_val = FPGA_FAIL; /* assume a failure */
|
int ret_val = FPGA_FAIL; /* assume a failure */
|
||||||
|
|
||||||
if (!altera_validate (desc, (char *)__FUNCTION__)) {
|
if (!altera_validate (desc, (char *)__func__)) {
|
||||||
printf ("%s: Invalid device descriptor\n", __FUNCTION__);
|
printf("%s: Invalid device descriptor\n", __func__);
|
||||||
} else {
|
} else {
|
||||||
switch (desc->family) {
|
switch (desc->family) {
|
||||||
case Altera_ACEX1K:
|
case Altera_ACEX1K:
|
||||||
case Altera_CYC2:
|
case Altera_CYC2:
|
||||||
#if defined(CONFIG_FPGA_ACEX1K)
|
#if defined(CONFIG_FPGA_ACEX1K)
|
||||||
PRINTF ("%s: Launching the ACEX1K Loader...\n",
|
debug_cond(FPGA_DEBUG,
|
||||||
__FUNCTION__);
|
"%s: Launching the ACEX1K Loader...\n",
|
||||||
|
__func__);
|
||||||
ret_val = ACEX1K_load (desc, buf, bsize);
|
ret_val = ACEX1K_load (desc, buf, bsize);
|
||||||
#elif defined(CONFIG_FPGA_CYCLON2)
|
#elif defined(CONFIG_FPGA_CYCLON2)
|
||||||
PRINTF ("%s: Launching the CYCLONE II Loader...\n",
|
debug_cond(FPGA_DEBUG,
|
||||||
__FUNCTION__);
|
"%s: Launching the CYCLONE II Loader...\n",
|
||||||
|
__func__);
|
||||||
ret_val = CYC2_load (desc, buf, bsize);
|
ret_val = CYC2_load (desc, buf, bsize);
|
||||||
#else
|
#else
|
||||||
printf ("%s: No support for ACEX1K devices.\n",
|
printf("%s: No support for ACEX1K devices.\n",
|
||||||
__FUNCTION__);
|
__func__);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(CONFIG_FPGA_STRATIX_II)
|
#if defined(CONFIG_FPGA_STRATIX_II)
|
||||||
case Altera_StratixII:
|
case Altera_StratixII:
|
||||||
PRINTF ("%s: Launching the Stratix II Loader...\n",
|
debug_cond(FPGA_DEBUG,
|
||||||
__FUNCTION__);
|
"%s: Launching the Stratix II Loader...\n",
|
||||||
|
__func__);
|
||||||
ret_val = StratixII_load (desc, buf, bsize);
|
ret_val = StratixII_load (desc, buf, bsize);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
printf ("%s: Unsupported family type, %d\n",
|
printf("%s: Unsupported family type, %d\n",
|
||||||
__FUNCTION__, desc->family);
|
__func__, desc->family);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,31 +69,33 @@ int altera_dump(Altera_desc *desc, const void *buf, size_t bsize)
|
||||||
{
|
{
|
||||||
int ret_val = FPGA_FAIL; /* assume a failure */
|
int ret_val = FPGA_FAIL; /* assume a failure */
|
||||||
|
|
||||||
if (!altera_validate (desc, (char *)__FUNCTION__)) {
|
if (!altera_validate (desc, (char *)__func__)) {
|
||||||
printf ("%s: Invalid device descriptor\n", __FUNCTION__);
|
printf("%s: Invalid device descriptor\n", __func__);
|
||||||
} else {
|
} else {
|
||||||
switch (desc->family) {
|
switch (desc->family) {
|
||||||
case Altera_ACEX1K:
|
case Altera_ACEX1K:
|
||||||
#if defined(CONFIG_FPGA_ACEX)
|
#if defined(CONFIG_FPGA_ACEX)
|
||||||
PRINTF ("%s: Launching the ACEX1K Reader...\n",
|
debug_cond(FPGA_DEBUG,
|
||||||
__FUNCTION__);
|
"%s: Launching the ACEX1K Reader...\n",
|
||||||
|
__func__);
|
||||||
ret_val = ACEX1K_dump (desc, buf, bsize);
|
ret_val = ACEX1K_dump (desc, buf, bsize);
|
||||||
#else
|
#else
|
||||||
printf ("%s: No support for ACEX1K devices.\n",
|
printf("%s: No support for ACEX1K devices.\n",
|
||||||
__FUNCTION__);
|
__func__);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(CONFIG_FPGA_STRATIX_II)
|
#if defined(CONFIG_FPGA_STRATIX_II)
|
||||||
case Altera_StratixII:
|
case Altera_StratixII:
|
||||||
PRINTF ("%s: Launching the Stratix II Reader...\n",
|
debug_cond(FPGA_DEBUG,
|
||||||
__FUNCTION__);
|
"%s: Launching the Stratix II Reader...\n",
|
||||||
|
__func__);
|
||||||
ret_val = StratixII_dump (desc, buf, bsize);
|
ret_val = StratixII_dump (desc, buf, bsize);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
printf ("%s: Unsupported family type, %d\n",
|
printf("%s: Unsupported family type, %d\n",
|
||||||
__FUNCTION__, desc->family);
|
__func__, desc->family);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,42 +106,42 @@ int altera_info( Altera_desc *desc )
|
||||||
{
|
{
|
||||||
int ret_val = FPGA_FAIL;
|
int ret_val = FPGA_FAIL;
|
||||||
|
|
||||||
if (altera_validate (desc, (char *)__FUNCTION__)) {
|
if (altera_validate (desc, (char *)__func__)) {
|
||||||
printf ("Family: \t");
|
printf("Family: \t");
|
||||||
switch (desc->family) {
|
switch (desc->family) {
|
||||||
case Altera_ACEX1K:
|
case Altera_ACEX1K:
|
||||||
printf ("ACEX1K\n");
|
printf("ACEX1K\n");
|
||||||
break;
|
break;
|
||||||
case Altera_CYC2:
|
case Altera_CYC2:
|
||||||
printf ("CYCLON II\n");
|
printf("CYCLON II\n");
|
||||||
break;
|
break;
|
||||||
case Altera_StratixII:
|
case Altera_StratixII:
|
||||||
printf ("Stratix II\n");
|
printf("Stratix II\n");
|
||||||
break;
|
break;
|
||||||
/* Add new family types here */
|
/* Add new family types here */
|
||||||
default:
|
default:
|
||||||
printf ("Unknown family type, %d\n", desc->family);
|
printf("Unknown family type, %d\n", desc->family);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("Interface type:\t");
|
printf("Interface type:\t");
|
||||||
switch (desc->iface) {
|
switch (desc->iface) {
|
||||||
case passive_serial:
|
case passive_serial:
|
||||||
printf ("Passive Serial (PS)\n");
|
printf("Passive Serial (PS)\n");
|
||||||
break;
|
break;
|
||||||
case passive_parallel_synchronous:
|
case passive_parallel_synchronous:
|
||||||
printf ("Passive Parallel Synchronous (PPS)\n");
|
printf("Passive Parallel Synchronous (PPS)\n");
|
||||||
break;
|
break;
|
||||||
case passive_parallel_asynchronous:
|
case passive_parallel_asynchronous:
|
||||||
printf ("Passive Parallel Asynchronous (PPA)\n");
|
printf("Passive Parallel Asynchronous (PPA)\n");
|
||||||
break;
|
break;
|
||||||
case passive_serial_asynchronous:
|
case passive_serial_asynchronous:
|
||||||
printf ("Passive Serial Asynchronous (PSA)\n");
|
printf("Passive Serial Asynchronous (PSA)\n");
|
||||||
break;
|
break;
|
||||||
case altera_jtag_mode: /* Not used */
|
case altera_jtag_mode: /* Not used */
|
||||||
printf ("JTAG Mode\n");
|
printf("JTAG Mode\n");
|
||||||
break;
|
break;
|
||||||
case fast_passive_parallel:
|
case fast_passive_parallel:
|
||||||
printf ("Fast Passive Parallel (FPP)\n");
|
printf("Fast Passive Parallel (FPP)\n");
|
||||||
break;
|
break;
|
||||||
case fast_passive_parallel_security:
|
case fast_passive_parallel_security:
|
||||||
printf
|
printf
|
||||||
|
@ -150,7 +149,7 @@ int altera_info( Altera_desc *desc )
|
||||||
break;
|
break;
|
||||||
/* Add new interface types here */
|
/* Add new interface types here */
|
||||||
default:
|
default:
|
||||||
printf ("Unsupported interface type, %d\n", desc->iface);
|
printf("Unsupported interface type, %d\n", desc->iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Device Size: \t%zd bytes\n"
|
printf("Device Size: \t%zd bytes\n"
|
||||||
|
@ -158,23 +157,23 @@ int altera_info( Altera_desc *desc )
|
||||||
desc->size, desc->cookie, desc->cookie);
|
desc->size, desc->cookie, desc->cookie);
|
||||||
|
|
||||||
if (desc->iface_fns) {
|
if (desc->iface_fns) {
|
||||||
printf ("Device Function Table @ 0x%p\n", desc->iface_fns);
|
printf("Device Function Table @ 0x%p\n", desc->iface_fns);
|
||||||
switch (desc->family) {
|
switch (desc->family) {
|
||||||
case Altera_ACEX1K:
|
case Altera_ACEX1K:
|
||||||
case Altera_CYC2:
|
case Altera_CYC2:
|
||||||
#if defined(CONFIG_FPGA_ACEX1K)
|
#if defined(CONFIG_FPGA_ACEX1K)
|
||||||
ACEX1K_info (desc);
|
ACEX1K_info(desc);
|
||||||
#elif defined(CONFIG_FPGA_CYCLON2)
|
#elif defined(CONFIG_FPGA_CYCLON2)
|
||||||
CYC2_info (desc);
|
CYC2_info(desc);
|
||||||
#else
|
#else
|
||||||
/* just in case */
|
/* just in case */
|
||||||
printf ("%s: No support for ACEX1K devices.\n",
|
printf("%s: No support for ACEX1K devices.\n",
|
||||||
__FUNCTION__);
|
__func__);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
#if defined(CONFIG_FPGA_STRATIX_II)
|
#if defined(CONFIG_FPGA_STRATIX_II)
|
||||||
case Altera_StratixII:
|
case Altera_StratixII:
|
||||||
StratixII_info (desc);
|
StratixII_info(desc);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
/* Add new family types here */
|
/* Add new family types here */
|
||||||
|
@ -183,12 +182,12 @@ int altera_info( Altera_desc *desc )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf ("No Device Function Table.\n");
|
printf("No Device Function Table.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ret_val = FPGA_SUCCESS;
|
ret_val = FPGA_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
printf ("%s: Invalid device descriptor\n", __FUNCTION__);
|
printf("%s: Invalid device descriptor\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
|
@ -208,17 +207,17 @@ static int altera_validate (Altera_desc * desc, const char *fn)
|
||||||
if (desc->size) {
|
if (desc->size) {
|
||||||
ret_val = true;
|
ret_val = true;
|
||||||
} else {
|
} else {
|
||||||
printf ("%s: NULL part size\n", fn);
|
printf("%s: NULL part size\n", fn);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf ("%s: Invalid Interface type, %d\n",
|
printf("%s: Invalid Interface type, %d\n",
|
||||||
fn, desc->iface);
|
fn, desc->iface);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf ("%s: Invalid family type, %d\n", fn, desc->family);
|
printf("%s: Invalid family type, %d\n", fn, desc->family);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf ("%s: NULL descriptor!\n", fn);
|
printf("%s: NULL descriptor!\n", fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
|
|
Loading…
Add table
Reference in a new issue