From ba91e26a1923dfc703d4b96ae9428067b7447ff2 Mon Sep 17 00:00:00 2001 From: wdenk Date: Mon, 30 May 2005 23:55:42 +0000 Subject: Patch by Juergen Selent, 17 May 2005: Add support for Funkwerk VoVPN gateway module. --- cpu/mpc8220/fec.c | 70 +++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 36 deletions(-) (limited to 'cpu/mpc8220') diff --git a/cpu/mpc8220/fec.c b/cpu/mpc8220/fec.c index 574682335..e974ab349 100644 --- a/cpu/mpc8220/fec.c +++ b/cpu/mpc8220/fec.c @@ -14,18 +14,18 @@ #include "dma.h" #include "fec.h" -#define DEBUG 0 +#undef DEBUG #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI) && \ defined(CONFIG_MPC8220_FEC) /*#if (CONFIG_COMMANDS & CFG_CMD_NET)*/ -#if (DEBUG & 0x60) +#ifdef DEBUG static void tfifo_print (mpc8220_fec_priv * fec); static void rfifo_print (mpc8220_fec_priv * fec); #endif /* DEBUG */ -#if (DEBUG & 0x40) +#ifdef DEBUG static u32 local_crc32 (char *string, unsigned int crc_value, int len); #endif @@ -37,7 +37,7 @@ typedef struct { } NBUF; /********************************************************************/ -#if (DEBUG & 0x2) +#ifdef DEBUG static void mpc8220_fec_phydump (void) { u16 phyStatus, i; @@ -144,7 +144,7 @@ static void mpc8220_fec_tbd_scrub (mpc8220_fec_priv * fec) { FEC_TBD *pUsedTbd; -#if (DEBUG & 0x1) +#ifdef DEBUG printf ("tbd_scrub: fec->cleanTbdNum = %d, fec->usedTbdIndex = %d\n", fec->cleanTbdNum, fec->usedTbdIndex); #endif @@ -155,7 +155,7 @@ static void mpc8220_fec_tbd_scrub (mpc8220_fec_priv * fec) while (fec->cleanTbdNum < FEC_TBD_NUM) { pUsedTbd = &fec->tbdBase[fec->usedTbdIndex]; if (pUsedTbd->status & FEC_TBD_READY) { -#if (DEBUG & 0x20) +#ifdef DEBUG printf ("Cannot clean TBD %d, in use\n", fec->cleanTbdNum); #endif @@ -242,7 +242,7 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) struct mpc8220_dma *dma = (struct mpc8220_dma *) MMAP_DMA; const u8 phyAddr = CONFIG_PHY_ADDR; /* Only one PHY */ -#if (DEBUG & 0x1) +#ifdef DEBUG printf ("mpc8220_fec_init... Begin\n"); #endif @@ -304,7 +304,7 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) */ fec->eth->rfifo_cntrl = 0x0c000000; fec->eth->rfifo_alarm = 0x0000030c; -#if (DEBUG & 0x22) +#ifdef DEBUG if (fec->eth->rfifo_status & 0x00700000) { printf ("mpc8220_fec_init() RFIFO error\n"); } @@ -315,7 +315,7 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) */ /*fec->eth->tfifo_cntrl = 0x0c000000; */ /*tbd - rtm */ fec->eth->tfifo_cntrl = 0x0e000000; -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("tfifo_status: 0x%08x\n", fec->eth->tfifo_status); printf ("tfifo_alarm: 0x%08x\n", fec->eth->tfifo_alarm); #endif @@ -407,7 +407,7 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) /* * Force 10Base-T, FDX operation */ -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("Forcing 10 Mbps ethernet link... "); #endif miiphy_read (phyAddr, 0x1, &phyStatus); @@ -420,13 +420,13 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) do { /* wait for link status to go down */ udelay (10000); if ((timeout--) == 0) { -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("hmmm, should not have waited..."); #endif break; } miiphy_read (phyAddr, 0x1, &phyStatus); -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("="); #endif } while ((phyStatus & 0x0004)); /* !link up */ @@ -439,12 +439,12 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) break; } miiphy_read (phyAddr, 0x1, &phyStatus); -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("+"); #endif } while (!(phyStatus & 0x0004)); /* !link up */ -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("done.\n"); #endif } else { /* MII100 */ @@ -466,7 +466,7 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) udelay (1000); if ((timeout--) == 0) { -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("PHY auto neg 0 failed...\n"); #endif return -1; @@ -474,14 +474,14 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) if (miiphy_read (phyAddr, 0x1, &phyStatus) != 0) { -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("PHY auto neg 1 failed 0x%04x...\n", phyStatus); #endif return -1; } } while (!(phyStatus & 0x0004)); -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("PHY auto neg complete! \n"); #endif } @@ -493,7 +493,7 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) */ fec->eth->ecntrl |= 0x00000006; -#if (DEBUG & 0x2) +#ifdef DEBUG if (fec->xcv_type != SEVENWIRE) mpc8220_fec_phydump (); #endif @@ -503,7 +503,7 @@ static int mpc8220_fec_init (struct eth_device *dev, bd_t * bis) */ DMA_TASK_ENABLE (FEC_RECV_TASK_NO); -#if (DEBUG & 0x1) +#ifdef DEBUG printf ("mpc8220_fec_init... Done \n"); #endif @@ -516,7 +516,7 @@ static void mpc8220_fec_halt (struct eth_device *dev) mpc8220_fec_priv *fec = (mpc8220_fec_priv *) dev->priv; int counter = 0xffff; -#if (DEBUG & 0x2) +#ifdef DEBUG if (fec->xcv_type != SEVENWIRE) mpc8220_fec_phydump (); #endif @@ -565,12 +565,12 @@ static void mpc8220_fec_halt (struct eth_device *dev) */ udelay (10); -#if (DEBUG & 0x3) +#ifdef DEBUG printf ("Ethernet task stopped\n"); #endif } -#if (DEBUG & 0x60) +#ifdef DEBUG /********************************************************************/ static void tfifo_print (mpc8220_fec_priv * fec) @@ -634,7 +634,7 @@ static int mpc8220_fec_send (struct eth_device *dev, volatile void *eth_data, mpc8220_fec_priv *fec = (mpc8220_fec_priv *) dev->priv; FEC_TBD *pTbd; -#if (DEBUG & 0x20) +#ifdef DEBUG printf ("tbd status: 0x%04x\n", fec->tbdBase[0].status); tfifo_print (fec); #endif @@ -655,7 +655,7 @@ static int mpc8220_fec_send (struct eth_device *dev, volatile void *eth_data, * Check the number of vacant TxBDs. */ if (fec->cleanTbdNum < 1) { -#if (DEBUG & 0x20) +#ifdef DEBUG printf ("No available TxBDs ...\n"); #endif return -1; @@ -670,7 +670,7 @@ static int mpc8220_fec_send (struct eth_device *dev, volatile void *eth_data, pTbd->status |= FEC_TBD_LAST | FEC_TBD_TC | FEC_TBD_READY; fec->tbdIndex = (fec->tbdIndex + 1) % FEC_TBD_NUM; -#if (DEBUG & 0x100) +#ifdef DEBUG printf ("DMA_TASK_ENABLE, fec->tbdIndex = %d \n", fec->tbdIndex); #endif @@ -687,23 +687,23 @@ static int mpc8220_fec_send (struct eth_device *dev, volatile void *eth_data, * Enable SmartDMA transmit task */ -#if (DEBUG & 0x20) +#ifdef DEBUG tfifo_print (fec); #endif DMA_TASK_ENABLE (FEC_XMIT_TASK_NO); -#if (DEBUG & 0x20) +#ifdef DEBUG tfifo_print (fec); #endif -#if (DEBUG & 0x8) +#ifdef DEBUG printf ("+"); #endif fec->cleanTbdNum -= 1; -#if (DEBUG & 0x129) && (DEBUG & 0x80000000) +#ifdef DEBUG printf ("smartDMA ethernet Tx task enabled\n"); #endif /* @@ -711,7 +711,7 @@ static int mpc8220_fec_send (struct eth_device *dev, volatile void *eth_data, */ while (pTbd->status & FEC_TBD_READY) { udelay (10); -#if (DEBUG & 0x8) +#ifdef DEBUG printf ("TDB status = %04x\n", pTbd->status); #endif } @@ -732,10 +732,8 @@ static int mpc8220_fec_recv (struct eth_device *dev) int frame_length, len = 0; NBUF *frame; -#if (DEBUG & 0x1) +#ifdef DEBUG printf ("mpc8220_fec_recv %d Start...\n", fec->rbdIndex); -#endif -#if (DEBUG & 0x8) printf ("-"); #endif @@ -901,7 +899,7 @@ int miiphy_read (u8 phyAddr, u8 regAddr, u16 * retVal) while ((timeout--) && (!(eth->ievent & 0x00800000))); if (timeout == 0) { -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("Read MDIO failed...\n"); #endif return -1; @@ -940,7 +938,7 @@ int miiphy_write (u8 phyAddr, u8 regAddr, u16 data) while ((timeout--) && (!(eth->ievent & 0x00800000))); if (timeout == 0) { -#if (DEBUG & 0x2) +#ifdef DEBUG printf ("Write MDIO failed...\n"); #endif return -1; @@ -954,7 +952,7 @@ int miiphy_write (u8 phyAddr, u8 regAddr, u16 data) return 0; } -#if (DEBUG & 0x40) +#ifdef DEBUG static u32 local_crc32 (char *string, unsigned int crc_value, int len) { int i; -- cgit v1.2.3