summaryrefslogtreecommitdiff
path: root/nuttx/drivers/net
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-06 16:17:50 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-06 16:17:50 +0000
commit4fc87116d818f5285403dbb37d2aa60d33e4203a (patch)
tree8e2327f902c41cf79ffab0997a6754d8e78b012a /nuttx/drivers/net
parent13a1d731ec51a27983bc9e6fcaa841607a090764 (diff)
downloadpx4-nuttx-4fc87116d818f5285403dbb37d2aa60d33e4203a.tar.gz
px4-nuttx-4fc87116d818f5285403dbb37d2aa60d33e4203a.tar.bz2
px4-nuttx-4fc87116d818f5285403dbb37d2aa60d33e4203a.zip
Reduce debug output; calibrate DM320 timer
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@372 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/net')
-rw-r--r--nuttx/drivers/net/dm90x0.c317
1 files changed, 160 insertions, 157 deletions
diff --git a/nuttx/drivers/net/dm90x0.c b/nuttx/drivers/net/dm90x0.c
index 63bde9c98..9a36ed51b 100644
--- a/nuttx/drivers/net/dm90x0.c
+++ b/nuttx/drivers/net/dm90x0.c
@@ -270,7 +270,7 @@
/* This is a helper pointer for accessing the contents of the Ethernet header */
-#define BUF ((struct uip_eth_hdr *)dm9x->dev.d_buf)
+#define BUF ((struct uip_eth_hdr *)dm9x->dm_dev.d_buf)
/****************************************************************************
* Private Types
@@ -278,12 +278,12 @@
union rx_desc_u
{
- uint8 buf[4];
+ uint8 rx_buf[4];
struct
{
- uint8 rxbyte;
- uint8 status;
- uint16 length;
+ uint8 rx_byte;
+ uint8 rx_status;
+ uint16 rx_len;
} desc;
};
@@ -293,35 +293,35 @@ union rx_desc_u
struct dm9x_driver_s
{
- boolean b100M; /* TRUE:speed == 100M; FALSE:speed == 10M */
- WDOG_ID txpoll; /* TX poll timer */
- WDOG_ID txtimeout; /* TX timeout timer */
- uint8 ntxpending; /* Count of packets pending transmission */
+ boolean dm_b100M; /* TRUE:speed == 100M; FALSE:speed == 10M */
+ WDOG_ID dm_txpoll; /* TX poll timer */
+ WDOG_ID dm_txtimeout; /* TX timeout timer */
+ uint8 dm_ntxpending; /* Count of packets pending transmission */
uint8 ncrxpackets; /* Number of continuous rx packets */
/* Mode-dependent function to move data in 8/16/32 I/O modes */
- void (*read)(uint8 *ptr, int len);
- void (*write)(const uint8 *ptr, int len);
- void (*discard)(int len);
-
-#if defined(CONFIG_DM9X_STATS) || defined(CONFIG_DEBUG)
- uint32 ntxpackets; /* Count of packets sent */
- uint32 ntxbytes; /* Count of bytes sent */
- uint32 ntxerrors; /* Count of TX errors */
- uint32 nrxpackets; /* Count of packets received */
- uint32 nrxbytes; /* Count of bytes received */
- uint32 nrxfifoerrors; /* Count of RX FIFO overflow errors */
- uint32 nrxcrcerrors; /* Count of RX CRC errors */
- uint32 nrxlengtherrors; /* Count of RX length errors */
- uint32 nphyserrors; /* Count of physical layer errors */
- uint32 nresets; /* Counts number of resets */
- uint32 ntxtimeouts; /* Counts resets caused by TX timeouts */
+ void (*dm_read)(uint8 *ptr, int len);
+ void (*dm_write)(const uint8 *ptr, int len);
+ void (*dm_discard)(int len);
+
+#if defined(CONFIG_DM9X_STATS)
+ uint32 dm_ntxpackets; /* Count of packets sent */
+ uint32 dm_ntxbytes; /* Count of bytes sent */
+ uint32 dm_ntxerrors; /* Count of TX errors */
+ uint32 dm_nrxpackets; /* Count of packets received */
+ uint32 dm_nrxbytes; /* Count of bytes received */
+ uint32 dm_nrxfifoerrors; /* Count of RX FIFO overflow errors */
+ uint32 dm_nrxcrcerrors; /* Count of RX CRC errors */
+ uint32 dm_nrxlengtherrors; /* Count of RX length errors */
+ uint32 dm_nphyserrors; /* Count of physical layer errors */
+ uint32 dm_nresets; /* Counts number of resets */
+ uint32 dm_ntxtimeouts; /* Counts resets caused by TX timeouts */
#endif
/* This holds the information visible to uIP/NuttX */
- struct uip_driver_s dev;
+ struct uip_driver_s dm_dev;
};
/****************************************************************************
@@ -354,7 +354,7 @@ static void write32(const uint8 *ptr, int len);
static uint16 dm9x_phyread(struct dm9x_driver_s *dm9x, int reg);
static void dm9x_phywrite(struct dm9x_driver_s *dm9x, int reg, uint16 value);
-#if defined(CONFIG_DM9X_STATS) || defined(CONFIG_DEBUG)
+#if defined(CONFIG_DM9X_STATS)
static void dm9x_resetstatistics(struct dm9x_driver_s *dm9x);
#else
# define dm9x_resetstatistics(dm9x)
@@ -665,20 +665,20 @@ static void dm9x_phywrite(struct dm9x_driver_s *dm9x, int reg, uint16 value)
*
****************************************************************************/
-#if defined(CONFIG_DM9X_STATS) || defined(CONFIG_DEBUG)
+#if defined(CONFIG_DM9X_STATS)
static void dm9x_resetstatistics(struct dm9x_driver_s *dm9x)
{
- dm9x->ntxpackets = 0; /* Count of packets sent */
- dm9x->ntxbytes = 0; /* Count of bytes sent */
- dm9x->ntxerrors = 0; /* Count of TX errors */
- dm9x->nrxpackets = 0; /* Count of packets received */
- dm9x->nrxbytes = 0; /* Count of bytes received */
- dm9x->nrxfifoerrors = 0; /* Count of RX FIFO overflow errors */
- dm9x->nrxcrcerrors = 0; /* Count of RX CRC errors */
- dm9x->nrxlengtherrors = 0; /* Count of RX length errors */
- dm9x->nphyserrors = 0; /* Count of physical layer errors */
- dm9x->nresets = 0; /* Counts number of resets */
- dm9x->ntxtimeouts = 0; /* Counts resets caused by TX timeouts */
+ dm9x->dm_ntxpackets = 0; /* Count of packets sent */
+ dm9x->dm_ntxbytes = 0; /* Count of bytes sent */
+ dm9x->dm_ntxerrors = 0; /* Count of TX errors */
+ dm9x->dm_nrxpackets = 0; /* Count of packets received */
+ dm9x->dm_nrxbytes = 0; /* Count of bytes received */
+ dm9x->dm_nrxfifoerrors = 0; /* Count of RX FIFO overflow errors */
+ dm9x->dm_nrxcrcerrors = 0; /* Count of RX CRC errors */
+ dm9x->dm_nrxlengtherrors = 0; /* Count of RX length errors */
+ dm9x->dm_nphyserrors = 0; /* Count of physical layer errors */
+ dm9x->dm_nresets = 0; /* Counts number of resets */
+ dm9x->dm_ntxtimeouts = 0; /* Counts resets caused by TX timeouts */
}
#endif
@@ -701,17 +701,17 @@ static void dm9x_resetstatistics(struct dm9x_driver_s *dm9x)
#if defined(CONFIG_DM9X_STATS) && defined(CONFIG_DEBUG)
static void dm9x_dumpstatistics(struct dm9x_driver_s *dm9x)
{
- dbg("TX packets: %d\n", dm9x->ntxpackets);
- dbg(" bytes: %d\n", dm9x->ntxbytes);
- dbg(" errors: %d\n", dm9x->ntxerrors);
- dbg("RX packets: %d\n", dm9x->nrxpackets);
- dbg(" bytes: %d\n", dm9x->nrxbytes);
- dbg(" FIFO overflows: %d\n", dm9x->nrxfifoerrors);
- dbg(" CRC errors: %d\n", dm9x->nrxcrcerrors);
- dbg(" length errors: %d\n", dm9x->nrxlengtherrors);
- dbg("Physical layer errors: %d\n", dm9x->nphyserrors);
- dbg("Resets: %d\n", dm9x->nresets);
- dbg("TX timeout resets: %d\n", dm9x->ntxtimeouts);
+ dbg("TX packets: %d\n", dm9x->dm_ntxpackets);
+ dbg(" bytes: %d\n", dm9x->dm_ntxbytes);
+ dbg(" errors: %d\n", dm9x->dm_ntxerrors);
+ dbg("RX packets: %d\n", dm9x->dm_nrxpackets);
+ dbg(" bytes: %d\n", dm9x->dm_nrxbytes);
+ dbg(" FIFO overflows: %d\n", dm9x->dm_nrxfifoerrors);
+ dbg(" CRC errors: %d\n", dm9x->dm_nrxcrcerrors);
+ dbg(" length errors: %d\n", dm9x->dm_nrxlengtherrors);
+ dbg("Physical layer errors: %d\n", dm9x->dm_nphyserrors);
+ dbg("Resets: %d\n", dm9x->dm_nresets);
+ dbg("TX timeout resets: %d\n", dm9x->dm_ntxtimeouts);
}
#endif
@@ -764,10 +764,10 @@ static int dm9x_transmit(struct dm9x_driver_s *dm9x)
{
/* Increment count of packets transmitted */
- dm9x->ntxpending++;
-#if defined(CONFIG_DM9X_STATS) || defined(CONFIG_DEBUG)
- dm9x->ntxpackets++;
- dm9x->ntxbytes += dm9x->dev.d_len;
+ dm9x->dm_ntxpending++;
+#if defined(CONFIG_DM9X_STATS)
+ dm9x->dm_ntxpackets++;
+ dm9x->dm_ntxbytes += dm9x->dm_dev.d_len;
#endif
/* Disable all DM90x0 interrupts */
@@ -776,13 +776,13 @@ static int dm9x_transmit(struct dm9x_driver_s *dm9x)
/* Set the TX length */
- putreg(DM9X_TXPLL, (dm9x->dev.d_len & 0xff));
- putreg(DM9X_TXPLH, (dm9x->dev.d_len >> 8) & 0xff);
+ putreg(DM9X_TXPLL, (dm9x->dm_dev.d_len & 0xff));
+ putreg(DM9X_TXPLH, (dm9x->dm_dev.d_len >> 8) & 0xff);
/* Move the data to be sent into TX SRAM */
DM9X_INDEX = DM9X_MWCMD;
- dm9x->write(dm9x->dev.d_buf, dm9x->dev.d_len);
+ dm9x->dm_write(dm9x->dm_dev.d_buf, dm9x->dm_dev.d_len);
#if !defined(CONFIG_DM9X_ETRANS)
/* Issue TX polling command */
@@ -800,7 +800,7 @@ static int dm9x_transmit(struct dm9x_driver_s *dm9x)
/* Setup the TX timeout watchdog (perhaps restarting the timer) */
- (void)wd_start(dm9x->txtimeout, DM6X_TXTIMEOUT, dm9x_txtimeout, 1, (uint32)dm9x);
+ (void)wd_start(dm9x->dm_txtimeout, DM6X_TXTIMEOUT, dm9x_txtimeout, 1, (uint32)dm9x);
return OK;
}
@@ -833,16 +833,16 @@ static int dm9x_uiptxpoll(struct uip_driver_s *dev)
* the field d_len is set to a value > 0.
*/
- if (dm9x->dev.d_len > 0)
+ if (dm9x->dm_dev.d_len > 0)
{
- uip_arp_out(&dm9x->dev);
+ uip_arp_out(&dm9x->dm_dev);
dm9x_transmit(dm9x);
/* Check if there is room in the DM90x0 to hold another packet. In 100M mode,
* that can be 2 packets, otherwise it is a single packet.
*/
- if (dm9x->ntxpending > 1 || !dm9x->b100M)
+ if (dm9x->dm_ntxpending > 1 || !dm9x->dm_b100M)
{
/* Returning a non-zero value will terminate the poll operation */
@@ -881,7 +881,7 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x)
uint8 mdral;
uint8 rxbyte;
- dbg("Packet received\n");
+ vdbg("Packet received\n");
do
{
@@ -907,62 +907,64 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x)
/* Read packet status & length */
- dm9x->read((uint8*)&rx, 4);
+ dm9x->dm_read((uint8*)&rx, 4);
/* Check if any errors were reported by the hardware */
- if (rx.desc.status & 0xbf)
+ if (rx.desc.rx_status & 0xbf)
{
/* Bad RX packet... update statistics */
-#if defined(CONFIG_DM9X_STATS) || defined(CONFIG_DEBUG)
- if (rx.desc.status & 0x01)
+#if defined(CONFIG_DM9X_STATS)
+ if (rx.desc.rx_status & 0x01)
{
- dm9x->nrxfifoerrors++;
- dbg("RX FIFO error: %d\n", dm9x->nrxfifoerrors);
+ dm9x->dm_nrxfifoerrors++;
+ dbg("RX FIFO error: %d\n", dm9x->dm_nrxfifoerrors);
}
- if (rx.desc.status & 0x02)
+ if (rx.desc.rx_status & 0x02)
{
- dm9x->nrxcrcerrors++;
- dbg("RX CRC error: %d\n", dm9x->nrxcrcerrors);
+ dm9x->dm_nrxcrcerrors++;
+ dbg("RX CRC error: %d\n", dm9x->dm_nrxcrcerrors);
}
- if (rx.desc.status & 0x80)
+ if (rx.desc.rx_status & 0x80)
{
- dm9x->nrxlengtherrors++;
- dbg("RX length error: %d\n", dm9x->nrxlengtherrors);
+ dm9x->dm_nrxlengtherrors++;
+ dbg("RX length error: %d\n", dm9x->dm_nrxlengtherrors);
}
- if (rx.desc.status & 0x08)
+ if (rx.desc.rx_status & 0x08)
{
- dm9x->nphyserrors++;
- dbg("Physical Layer error: %d\n", dm9x->nphyserrors);
+ dm9x->dm_nphyserrors++;
+ dbg("Physical Layer error: %d\n", dm9x->dm_nphyserrors);
}
+#else
+ dbg("Received packet with errors: %02x\n", rx.desc.rx_status);
#endif
/* Drop this packet and continue to check the next packet */
- dm9x->discard(rx.desc.length);
+ dm9x->dm_discard(rx.desc.rx_len);
}
/* Also check if the packet is a valid size for the uIP configuration */
- else if (rx.desc.length < UIP_LLH_LEN || rx.desc.length > (UIP_BUFSIZE + 2))
+ else if (rx.desc.rx_len < UIP_LLH_LEN || rx.desc.rx_len > (UIP_BUFSIZE + 2))
{
-#if defined(CONFIG_DM9X_STATS) || defined(CONFIG_DEBUG)
- dm9x->nrxlengtherrors++;
- dbg("RX length error: %d\n", dm9x->nrxlengtherrors);
+#if defined(CONFIG_DM9X_STATS)
+ dm9x->dm_nrxlengtherrors++;
+ dbg("RX length error: %d\n", dm9x->dm_nrxlengtherrors);
#endif
/* Drop this packet and continue to check the next packet */
- dm9x->discard(rx.desc.length);
+ dm9x->dm_discard(rx.desc.rx_len);
}
else
{
/* Good packet... Copy the packet data out of SRAM and pass it one to uIP */
- dm9x->dev.d_len = rx.desc.length;
- dm9x->read(dm9x->dev.d_buf, rx.desc.length);
+ dm9x->dm_dev.d_len = rx.desc.rx_len;
+ dm9x->dm_read(dm9x->dm_dev.d_buf, rx.desc.rx_len);
/* We only accept IP packets of the configured type and ARP packets */
@@ -973,43 +975,43 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x)
#endif
{
uip_arp_ipin();
- uip_input(&dm9x->dev);
+ uip_input(&dm9x->dm_dev);
/* If the above function invocation resulted in data that
* should be sent out on the network, the global variable
* d_len is set to a value > 0.
*/
- if (dm9x->dev.d_len > 0)
+ if (dm9x->dm_dev.d_len > 0)
{
- uip_arp_out(&dm9x->dev);
+ uip_arp_out(&dm9x->dm_dev);
dm9x_transmit(dm9x);
}
}
else if (BUF->type == htons(UIP_ETHTYPE_ARP))
{
- uip_arp_arpin(&dm9x->dev);
+ uip_arp_arpin(&dm9x->dm_dev);
/* If the above function invocation resulted in data that
* should be sent out on the network, the global variable
* d_len is set to a value > 0.
*/
- if (dm9x->dev.d_len > 0)
+ if (dm9x->dm_dev.d_len > 0)
{
dm9x_transmit(dm9x);
}
}
}
-#if defined(CONFIG_DM9X_STATS) || defined(CONFIG_DEBUG)
- dm9x->nrxpackets++;
- dm9x->nrxbytes += rx.desc.length;
+#if defined(CONFIG_DM9X_STATS)
+ dm9x->dm_nrxpackets++;
+ dm9x->dm_nrxbytes += rx.desc.rx_len;
#endif
dm9x->ncrxpackets++;
}
while ((rxbyte & 0x01) == DM9X_PKTRDY && dm9x->ncrxpackets < DM9X_CRXTHRES);
- dbg("All RX packets processed\n");
+ vdbg("All RX packets processed\n");
}
/****************************************************************************
@@ -1032,7 +1034,7 @@ static void dm9x_txdone(struct dm9x_driver_s *dm9x)
{
int nsr;
- dbg("TX done\n");
+ vdbg("TX done\n");
/* Another packet has completed transmission. Decrement the count of
* of pending TX transmissions.
@@ -1041,38 +1043,38 @@ static void dm9x_txdone(struct dm9x_driver_s *dm9x)
nsr = getreg(DM9X_NETS);
if (nsr & DM9X_NETS_TX1END)
{
- if (dm9x->ntxpending)
+ if (dm9x->dm_ntxpending)
{
- dm9x->ntxpending--;
+ dm9x->dm_ntxpending--;
}
else
{
- dbg("ntxpending ERROR on TX1END\n");
+ dbg("Bad TX count (TX1END)\n");
}
}
if (nsr & DM9X_NETS_TX2END)
{
- if (dm9x->ntxpending)
+ if (dm9x->dm_ntxpending)
{
- dm9x->ntxpending--;
+ dm9x->dm_ntxpending--;
}
else
{
- dbg("ntxpending ERROR on TX2END\n");
+ dbg("Bad TX count (TX2END)\n");
}
}
/* Cancel the TX timeout */
- if (dm9x->ntxpending == 0)
+ if (dm9x->dm_ntxpending == 0)
{
- wd_cancel(dm9x->txtimeout);
+ wd_cancel(dm9x->dm_txtimeout);
}
/* Then poll uIP for new XMIT data */
- (void)uip_poll(&dm9x->dev, dm9x_uiptxpoll, UIP_POLL);
+ (void)uip_poll(&dm9x->dm_dev, dm9x_uiptxpoll, UIP_POLL);
}
/****************************************************************************
@@ -1111,7 +1113,7 @@ static int dm9x_interrupt(int irq, FAR void *context)
isr = getreg(DM9X_ISR);
putreg(DM9X_ISR, isr);
- vdbg("Interrupt: ISR=%02x\n", isr);
+ vdbg("Interrupt status: %02x\n", isr);
/* Check for link status change */
@@ -1135,17 +1137,17 @@ static int dm9x_interrupt(int irq, FAR void *context)
if (dm9x_phyread(dm9x, 0) & 0x2000)
{
- dm9x->b100M = TRUE;
+ dm9x->dm_b100M = TRUE;
}
else
{
- dm9x->b100M = FALSE;
+ dm9x->dm_b100M = FALSE;
}
break;
}
up_mdelay(1);
}
- dbg("delay: %d mS speed: %s\n", i, dm9x->b100M ? "100M" : "10M");
+ dbg("delay: %dmS speed: %s\n", i, dm9x->dm_b100M ? "100M" : "10M");
}
/* Check if we received an incoming packet */
@@ -1211,13 +1213,13 @@ static void dm9x_txtimeout(int argc, uint32 arg, ...)
/* Increment statistics and dump debug info */
-#if defined(CONFIG_DM9X_STATS) || defined(CONFIG_DEBUG)
- dm9x->ntxtimeouts++;
- dm9x->ntxerrors++;
+#if defined(CONFIG_DM9X_STATS)
+ dm9x->dm_ntxtimeouts++;
+ dm9x->dm_ntxerrors++;
#endif
- dbg(" TX packet count: %d\n", dm9x->ntxpending);
- dbg(" TX timeouts: %d\n", dm9x->ntxtimeouts);
+ dbg(" TX packet count: %d\n", dm9x->dm_ntxpending);
+ dbg(" TX timeouts: %d\n", dm9x->dm_ntxtimeouts);
dbg(" TX read pointer address: 0x%02x:%02x\n",
getreg(DM9X_TRPAH), getreg(DM9X_TRPAL));
dbg(" Memory data write address: 0x%02x:%02x (DM9010)\n",
@@ -1229,7 +1231,7 @@ static void dm9x_txtimeout(int argc, uint32 arg, ...)
/* Then poll uIP for new XMIT data */
- (void)uip_poll(&dm9x->dev, dm9x_uiptxpoll, UIP_POLL);
+ (void)uip_poll(&dm9x->dm_dev, dm9x_uiptxpoll, UIP_POLL);
}
/****************************************************************************
@@ -1269,16 +1271,16 @@ static void dm9x_polltimer(int argc, uint32 arg, ...)
* that can be 2 packets, otherwise it is a single packet.
*/
- if (dm9x->ntxpending < 1 || (dm9x->b100M && dm9x->ntxpending < 2))
+ if (dm9x->dm_ntxpending < 1 || (dm9x->dm_b100M && dm9x->dm_ntxpending < 2))
{
/* If so, poll uIP for new XMIT data */
- (void)uip_poll(&dm9x->dev, dm9x_uiptxpoll, UIP_TIMER);
+ (void)uip_poll(&dm9x->dm_dev, dm9x_uiptxpoll, UIP_TIMER);
}
/* Setup the watchdog poll timer again */
- (void)wd_start(dm9x->txpoll, DM6X_WDDELAY, dm9x_polltimer, 1, arg);
+ (void)wd_start(dm9x->dm_txpoll, DM6X_WDDELAY, dm9x_polltimer, 1, arg);
}
/****************************************************************************
@@ -1356,7 +1358,7 @@ static int dm9x_ifup(struct uip_driver_s *dev)
/* Check link state and media speed (waiting up to 3s for link OK) */
- dm9x->b100M = FALSE;
+ dm9x->dm_b100M = FALSE;
for (i = 0; i < 3000; i++)
{
netstatus = getreg(DM9X_NETS);
@@ -1368,7 +1370,7 @@ static int dm9x_ifup(struct uip_driver_s *dev)
netstatus = getreg(DM9X_NETS);
if ((netstatus & DM9X_NETS_SPEED) == 0)
{
- dm9x->b100M = TRUE;
+ dm9x->dm_b100M = TRUE;
}
break;
}
@@ -1376,11 +1378,11 @@ static int dm9x_ifup(struct uip_driver_s *dev)
up_mdelay(1);
}
- dbg("i=%d mS speed=%s\n", i, dm9x->b100M ? "100M" : "10M");
+ dbg("delay: %dmS speed: %s\n", i, dm9x->dm_b100M ? "100M" : "10M");
/* Set and activate a timer process */
- (void)wd_start(dm9x->txpoll, DM6X_WDDELAY, dm9x_polltimer, 1, (uint32)dm9x);
+ (void)wd_start(dm9x->dm_txpoll, DM6X_WDDELAY, dm9x_polltimer, 1, (uint32)dm9x);
/* Enable the DM9X interrupt */
@@ -1418,12 +1420,12 @@ static int dm9x_ifdown(struct uip_driver_s *dev)
/* Cancel the TX poll timer and TX timeout timers */
- wd_cancel(dm9x->txpoll);
- wd_cancel(dm9x->txtimeout);
+ wd_cancel(dm9x->dm_txpoll);
+ wd_cancel(dm9x->dm_txtimeout);
/* Reset the device */
- dm9x_phywrite(dm9x, 0x00, 0x8000); /* PHY RESET */
+ dm9x_phywrite(dm9x, 0x00, 0x8000); /* PHY reset */
putreg(DM9X_GPD, 0x01); /* Power-down PHY (GEPIO0=1) */
putreg(DM9X_IMR, DM9X_IMRDISABLE); /* Disable all interrupts */
putreg(DM9X_RXC, 0x00); /* Disable RX */
@@ -1461,7 +1463,7 @@ static void dm9x_bringup(struct dm9x_driver_s *dm9x)
putreg(DM9X_GPD, 0x01); /* Power-down the PHY (GEPIO0=1) */
up_udelay(500);
putreg(DM9X_GPD, 0x00); /* Preactivate PHY (GPIO0=0 */
- up_udelay(20); /* Wait 2ms for PHY power-on ready */
+ up_udelay(20); /* Wait 20us for PHY power-on ready */
/* Do a software reset and wait 20us (twice). The reset autoclears
* in 10us; 20us guarantees completion of the reset
@@ -1477,43 +1479,43 @@ static void dm9x_bringup(struct dm9x_driver_s *dm9x)
switch (getreg(DM9X_ISR) & DM9X_ISR_IOMODEM)
{
case DM9X_ISR_IOMODE8:
- dm9x->read = read8;
- dm9x->write = write8;
- dm9x->discard = discard8;
+ dm9x->dm_read = read8;
+ dm9x->dm_write = write8;
+ dm9x->dm_discard = discard8;
break;
case DM9X_ISR_IOMODE16:
- dm9x->read = read16;
- dm9x->write = write16;
- dm9x->discard = discard16;
+ dm9x->dm_read = read16;
+ dm9x->dm_write = write16;
+ dm9x->dm_discard = discard16;
break;
case DM9X_ISR_IOMODE32:
- dm9x->read = read32;
- dm9x->write = write32;
- dm9x->discard = discard32;
+ dm9x->dm_read = read32;
+ dm9x->dm_write = write32;
+ dm9x->dm_discard = discard32;
break;
default:
break;
}
- /* Set PHY operating mode */
+ /* Program PHY operating mode */
dm9x_phymode(dm9x);
- /* Program operating register */
+ /* Program operating mode */
- putreg(DM9X_NETC, 0x00); /* Network control */
- putreg(DM9X_TXC, 0x00); /* TX Polling clear */
- putreg(DM9X_BPTHRES, 0x3f); /* Less 3kb, 600us */
- putreg(DM9X_SMODEC, 0x00); /* Special mode */
+ putreg(DM9X_NETC, 0x00); /* Network control */
+ putreg(DM9X_TXC, 0x00); /* Clear TX Polling */
+ putreg(DM9X_BPTHRES, 0x3f); /* Less 3kb, 600us */
+ putreg(DM9X_SMODEC, 0x00); /* Special mode */
putreg(DM9X_NETS, (DM9X_NETS_WAKEST|DM9X_NETS_TX1END|DM9X_NETS_TX2END)); /* Clear TX status */
putreg(DM9X_ISR, DM9X_INT_ALL); /* Clear interrupt status */
#if defined(CONFIG_DM9X_CHECKSUM)
- putreg(DM9X_TCCR, 0x07); /* TX UDP/TCP/IP checksum enable */
- putreg(DM9X_RCSR, 0x02); /* Receive checksum enable */
+ putreg(DM9X_TCCR, 0x07); /* TX UDP/TCP/IP checksum enable */
+ putreg(DM9X_RCSR, 0x02); /* Receive checksum enable */
#endif
#if defined(CONFIG_DM9X_ETRANS)
@@ -1523,7 +1525,7 @@ static void dm9x_bringup(struct dm9x_driver_s *dm9x)
/* Initialize statistics */
dm9x->ncrxpackets = 0; /* Number of continuous RX packets */
- dm9x->ntxpending = 0; /* Number of pending TX packets */
+ dm9x->dm_ntxpending = 0; /* Number of pending TX packets */
dm9x_resetstatistics(dm9x);
/* Activate DM9000A/DM9010 */
@@ -1556,26 +1558,26 @@ static void dm9x_reset(struct dm9x_driver_s *dm9x)
/* Cancel the TX poll timer and TX timeout timers */
- wd_cancel(dm9x->txpoll);
- wd_cancel(dm9x->txtimeout);
+ wd_cancel(dm9x->dm_txpoll);
+ wd_cancel(dm9x->dm_txtimeout);
/* Save previous register address */
save = (uint8)DM9X_INDEX;
- dm9x->nresets++;
+ dm9x->dm_nresets++;
dm9x_bringup(dm9x);
/* Wait up to 1 second for the link to be OK */
- dm9x->b100M = FALSE;
+ dm9x->dm_b100M = FALSE;
for (i = 0; i < 1000; i++)
{
- if (dm9x_phyread(dm9x,0x1) & 0x4) /*Link OK*/
+ if (dm9x_phyread(dm9x,0x1) & 0x4)
{
if (dm9x_phyread(dm9x, 0) &0x2000)
{
- dm9x->b100M = TRUE;
+ dm9x->dm_b100M = TRUE;
}
break;
}
@@ -1627,7 +1629,7 @@ int dm9x_initialize(void)
if (vid != DM9X_DAVICOMVID || (pid != DM9X_DM9000PID && pid != DM9X_DM9010PID))
{
- dbg("DM90x0 vender/product ID not found at this base address\n");
+ lldbg("DM90x0 vender/product ID not found at this base address\n");
return -ENODEV;
}
@@ -1636,6 +1638,7 @@ int dm9x_initialize(void)
if (irq_attach(CONFIG_DM9X_IRQ, dm9x_interrupt))
{
/* We could not attach the ISR to the ISR */
+
lldbg("irq_attach() failed\n");
return -EAGAIN;
}
@@ -1643,18 +1646,18 @@ int dm9x_initialize(void)
/* Initialize the driver structure */
memset(g_dm9x, 0, CONFIG_DM9X_NINTERFACES*sizeof(struct dm9x_driver_s));
- g_dm9x[0].dev.ifup = dm9x_ifup; /* I/F down callback */
- g_dm9x[0].dev.ifdown = dm9x_ifdown; /* I/F up (new IP address) callback */
- g_dm9x[0].dev.d_private = (void*)g_dm9x; /* Used to recover private state from dev */
+ g_dm9x[0].dm_dev.d_ifup = dm9x_ifup; /* I/F down callback */
+ g_dm9x[0].dm_dev.d_ifdown = dm9x_ifdown; /* I/F up (new IP address) callback */
+ g_dm9x[0].dm_dev.d_private = (void*)g_dm9x; /* Used to recover private state from dev */
/* Create a watchdog for timing polling for and timing of transmisstions */
- g_dm9x[0].txpoll = wd_create(); /* Create periodic poll timer */
- g_dm9x[0].txtimeout = wd_create(); /* Create TX timeout timer */
+ g_dm9x[0].dm_txpoll = wd_create(); /* Create periodic poll timer */
+ g_dm9x[0].dm_txtimeout = wd_create(); /* Create TX timeout timer */
/* Read the MAC address */
- mptr = g_dm9x[0].dev.d_mac.addr;
+ mptr = g_dm9x[0].dm_dev.d_mac.addr;
for (i = 0, j = DM9X_PAB0; i < 6; i++, j++)
{
mptr[i] = getreg(j);
@@ -1665,7 +1668,7 @@ int dm9x_initialize(void)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&g_dm9x[0].dev);
+ (void)netdev_register(&g_dm9x[0].dm_dev);
return OK;
}