GRETH: made debug printouts use common debug() macro.

Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
This commit is contained in:
Daniel Hellstrom 2010-10-27 09:24:13 +02:00
parent e3ce686c6e
commit 6644c19573
1 changed files with 25 additions and 41 deletions

View File

@ -24,6 +24,8 @@
* MA 02111-1307 USA * MA 02111-1307 USA
*/ */
/* #define DEBUG */
#include <common.h> #include <common.h>
#include <command.h> #include <command.h>
#include <net.h> #include <net.h>
@ -33,8 +35,6 @@
#include <ambapp.h> #include <ambapp.h>
#include <asm/leon.h> #include <asm/leon.h>
/* #define DEBUG */
#include "greth.h" #include "greth.h"
/* Default to 3s timeout on autonegotiation */ /* Default to 3s timeout on autonegotiation */
@ -142,9 +142,8 @@ int greth_init(struct eth_device *dev, bd_t * bis)
greth_priv *greth = dev->priv; greth_priv *greth = dev->priv;
greth_regs *regs = greth->regs; greth_regs *regs = greth->regs;
#ifdef DEBUG
printf("greth_init\n"); debug("greth_init\n");
#endif
if (!greth->rxbd_base) { if (!greth->rxbd_base) {
@ -199,9 +198,7 @@ int greth_init(struct eth_device *dev, bd_t * bis)
/* Enable Transmitter, GRETH will now scan descriptors for packets /* Enable Transmitter, GRETH will now scan descriptors for packets
* to transmitt */ * to transmitt */
#ifdef DEBUG debug("greth_init: enabling receiver\n");
printf("greth_init: enabling receiver\n");
#endif
GRETH_REGORIN(&regs->control, GRETH_RXEN); GRETH_REGORIN(&regs->control, GRETH_RXEN);
return 0; return 0;
@ -306,10 +303,8 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
} }
auto_neg_done: auto_neg_done:
#ifdef DEBUG debug("%s GRETH Ethermac at [0x%x] irq %d. Running \
printf("%s GRETH Ethermac at [0x%x] irq %d. Running \
%d Mbps %s duplex\n", dev->gbit_mac ? "10/100/1000" : "10/100", (unsigned int)(regs), (unsigned int)(dev->irq), dev->gb ? 1000 : (dev->sp ? 100 : 10), dev->fd ? "full" : "half"); %d Mbps %s duplex\n", dev->gbit_mac ? "10/100/1000" : "10/100", (unsigned int)(regs), (unsigned int)(dev->irq), dev->gb ? 1000 : (dev->sp ? 100 : 10), dev->fd ? "full" : "half");
#endif
/* Read out PHY info if extended registers are available */ /* Read out PHY info if extended registers are available */
if (tmp & 1) { if (tmp & 1) {
tmp1 = read_mii(2, regs); tmp1 = read_mii(2, regs);
@ -318,10 +313,8 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
tmp = tmp2 & 0xF; tmp = tmp2 & 0xF;
tmp2 = (tmp2 >> 4) & 0x3F; tmp2 = (tmp2 >> 4) & 0x3F;
#ifdef DEBUG debug("PHY: Vendor %x Device %x Revision %d\n", tmp1,
printf("PHY: Vendor %x Device %x Revision %d\n", tmp1,
tmp2, tmp); tmp2, tmp);
#endif
} else { } else {
printf("PHY info not available\n"); printf("PHY info not available\n");
} }
@ -338,9 +331,9 @@ void greth_halt(struct eth_device *dev)
greth_priv *greth; greth_priv *greth;
greth_regs *regs; greth_regs *regs;
int i; int i;
#ifdef DEBUG
printf("greth_halt\n"); debug("greth_halt\n");
#endif
if (!dev || !dev->priv) if (!dev || !dev->priv)
return; return;
@ -376,9 +369,9 @@ int greth_send(struct eth_device *dev, volatile void *eth_data, int data_length)
greth_bd *txbd; greth_bd *txbd;
void *txbuf; void *txbuf;
unsigned int status; unsigned int status;
#ifdef DEBUG
printf("greth_send\n"); debug("greth_send\n");
#endif
/* send data, wait for data to be sent, then return */ /* send data, wait for data to be sent, then return */
if (((unsigned int)eth_data & (GRETH_BUF_ALIGN - 1)) if (((unsigned int)eth_data & (GRETH_BUF_ALIGN - 1))
&& !greth->gbit_mac) { && !greth->gbit_mac) {
@ -387,9 +380,6 @@ int greth_send(struct eth_device *dev, volatile void *eth_data, int data_length)
*/ */
if (!greth->txbuf) { if (!greth->txbuf) {
greth->txbuf = malloc(GRETH_RXBUF_SIZE); greth->txbuf = malloc(GRETH_RXBUF_SIZE);
#ifdef DEBUG
printf("GRETH: allocated aligned tx-buf\n");
#endif
} }
txbuf = greth->txbuf; txbuf = greth->txbuf;
@ -455,9 +445,7 @@ int greth_recv(struct eth_device *dev)
unsigned char *d; unsigned char *d;
int enable = 0; int enable = 0;
int i; int i;
#ifdef DEBUG
/* printf("greth_recv\n"); */
#endif
/* Receive One packet only, but clear as many error packets as there are /* Receive One packet only, but clear as many error packets as there are
* available. * available.
*/ */
@ -474,10 +462,9 @@ int greth_recv(struct eth_device *dev)
if (status & GRETH_BD_EN) { if (status & GRETH_BD_EN) {
goto done; goto done;
} }
#ifdef DEBUG
printf("greth_recv: packet 0x%lx, 0x%lx, len: %d\n", debug("greth_recv: packet 0x%lx, 0x%lx, len: %d\n",
(unsigned int)rxbd, status, status & GRETH_BD_LEN); (unsigned int)rxbd, status, status & GRETH_BD_LEN);
#endif
/* Check status for errors. /* Check status for errors.
*/ */
@ -512,12 +499,12 @@ int greth_recv(struct eth_device *dev)
/* Process the incoming packet. */ /* Process the incoming packet. */
len = status & GRETH_BD_LEN; len = status & GRETH_BD_LEN;
d = (char *)rxbd->addr; d = (char *)rxbd->addr;
#ifdef DEBUG
printf debug
("greth_recv: new packet, length: %d. data: %x %x %x %x %x %x %x %x\n", ("greth_recv: new packet, length: %d. data: %x %x %x %x %x %x %x %x\n",
len, d[0], d[1], d[2], d[3], d[4], d[5], d[6], len, d[0], d[1], d[2], d[3], d[4], d[5], d[6],
d[7]); d[7]);
#endif
/* flush all data cache to make sure we're not reading old packet data */ /* flush all data cache to make sure we're not reading old packet data */
sparc_dcache_flush_all(); sparc_dcache_flush_all();
@ -565,10 +552,9 @@ void greth_set_hwaddr(greth_priv * greth, unsigned char *mac)
greth->regs->esa_msb = (mac[0] << 8) | mac[1]; greth->regs->esa_msb = (mac[0] << 8) | mac[1];
greth->regs->esa_lsb = greth->regs->esa_lsb =
(mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5]; (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5];
#ifdef DEBUG
printf("GRETH: New MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n", debug("GRETH: New MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
#endif
} }
int greth_initialize(bd_t * bis) int greth_initialize(bd_t * bis)
@ -579,9 +565,9 @@ int greth_initialize(bd_t * bis)
int i; int i;
char *addr_str, *end; char *addr_str, *end;
unsigned char addr[6]; unsigned char addr[6];
#ifdef DEBUG
printf("Scanning for GRETH\n"); debug("Scanning for GRETH\n");
#endif
/* Find Device & IRQ via AMBA Plug&Play information */ /* Find Device & IRQ via AMBA Plug&Play information */
if (ambapp_apb_first(VENDOR_GAISLER, GAISLER_ETHMAC, &apbdev) != 1) { if (ambapp_apb_first(VENDOR_GAISLER, GAISLER_ETHMAC, &apbdev) != 1) {
return -1; /* GRETH not found */ return -1; /* GRETH not found */
@ -594,9 +580,7 @@ int greth_initialize(bd_t * bis)
greth->regs = (greth_regs *) apbdev.address; greth->regs = (greth_regs *) apbdev.address;
greth->irq = apbdev.irq; greth->irq = apbdev.irq;
#ifdef DEBUG debug("Found GRETH at 0x%lx, irq %d\n", greth->regs, greth->irq);
printf("Found GRETH at 0x%lx, irq %d\n", greth->regs, greth->irq);
#endif
dev->priv = (void *)greth; dev->priv = (void *)greth;
dev->iobase = (unsigned int)greth->regs; dev->iobase = (unsigned int)greth->regs;
dev->init = greth_init; dev->init = greth_init;