Fix nxstyle warning

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2020-08-07 01:41:45 +08:00
committed by Alan Carvalho de Assis
parent 4c706771c3
commit f618de9c97
58 changed files with 2765 additions and 2165 deletions
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -685,7 +685,7 @@ static inline void imxrt_dispatch(FAR struct imxrt_driver_s *priv)
NETDEV_RXPACKETS(&priv->dev); NETDEV_RXPACKETS(&priv->dev);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -706,7 +706,7 @@ static inline void imxrt_dispatch(FAR struct imxrt_driver_s *priv)
ipv4_input(&priv->dev); ipv4_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -746,7 +746,7 @@ static inline void imxrt_dispatch(FAR struct imxrt_driver_s *priv)
ipv6_input(&priv->dev); ipv6_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
+1 -3
View File
@@ -645,9 +645,7 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv)
(uint8_t *)kinesis_swap32((uint32_t)priv->rxdesc[priv->rxtail].data); (uint8_t *)kinesis_swap32((uint32_t)priv->rxdesc[priv->rxtail].data);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet /* When packet sockets are enabled, feed the frame into the tap */
* tap
*/
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
+16 -8
View File
@@ -157,7 +157,9 @@
/* Timing *******************************************************************/ /* Timing *******************************************************************/
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll deley = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define LPC17_40_WDDELAY (1*CLK_TCK) #define LPC17_40_WDDELAY (1*CLK_TCK)
@@ -174,7 +176,7 @@
/* Misc. Helpers ************************************************************/ /* Misc. Helpers ************************************************************/
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* This is a helper pointer for accessing the contents of Ethernet header */
#define BUF ((struct eth_hdr_s *)priv->lp_dev.d_buf) #define BUF ((struct eth_hdr_s *)priv->lp_dev.d_buf)
@@ -966,7 +968,9 @@ static void lpc17_40_rxdone_work(FAR void *arg)
pkt_input(&priv->lp_dev); pkt_input(&priv->lp_dev);
#endif #endif
/* We only accept IP packets of the configured type and ARP packets */ /* We only accept IP packets of the configured type and ARP
* packets
*/
#ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv4
if (BUF->type == HTONS(ETHTYPE_IP)) if (BUF->type == HTONS(ETHTYPE_IP))
@@ -988,7 +992,7 @@ static void lpc17_40_rxdone_work(FAR void *arg)
if (priv->lp_dev.d_len > 0) if (priv->lp_dev.d_len > 0)
{ {
/* Update the Ethernet header with the correct MAC address */ /* Update Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->lp_dev.d_flags)) if (IFF_IS_IPv4(priv->lp_dev.d_flags))
@@ -1027,7 +1031,7 @@ static void lpc17_40_rxdone_work(FAR void *arg)
if (priv->lp_dev.d_len > 0) if (priv->lp_dev.d_len > 0)
{ {
/* Update the Ethernet header with the correct MAC address */ /* Update Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv4
if (IFF_IS_IPv4(priv->lp_dev.d_flags)) if (IFF_IS_IPv4(priv->lp_dev.d_flags))
@@ -1139,7 +1143,9 @@ static void lpc17_40_txdone_work(FAR void *arg)
net_lock(); net_lock();
if (priv->lp_txpending) if (priv->lp_txpending)
{ {
/* Clear the pending condition, send the packet, and restore Rx interrupts */ /* Clear the pending condition, send the packet,
* and restore Rx interrupts
*/
priv->lp_txpending = false; priv->lp_txpending = false;
@@ -1675,7 +1681,9 @@ static int lpc17_40_ifup(struct net_driver_s *dev)
lpc17_40_macmode(priv->lp_mode); lpc17_40_macmode(priv->lp_mode);
/* Initialize EMAC DMA memory -- descriptors, status, packet buffers, etc. */ /* Initialize EMAC DMA memory --
* descriptors, status, packet buffers, etc.
*/
lpc17_40_txdescinit(priv); lpc17_40_txdescinit(priv);
lpc17_40_rxdescinit(priv); lpc17_40_rxdescinit(priv);
@@ -1838,7 +1846,7 @@ static void lpc17_40_txavail_work(FAR void *arg)
net_lock(); net_lock();
if (priv->lp_ifup) if (priv->lp_ifup)
{ {
/* Check if there is room in the hardware to hold another outgoing packet. */ /* Check if there is room in the hardware to hold another packet. */
if (lpc17_40_txdesc(priv) == OK) if (lpc17_40_txdesc(priv) == OK)
{ {
+1
View File
@@ -403,6 +403,7 @@ static int lpc17_40_i2c_interrupt(int irq, FAR void *context, void *arg)
{ {
case 0x08: /* A START condition has been transmitted. */ case 0x08: /* A START condition has been transmitted. */
case 0x10: /* A Repeated START condition has been transmitted. */ case 0x10: /* A Repeated START condition has been transmitted. */
/* Set address */ /* Set address */
putreg32(((I2C_M_READ & msg->flags) == I2C_M_READ) ? putreg32(((I2C_M_READ & msg->flags) == I2C_M_READ) ?
+3 -3
View File
@@ -314,9 +314,9 @@ static int lpc2378_i2c_interrupt(int irq, FAR void *context, FAR void *arg)
state &= 0xf8; /* state mask, only 0xX8 is possible */ state &= 0xf8; /* state mask, only 0xX8 is possible */
switch (state) switch (state)
{ {
case 0x08: /* A START condition has been transmitted. */ case 0x08: /* A START condition has been transmitted. */
case 0x10: /* A Repeated START condition has been transmitted. */ case 0x10: /* A Repeated START condition has been transmitted. */
/* Set address */ /* Set address */
putreg32(((I2C_M_READ & msg->flags) == I2C_M_READ) ? putreg32(((I2C_M_READ & msg->flags) == I2C_M_READ) ?
@@ -430,7 +430,7 @@ static int lpc2378_i2c_transfer(FAR struct i2c_master_s *dev,
return ret; return ret;
} }
/************************************************************************************ /****************************************************************************
* Name: lpc2378_i2c_reset * Name: lpc2378_i2c_reset
* *
* Description: * Description:
@@ -442,7 +442,7 @@ static int lpc2378_i2c_transfer(FAR struct i2c_master_s *dev,
* Returned Value: * Returned Value:
* Zero (OK) on success; a negated errno value on failure. * Zero (OK) on success; a negated errno value on failure.
* *
************************************************************************************/ ****************************************************************************/
#ifdef CONFIG_I2C_RESET #ifdef CONFIG_I2C_RESET
static int lpc2378_i2c_reset(FAR struct i2c_master_s * dev) static int lpc2378_i2c_reset(FAR struct i2c_master_s * dev)
+50 -25
View File
@@ -3,7 +3,8 @@
* *
* Author: David Hewson * Author: David Hewson
* *
* Copyright (C) 2010-2011, 2014, 2016-2017 Gregory Nutt. All rights reserved. * Copyright (C) 2010-2011, 2014, 2016-2017 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -78,6 +79,7 @@
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
struct lpc31_i2cdev_s struct lpc31_i2cdev_s
{ {
struct i2c_master_s dev; /* Generic I2C device */ struct i2c_master_s dev; /* Generic I2C device */
@@ -116,7 +118,8 @@ static int i2c_interrupt(int irq, FAR void *context, FAR void *arg);
static void i2c_progress(struct lpc31_i2cdev_s *priv); static void i2c_progress(struct lpc31_i2cdev_s *priv);
static void i2c_timeout(int argc, wdparm_t arg, ...); static void i2c_timeout(int argc, wdparm_t arg, ...);
static void i2c_hwreset(struct lpc31_i2cdev_s *priv); static void i2c_hwreset(struct lpc31_i2cdev_s *priv);
static void i2c_setfrequency(struct lpc31_i2cdev_s *priv, uint32_t frequency); static void i2c_setfrequency(struct lpc31_i2cdev_s *priv,
uint32_t frequency);
static int i2c_transfer(FAR struct i2c_master_s *dev, static int i2c_transfer(FAR struct i2c_master_s *dev,
FAR struct i2c_msg_s *msgs, int count); FAR struct i2c_msg_s *msgs, int count);
#ifdef CONFIG_I2C_RESET #ifdef CONFIG_I2C_RESET
@@ -204,7 +207,8 @@ static int i2c_interrupt(int irq, FAR void *context, FAR void *arg)
static void i2c_progress(struct lpc31_i2cdev_s *priv) static void i2c_progress(struct lpc31_i2cdev_s *priv)
{ {
struct i2c_msg_s *msg; struct i2c_msg_s *msg;
uint32_t stat, ctrl; uint32_t stat;
uint32_t ctrl;
stat = getreg32(priv->base + LPC31_I2C_STAT_OFFSET); stat = getreg32(priv->base + LPC31_I2C_STAT_OFFSET);
@@ -233,8 +237,9 @@ static void i2c_progress(struct lpc31_i2cdev_s *priv)
case I2C_STATE_START: case I2C_STATE_START:
if ((msg->flags & I2C_M_TEN) != 0) if ((msg->flags & I2C_M_TEN) != 0)
{ {
priv->header[0] = I2C_TX_START | 0xF0 | ((msg->addr & 0x300) >> 7); priv->header[0] = I2C_TX_START | 0xf0 |
priv->header[1] = msg->addr & 0xFF; ((msg->addr & 0x300) >> 7);
priv->header[1] = msg->addr & 0xff;
priv->hdrcnt = 2; priv->hdrcnt = 2;
if (msg->flags & I2C_M_READ) if (msg->flags & I2C_M_READ)
{ {
@@ -244,7 +249,8 @@ static void i2c_progress(struct lpc31_i2cdev_s *priv)
} }
else else
{ {
priv->header[0] = I2C_TX_START | (msg->addr << 1) | (msg->flags & I2C_M_READ); priv->header[0] = I2C_TX_START | (msg->addr << 1) |
(msg->flags & I2C_M_READ);
priv->hdrcnt = 1; priv->hdrcnt = 1;
} }
@@ -252,12 +258,14 @@ static void i2c_progress(struct lpc31_i2cdev_s *priv)
priv->state = I2C_STATE_HEADER; priv->state = I2C_STATE_HEADER;
priv->wrcnt = 0; priv->wrcnt = 0;
/* DROP THROUGH */ /* DROP THROUGH */
case I2C_STATE_HEADER: case I2C_STATE_HEADER:
while ((priv->wrcnt != priv->hdrcnt) && (stat & I2C_STAT_TFF) == 0) while ((priv->wrcnt != priv->hdrcnt) && (stat & I2C_STAT_TFF) == 0)
{ {
putreg32(priv->header[priv->wrcnt], priv->base + LPC31_I2C_TX_OFFSET); putreg32(priv->header[priv->wrcnt],
priv->base + LPC31_I2C_TX_OFFSET);
priv->wrcnt++; priv->wrcnt++;
stat = getreg32(priv->base + LPC31_I2C_STAT_OFFSET); stat = getreg32(priv->base + LPC31_I2C_STAT_OFFSET);
@@ -267,21 +275,25 @@ static void i2c_progress(struct lpc31_i2cdev_s *priv)
{ {
/* Enable Tx FIFO Not Full Interrupt */ /* Enable Tx FIFO Not Full Interrupt */
putreg32(ctrl | I2C_CTRL_TFFIE, priv->base + LPC31_I2C_CTRL_OFFSET); putreg32(ctrl | I2C_CTRL_TFFIE,
priv->base + LPC31_I2C_CTRL_OFFSET);
goto out; goto out;
} }
priv->state = I2C_STATE_TRANSFER; priv->state = I2C_STATE_TRANSFER;
priv->wrcnt = 0; priv->wrcnt = 0;
priv->rdcnt = 0; priv->rdcnt = 0;
/* DROP THROUGH */ /* DROP THROUGH */
case I2C_STATE_TRANSFER: case I2C_STATE_TRANSFER:
if (msg->flags & I2C_M_READ) if (msg->flags & I2C_M_READ)
{ {
while ((priv->rdcnt != msg->length) && (stat & I2C_STAT_RFE) == 0) while ((priv->rdcnt != msg->length) &&
(stat & I2C_STAT_RFE) == 0)
{ {
msg->buffer[priv->rdcnt] = getreg32 (priv->base + LPC31_I2C_RX_OFFSET); msg->buffer[priv->rdcnt] =
getreg32(priv->base + LPC31_I2C_RX_OFFSET);
priv->rdcnt++; priv->rdcnt++;
stat = getreg32(priv->base + LPC31_I2C_STAT_OFFSET); stat = getreg32(priv->base + LPC31_I2C_STAT_OFFSET);
@@ -289,13 +301,17 @@ static void i2c_progress(struct lpc31_i2cdev_s *priv)
if (priv->rdcnt < msg->length) if (priv->rdcnt < msg->length)
{ {
/* Not all data received, fill the Tx FIFO with more dummies */ /* Not all data received,
* fill the Tx FIFO with more dummies
*/
while ((priv->wrcnt != msg->length) && (stat & I2C_STAT_TFF) == 0) while ((priv->wrcnt != msg->length) &&
(stat & I2C_STAT_TFF) == 0)
{ {
if ((priv->wrcnt + 1) == msg->length && priv->nmsg == 1) if (priv->wrcnt + 1 == msg->length && priv->nmsg == 1)
{ {
putreg32(I2C_TX_STOP, priv->base + LPC31_I2C_TX_OFFSET); putreg32(I2C_TX_STOP,
priv->base + LPC31_I2C_TX_OFFSET);
} }
else else
{ {
@@ -309,30 +325,37 @@ static void i2c_progress(struct lpc31_i2cdev_s *priv)
if (priv->wrcnt < msg->length) if (priv->wrcnt < msg->length)
{ {
/* Enable Tx FIFO not full and Rx Fifo Avail Interrupts */ /* Enable Tx FIFO not full and
* Rx Fifo Avail Interrupts
*/
putreg32(ctrl | I2C_CTRL_TFFIE | I2C_CTRL_RFDAIE, priv->base + LPC31_I2C_CTRL_OFFSET); putreg32(ctrl | I2C_CTRL_TFFIE | I2C_CTRL_RFDAIE,
priv->base + LPC31_I2C_CTRL_OFFSET);
} }
else else
{ {
/* Enable Rx Fifo Avail Interrupts */ /* Enable Rx Fifo Avail Interrupts */
putreg32(ctrl | I2C_CTRL_RFDAIE, priv->base + LPC31_I2C_CTRL_OFFSET); putreg32(ctrl | I2C_CTRL_RFDAIE,
priv->base + LPC31_I2C_CTRL_OFFSET);
} }
goto out; goto out;
} }
} }
else /* WRITE */ else /* WRITE */
{ {
while ((priv->wrcnt != msg->length) && (stat & I2C_STAT_TFF) == 0) while (!!(priv->wrcnt != msg->length) && (stat & I2C_STAT_TFF))
{ {
if ((priv->wrcnt + 1) == msg->length && priv->nmsg == 1) if ((priv->wrcnt + 1) == msg->length && priv->nmsg == 1)
{ {
putreg32(I2C_TX_STOP | msg->buffer[priv->wrcnt], priv->base + LPC31_I2C_TX_OFFSET); putreg32(I2C_TX_STOP | msg->buffer[priv->wrcnt],
priv->base + LPC31_I2C_TX_OFFSET);
} }
else else
{ {
putreg32(msg->buffer[priv->wrcnt], priv->base + LPC31_I2C_TX_OFFSET); putreg32(msg->buffer[priv->wrcnt],
priv->base + LPC31_I2C_TX_OFFSET);
} }
priv->wrcnt++; priv->wrcnt++;
@@ -344,7 +367,8 @@ static void i2c_progress(struct lpc31_i2cdev_s *priv)
{ {
/* Enable Tx Fifo not full Interrupt */ /* Enable Tx Fifo not full Interrupt */
putreg32(ctrl | I2C_CTRL_TFFIE, priv->base + LPC31_I2C_CTRL_OFFSET); putreg32(ctrl | I2C_CTRL_TFFIE,
priv->base + LPC31_I2C_CTRL_OFFSET);
goto out; goto out;
} }
} }
@@ -447,7 +471,7 @@ static void i2c_hwreset(struct lpc31_i2cdev_s *priv)
/* Wait for Reset to complete */ /* Wait for Reset to complete */
while ((getreg32(priv->base + LPC31_I2C_CTRL_OFFSET) & I2C_CTRL_RESET) != 0) while (!!(getreg32(priv->base + LPC31_I2C_CTRL_OFFSET) & I2C_CTRL_RESET))
; ;
} }
@@ -459,7 +483,8 @@ static void i2c_hwreset(struct lpc31_i2cdev_s *priv)
* *
****************************************************************************/ ****************************************************************************/
static int i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count) static int i2c_transfer(FAR struct i2c_master_s *dev,
FAR struct i2c_msg_s *msgs, int count)
{ {
struct lpc31_i2cdev_s *priv = (struct lpc31_i2cdev_s *) dev; struct lpc31_i2cdev_s *priv = (struct lpc31_i2cdev_s *) dev;
irqstate_t flags; irqstate_t flags;
@@ -507,7 +532,7 @@ static int i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs
return ret; return ret;
} }
/************************************************************************************ /****************************************************************************
* Name: i2c_reset * Name: i2c_reset
* *
* Description: * Description:
@@ -519,7 +544,7 @@ static int i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs
* Returned Value: * Returned Value:
* Zero (OK) on success; a negated errno value on failure. * Zero (OK) on success; a negated errno value on failure.
* *
************************************************************************************/ ****************************************************************************/
#ifdef CONFIG_I2C_RESET #ifdef CONFIG_I2C_RESET
static int i2c_reset(FAR struct i2c_master_s * dev) static int i2c_reset(FAR struct i2c_master_s * dev)
File diff suppressed because it is too large Load Diff
+7 -4
View File
@@ -297,6 +297,7 @@ static int lpc43_i2c_interrupt(int irq, FAR void *context, FAR void *arg)
{ {
case 0x08: /* A START condition has been transmitted. */ case 0x08: /* A START condition has been transmitted. */
case 0x10: /* A Repeated START condition has been transmitted. */ case 0x10: /* A Repeated START condition has been transmitted. */
/* Set address */ /* Set address */
putreg32(((I2C_M_READ & msg->flags) == I2C_M_READ) ? putreg32(((I2C_M_READ & msg->flags) == I2C_M_READ) ?
@@ -344,7 +345,8 @@ static int lpc43_i2c_interrupt(int irq, FAR void *context, FAR void *arg)
case 0x50: /* Data byte has been received; ACK has been returned. */ case 0x50: /* Data byte has been received; ACK has been returned. */
priv->rdcnt++; priv->rdcnt++;
msg->buffer[priv->rdcnt - 1] = getreg32(priv->base + LPC43_I2C_BUFR_OFFSET); msg->buffer[priv->rdcnt - 1] =
getreg32(priv->base + LPC43_I2C_BUFR_OFFSET);
if (priv->rdcnt >= (msg->length - 1)) if (priv->rdcnt >= (msg->length - 1))
{ {
@@ -353,7 +355,8 @@ static int lpc43_i2c_interrupt(int irq, FAR void *context, FAR void *arg)
break; break;
case 0x58: /* Data byte has been received; NACK has been returned. */ case 0x58: /* Data byte has been received; NACK has been returned. */
msg->buffer[priv->rdcnt] = getreg32(priv->base + LPC43_I2C_BUFR_OFFSET); msg->buffer[priv->rdcnt] =
getreg32(priv->base + LPC43_I2C_BUFR_OFFSET);
lpc32_i2c_nextmsg(priv); lpc32_i2c_nextmsg(priv);
break; break;
@@ -410,7 +413,7 @@ static int lpc43_i2c_transfer(FAR struct i2c_master_s *dev,
return ret; return ret;
} }
/************************************************************************************ /****************************************************************************
* Name: lpc43_i2c_reset * Name: lpc43_i2c_reset
* *
* Description: * Description:
@@ -422,7 +425,7 @@ static int lpc43_i2c_transfer(FAR struct i2c_master_s *dev,
* Returned Value: * Returned Value:
* Zero (OK) on success; a negated errno value on failure. * Zero (OK) on success; a negated errno value on failure.
* *
************************************************************************************/ ****************************************************************************/
#ifdef CONFIG_I2C_RESET #ifdef CONFIG_I2C_RESET
static int lpc43_i2c_reset(FAR struct i2c_master_s * dev) static int lpc43_i2c_reset(FAR struct i2c_master_s * dev)
+22 -12
View File
@@ -90,8 +90,8 @@
#define LPC54_ETH_MAC_SYS_TIMESTMP_ADDEND_OFFSET 0x0b18 /* Timestamp addend */ #define LPC54_ETH_MAC_SYS_TIMESTMP_ADDEND_OFFSET 0x0b18 /* Timestamp addend */
#define LPC54_ETH_MAC_SYS_TIME_HWORD_SCND_OFFSET 0x0b1c /* System time-higher word seconds */ #define LPC54_ETH_MAC_SYS_TIME_HWORD_SCND_OFFSET 0x0b1c /* System time-higher word seconds */
#define LPC54_ETH_MAC_SYS_TIMESTMP_STAT_OFFSET 0x0b20 /* Timestamp status */ #define LPC54_ETH_MAC_SYS_TIMESTMP_STAT_OFFSET 0x0b20 /* Timestamp status */
#define LPC54_ETH_MAC_Tx_TIMESTAMP_STATUS_NSECS_OFFSET 0x0b30 /* Tx timestamp status nanoseconds */ #define LPC54_ETH_MAC_TX_TIMESTAMP_STATUS_NSECS_OFFSET 0x0b30 /* Tx timestamp status nanoseconds */
#define LPC54_ETH_MAC_Tx_TIMESTAMP_STATUS_SECS_OFFSET 0x0b34 /* Tx timestamp status seconds */ #define LPC54_ETH_MAC_TX_TIMESTAMP_STATUS_SECS_OFFSET 0x0b34 /* Tx timestamp status seconds */
#define LPC54_ETH_MAC_TIMESTAMP_INGRESS_CORR_NSEC_OFFSET 0x0b58 /* Timestamp ingress correction */ #define LPC54_ETH_MAC_TIMESTAMP_INGRESS_CORR_NSEC_OFFSET 0x0b58 /* Timestamp ingress correction */
#define LPC54_ETH_MAC_TIMESTAMP_EGRESS_CORR_NSEC_OFFSET 0x0b5c /* Timestamp egress correction */ #define LPC54_ETH_MAC_TIMESTAMP_EGRESS_CORR_NSEC_OFFSET 0x0b5c /* Timestamp egress correction */
@@ -185,8 +185,8 @@
#define LPC54_ETH_MAC_SYS_TIMESTMP_ADDEND (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_SYS_TIMESTMP_ADDEND_OFFSET) #define LPC54_ETH_MAC_SYS_TIMESTMP_ADDEND (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_SYS_TIMESTMP_ADDEND_OFFSET)
#define LPC54_ETH_MAC_SYS_TIME_HWORD_SCND (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_SYS_TIME_HWORD_SCND_OFFSET) #define LPC54_ETH_MAC_SYS_TIME_HWORD_SCND (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_SYS_TIME_HWORD_SCND_OFFSET)
#define LPC54_ETH_MAC_SYS_TIMESTMP_STAT (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_SYS_TIMESTMP_STAT_OFFSET) #define LPC54_ETH_MAC_SYS_TIMESTMP_STAT (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_SYS_TIMESTMP_STAT_OFFSET)
#define LPC54_ETH_MAC_Tx_TIMESTAMP_STATUS_NSECS (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_Tx_TIMESTAMP_STATUS_NSECS_OFFSET) #define LPC54_ETH_MAC_TX_TIMESTAMP_STATUS_NSECS (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_TX_TIMESTAMP_STATUS_NSECS_OFFSET)
#define LPC54_ETH_MAC_Tx_TIMESTAMP_STATUS_SECS (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_Tx_TIMESTAMP_STATUS_SECS_OFFSET) #define LPC54_ETH_MAC_TX_TIMESTAMP_STATUS_SECS (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_TX_TIMESTAMP_STATUS_SECS_OFFSET)
#define LPC54_ETH_MAC_TIMESTAMP_INGRESS_CORR_NSEC (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_TIMESTAMP_INGRESS_CORR_NSEC_OFFSET) #define LPC54_ETH_MAC_TIMESTAMP_INGRESS_CORR_NSEC (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_TIMESTAMP_INGRESS_CORR_NSEC_OFFSET)
#define LPC54_ETH_MAC_TIMESTAMP_EGRESS_CORR_NSEC (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_TIMESTAMP_EGRESS_CORR_NSEC_OFFSET) #define LPC54_ETH_MAC_TIMESTAMP_EGRESS_CORR_NSEC (LPC54_ETHERNET_BASE + LPC54_ETH_MAC_TIMESTAMP_EGRESS_CORR_NSEC_OFFSET)
@@ -471,9 +471,9 @@
/* Timestamp status */ /* Timestamp status */
#define ETH_MAC_SYS_TIMESTMP_STAT_ #define ETH_MAC_SYS_TIMESTMP_STAT_
/* Tx timestamp status nanoseconds */ /* Tx timestamp status nanoseconds */
#define ETH_MAC_Tx_TIMESTAMP_STATUS_NSECS_ #define ETH_MAC_TX_TIMESTAMP_STATUS_NSECS_
/* Tx timestamp status seconds */ /* Tx timestamp status seconds */
#define ETH_MAC_Tx_TIMESTAMP_STATUS_SECS_ #define ETH_MAC_TX_TIMESTAMP_STATUS_SECS_
/* Timestamp ingress correction */ /* Timestamp ingress correction */
#define ETH_MAC_TIMESTAMP_INGRESS_CORR_NSEC_ #define ETH_MAC_TIMESTAMP_INGRESS_CORR_NSEC_
/* Timestamp egress correction */ /* Timestamp egress correction */
@@ -623,9 +623,9 @@
#define ETH_DMACH_TX_CTRL_TCW_MASK (7 << ETH_DMACH_TX_CTRL_TCW_SHIFT) #define ETH_DMACH_TX_CTRL_TCW_MASK (7 << ETH_DMACH_TX_CTRL_TCW_SHIFT)
# define ETH_DMACH_TX_CTRL_TCW(n) ((uint32_t)(n) << ETH_DMACH_TX_CTRL_TCW_SHIFT) # define ETH_DMACH_TX_CTRL_TCW(n) ((uint32_t)(n) << ETH_DMACH_TX_CTRL_TCW_SHIFT)
#define ETH_DMACH_TX_CTRL_OSF (1 << 4) /* Bit 4: Operate on second frame */ #define ETH_DMACH_TX_CTRL_OSF (1 << 4) /* Bit 4: Operate on second frame */
#define ETH_DMACH_TX_CTRL_TxPBL_SHIFT (16) /* Bits 16-21: Transmit programmable burst length */ #define ETH_DMACH_TX_CTRL_TXPBL_SHIFT (16) /* Bits 16-21: Transmit programmable burst length */
#define ETH_DMACH_TX_CTRL_TxPBL_MASK (0x3f << ETH_DMACH_TX_CTRL_TxPBL_SHIFT) #define ETH_DMACH_TX_CTRL_TXPBL_MASK (0x3f << ETH_DMACH_TX_CTRL_TXPBL_SHIFT)
# define ETH_DMACH_TX_CTRL_TxPBL(n) ((uint32_t)(n) << ETH_DMACH_TX_CTRL_TxPBL_SHIFT) # define ETH_DMACH_TX_CTRL_TXPBL(n) ((uint32_t)(n) << ETH_DMACH_TX_CTRL_TXPBL_SHIFT)
/* DMA channel n receive control */ /* DMA channel n receive control */
@@ -633,14 +633,17 @@
#define ETH_DMACH_RX_CTRL_RBSZ_SHIFT (3) /* Bits 3-14: Receive buffer size */ #define ETH_DMACH_RX_CTRL_RBSZ_SHIFT (3) /* Bits 3-14: Receive buffer size */
#define ETH_DMACH_RX_CTRL_RBSZ_MASK (0xfff << ETH_DMACH_RX_CTRL_RBSZ_SHIFT) #define ETH_DMACH_RX_CTRL_RBSZ_MASK (0xfff << ETH_DMACH_RX_CTRL_RBSZ_SHIFT)
# define ETH_DMACH_RX_CTRL_RBSZ(n) ((uint32_t)(n) << ETH_DMACH_RX_CTRL_RBSZ_SHIFT) # define ETH_DMACH_RX_CTRL_RBSZ(n) ((uint32_t)(n) << ETH_DMACH_RX_CTRL_RBSZ_SHIFT)
#define ETH_DMACH_RX_CTRL_RxPBL_SHIFT (16) /* Bits 16-21: Receive programmable burst length */ #define ETH_DMACH_RX_CTRL_RXPBL_SHIFT (16) /* Bits 16-21: Receive programmable burst length */
#define ETH_DMACH_RX_CTRL_RxPBL_MASK (0x3f << ETH_DMACH_RX_CTRL_RxPBL_SHIFT) #define ETH_DMACH_RX_CTRL_RXPBL_MASK (0x3f << ETH_DMACH_RX_CTRL_RXPBL_SHIFT)
# define ETH_DMACH_RX_CTRL_RxPBL(n) ((uint32_t)(n) << ETH_DMACH_RX_CTRL_RxPBL_SHIFT) # define ETH_DMACH_RX_CTRL_RXPBL(n) ((uint32_t)(n) << ETH_DMACH_RX_CTRL_RXPBL_SHIFT)
#define ETH_DMACH_RX_CTRL_RPF (1 << 31) /* Bit 31: DMA Rx channel n packet flush */ #define ETH_DMACH_RX_CTRL_RPF (1 << 31) /* Bit 31: DMA Rx channel n packet flush */
/* DMA channel n Tx descriptor list address (32-bit, word-aligned address) */ /* DMA channel n Tx descriptor list address (32-bit, word-aligned address) */
/* DMA channel n Rx descriptor list address (32-bit, word-aligned address) */ /* DMA channel n Rx descriptor list address (32-bit, word-aligned address) */
/* DMA channel n Tx descriptor tail pointer (32-bit, word-aligned address) */ /* DMA channel n Tx descriptor tail pointer (32-bit, word-aligned address) */
/* DMA channel n Rx descriptor tail pointer (32-bit, word-aligned address) */ /* DMA channel n Rx descriptor tail pointer (32-bit, word-aligned address) */
/* DMA channel n Tx descriptor ring length */ /* DMA channel n Tx descriptor ring length */
@@ -689,8 +692,11 @@
/* DMA descriptors ******************************************************************************************/ /* DMA descriptors ******************************************************************************************/
/* Receive descriptor (read-format) */ /* Receive descriptor (read-format) */
/* RDES0: 32-bit address */ /* RDES0: 32-bit address */
/* RDES1: Reserved */ /* RDES1: Reserved */
/* RDES2: 32-bit address */ /* RDES2: 32-bit address */
/* RDES3: */ /* RDES3: */
@@ -701,6 +707,7 @@
#define ETH_RXDES3_OWN (1 << 31) /* Bit 31: Own bit */ #define ETH_RXDES3_OWN (1 << 31) /* Bit 31: Own bit */
/* Receive descriptor (writeback-format) */ /* Receive descriptor (writeback-format) */
/* RDES0: Reserved */ /* RDES0: Reserved */
/* RDES1: */ /* RDES1: */
@@ -776,6 +783,7 @@
/* Bit 31: Own bit (see read-format) */ /* Bit 31: Own bit (see read-format) */
/* Transmit normal descriptor (read-format) */ /* Transmit normal descriptor (read-format) */
/* TDES0/1: 32-bit address */ /* TDES0/1: 32-bit address */
/* TDES2: */ /* TDES2: */
@@ -814,7 +822,9 @@
#define ETH_TXDES3_OWN (1 << 31) /* Bit 31: Own bit */ #define ETH_TXDES3_OWN (1 << 31) /* Bit 31: Own bit */
/* Transmit normal descriptor (writeback-format) */ /* Transmit normal descriptor (writeback-format) */
/* TDES0/1: 64-bit transmit packet timestamp */ /* TDES0/1: 64-bit transmit packet timestamp */
/* TDES2: Reserved */ /* TDES2: Reserved */
/* TDES3: */ /* TDES3: */
+60 -40
View File
@@ -132,7 +132,9 @@
#define ETHWORK LPWORK #define ETHWORK LPWORK
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define LPC54_WDDELAY (1*CLK_TCK) #define LPC54_WDDELAY (1*CLK_TCK)
@@ -206,31 +208,31 @@
#if CONFIG_LPC54_ETH_BURSTLEN < 2 #if CONFIG_LPC54_ETH_BURSTLEN < 2
# define LPC54_BURSTLEN 1 # define LPC54_BURSTLEN 1
# define LPC54_PBLx8 0 # define LPC54_PBLX8 0
#elif CONFIG_LPC54_ETH_BURSTLEN < 4 #elif CONFIG_LPC54_ETH_BURSTLEN < 4
# define LPC54_BURSTLEN 2 # define LPC54_BURSTLEN 2
# define LPC54_PBLx8 0 # define LPC54_PBLX8 0
#elif CONFIG_LPC54_ETH_BURSTLEN < 8 #elif CONFIG_LPC54_ETH_BURSTLEN < 8
# define LPC54_BURSTLEN 4 # define LPC54_BURSTLEN 4
# define LPC54_PBLx8 0 # define LPC54_PBLX8 0
#elif CONFIG_LPC54_ETH_BURSTLEN < 16 #elif CONFIG_LPC54_ETH_BURSTLEN < 16
# define LPC54_BURSTLEN 8 # define LPC54_BURSTLEN 8
# define LPC54_PBLx8 0 # define LPC54_PBLX8 0
#elif CONFIG_LPC54_ETH_BURSTLEN < 32 #elif CONFIG_LPC54_ETH_BURSTLEN < 32
# define LPC54_BURSTLEN 16 # define LPC54_BURSTLEN 16
# define LPC54_PBLx8 0 # define LPC54_PBLX8 0
#elif CONFIG_LPC54_ETH_BURSTLEN < 64 #elif CONFIG_LPC54_ETH_BURSTLEN < 64
# define LPC54_BURSTLEN 32 # define LPC54_BURSTLEN 32
# define LPC54_PBLx8 0 # define LPC54_PBLX8 0
#elif CONFIG_LPC54_ETH_BURSTLEN < 128 #elif CONFIG_LPC54_ETH_BURSTLEN < 128
# define LPC54_BURSTLEN 8 # define LPC54_BURSTLEN 8
# define LPC54_PBLx8 ETH_DMACH_CTRL_PBLx8 # define LPC54_PBLX8 ETH_DMACH_CTRL_PBLx8
#elif CONFIG_LPC54_ETH_BURSTLEN < 256 #elif CONFIG_LPC54_ETH_BURSTLEN < 256
# define LPC54_BURSTLEN 16 # define LPC54_BURSTLEN 16
# define LPC54_PBLx8 ETH_DMACH_CTRL_PBLx8 # define LPC54_PBLX8 ETH_DMACH_CTRL_PBLx8
#else #else
# define LPC54_BURSTLEN 32 # define LPC54_BURSTLEN 32
# define LPC54_PBLx8 ETH_DMACH_CTRL_PBLx8 # define LPC54_PBLX8 ETH_DMACH_CTRL_PBLx8
#endif #endif
#ifdef CONFIG_LPC54_ETH_DYNAMICMAP #ifdef CONFIG_LPC54_ETH_DYNAMICMAP
@@ -514,7 +516,7 @@ static uint32_t lpc54_getreg(uintptr_t addr)
{ {
/* Yes.. then show how many times the value repeated */ /* Yes.. then show how many times the value repeated */
ninfo("[repeats %d more times]\n", count-3); ninfo("[repeats %d more times]\n", count - 3);
} }
/* Save the new address, value, and count */ /* Save the new address, value, and count */
@@ -811,15 +813,15 @@ static int lpc54_eth_txpoll(struct net_driver_s *dev)
#ifdef CONFIG_LPC54_ETH_MULTIQUEUE #ifdef CONFIG_LPC54_ETH_MULTIQUEUE
txring1 = &priv->eth_txring[1]; txring1 = &priv->eth_txring[1];
/* We cannot perform the Tx poll now if all of the Tx descriptors for /* We cannot perform the Tx poll now if all of the Tx descriptors
* both channels are in-use. * for both channels are in-use.
*/ */
if (txring0->tr_inuse >= txring0->tr_ndesc || if (txring0->tr_inuse >= txring0->tr_ndesc ||
txring1->tr_inuse >= txring1->tr_ndesc) txring1->tr_inuse >= txring1->tr_ndesc)
#else #else
/* We cannot continue the Tx poll now if all of the Tx descriptors for /* We cannot continue the Tx poll now if all of the Tx descriptors
* this channel 0 are in-use. * for this channel 0 are in-use.
*/ */
if (txring0->tr_inuse >= txring0->tr_ndesc) if (txring0->tr_inuse >= txring0->tr_ndesc)
@@ -944,7 +946,7 @@ static void lpc54_eth_reply(struct lpc54_ethdriver_s *priv)
static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv) static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
{ {
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->eth_dev); pkt_input(&priv->eth_dev);
#endif #endif
@@ -957,7 +959,9 @@ static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
ninfo("IPv4 packet\n"); ninfo("IPv4 packet\n");
NETDEV_RXIPV4(&priv->eth_dev); NETDEV_RXIPV4(&priv->eth_dev);
/* Handle ARP on input, then dispatch IPv4 packet to the network layer */ /* Handle ARP on input,
* then dispatch IPv4 packet to the network layer
*/
arp_ipin(&priv->eth_dev); arp_ipin(&priv->eth_dev);
ipv4_input(&priv->eth_dev); ipv4_input(&priv->eth_dev);
@@ -1012,7 +1016,7 @@ static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
NETDEV_RXARP(&priv->eth_dev); NETDEV_RXARP(&priv->eth_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->eth_dev.d_len > 0) if (priv->eth_dev.d_len > 0)
@@ -1150,7 +1154,8 @@ static int lpc54_eth_receive(struct lpc54_ethdriver_s *priv,
* this extra array of saved allocation addresses. * this extra array of saved allocation addresses.
*/ */
priv->eth_dev.d_buf = (uint8_t *)(rxring->rr_buffers)[supply]; priv->eth_dev.d_buf = (uint8_t *)
(rxring->rr_buffers)[supply];
(rxring->rr_buffers)[supply] = NULL; (rxring->rr_buffers)[supply] = NULL;
DEBUGASSERT(priv->eth_dev.d_buf != NULL); DEBUGASSERT(priv->eth_dev.d_buf != NULL);
@@ -1185,7 +1190,8 @@ static int lpc54_eth_receive(struct lpc54_ethdriver_s *priv,
* owned by DMA. * owned by DMA.
*/ */
regval = ETH_RXDES3_BUF1V | ETH_RXDES3_IOC | ETH_RXDES3_OWN; regval = ETH_RXDES3_BUF1V | ETH_RXDES3_IOC |
ETH_RXDES3_OWN;
#if LPC54_BUFFER_SIZE > LPC54_BUFFER_MAX #if LPC54_BUFFER_SIZE > LPC54_BUFFER_MAX
regval |= ETH_RXDES3_BUF2V; regval |= ETH_RXDES3_BUF2V;
#endif #endif
@@ -1227,7 +1233,9 @@ static int lpc54_eth_receive(struct lpc54_ethdriver_s *priv,
lpc54_putreg(ETH_DMACH_INT_RBU, LPC54_ETH_DMACH_STAT(chan)); lpc54_putreg(ETH_DMACH_INT_RBU, LPC54_ETH_DMACH_STAT(chan));
/* Writing to the tail pointer register will restart the Rx processing */ /* Writing to the tail pointer register
* will restart the Rx processing
*/
regval = lpc54_getreg(regaddr); regval = lpc54_getreg(regaddr);
lpc54_putreg(regval, regaddr); lpc54_putreg(regval, regaddr);
@@ -1415,7 +1423,9 @@ static void lpc54_eth_channel_work(struct lpc54_ethdriver_s *priv,
lpc54_putreg(ETH_DMACH_INT_RI | ETH_DMACH_INT_NI, regaddr); lpc54_putreg(ETH_DMACH_INT_RI | ETH_DMACH_INT_NI, regaddr);
pending &= ~(ETH_DMACH_INT_RI | ETH_DMACH_INT_NI); pending &= ~(ETH_DMACH_INT_RI | ETH_DMACH_INT_NI);
/* Loop until all available Rx packets in the ring have been processed */ /* Loop until all available Rx packets
* in the ring have been processed
*/
for (; ; ) for (; ; )
{ {
@@ -1901,7 +1911,8 @@ static void lpc54_eth_poll_expiry(int argc, wdparm_t arg, ...)
static int lpc54_eth_ifup(struct net_driver_s *dev) static int lpc54_eth_ifup(struct net_driver_s *dev)
{ {
struct lpc54_ethdriver_s *priv = (struct lpc54_ethdriver_s *)dev->d_private; struct lpc54_ethdriver_s *priv =
(struct lpc54_ethdriver_s *)dev->d_private;
uint8_t *mptr; uint8_t *mptr;
uintptr_t base; uintptr_t base;
uint32_t regval; uint32_t regval;
@@ -1930,6 +1941,7 @@ static int lpc54_eth_ifup(struct net_driver_s *dev)
} }
/* Initialize Ethernet DMA ************************************************/ /* Initialize Ethernet DMA ************************************************/
/* Reset DMA. Resets the logic and all internal registers of the OMA, MTL, /* Reset DMA. Resets the logic and all internal registers of the OMA, MTL,
* and MAC. This bit is automatically cleared after the reset operation * and MAC. This bit is automatically cleared after the reset operation
* is complete in all Ethernet Block clock domains. * is complete in all Ethernet Block clock domains.
@@ -1950,16 +1962,16 @@ static int lpc54_eth_ifup(struct net_driver_s *dev)
for (i = 0; i < LPC54_NRINGS; i++) for (i = 0; i < LPC54_NRINGS; i++)
{ {
base = LPC54_ETH_DMACH_BASE(i); base = LPC54_ETH_DMACH_BASE(i);
lpc54_putreg(LPC54_PBLx8, base + LPC54_ETH_DMACH_CTRL_OFFSET); lpc54_putreg(LPC54_PBLX8, base + LPC54_ETH_DMACH_CTRL_OFFSET);
regval = lpc54_getreg(base + LPC54_ETH_DMACH_TX_CTRL_OFFSET); regval = lpc54_getreg(base + LPC54_ETH_DMACH_TX_CTRL_OFFSET);
regval &= ~ETH_DMACH_TX_CTRL_TxPBL_MASK; regval &= ~ETH_DMACH_TX_CTRL_TXPBL_MASK;
regval |= ETH_DMACH_TX_CTRL_TxPBL(LPC54_BURSTLEN); regval |= ETH_DMACH_TX_CTRL_TXPBL(LPC54_BURSTLEN);
lpc54_putreg(regval, base + LPC54_ETH_DMACH_TX_CTRL_OFFSET); lpc54_putreg(regval, base + LPC54_ETH_DMACH_TX_CTRL_OFFSET);
regval = lpc54_getreg(base + LPC54_ETH_DMACH_RX_CTRL_OFFSET); regval = lpc54_getreg(base + LPC54_ETH_DMACH_RX_CTRL_OFFSET);
regval &= ~ETH_DMACH_RX_CTRL_RxPBL_MASK; regval &= ~ETH_DMACH_RX_CTRL_RXPBL_MASK;
regval |= ETH_DMACH_RX_CTRL_RxPBL(LPC54_BURSTLEN); regval |= ETH_DMACH_RX_CTRL_RXPBL(LPC54_BURSTLEN);
lpc54_putreg(regval, base + LPC54_ETH_DMACH_RX_CTRL_OFFSET); lpc54_putreg(regval, base + LPC54_ETH_DMACH_RX_CTRL_OFFSET);
} }
@@ -2034,6 +2046,7 @@ static int lpc54_eth_ifup(struct net_driver_s *dev)
#endif #endif
/* Initialize the Ethernet MAC ********************************************/ /* Initialize the Ethernet MAC ********************************************/
/* Instantiate the MAC address that application logic should have set in /* Instantiate the MAC address that application logic should have set in
* the device structure. * the device structure.
* *
@@ -2077,7 +2090,7 @@ static int lpc54_eth_ifup(struct net_driver_s *dev)
lpc54_putreg(regval, LPC54_ETH_MAC_TX_FLOW_CTRL_Q1); lpc54_putreg(regval, LPC54_ETH_MAC_TX_FLOW_CTRL_Q1);
#endif #endif
/* Set the 1uS tick counter*/ /* Set the 1uS tick counter */
regval = ETH_MAC_1US_TIC_COUNTR(BOARD_MAIN_CLK / USEC_PER_SEC); regval = ETH_MAC_1US_TIC_COUNTR(BOARD_MAIN_CLK / USEC_PER_SEC);
lpc54_putreg(regval, LPC54_ETH_MAC_1US_TIC_COUNTR); lpc54_putreg(regval, LPC54_ETH_MAC_1US_TIC_COUNTR);
@@ -2185,7 +2198,8 @@ static int lpc54_eth_ifup(struct net_driver_s *dev)
static int lpc54_eth_ifdown(struct net_driver_s *dev) static int lpc54_eth_ifdown(struct net_driver_s *dev)
{ {
struct lpc54_ethdriver_s *priv = (struct lpc54_ethdriver_s *)dev->d_private; struct lpc54_ethdriver_s *priv =
(struct lpc54_ethdriver_s *)dev->d_private;
irqstate_t flags; irqstate_t flags;
uint32_t regval; uint32_t regval;
int ret; int ret;
@@ -2304,7 +2318,8 @@ static void lpc54_eth_txavail_work(void *arg)
static int lpc54_eth_txavail(struct net_driver_s *dev) static int lpc54_eth_txavail(struct net_driver_s *dev)
{ {
struct lpc54_ethdriver_s *priv = (struct lpc54_ethdriver_s *)dev->d_private; struct lpc54_ethdriver_s *priv =
(struct lpc54_ethdriver_s *)dev->d_private;
/* Is our single work structure available? It may not be if there are /* Is our single work structure available? It may not be if there are
* pending interrupt actions and we will have to ignore the Tx * pending interrupt actions and we will have to ignore the Tx
@@ -2315,7 +2330,8 @@ static int lpc54_eth_txavail(struct net_driver_s *dev)
{ {
/* Schedule to serialize the poll on the worker thread. */ /* Schedule to serialize the poll on the worker thread. */
work_queue(ETHWORK, &priv->eth_pollwork, lpc54_eth_txavail_work, priv, 0); work_queue(ETHWORK, &priv->eth_pollwork,
lpc54_eth_txavail_work, priv, 0);
} }
return OK; return OK;
@@ -2353,8 +2369,8 @@ static int lpc54_eth_addmac(struct net_driver_s *dev, const uint8_t *mac)
* Name: lpc54_eth_rmmac * Name: lpc54_eth_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
@@ -2401,7 +2417,8 @@ static int lpc54_eth_ioctl(struct net_driver_s *dev, int cmd,
unsigned long arg) unsigned long arg)
{ {
#ifdef CONFIG_NETDEV_PHY_IOCTL #ifdef CONFIG_NETDEV_PHY_IOCTL
struct lpc54_ethdriver_s *priv = (struct lpc54_ethdriver_s *)dev->d_private; struct lpc54_ethdriver_s *priv =
(struct lpc54_ethdriver_s *)dev->d_private;
#endif #endif
int ret; int ret;
@@ -2412,7 +2429,8 @@ static int lpc54_eth_ioctl(struct net_driver_s *dev, int cmd,
#ifdef CONFIG_NETDEV_PHY_IOCTL #ifdef CONFIG_NETDEV_PHY_IOCTL
case SIOCGMIIPHY: /* Get MII PHY address */ case SIOCGMIIPHY: /* Get MII PHY address */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->phy_id = CONFIG_LPC54_ETH_PHYADDR; req->phy_id = CONFIG_LPC54_ETH_PHYADDR;
ret = OK; ret = OK;
} }
@@ -2420,7 +2438,8 @@ static int lpc54_eth_ioctl(struct net_driver_s *dev, int cmd,
case SIOCGMIIREG: /* Get register from MII PHY */ case SIOCGMIIREG: /* Get register from MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->val_out = lpc54_phy_read(priv, req->reg_num); req->val_out = lpc54_phy_read(priv, req->reg_num);
ret = OK ret = OK
} }
@@ -2428,7 +2447,8 @@ static int lpc54_eth_ioctl(struct net_driver_s *dev, int cmd,
case SIOCSMIIREG: /* Set register in MII PHY */ case SIOCSMIIREG: /* Set register in MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
lpc54_phy_write(priv, req->reg_num, req->val_in); lpc54_phy_write(priv, req->reg_num, req->val_in);
ret = OK ret = OK
} }
@@ -2642,7 +2662,7 @@ static void lpc54_rxring_initialize(struct lpc54_ethdriver_s *priv,
rxdesc->buffer2 = 0; rxdesc->buffer2 = 0;
#endif #endif
/* Buffer1 (and maybe 2) valid, interrupt on completion, owned by DMA. */ /* Buffer1 and maybe 2 valid, interrupt on completion, owned by DMA. */
rxdesc->ctrl = regval; rxdesc->ctrl = regval;
} }
@@ -2897,7 +2917,6 @@ static int lpc54_phy_autonegotiate(struct lpc54_ethdriver_s *priv)
} }
phyval = lpc54_phy_read(priv, MII_LAN8720_SCSR); phyval = lpc54_phy_read(priv, MII_LAN8720_SCSR);
} }
while ((phyval & MII_LAN8720_SPSCR_ANEGDONE) == 0); while ((phyval & MII_LAN8720_SPSCR_ANEGDONE) == 0);
#else #else
@@ -3076,6 +3095,7 @@ int arm_netinitialize(int intf)
DEBUGASSERT(priv->eth_txpoll != NULL && priv->eth_txtimeout != NULL); DEBUGASSERT(priv->eth_txpoll != NULL && priv->eth_txtimeout != NULL);
/* Configure GPIO pins to support Ethernet */ /* Configure GPIO pins to support Ethernet */
/* Common MIIM interface */ /* Common MIIM interface */
lpc54_gpio_config(GPIO_ENET_MDIO); /* Ethernet MIIM data input and output */ lpc54_gpio_config(GPIO_ENET_MDIO); /* Ethernet MIIM data input and output */
+8 -6
View File
@@ -308,8 +308,8 @@ static void lpc54_i2c_setfrequency(struct lpc54_i2cdev_s *priv,
if (err == 0 || divider >= 0x10000) if (err == 0 || divider >= 0x10000)
{ {
/* Break out of the loop early ifeither exact value was found or /* Break out of the loop early ifeither exact value was found
* the divider is at its maximum value. * or the divider is at its maximum value.
*/ */
break; break;
@@ -472,8 +472,9 @@ static bool lpc54_i2c_nextmsg(struct lpc54_i2cdev_s *priv)
} }
else else
{ {
/* That was the last message... we are done. */ /* That was the last message... we are done.
/* Cancel any timeout */ * Cancel any timeout
*/
wd_cancel(priv->timeout); wd_cancel(priv->timeout);
@@ -792,7 +793,7 @@ static int lpc54_i2c_transfer(FAR struct i2c_master_s *dev,
return ret; return ret;
} }
/************************************************************************************ /****************************************************************************
* Name: lpc54_i2c_reset * Name: lpc54_i2c_reset
* *
* Description: * Description:
@@ -804,7 +805,7 @@ static int lpc54_i2c_transfer(FAR struct i2c_master_s *dev,
* Returned Value: * Returned Value:
* Zero (OK) on success; a negated errno value on failure. * Zero (OK) on success; a negated errno value on failure.
* *
************************************************************************************/ ****************************************************************************/
#ifdef CONFIG_I2C_RESET #ifdef CONFIG_I2C_RESET
static int lpc54_i2c_reset(FAR struct i2c_master_s * dev) static int lpc54_i2c_reset(FAR struct i2c_master_s * dev)
@@ -837,6 +838,7 @@ struct i2c_master_s *lpc54_i2cbus_initialize(int port)
flags = enter_critical_section(); flags = enter_critical_section();
/* Configure the requestin I2C peripheral */ /* Configure the requestin I2C peripheral */
/* NOTE: The basic FLEXCOMM initialization was performed in /* NOTE: The basic FLEXCOMM initialization was performed in
* lpc54_lowputc.c. * lpc54_lowputc.c.
*/ */
+10 -9
View File
@@ -250,7 +250,7 @@
#define CRITICAL_ERROR (ENET_INT_UN | ENET_INT_RL | ENET_INT_EBERR ) #define CRITICAL_ERROR (ENET_INT_UN | ENET_INT_RL | ENET_INT_EBERR )
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* This is a helper pointer for accessing the contents of Ethernet header */
#define BUF ((struct eth_hdr_s *)priv->dev.d_buf) #define BUF ((struct eth_hdr_s *)priv->dev.d_buf)
@@ -646,8 +646,8 @@ static int s32k1xx_txpoll(struct net_driver_s *dev)
/* Send the packet */ /* Send the packet */
s32k1xx_transmit(priv); s32k1xx_transmit(priv);
priv->dev.d_buf = priv->dev.d_buf = (uint8_t *)
(uint8_t *)s32k1xx_swap32((uint32_t)priv->txdesc[priv->txhead].data); s32k1xx_swap32((uint32_t)priv->txdesc[priv->txhead].data);
/* Check if there is room in the device to hold another packet. If /* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll. * not, return a non-zero value to terminate the poll.
@@ -692,7 +692,7 @@ static inline void s32k1xx_dispatch(FAR struct s32k1xx_driver_s *priv)
NETDEV_RXPACKETS(&priv->dev); NETDEV_RXPACKETS(&priv->dev);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -713,7 +713,7 @@ static inline void s32k1xx_dispatch(FAR struct s32k1xx_driver_s *priv)
ipv4_input(&priv->dev); ipv4_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -753,7 +753,7 @@ static inline void s32k1xx_dispatch(FAR struct s32k1xx_driver_s *priv)
ipv6_input(&priv->dev); ipv6_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -873,8 +873,8 @@ static void s32k1xx_receive(FAR struct s32k1xx_driver_s *priv)
* queue is not full. * queue is not full.
*/ */
priv->dev.d_buf = priv->dev.d_buf = (uint8_t *)
(uint8_t *)s32k1xx_swap32((uint32_t)priv->txdesc[priv->txhead].data); s32k1xx_swap32((uint32_t)priv->txdesc[priv->txhead].data);
rxdesc->status1 |= RXDESC_E; rxdesc->status1 |= RXDESC_E;
/* Update the index to the next descriptor */ /* Update the index to the next descriptor */
@@ -2404,7 +2404,8 @@ static void s32k1xx_initbuffers(struct s32k1xx_driver_s *priv)
/* Get an aligned RX descriptor (array) address */ /* Get an aligned RX descriptor (array) address */
addr += CONFIG_S32K1XX_ENET_NTXBUFFERS * sizeof(struct enet_desc_s); addr += CONFIG_S32K1XX_ENET_NTXBUFFERS *
sizeof(struct enet_desc_s);
priv->rxdesc = (struct enet_desc_s *)addr; priv->rxdesc = (struct enet_desc_s *)addr;
/* Get the beginning of the first aligned buffer */ /* Get the beginning of the first aligned buffer */
+85 -55
View File
@@ -91,6 +91,7 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/* If processing is not done at the interrupt level, then work queue support /* If processing is not done at the interrupt level, then work queue support
@@ -238,8 +239,9 @@
#endif #endif
/* Timing *******************************************************************/ /* Timing *******************************************************************/
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per
* second /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/ */
#define SAM_WDDELAY (1*CLK_TCK) #define SAM_WDDELAY (1*CLK_TCK)
@@ -253,6 +255,7 @@
#define PHY_RETRY_MAX 1000000 #define PHY_RETRY_MAX 1000000
/* Helpers ******************************************************************/ /* Helpers ******************************************************************/
/* This is a helper pointer for accessing the contents of the EMAC /* This is a helper pointer for accessing the contents of the EMAC
* header * header
*/ */
@@ -263,7 +266,7 @@
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
/* The sam_emac_s encapsulates all state information for the EMAC peripheral */ /* The sam_emac_s encapsulates all state information for EMAC peripheral */
struct sam_emac_s struct sam_emac_s
{ {
@@ -320,6 +323,7 @@ static uint8_t g_pktbuf[MAX_NETDEV_PKTSIZE + CONFIG_NET_GUARDSIZE];
#ifdef CONFIG_SAM34_EMAC_PREALLOCATE #ifdef CONFIG_SAM34_EMAC_PREALLOCATE
/* Preallocated data */ /* Preallocated data */
/* TX descriptors list */ /* TX descriptors list */
static struct emac_txdesc_s g_txdesc[CONFIG_SAM34_EMAC_NTXBUFFERS] static struct emac_txdesc_s g_txdesc[CONFIG_SAM34_EMAC_NTXBUFFERS]
@@ -332,9 +336,9 @@ static struct emac_rxdesc_s g_rxdesc[CONFIG_SAM34_EMAC_NRXBUFFERS]
/* Transmit Buffers /* Transmit Buffers
* *
* Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K Boundaries. * Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K
* Receive buffer manager writes are burst of 2 words => 3 lsb bits of the address * Boundaries. Receive buffer manager writes are burst of 2 words => 3
* shall be set to 0 * lsb bits of the address shall be set to 0
*/ */
static uint8_t g_txbuffer[CONFIG_SAM34_EMAC_NTXBUFFERS * EMAC_TX_UNITSIZE]; static uint8_t g_txbuffer[CONFIG_SAM34_EMAC_NTXBUFFERS * EMAC_TX_UNITSIZE];
@@ -350,13 +354,15 @@ static uint8_t g_rxbuffer[CONFIG_SAM34_EMAC_NRXBUFFERS * EMAC_RX_UNITSIZE]
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
/* Register operations ******************************************************/ /* Register operations ******************************************************/
#if defined(CONFIG_SAM34_EMAC_REGDEBUG) && defined(CONFIG_DEBUG_FEATURES) #if defined(CONFIG_SAM34_EMAC_REGDEBUG) && defined(CONFIG_DEBUG_FEATURES)
static bool sam_checkreg(struct sam_emac_s *priv, bool wr, static bool sam_checkreg(struct sam_emac_s *priv, bool wr,
uint32_t regval, uintptr_t address); uint32_t regval, uintptr_t address);
static uint32_t sam_getreg(struct sam_emac_s *priv, uintptr_t addr); static uint32_t sam_getreg(struct sam_emac_s *priv, uintptr_t addr);
static void sam_putreg(struct sam_emac_s *priv, uintptr_t addr, uint32_t val); static void sam_putreg(struct sam_emac_s *priv,
uintptr_t addr, uint32_t val);
#else #else
# define sam_getreg(priv,addr) getreg32(addr) # define sam_getreg(priv,addr) getreg32(addr)
# define sam_putreg(priv,addr,val) putreg32(val,addr) # define sam_putreg(priv,addr,val) putreg32(val,addr)
@@ -534,8 +540,8 @@ static uint32_t sam_getreg(struct sam_emac_s *priv, uintptr_t address)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SAM34_EMAC_REGDEBUG #ifdef CONFIG_SAM34_EMAC_REGDEBUG
static void sam_putreg(struct sam_emac_s *priv, uintptr_t address, static void sam_putreg(struct sam_emac_s *priv,
uint32_t regval) uintptr_t address, uint32_t regval)
{ {
if (sam_checkreg(priv, true, regval, address)) if (sam_checkreg(priv, true, regval, address))
{ {
@@ -592,7 +598,7 @@ static uint16_t sam_txfree(struct sam_emac_s *priv)
* the configured size minus 1. * the configured size minus 1.
*/ */
return (CONFIG_SAM34_EMAC_NTXBUFFERS-1) - sam_txinuse(priv); return (CONFIG_SAM34_EMAC_NTXBUFFERS - 1) - sam_txinuse(priv);
} }
/**************************************************************************** /****************************************************************************
@@ -784,7 +790,7 @@ static int sam_transmit(struct sam_emac_s *priv)
/* Update TX descriptor status. */ /* Update TX descriptor status. */
status = dev->d_len | EMACTXD_STA_LAST; status = dev->d_len | EMACTXD_STA_LAST;
if (priv->txhead == CONFIG_SAM34_EMAC_NTXBUFFERS-1) if (priv->txhead == CONFIG_SAM34_EMAC_NTXBUFFERS - 1)
{ {
status |= EMACTXD_STA_WRAP; status |= EMACTXD_STA_WRAP;
} }
@@ -837,8 +843,9 @@ static int sam_transmit(struct sam_emac_s *priv)
* Function: sam_txpoll * Function: sam_txpoll
* *
* Description: * Description:
* The transmitter is available, check if the network has any outgoing packets ready * The transmitter is available, check if the network has any outgoing
* to send. This is a callback from devif_poll(). devif_poll() may be called: * packets ready to send. This is a callback from devif_poll().
* devif_poll() may be called:
* *
* 1. When the preceding TX packet send is complete, * 1. When the preceding TX packet send is complete,
* 2. When the preceding TX packet send timesout and the interface is reset * 2. When the preceding TX packet send timesout and the interface is reset
@@ -910,8 +917,8 @@ static int sam_txpoll(struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -950,7 +957,9 @@ static void sam_dopoll(struct sam_emac_s *priv)
if (sam_txfree(priv) > 0) if (sam_txfree(priv) > 0)
{ {
/* If we have the descriptor, then poll the network for new XMIT data. */ /* If we have the descriptor,
* then poll the network for new XMIT data.
*/
devif_poll(dev, sam_txpoll); devif_poll(dev, sam_txpoll);
} }
@@ -1135,7 +1144,8 @@ static int sam_recvframe(struct sam_emac_s *priv)
if (pktlen < dev->d_len) if (pktlen < dev->d_len)
{ {
nerr("ERROR: Buffer size %d; frame size %d\n", dev->d_len, pktlen); nerr("ERROR: Buffer size %d; frame size %d\n",
dev->d_len, pktlen);
return -E2BIG; return -E2BIG;
} }
@@ -1143,7 +1153,9 @@ static int sam_recvframe(struct sam_emac_s *priv)
} }
} }
/* We have not encount the SOF yet... discard this fragment and keep looking */ /* We have not encount the SOF yet...
* discard this fragment and keep looking
*/
else else
{ {
@@ -1214,8 +1226,8 @@ static void sam_receive(struct sam_emac_s *priv)
{ {
sam_dumppacket("Received packet", dev->d_buf, dev->d_len); sam_dumppacket("Received packet", dev->d_buf, dev->d_len);
/* Check if the packet is a valid size for the network buffer configuration /* Check if the packet is a valid size for the network buffer
* (this should not happen) * configuration (this should not happen)
*/ */
if (dev->d_len > CONFIG_NET_ETH_PKTSIZE) if (dev->d_len > CONFIG_NET_ETH_PKTSIZE)
@@ -1225,7 +1237,7 @@ static void sam_receive(struct sam_emac_s *priv)
} }
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -1245,7 +1257,7 @@ static void sam_receive(struct sam_emac_s *priv)
ipv4_input(&priv->dev); ipv4_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1282,7 +1294,7 @@ static void sam_receive(struct sam_emac_s *priv)
ipv6_input(&priv->dev); ipv6_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1319,7 +1331,7 @@ static void sam_receive(struct sam_emac_s *priv)
arp_arpin(&priv->dev); arp_arpin(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1377,14 +1389,15 @@ static void sam_txdone(struct sam_emac_s *priv)
/* Yes.. the descriptor is still in use. However, I have seen a /* Yes.. the descriptor is still in use. However, I have seen a
* case (only repeatable on start-up) where the USED bit is never * case (only repeatable on start-up) where the USED bit is never
* set. Yikes! If we have encountered the first still busy * set. Yikes! If we have encountered the first still busy
* descriptor, then we should also have TQBD equal to the descriptor * descriptor, then we should also have TQBD equal to the
* address. If it is not, then treat is as used anyway. * descriptor address. If it is not, then treat is as used anyway.
*/ */
#if 0 /* The issue does not exist in the current configuration, but may return */ #if 0 /* The issue does not exist in the current configuration, but may return */
#warning REVISIT #warning REVISIT
if (priv->txtail == 0 && if (priv->txtail == 0 &&
sam_physramaddr((uintptr_t)txdesc) != sam_getreg(priv, SAM_EMAC_TBQB)) sam_physramaddr((uintptr_t)txdesc) !=
sam_getreg(priv, SAM_EMAC_TBQB))
{ {
txdesc->status = (uint32_t)EMACTXD_STA_USED; txdesc->status = (uint32_t)EMACTXD_STA_USED;
} }
@@ -1461,12 +1474,12 @@ static void sam_interrupt_work(FAR void *arg)
ninfo("isr: %08x pending: %08x\n", isr, pending); ninfo("isr: %08x pending: %08x\n", isr, pending);
/* Check for the completion of a transmission. This should be done before /* Check for the completion of a transmission. This should be done before
* checking for received data (because receiving can cause another transmission * checking for received data (because receiving can cause another
* before we had a chance to handle the last one). * transmission before we had a chance to handle the last one).
* *
* ISR:TCOMP is set when a frame has been transmitted. Cleared on read. * ISR:TCOMP is set when a frame has been transmitted. Cleared on read.
* TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing a * TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing
* one to this bit. * a one to this bit.
*/ */
if ((pending & EMAC_INT_TCOMP) != 0 || (tsr & EMAC_TSR_TXCOMP) != 0) if ((pending & EMAC_INT_TCOMP) != 0 || (tsr & EMAC_TSR_TXCOMP) != 0)
@@ -1503,7 +1516,8 @@ static void sam_interrupt_work(FAR void *arg)
if ((tsr & EMAC_TSR_TFC) != 0) if ((tsr & EMAC_TSR_TFC) != 0)
{ {
nerr("ERROR: Transmit Frame Corruption due to AHB error: %08x\n", tsr); nerr("ERROR: Transmit Frame Corruption due to AHB error: %08x\n",
tsr);
clrbits |= EMAC_TSR_TFC; clrbits |= EMAC_TSR_TFC;
} }
@@ -1649,8 +1663,8 @@ static int sam_emac_interrupt(int irq, void *context, FAR void *arg)
* *
* ISR:TCOMP is set when a frame has been transmitted. Cleared on read (so * ISR:TCOMP is set when a frame has been transmitted. Cleared on read (so
* we cannot read it here). * we cannot read it here).
* TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing a * TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing
* one to this bit. * a one to this bit.
*/ */
tsr = sam_getreg(priv, SAM_EMAC_TSR); tsr = sam_getreg(priv, SAM_EMAC_TSR);
@@ -2042,7 +2056,8 @@ static unsigned int sam_hashindx(const uint8_t *mac)
unsigned int ndx; unsigned int ndx;
/* Isolate: mac[0] /* Isolate: mac[0]
* ... 05 04 03 02 01 00] */ * ... 05 04 03 02 01 00]
*/
ndx = mac[0]; ndx = mac[0];
@@ -2213,8 +2228,8 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac)
* Function: sam_rmmac * Function: sam_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
@@ -2311,9 +2326,9 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac)
* specified using the req->reg_no struct field and then write its output * specified using the req->reg_no struct field and then write its output
* to the req->val_out field. * to the req->val_out field.
* *
* When called with SIOCSMIIREG it will write to a register of the PHY that * When called with SIOCSMIIREG it will write to a register of the PHY
* is specified using the req->reg_no struct field and use req->val_in as * that is specified using the req->reg_no struct field and use req->
* its input. * val_in as its input.
* *
* Input Parameters: * Input Parameters:
* dev - Ethernet device structure * dev - Ethernet device structure
@@ -2340,7 +2355,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
#ifdef CONFIG_ARCH_PHY_INTERRUPT #ifdef CONFIG_ARCH_PHY_INTERRUPT
case SIOCMIINOTIFY: /* Set up for PHY event notifications */ case SIOCMIINOTIFY: /* Set up for PHY event notifications */
{ {
struct mii_ioctl_notify_s *req = (struct mii_ioctl_notify_s *)((uintptr_t)arg); struct mii_ioctl_notify_s *req =
(struct mii_ioctl_notify_s *)((uintptr_t)arg);
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event); ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
if (ret == OK) if (ret == OK)
@@ -2355,7 +2371,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCGMIIPHY: /* Get MII PHY address */ case SIOCGMIIPHY: /* Get MII PHY address */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->phy_id = priv->phyaddr; req->phy_id = priv->phyaddr;
ret = OK; ret = OK;
} }
@@ -2363,7 +2380,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCGMIIREG: /* Get register from MII PHY */ case SIOCGMIIREG: /* Get register from MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
uint32_t regval; uint32_t regval;
/* Enable management port */ /* Enable management port */
@@ -2383,7 +2401,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCSMIIREG: /* Set register in MII PHY */ case SIOCSMIIREG: /* Set register in MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
uint32_t regval; uint32_t regval;
/* Enable management port */ /* Enable management port */
@@ -3042,6 +3061,7 @@ static int sam_autonegotiate(struct sam_emac_s *priv)
sam_putreg(priv, SAM_EMAC_UR, regval); sam_putreg(priv, SAM_EMAC_UR, regval);
errout: errout:
/* Disable management port */ /* Disable management port */
regval = sam_getreg(priv, SAM_EMAC_NCR); regval = sam_getreg(priv, SAM_EMAC_NCR);
@@ -3138,6 +3158,7 @@ static bool sam_linkup(struct sam_emac_s *priv)
linkup = true; linkup = true;
errout: errout:
/* Disable management port */ /* Disable management port */
regval = sam_getreg(priv, SAM_EMAC_NCR); regval = sam_getreg(priv, SAM_EMAC_NCR);
@@ -3171,13 +3192,13 @@ static int sam_phyinit(struct sam_emac_s *priv)
regval = sam_getreg(priv, SAM_EMAC_NCFGR); regval = sam_getreg(priv, SAM_EMAC_NCFGR);
regval &= ~EMAC_NCFGR_CLK_MASK; regval &= ~EMAC_NCFGR_CLK_MASK;
#if BOARD_MCK_FREQUENCY > (160*1000*1000) #if BOARD_MCK_FREQUENCY > (160 * 1000 * 1000)
# error Supported MCK frequency # error Supported MCK frequency
#elif BOARD_MCK_FREQUENCY > (80*1000*1000) #elif BOARD_MCK_FREQUENCY > (80 * 1000 * 1000)
regval |= EMAC_NCFGR_CLK_DIV64; /* MCK divided by 64 (MCK up to 160 MHz) */ regval |= EMAC_NCFGR_CLK_DIV64; /* MCK divided by 64 (MCK up to 160 MHz) */
#elif BOARD_MCK_FREQUENCY > (40*1000*1000) #elif BOARD_MCK_FREQUENCY > (40 * 1000 * 1000)
regval |= EMAC_NCFGR_CLK_DIV32; /* MCK divided by 32 (MCK up to 80 MHz) */ regval |= EMAC_NCFGR_CLK_DIV32; /* MCK divided by 32 (MCK up to 80 MHz) */
#elif BOARD_MCK_FREQUENCY > (20*1000*1000) #elif BOARD_MCK_FREQUENCY > (20 * 1000 * 1000)
regval |= EMAC_NCFGR_CLK_DIV16; /* MCK divided by 16 (MCK up to 40 MHz) */ regval |= EMAC_NCFGR_CLK_DIV16; /* MCK divided by 16 (MCK up to 40 MHz) */
#else #else
regval |= EMAC_NCFGR_CLK_DIV8; /* MCK divided by 8 (MCK up to 20 MHz) */ regval |= EMAC_NCFGR_CLK_DIV8; /* MCK divided by 8 (MCK up to 20 MHz) */
@@ -3229,7 +3250,9 @@ static inline void sam_ethgpioconfig(struct sam_emac_s *priv)
sam_configgpio(GPIO_EMAC_TX1); /* Transmit data TXD1 */ sam_configgpio(GPIO_EMAC_TX1); /* Transmit data TXD1 */
sam_configgpio(GPIO_EMAC_TX2); /* Transmit data TXD2 */ sam_configgpio(GPIO_EMAC_TX2); /* Transmit data TXD2 */
sam_configgpio(GPIO_EMAC_TX3); /* Transmit data TXD3 */ sam_configgpio(GPIO_EMAC_TX3); /* Transmit data TXD3 */
//sam_configgpio(GPIO_EMAC_TXER); /* Transmit Coding Error */ #if 0
sam_configgpio(GPIO_EMAC_TXER); /* Transmit Coding Error */
#endif
sam_configgpio(GPIO_EMAC_RXCK); /* Receive Clock */ sam_configgpio(GPIO_EMAC_RXCK); /* Receive Clock */
sam_configgpio(GPIO_EMAC_RXDV); /* Receive Data Valid */ sam_configgpio(GPIO_EMAC_RXDV); /* Receive Data Valid */
sam_configgpio(GPIO_EMAC_RX0); /* Receive data RXD0 */ sam_configgpio(GPIO_EMAC_RX0); /* Receive data RXD0 */
@@ -3282,7 +3305,9 @@ static void sam_txreset(struct sam_emac_s *priv)
{ {
bufaddr = (uint32_t)(&(txbuffer[ndx * EMAC_TX_UNITSIZE])); bufaddr = (uint32_t)(&(txbuffer[ndx * EMAC_TX_UNITSIZE]));
/* Set the buffer address and mark the descriptor as in used by firmware */ /* Set the buffer address and mark the descriptor
* as in used by firmware
*/
txdesc[ndx].addr = bufaddr; txdesc[ndx].addr = bufaddr;
txdesc[ndx].status = EMACTXD_STA_USED; txdesc[ndx].status = EMACTXD_STA_USED;
@@ -3437,9 +3462,12 @@ static void sam_macaddress(struct sam_emac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname, dev->d_ifname,
dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1], dev->d_mac.ether.ether_addr_octet[0],
dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3], dev->d_mac.ether.ether_addr_octet[1],
dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]); dev->d_mac.ether.ether_addr_octet[2],
dev->d_mac.ether.ether_addr_octet[3],
dev->d_mac.ether.ether_addr_octet[4],
dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address */ /* Set the MAC address */
@@ -3692,7 +3720,8 @@ void arm_netinitialize(void)
ret = irq_attach(SAM_IRQ_EMAC, sam_emac_interrupt, NULL); ret = irq_attach(SAM_IRQ_EMAC, sam_emac_interrupt, NULL);
if (ret < 0) if (ret < 0)
{ {
nerr("ERROR: Failed to attach the handler to the IRQ%d\n", SAM_IRQ_EMAC); nerr("ERROR: Failed to attach the handler to the IRQ%d\n",
SAM_IRQ_EMAC);
goto errout_with_buffers; goto errout_with_buffers;
} }
@@ -3705,7 +3734,8 @@ void arm_netinitialize(void)
ret = sam_ifdown(&priv->dev); ret = sam_ifdown(&priv->dev);
if (ret < 0) if (ret < 0)
{ {
nerr("ERROR: Failed to put the interface in the down state: %d\n", ret); nerr("ERROR: Failed to put the interface in the down state: %d\n",
ret);
goto errout_with_buffers; goto errout_with_buffers;
} }
+85 -59
View File
@@ -92,6 +92,7 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/* If processing is not done at the interrupt level, then work queue support /* If processing is not done at the interrupt level, then work queue support
@@ -242,8 +243,9 @@
#endif #endif
/* Timing *******************************************************************/ /* Timing *******************************************************************/
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per
* second /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/ */
#define SAM_WDDELAY (1*CLK_TCK) #define SAM_WDDELAY (1*CLK_TCK)
@@ -257,6 +259,7 @@
#define PHY_RETRY_MAX 1000000 #define PHY_RETRY_MAX 1000000
/* Helpers ******************************************************************/ /* Helpers ******************************************************************/
/* This is a helper pointer for accessing the contents of the EMAC /* This is a helper pointer for accessing the contents of the EMAC
* header * header
*/ */
@@ -267,7 +270,7 @@
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
/* The sam_emac_s encapsulates all state information for the EMAC peripheral */ /* The sam_emac_s encapsulates all state information for EMAC peripheral */
struct sam_emac_s struct sam_emac_s
{ {
@@ -324,6 +327,7 @@ static uint8_t g_pktbuf[MAX_NETDEV_PKTSIZE + CONFIG_NET_GUARDSIZE];
#ifdef CONFIG_SAMA5_EMACA_PREALLOCATE #ifdef CONFIG_SAMA5_EMACA_PREALLOCATE
/* Preallocated data */ /* Preallocated data */
/* TX descriptors list */ /* TX descriptors list */
static struct emac_txdesc_s g_txdesc[CONFIG_SAMA5_EMAC_NTXBUFFERS] static struct emac_txdesc_s g_txdesc[CONFIG_SAMA5_EMAC_NTXBUFFERS]
@@ -336,9 +340,9 @@ static struct emac_rxdesc_s g_rxdesc[CONFIG_SAMA5_EMAC_NRXBUFFERS]
/* Transmit Buffers /* Transmit Buffers
* *
* Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K Boundaries. * Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K
* Receive buffer manager writes are burst of 2 words => 3 lsb bits of the address * Boundaries. Receive buffer manager writes are burst of 2 words => 3
* shall be set to 0 * lsb bits of the address shall be set to 0
*/ */
static uint8_t g_txbuffer[CONFIG_SAMA5_EMAC_NTXBUFFERS * EMAC_TX_UNITSIZE]; static uint8_t g_txbuffer[CONFIG_SAMA5_EMAC_NTXBUFFERS * EMAC_TX_UNITSIZE];
@@ -354,13 +358,15 @@ static uint8_t g_rxbuffer[CONFIG_SAMA5_EMAC_NRXBUFFERS * EMAC_RX_UNITSIZE]
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
/* Register operations ******************************************************/ /* Register operations ******************************************************/
#ifdef CONFIG_SAMA5_EMACA_REGDEBUG #ifdef CONFIG_SAMA5_EMACA_REGDEBUG
static bool sam_checkreg(struct sam_emac_s *priv, bool wr, static bool sam_checkreg(struct sam_emac_s *priv, bool wr,
uint32_t regval, uintptr_t address); uint32_t regval, uintptr_t address);
static uint32_t sam_getreg(struct sam_emac_s *priv, uintptr_t addr); static uint32_t sam_getreg(struct sam_emac_s *priv, uintptr_t addr);
static void sam_putreg(struct sam_emac_s *priv, uintptr_t addr, uint32_t val); static void sam_putreg(struct sam_emac_s *priv,
uintptr_t addr, uint32_t val);
#else #else
# define sam_getreg(priv,addr) getreg32(addr) # define sam_getreg(priv,addr) getreg32(addr)
# define sam_putreg(priv,addr,val) putreg32(val,addr) # define sam_putreg(priv,addr,val) putreg32(val,addr)
@@ -452,8 +458,8 @@ static int sam_emac_configure(struct sam_emac_s *priv);
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: sam_checkreg
* *
* Description: * Description:
* Check if the current register access is a duplicate of the preceding. * Check if the current register access is a duplicate of the preceding.
@@ -537,8 +543,8 @@ static uint32_t sam_getreg(struct sam_emac_s *priv, uintptr_t address)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SAMA5_EMACA_REGDEBUG #ifdef CONFIG_SAMA5_EMACA_REGDEBUG
static void sam_putreg(struct sam_emac_s *priv, uintptr_t address, static void sam_putreg(struct sam_emac_s *priv,
uint32_t regval) uintptr_t address, uint32_t regval)
{ {
if (sam_checkreg(priv, true, regval, address)) if (sam_checkreg(priv, true, regval, address))
{ {
@@ -595,7 +601,7 @@ static uint16_t sam_txfree(struct sam_emac_s *priv)
* the configured size minus 1. * the configured size minus 1.
*/ */
return (CONFIG_SAMA5_EMAC_NTXBUFFERS-1) - sam_txinuse(priv); return (CONFIG_SAMA5_EMAC_NTXBUFFERS - 1) - sam_txinuse(priv);
} }
/**************************************************************************** /****************************************************************************
@@ -790,7 +796,7 @@ static int sam_transmit(struct sam_emac_s *priv)
/* Update TX descriptor status. */ /* Update TX descriptor status. */
status = dev->d_len | EMACTXD_STA_LAST; status = dev->d_len | EMACTXD_STA_LAST;
if (priv->txhead == CONFIG_SAMA5_EMAC_NTXBUFFERS-1) if (priv->txhead == CONFIG_SAMA5_EMAC_NTXBUFFERS - 1)
{ {
status |= EMACTXD_STA_WRAP; status |= EMACTXD_STA_WRAP;
} }
@@ -845,8 +851,9 @@ static int sam_transmit(struct sam_emac_s *priv)
* Function: sam_txpoll * Function: sam_txpoll
* *
* Description: * Description:
* The transmitter is available, check if the network has any outgoing packets ready * The transmitter is available, check if the network has any outgoing
* to send. This is a callback from devif_poll(). devif_poll() may be called: * packets ready to send. This is a callback from devif_poll().
* devif_poll() may be called:
* *
* 1. When the preceding TX packet send is complete, * 1. When the preceding TX packet send is complete,
* 2. When the preceding TX packet send timesout and the interface is reset * 2. When the preceding TX packet send timesout and the interface is reset
@@ -918,8 +925,8 @@ static int sam_txpoll(struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -934,7 +941,8 @@ static int sam_txpoll(struct net_driver_s *dev)
* *
* 1. After completion of a transmission (sam_txdone), * 1. After completion of a transmission (sam_txdone),
* 2. When new TX data is available (sam_txavail), and * 2. When new TX data is available (sam_txavail), and
* 3. After a TX timeout to restart the sending process (sam_txtimeout_expiry). * 3. After a TX timeout to restart the sending process
* (sam_txtimeout_expiry).
* *
* Input Parameters: * Input Parameters:
* priv - Reference to the driver state structure * priv - Reference to the driver state structure
@@ -957,7 +965,9 @@ static void sam_dopoll(struct sam_emac_s *priv)
if (sam_txfree(priv) > 0) if (sam_txfree(priv) > 0)
{ {
/* If we have the descriptor, then poll the network for new XMIT data. */ /* If we have the descriptor,
* then poll the network for new XMIT data.
*/
devif_poll(dev, sam_txpoll); devif_poll(dev, sam_txpoll);
} }
@@ -1163,7 +1173,8 @@ static int sam_recvframe(struct sam_emac_s *priv)
if (pktlen < dev->d_len) if (pktlen < dev->d_len)
{ {
nerr("ERROR: Buffer size %d; frame size %d\n", dev->d_len, pktlen); nerr("ERROR: Buffer size %d; frame size %d\n",
dev->d_len, pktlen);
return -E2BIG; return -E2BIG;
} }
@@ -1251,8 +1262,8 @@ static void sam_receive(struct sam_emac_s *priv)
{ {
sam_dumppacket("Received packet", dev->d_buf, dev->d_len); sam_dumppacket("Received packet", dev->d_buf, dev->d_len);
/* Check if the packet is a valid size for the network buffer configuration /* Check if the packet is a valid size for the network buffer
* (this should not happen) * configuration (this should not happen)
*/ */
if (dev->d_len > CONFIG_NET_ETH_PKTSIZE) if (dev->d_len > CONFIG_NET_ETH_PKTSIZE)
@@ -1262,7 +1273,7 @@ static void sam_receive(struct sam_emac_s *priv)
} }
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -1282,7 +1293,7 @@ static void sam_receive(struct sam_emac_s *priv)
ipv4_input(&priv->dev); ipv4_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1319,7 +1330,7 @@ static void sam_receive(struct sam_emac_s *priv)
ipv6_input(&priv->dev); ipv6_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1356,7 +1367,7 @@ static void sam_receive(struct sam_emac_s *priv)
arp_arpin(&priv->dev); arp_arpin(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1414,14 +1425,15 @@ static void sam_txdone(struct sam_emac_s *priv)
/* Yes.. the descriptor is still in use. However, I have seen a /* Yes.. the descriptor is still in use. However, I have seen a
* case (only repeatable on start-up) where the USED bit is never * case (only repeatable on start-up) where the USED bit is never
* set. Yikes! If we have encountered the first still busy * set. Yikes! If we have encountered the first still busy
* descriptor, then we should also have TQBD equal to the descriptor * descriptor, then we should also have TQBD equal to the
* address. If it is not, then treat is as used anyway. * descriptor address. If it is not, then treat is as used anyway.
*/ */
#if 0 /* The issue does not exist in the current configuration, but may return */ #if 0 /* The issue does not exist in the current configuration, but may return */
#warning REVISIT #warning REVISIT
if (priv->txtail == 0 && if (priv->txtail == 0 &&
sam_physramaddr((uintptr_t)txdesc) != sam_getreg(priv, SAM_EMAC_TBQP)) sam_physramaddr((uintptr_t)txdesc) !=
sam_getreg(priv, SAM_EMAC_TBQP))
{ {
txdesc->status = (uint32_t)EMACTXD_STA_USED; txdesc->status = (uint32_t)EMACTXD_STA_USED;
up_clean_dcache((uintptr_t)txdesc, up_clean_dcache((uintptr_t)txdesc,
@@ -1500,8 +1512,8 @@ static void sam_interrupt_work(FAR void *arg)
ninfo("isr: %08x pending: %08x\n", isr, pending); ninfo("isr: %08x pending: %08x\n", isr, pending);
/* Check for the completion of a transmission. This should be done before /* Check for the completion of a transmission. This should be done before
* checking for received data (because receiving can cause another transmission * checking for received data (because receiving can cause another
* before we had a chance to handle the last one). * transmission before we had a chance to handle the last one).
* *
* ISR:TCOMP is set when a frame has been transmitted. Cleared on read. * ISR:TCOMP is set when a frame has been transmitted. Cleared on read.
* TSR:COMP is set when a frame has been transmitted. Cleared by writing a * TSR:COMP is set when a frame has been transmitted. Cleared by writing a
@@ -1627,7 +1639,8 @@ static void sam_interrupt_work(FAR void *arg)
#ifdef CONFIG_DEBUG_NET #ifdef CONFIG_DEBUG_NET
/* Check for PAUSE Frame received (PFRE). /* Check for PAUSE Frame received (PFRE).
* *
* ISR:PFRE indicates that a pause frame has been received. Cleared on a read. * ISR:PFRE indicates that a pause frame has been received.
* Cleared on a read.
*/ */
if ((pending & EMAC_INT_PFR) != 0) if ((pending & EMAC_INT_PFR) != 0)
@@ -1686,8 +1699,8 @@ static int sam_emac_interrupt(int irq, void *context, FAR void *arg)
* *
* ISR:TCOMP is set when a frame has been transmitted. Cleared on read (so * ISR:TCOMP is set when a frame has been transmitted. Cleared on read (so
* we cannot read it here). * we cannot read it here).
* TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing a * TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing
* one to this bit. * a one to this bit.
*/ */
tsr = sam_getreg(priv, SAM_EMAC_TSR_OFFSET); tsr = sam_getreg(priv, SAM_EMAC_TSR_OFFSET);
@@ -2077,7 +2090,8 @@ static unsigned int sam_hashindx(const uint8_t *mac)
unsigned int ndx; unsigned int ndx;
/* Isolate: mac[0] /* Isolate: mac[0]
* ... 05 04 03 02 01 00] */ * ... 05 04 03 02 01 00]
*/
ndx = mac[0]; ndx = mac[0];
@@ -2248,8 +2262,8 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac)
* Function: sam_rmmac * Function: sam_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
@@ -2346,9 +2360,9 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac)
* specified using the req->reg_no struct field and then write its output * specified using the req->reg_no struct field and then write its output
* to the req->val_out field. * to the req->val_out field.
* *
* When called with SIOCSMIIREG it will write to a register of the PHY that * When called with SIOCSMIIREG it will write to a register of the PHY
* is specified using the req->reg_no struct field and use req->val_in as * that is specified using the req->reg_no struct field and use req->
* its input. * val_in as its input.
* *
* Input Parameters: * Input Parameters:
* dev - Ethernet device structure * dev - Ethernet device structure
@@ -2375,7 +2389,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
#ifdef CONFIG_ARCH_PHY_INTERRUPT #ifdef CONFIG_ARCH_PHY_INTERRUPT
case SIOCMIINOTIFY: /* Set up for PHY event notifications */ case SIOCMIINOTIFY: /* Set up for PHY event notifications */
{ {
struct mii_ioctl_notify_s *req = (struct mii_ioctl_notify_s *)((uintptr_t)arg); struct mii_ioctl_notify_s *req =
(struct mii_ioctl_notify_s *)((uintptr_t)arg);
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event); ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
if (ret == OK) if (ret == OK)
@@ -2390,7 +2405,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCGMIIPHY: /* Get MII PHY address */ case SIOCGMIIPHY: /* Get MII PHY address */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->phy_id = priv->phyaddr; req->phy_id = priv->phyaddr;
ret = OK; ret = OK;
} }
@@ -2398,7 +2414,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCGMIIREG: /* Get register from MII PHY */ case SIOCGMIIREG: /* Get register from MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
uint32_t regval; uint32_t regval;
/* Enable management port */ /* Enable management port */
@@ -2418,7 +2435,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCSMIIREG: /* Set register in MII PHY */ case SIOCSMIIREG: /* Set register in MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
uint32_t regval; uint32_t regval;
/* Enable management port */ /* Enable management port */
@@ -3063,6 +3081,7 @@ static int sam_autonegotiate(struct sam_emac_s *priv)
sam_putreg(priv, SAM_EMAC_USRIO, regval); sam_putreg(priv, SAM_EMAC_USRIO, regval);
errout: errout:
/* Disable management port */ /* Disable management port */
regval = sam_getreg(priv, SAM_EMAC_NCR); regval = sam_getreg(priv, SAM_EMAC_NCR);
@@ -3159,6 +3178,7 @@ static bool sam_linkup(struct sam_emac_s *priv)
linkup = true; linkup = true;
errout: errout:
/* Disable management port */ /* Disable management port */
regval = sam_getreg(priv, SAM_EMAC_NCR); regval = sam_getreg(priv, SAM_EMAC_NCR);
@@ -3194,20 +3214,20 @@ static int sam_phyinit(struct sam_emac_s *priv)
regval &= ~EMAC_NCFGR_CLK_MASK; regval &= ~EMAC_NCFGR_CLK_MASK;
mck = BOARD_MCK_FREQUENCY; mck = BOARD_MCK_FREQUENCY;
if (mck > (160*1000*1000)) if (mck > (160 * 1000 * 1000))
{ {
nerr("ERROR: Cannot realize PHY clock\n"); nerr("ERROR: Cannot realize PHY clock\n");
return -EINVAL; return -EINVAL;
} }
else if (mck > (80*1000*1000)) else if (mck > (80 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV64; /* MCK divided by 64 (MCK up to 160 MHz) */ regval |= EMAC_NCFGR_CLK_DIV64; /* MCK divided by 64 (MCK up to 160 MHz) */
} }
else if (mck > (40*1000*1000)) else if (mck > (40 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV32; /* MCK divided by 32 (MCK up to 80 MHz) */ regval |= EMAC_NCFGR_CLK_DIV32; /* MCK divided by 32 (MCK up to 80 MHz) */
} }
else if (mck > (20*1000*1000)) else if (mck > (20 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV16; /* MCK divided by 16 (MCK up to 40 MHz) */ regval |= EMAC_NCFGR_CLK_DIV16; /* MCK divided by 16 (MCK up to 40 MHz) */
} }
@@ -3255,6 +3275,7 @@ static int sam_phyinit(struct sam_emac_s *priv)
static inline void sam_ethgpioconfig(struct sam_emac_s *priv) static inline void sam_ethgpioconfig(struct sam_emac_s *priv)
{ {
/* Configure PIO pins to support EMAC */ /* Configure PIO pins to support EMAC */
/* Configure EMAC PIO pins common to both MII and RMII */ /* Configure EMAC PIO pins common to both MII and RMII */
sam_configpio(PIO_EMAC_TX0); sam_configpio(PIO_EMAC_TX0);
@@ -3309,7 +3330,9 @@ static void sam_txreset(struct sam_emac_s *priv)
{ {
bufaddr = (uint32_t)(&(txbuffer[ndx * EMAC_TX_UNITSIZE])); bufaddr = (uint32_t)(&(txbuffer[ndx * EMAC_TX_UNITSIZE]));
/* Set the buffer address and mark the descriptor as in used by firmware */ /* Set the buffer address and mark the descriptor
* as in used by firmware
*/
physaddr = sam_physramaddr(bufaddr); physaddr = sam_physramaddr(bufaddr);
txdesc[ndx].addr = physaddr; txdesc[ndx].addr = physaddr;
@@ -3323,8 +3346,7 @@ static void sam_txreset(struct sam_emac_s *priv)
/* Flush the entire TX descriptor table to RAM */ /* Flush the entire TX descriptor table to RAM */
up_clean_dcache((uintptr_t)txdesc, up_clean_dcache((uintptr_t)txdesc, (uintptr_t)txdesc +
(uintptr_t)txdesc +
CONFIG_SAMA5_EMAC_NTXBUFFERS * sizeof(struct emac_txdesc_s)); CONFIG_SAMA5_EMAC_NTXBUFFERS * sizeof(struct emac_txdesc_s));
/* Set the Transmit Buffer Queue Pointer Register */ /* Set the Transmit Buffer Queue Pointer Register */
@@ -3387,8 +3409,7 @@ static void sam_rxreset(struct sam_emac_s *priv)
/* Flush the entire RX descriptor table to RAM */ /* Flush the entire RX descriptor table to RAM */
up_clean_dcache((uintptr_t)rxdesc, up_clean_dcache((uintptr_t)rxdesc, (uintptr_t)rxdesc +
(uintptr_t)rxdesc +
CONFIG_SAMA5_EMAC_NRXBUFFERS * sizeof(struct emac_rxdesc_s)); CONFIG_SAMA5_EMAC_NRXBUFFERS * sizeof(struct emac_rxdesc_s));
/* Set the Receive Buffer Queue Pointer Register */ /* Set the Receive Buffer Queue Pointer Register */
@@ -3478,9 +3499,12 @@ static void sam_macaddress(struct sam_emac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname, dev->d_ifname,
dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1], dev->d_mac.ether.ether_addr_octet[0],
dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3], dev->d_mac.ether.ether_addr_octet[1],
dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]); dev->d_mac.ether.ether_addr_octet[2],
dev->d_mac.ether.ether_addr_octet[3],
dev->d_mac.ether.ether_addr_octet[4],
dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address */ /* Set the MAC address */
@@ -3649,8 +3673,8 @@ static int sam_emac_configure(struct sam_emac_s *priv)
/* Setup the interrupts for TX events, RX events, and error events */ /* Setup the interrupts for TX events, RX events, and error events */
regval = (EMAC_INT_RCOMP | EMAC_INT_RXUBR | EMAC_INT_TUND | EMAC_INT_RLE | regval = (EMAC_INT_RCOMP | EMAC_INT_RXUBR | EMAC_INT_TUND | EMAC_INT_RLE |
EMAC_INT_TXERR | EMAC_INT_TCOMP | EMAC_INT_ROVR | EMAC_INT_HRESP | EMAC_INT_TXERR | EMAC_INT_TCOMP | EMAC_INT_ROVR |
EMAC_INT_PFR | EMAC_INT_PTZ); EMAC_INT_HRESP | EMAC_INT_PFR | EMAC_INT_PTZ);
sam_putreg(priv, SAM_EMAC_IER, regval); sam_putreg(priv, SAM_EMAC_IER, regval);
return OK; return OK;
} }
@@ -3735,7 +3759,8 @@ int sam_emac_initialize(void)
ret = irq_attach(SAM_IRQ_EMAC, sam_emac_interrupt, NULL); ret = irq_attach(SAM_IRQ_EMAC, sam_emac_interrupt, NULL);
if (ret < 0) if (ret < 0)
{ {
nerr("ERROR: Failed to attach the handler to the IRQ%d\n", SAM_IRQ_EMAC); nerr("ERROR: Failed to attach the handler to the IRQ%d\n",
SAM_IRQ_EMAC);
goto errout_with_buffers; goto errout_with_buffers;
} }
@@ -3748,7 +3773,8 @@ int sam_emac_initialize(void)
ret = sam_ifdown(&priv->dev); ret = sam_ifdown(&priv->dev);
if (ret < 0) if (ret < 0)
{ {
nerr("ERROR: Failed to put the interface in the down state: %d\n", ret); nerr("ERROR: Failed to put the interface in the down state: %d\n",
ret);
goto errout_with_buffers; goto errout_with_buffers;
} }
+103 -71
View File
@@ -106,6 +106,7 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/* If processing is not done at the interrupt level, then work queue support /* If processing is not done at the interrupt level, then work queue support
@@ -317,8 +318,9 @@
#define EMAC_TX_UNITSIZE CONFIG_NET_ETH_PKTSIZE /* MAX size for Ethernet packet */ #define EMAC_TX_UNITSIZE CONFIG_NET_ETH_PKTSIZE /* MAX size for Ethernet packet */
/* Timing *******************************************************************/ /* Timing *******************************************************************/
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per
* second /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/ */
#define SAM_WDDELAY (1*CLK_TCK) #define SAM_WDDELAY (1*CLK_TCK)
@@ -332,6 +334,7 @@
#define PHY_RETRY_MAX 1000000 #define PHY_RETRY_MAX 1000000
/* Helpers ******************************************************************/ /* Helpers ******************************************************************/
/* This is a helper pointer for accessing the contents of the EMAC /* This is a helper pointer for accessing the contents of the EMAC
* header * header
*/ */
@@ -341,6 +344,7 @@
/**************************************************************************** /****************************************************************************
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
/* This structure defines the constant an configured attributes of an EMAC */ /* This structure defines the constant an configured attributes of an EMAC */
struct sam_emacattr_s struct sam_emacattr_s
@@ -359,7 +363,7 @@ struct sam_emacattr_s
uint8_t lsoui; /* LS 2 bits of the 18-bit OUI */ uint8_t lsoui; /* LS 2 bits of the 18-bit OUI */
bool rmii; /* True: RMII vs. False: MII */ bool rmii; /* True: RMII vs. False: MII */
bool clause45; /* True: Clause 45 behavior */ bool clause45; /* True: Clause 45 behavior */
//bool autoneg; /* True: Autonegotiate rate and *plex */ bool autoneg; /* True: Autonegotiate rate and *plex */
bool sralt; /* True: Alternate PHYSR bit access */ bool sralt; /* True: Alternate PHYSR bit access */
union union
@@ -404,7 +408,7 @@ struct sam_emacattr_s
#endif #endif
}; };
/* The sam_emac_s encapsulates all state information for the EMAC peripheral */ /* The sam_emac_s encapsulates all state information for EMAC peripheral */
struct sam_emac_s struct sam_emac_s
{ {
@@ -450,6 +454,7 @@ struct sam_emac_s
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
/* Register operations ******************************************************/ /* Register operations ******************************************************/
#if defined(CONFIG_SAMA5_EMACB_REGDEBUG) && defined(CONFIG_DEBUG_FEATURES) #if defined(CONFIG_SAMA5_EMACB_REGDEBUG) && defined(CONFIG_DEBUG_FEATURES)
@@ -458,7 +463,8 @@ static bool sam_checkreg(struct sam_emac_s *priv, bool wr,
#endif #endif
static uint32_t sam_getreg(struct sam_emac_s *priv, uint16_t offset); static uint32_t sam_getreg(struct sam_emac_s *priv, uint16_t offset);
static void sam_putreg(struct sam_emac_s *priv, uint16_t offset, uint32_t val); static void sam_putreg(struct sam_emac_s *priv,
uint16_t offset, uint32_t val);
/* Buffer management */ /* Buffer management */
@@ -574,18 +580,20 @@ static struct emac_rxdesc_s g_emac0_rxdesc[CONFIG_SAMA5_EMAC0_NRXBUFFERS]
/* EMAC0 Transmit Buffers /* EMAC0 Transmit Buffers
* *
* Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K Boundaries. * Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K
* Receive buffer manager writes are burst of 2 words => 3 lsb bits of the address * Boundaries. Receive buffer manager writes are burst of 2 words => 3
* shall be set to 0 * lsb bits of the address shall be set to 0
*/ */
static uint8_t g_emac0_txbuffer[CONFIG_SAMA5_EMAC0_NTXBUFFERS * EMAC_TX_UNITSIZE]; static uint8_t
__attribute__((aligned(8))) g_emac0_txbuffer[CONFIG_SAMA5_EMAC0_NTXBUFFERS * EMAC_TX_UNITSIZE]
__attribute__((aligned(8)));
/* EMAC0 Receive Buffers */ /* EMAC0 Receive Buffers */
static uint8_t g_emac0_rxbuffer[CONFIG_SAMA5_EMAC0_NRXBUFFERS * EMAC_RX_UNITSIZE] static uint8_t
__attribute__((aligned(8))); g_emac0_rxbuffer[CONFIG_SAMA5_EMAC0_NRXBUFFERS * EMAC_RX_UNITSIZE]
__attribute__((aligned(8)));
#endif #endif
@@ -602,18 +610,20 @@ static struct emac_rxdesc_s g_emac1_rxdesc[CONFIG_SAMA5_EMAC1_NRXBUFFERS]
/* EMAC1 Transmit Buffers /* EMAC1 Transmit Buffers
* *
* Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K Boundaries. * Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K
* Receive buffer manager writes are burst of 2 words => 3 lsb bits of the address * Boundaries. Receive buffer manager writes are burst of 2 words => 3
* shall be set to 0 * lsb bits of the address shall be set to 0
*/ */
static uint8_t g_emac1_txbuffer[CONFIG_SAMA5_EMAC1_NTXBUFFERS * EMAC_TX_UNITSIZE]; static uint8_t
__attribute__((aligned(8))) g_emac1_txbuffer[CONFIG_SAMA5_EMAC1_NTXBUFFERS * EMAC_TX_UNITSIZE]
__attribute__((aligned(8)));
/* EMAC1 Receive Buffers */ /* EMAC1 Receive Buffers */
static uint8_t g_emac1_rxbuffer[CONFIG_SAMA5_EMAC1_NRXBUFFERS * EMAC_RX_UNITSIZE] static uint8_t
__attribute__((aligned(8))); g_emac1_rxbuffer[CONFIG_SAMA5_EMAC1_NRXBUFFERS * EMAC_RX_UNITSIZE]
__attribute__((aligned(8)));
#endif #endif
#endif #endif
@@ -642,7 +652,7 @@ static const struct sam_emacattr_s g_emac0_attr =
.clause45 = true, .clause45 = true,
#endif #endif
#ifdef CONFIG_SAMA5_EMAC0_AUTONEG #ifdef CONFIG_SAMA5_EMAC0_AUTONEG
//.autoneg = true, .autoneg = true,
#endif #endif
#ifdef CONFIG_SAMA5_EMAC0_PHYSR_ALTCONFIG #ifdef CONFIG_SAMA5_EMAC0_PHYSR_ALTCONFIG
.sralt = true, .sralt = true,
@@ -662,7 +672,8 @@ static const struct sam_emacattr_s g_emac0_attr =
#else #else
.std = .std =
{ {
.stdmask = (CONFIG_SAMA5_EMAC0_PHYSR_SPEED | CONFIG_SAMA5_EMAC0_PHYSR_MODE), .stdmask = CONFIG_SAMA5_EMAC0_PHYSR_SPEED |
CONFIG_SAMA5_EMAC0_PHYSR_MODE,
.speed100 = CONFIG_SAMA5_EMAC0_PHYSR_100MBPS, .speed100 = CONFIG_SAMA5_EMAC0_PHYSR_100MBPS,
.fduplex = CONFIG_SAMA5_EMAC0_PHYSR_FULLDUPLEX, .fduplex = CONFIG_SAMA5_EMAC0_PHYSR_FULLDUPLEX,
}, },
@@ -722,7 +733,7 @@ static const struct sam_emacattr_s g_emac1_attr =
.clause45 = true, .clause45 = true,
#endif #endif
#ifdef CONFIG_SAMA5_EMAC1_AUTONEG #ifdef CONFIG_SAMA5_EMAC1_AUTONEG
//.autoneg = true, .autoneg = true,
#endif #endif
#ifdef CONFIG_SAMA5_EMAC1_PHYSR_ALTCONFIG #ifdef CONFIG_SAMA5_EMAC1_PHYSR_ALTCONFIG
.sralt = true, .sralt = true,
@@ -742,7 +753,8 @@ static const struct sam_emacattr_s g_emac1_attr =
#else #else
.std = .std =
{ {
.stdmask = (CONFIG_SAMA5_EMAC1_PHYSR_SPEED | CONFIG_SAMA5_EMAC1_PHYSR_MODE), .stdmask = CONFIG_SAMA5_EMAC1_PHYSR_SPEED |
CONFIG_SAMA5_EMAC1_PHYSR_MODE,
.speed100 = CONFIG_SAMA5_EMAC1_PHYSR_100MBPS, .speed100 = CONFIG_SAMA5_EMAC1_PHYSR_100MBPS,
.fduplex = CONFIG_SAMA5_EMAC1_PHYSR_FULLDUPLEX, .fduplex = CONFIG_SAMA5_EMAC1_PHYSR_FULLDUPLEX,
}, },
@@ -783,8 +795,8 @@ static struct sam_emac_s g_emac1;
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: sam_checkreg
* *
* Description: * Description:
* Check if the current register access is a duplicate of the preceding. * Check if the current register access is a duplicate of the preceding.
@@ -869,8 +881,8 @@ static uint32_t sam_getreg(struct sam_emac_s *priv, uint16_t offset)
* *
****************************************************************************/ ****************************************************************************/
static void sam_putreg(struct sam_emac_s *priv, uint16_t offset, static void sam_putreg(struct sam_emac_s *priv,
uint32_t regval) uint16_t offset, uint32_t regval)
{ {
uintptr_t regaddr = priv->attr->base + (uintptr_t)offset; uintptr_t regaddr = priv->attr->base + (uintptr_t)offset;
@@ -930,7 +942,7 @@ static uint16_t sam_txfree(struct sam_emac_s *priv)
* the configured size minus 1. * the configured size minus 1.
*/ */
return (priv->attr->ntxbuffers-1) - sam_txinuse(priv); return (priv->attr->ntxbuffers - 1) - sam_txinuse(priv);
} }
/**************************************************************************** /****************************************************************************
@@ -1125,7 +1137,7 @@ static int sam_transmit(struct sam_emac_s *priv)
/* Update TX descriptor status. */ /* Update TX descriptor status. */
status = dev->d_len | EMACTXD_STA_LAST; status = dev->d_len | EMACTXD_STA_LAST;
if (priv->txhead == priv->attr->ntxbuffers-1) if (priv->txhead == priv->attr->ntxbuffers - 1)
{ {
status |= EMACTXD_STA_WRAP; status |= EMACTXD_STA_WRAP;
} }
@@ -1180,8 +1192,9 @@ static int sam_transmit(struct sam_emac_s *priv)
* Function: sam_txpoll * Function: sam_txpoll
* *
* Description: * Description:
* The transmitter is available, check if the network has any outgoing packets ready * The transmitter is available, check if the network has any outgoing
* to send. This is a callback from devif_poll(). devif_poll() may be called: * packets ready to send. This is a callback from devif_poll().
* devif_poll() may be called:
* *
* 1. When the preceding TX packet send is complete, * 1. When the preceding TX packet send is complete,
* 2. When the preceding TX packet send timesout and the interface is reset * 2. When the preceding TX packet send timesout and the interface is reset
@@ -1253,8 +1266,8 @@ static int sam_txpoll(struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -1293,7 +1306,9 @@ static void sam_dopoll(struct sam_emac_s *priv)
if (sam_txfree(priv) > 0) if (sam_txfree(priv) > 0)
{ {
/* If we have the descriptor, then poll the network for new XMIT data. */ /* If we have the descriptor,
* then poll the network for new XMIT data.
*/
devif_poll(dev, sam_txpoll); devif_poll(dev, sam_txpoll);
} }
@@ -1586,8 +1601,8 @@ static void sam_receive(struct sam_emac_s *priv)
{ {
sam_dumppacket("Received packet", dev->d_buf, dev->d_len); sam_dumppacket("Received packet", dev->d_buf, dev->d_len);
/* Check if the packet is a valid size for the network buffer configuration /* Check if the packet is a valid size for the network buffer
* (this should not happen) * configuration (this should not happen)
*/ */
if (dev->d_len > CONFIG_NET_ETH_PKTSIZE) if (dev->d_len > CONFIG_NET_ETH_PKTSIZE)
@@ -1597,7 +1612,7 @@ static void sam_receive(struct sam_emac_s *priv)
} }
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -1617,7 +1632,7 @@ static void sam_receive(struct sam_emac_s *priv)
ipv4_input(&priv->dev); ipv4_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1654,7 +1669,7 @@ static void sam_receive(struct sam_emac_s *priv)
ipv6_input(&priv->dev); ipv6_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1691,7 +1706,7 @@ static void sam_receive(struct sam_emac_s *priv)
arp_arpin(&priv->dev); arp_arpin(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1765,14 +1780,15 @@ static void sam_txdone(struct sam_emac_s *priv)
/* Yes.. the descriptor is still in use. However, I have seen a /* Yes.. the descriptor is still in use. However, I have seen a
* case (only repeatable on start-up) where the USED bit is never * case (only repeatable on start-up) where the USED bit is never
* set. Yikes! If we have encountered the first still busy * set. Yikes! If we have encountered the first still busy
* descriptor, then we should also have TQBD equal to the descriptor * descriptor, then we should also have TQBD equal to the
* address. If it is not, then treat is as used anyway. * descriptor address. If it is not, then treat is as used anyway.
*/ */
#if 0 /* The issue does not exist in the current configuration, but may return */ #if 0 /* The issue does not exist in the current configuration, but may return */
#warning REVISIT #warning REVISIT
if (priv->txtail == 0 && if (priv->txtail == 0 &&
sam_physramaddr((uintptr_t)txdesc) != sam_getreg(priv, SAM_EMAC_TBQB_OFFSET)) sam_physramaddr((uintptr_t)txdesc) !=
sam_getreg(priv, SAM_EMAC_TBQB_OFFSET))
{ {
txdesc->status = (uint32_t)EMACTXD_STA_USED; txdesc->status = (uint32_t)EMACTXD_STA_USED;
up_clean_dcache((uintptr_t)txdesc, up_clean_dcache((uintptr_t)txdesc,
@@ -1859,12 +1875,12 @@ static void sam_interrupt_work(FAR void *arg)
ninfo("isr: %08x pending: %08x\n", isr, pending); ninfo("isr: %08x pending: %08x\n", isr, pending);
/* Check for the completion of a transmission. This should be done before /* Check for the completion of a transmission. This should be done before
* checking for received data (because receiving can cause another transmission * checking for received data (because receiving can cause another
* before we had a chance to handle the last one). * transmission before we had a chance to handle the last one).
* *
* ISR:TCOMP is set when a frame has been transmitted. Cleared on read. * ISR:TCOMP is set when a frame has been transmitted. Cleared on read.
* TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing a * TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing
* one to this bit. * a one to this bit.
*/ */
if ((pending & EMAC_INT_TCOMP) != 0 || (tsr & EMAC_TSR_TXCOMP) != 0) if ((pending & EMAC_INT_TCOMP) != 0 || (tsr & EMAC_TSR_TXCOMP) != 0)
@@ -1901,7 +1917,8 @@ static void sam_interrupt_work(FAR void *arg)
if ((tsr & EMAC_TSR_TFC) != 0) if ((tsr & EMAC_TSR_TFC) != 0)
{ {
nerr("ERROR: Transmit Frame Corruption due to AHB error: %08x\n", tsr); nerr("ERROR: Transmit Frame Corruption due to AHB error: %08x\n",
tsr);
clrbits |= EMAC_TSR_TFC; clrbits |= EMAC_TSR_TFC;
} }
@@ -2047,8 +2064,8 @@ static int sam_emac_interrupt(int irq, void *context, FAR void *arg)
* *
* ISR:TCOMP is set when a frame has been transmitted. Cleared on read (so * ISR:TCOMP is set when a frame has been transmitted. Cleared on read (so
* we cannot read it here). * we cannot read it here).
* TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing a * TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing
* one to this bit. * a one to this bit.
*/ */
tsr = sam_getreg(priv, SAM_EMAC_TSR_OFFSET); tsr = sam_getreg(priv, SAM_EMAC_TSR_OFFSET);
@@ -2446,7 +2463,8 @@ static unsigned int sam_hashindx(const uint8_t *mac)
unsigned int ndx; unsigned int ndx;
/* Isolate: mac[0] /* Isolate: mac[0]
* ... 05 04 03 02 01 00] */ * ... 05 04 03 02 01 00]
*/
ndx = mac[0]; ndx = mac[0];
@@ -2616,8 +2634,8 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac)
* Function: sam_rmmac * Function: sam_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
@@ -2713,9 +2731,9 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac)
* specified using the req->reg_no struct field and then write its output * specified using the req->reg_no struct field and then write its output
* to the req->val_out field. * to the req->val_out field.
* *
* When called with SIOCSMIIREG it will write to a register of the PHY that * When called with SIOCSMIIREG it will write to a register of the PHY
* is specified using the req->reg_no struct field and use req->val_in as * that is specified using the req->reg_no struct field and use req->
* its input. * val_in as its input.
* *
* Input Parameters: * Input Parameters:
* dev - Ethernet device structure * dev - Ethernet device structure
@@ -2742,7 +2760,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
#ifdef CONFIG_ARCH_PHY_INTERRUPT #ifdef CONFIG_ARCH_PHY_INTERRUPT
case SIOCMIINOTIFY: /* Set up for PHY event notifications */ case SIOCMIINOTIFY: /* Set up for PHY event notifications */
{ {
struct mii_ioctl_notify_s *req = (struct mii_ioctl_notify_s *)((uintptr_t)arg); struct mii_ioctl_notify_s *req =
(struct mii_ioctl_notify_s *)((uintptr_t)arg);
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event); ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
if (ret == OK) if (ret == OK)
@@ -2757,7 +2776,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCGMIIPHY: /* Get MII PHY address */ case SIOCGMIIPHY: /* Get MII PHY address */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->phy_id = priv->phyaddr; req->phy_id = priv->phyaddr;
ret = OK; ret = OK;
} }
@@ -2765,7 +2785,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCGMIIREG: /* Get register from MII PHY */ case SIOCGMIIREG: /* Get register from MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
uint32_t regval; uint32_t regval;
/* Enable management port */ /* Enable management port */
@@ -2785,7 +2806,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCSMIIREG: /* Set register in MII PHY */ case SIOCSMIIREG: /* Set register in MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
uint32_t regval; uint32_t regval;
/* Enable management port */ /* Enable management port */
@@ -2984,7 +3006,8 @@ static int sam_phyintenable(struct sam_emac_s *priv)
/* Does this MAC support a KSZ80X1 PHY? */ /* Does this MAC support a KSZ80X1 PHY? */
if (priv->phytype == SAMA5_PHY_KSZ8051 || priv->phytype == SAMA5_PHY_KSZ8081) if (priv->phytype == SAMA5_PHY_KSZ8051 ||
priv->phytype == SAMA5_PHY_KSZ8081)
{ {
/* Enable management port */ /* Enable management port */
@@ -3262,7 +3285,7 @@ static int sam_phyread(struct sam_emac_s *priv, uint8_t phyaddr,
/* Return data */ /* Return data */
*phyval = (uint16_t)(sam_getreg(priv, SAM_EMAC_MAN_OFFSET) & EMAC_MAN_DATA_MASK); *phyval = sam_getreg(priv, SAM_EMAC_MAN_OFFSET) & EMAC_MAN_DATA_MASK;
return OK; return OK;
} }
@@ -3549,6 +3572,7 @@ static int sam_autonegotiate(struct sam_emac_s *priv)
sam_putreg(priv, SAM_EMAC_UR_OFFSET, regval); sam_putreg(priv, SAM_EMAC_UR_OFFSET, regval);
errout: errout:
/* Disable management port */ /* Disable management port */
regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET);
@@ -3645,6 +3669,7 @@ static bool sam_linkup(struct sam_emac_s *priv)
linkup = true; linkup = true;
errout: errout:
/* Disable management port */ /* Disable management port */
regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET);
@@ -3680,20 +3705,20 @@ static int sam_phyinit(struct sam_emac_s *priv)
regval &= ~EMAC_NCFGR_CLK_MASK; regval &= ~EMAC_NCFGR_CLK_MASK;
mck = BOARD_MCK_FREQUENCY; mck = BOARD_MCK_FREQUENCY;
if (mck > (160*1000*1000)) if (mck > (160 * 1000 * 1000))
{ {
nerr("ERROR: Cannot realize PHY clock\n"); nerr("ERROR: Cannot realize PHY clock\n");
return -EINVAL; return -EINVAL;
} }
else if (mck > (80*1000*1000)) else if (mck > (80 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV64; /* MCK divided by 64 (MCK up to 160 MHz) */ regval |= EMAC_NCFGR_CLK_DIV64; /* MCK divided by 64 (MCK up to 160 MHz) */
} }
else if (mck > (40*1000*1000)) else if (mck > (40 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV32; /* MCK divided by 32 (MCK up to 80 MHz) */ regval |= EMAC_NCFGR_CLK_DIV32; /* MCK divided by 32 (MCK up to 80 MHz) */
} }
else if (mck > (20*1000*1000)) else if (mck > (20 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV16; /* MCK divided by 16 (MCK up to 40 MHz) */ regval |= EMAC_NCFGR_CLK_DIV16; /* MCK divided by 16 (MCK up to 40 MHz) */
} }
@@ -3869,7 +3894,9 @@ static void sam_txreset(struct sam_emac_s *priv)
{ {
bufaddr = (uint32_t)(&(txbuffer[ndx * EMAC_TX_UNITSIZE])); bufaddr = (uint32_t)(&(txbuffer[ndx * EMAC_TX_UNITSIZE]));
/* Set the buffer address and mark the descriptor as in used by firmware */ /* Set the buffer address and mark the descriptor
* as in used by firmware
*/
physaddr = sam_physramaddr(bufaddr); physaddr = sam_physramaddr(bufaddr);
txdesc[ndx].addr = physaddr; txdesc[ndx].addr = physaddr;
@@ -4126,9 +4153,12 @@ static void sam_macaddress(struct sam_emac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname, dev->d_ifname,
dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1], dev->d_mac.ether.ether_addr_octet[0],
dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3], dev->d_mac.ether.ether_addr_octet[1],
dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]); dev->d_mac.ether.ether_addr_octet[2],
dev->d_mac.ether.ether_addr_octet[3],
dev->d_mac.ether.ether_addr_octet[4],
dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address */ /* Set the MAC address */
@@ -4424,7 +4454,8 @@ int sam_emac_initialize(int intf)
ret = irq_attach(priv->attr->irq, sam_emac_interrupt, priv); ret = irq_attach(priv->attr->irq, sam_emac_interrupt, priv);
if (ret < 0) if (ret < 0)
{ {
nerr("ERROR: Failed to attach the handler to the IRQ%d\n", priv->attr->irq); nerr("ERROR: Failed to attach the handler to the IRQ%d\n",
priv->attr->irq);
goto errout_with_buffers; goto errout_with_buffers;
} }
@@ -4437,7 +4468,8 @@ int sam_emac_initialize(int intf)
ret = sam_ifdown(&priv->dev); ret = sam_ifdown(&priv->dev);
if (ret < 0) if (ret < 0)
{ {
nerr("ERROR: Failed to put the interface in the down state: %d\n", ret); nerr("ERROR: Failed to put the interface in the down state: %d\n",
ret);
goto errout_with_buffers; goto errout_with_buffers;
} }
+15 -12
View File
@@ -170,8 +170,8 @@
/* Timing *******************************************************************/ /* Timing *******************************************************************/
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per /* TX poll delay = 1 seconds.
* second * CLK_TCK is the number of clock ticks per second
*/ */
#define SAM_WDDELAY (1*CLK_TCK) #define SAM_WDDELAY (1*CLK_TCK)
@@ -196,7 +196,7 @@
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
/* The sam_gmac_s encapsulates all state information for the GMAC peripheral */ /* The sam_gmac_s encapsulates all state information for GMAC peripheral */
struct sam_gmac_s struct sam_gmac_s
{ {
@@ -475,8 +475,8 @@ static uint32_t sam_getreg(struct sam_gmac_s *priv, uintptr_t address)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SAMA5_GMAC_REGDEBUG #ifdef CONFIG_SAMA5_GMAC_REGDEBUG
static void sam_putreg(struct sam_gmac_s *priv, uintptr_t address, static void sam_putreg(struct sam_gmac_s *priv,
uint32_t regval) uintptr_t address, uint32_t regval)
{ {
if (sam_checkreg(priv, true, regval, address)) if (sam_checkreg(priv, true, regval, address))
{ {
@@ -907,7 +907,9 @@ static void sam_dopoll(struct sam_gmac_s *priv)
if (sam_txfree(priv) > 0) if (sam_txfree(priv) > 0)
{ {
/* If we have the descriptor, then poll the network for new XMIT data. */ /* If we have the descriptor,
* then poll the network for new XMIT data.
*/
devif_poll(dev, sam_txpoll); devif_poll(dev, sam_txpoll);
} }
@@ -2524,13 +2526,13 @@ static int sam_phyintenable(struct sam_gmac_s *priv)
* interrupts * interrupts
*/ */
ret = sam_phyread(priv, priv->phyaddr, GMII_KSZ90x1_ICS, &phyval); ret = sam_phyread(priv, priv->phyaddr, GMII_KSZ90X1_ICS, &phyval);
if (ret == OK) if (ret == OK)
{ {
/* Enable link up/down interrupts */ /* Enable link up/down interrupts */
ret = sam_phywrite(priv, priv->phyaddr, GMII_KSZ90x1_ICS, ret = sam_phywrite(priv, priv->phyaddr, GMII_KSZ90X1_ICS,
(GMII_KSZ90x1_INT_LDEN | GMII_KSZ90x1_INT_LUEN)); (GMII_KSZ90X1_INT_LDEN | GMII_KSZ90X1_INT_LUEN));
} }
/* Disable the management port */ /* Disable the management port */
@@ -2961,15 +2963,16 @@ static int sam_autonegotiate(struct sam_gmac_s *priv)
#ifdef SAMA5_GMAC_PHY_KSZ90x1 #ifdef SAMA5_GMAC_PHY_KSZ90x1
/* Set up the KSZ9020/31 PHY */ /* Set up the KSZ9020/31 PHY */
phyval = GMII_KSZ90x1_RCCPSR | GMII_ERCR_WRITE; phyval = GMII_KSZ90X1_RCCPSR | GMII_ERCR_WRITE;
sam_phywrite(priv, priv->phyaddr, GMII_ERCR, phyval); sam_phywrite(priv, priv->phyaddr, GMII_ERCR, phyval);
sam_phywrite(priv, priv->phyaddr, GMII_ERDWR, 0xf2f4); sam_phywrite(priv, priv->phyaddr, GMII_ERDWR, 0xf2f4);
phyval = GMII_KSZ90x1_RRDPSR | GMII_ERCR_WRITE; phyval = GMII_KSZ90X1_RRDPSR | GMII_ERCR_WRITE;
sam_phywrite(priv, priv->phyaddr, GMII_ERCR, phyval); sam_phywrite(priv, priv->phyaddr, GMII_ERCR, phyval);
sam_phywrite(priv, priv->phyaddr, GMII_ERDWR, 0x2222); sam_phywrite(priv, priv->phyaddr, GMII_ERDWR, 0x2222);
ret = sam_phywrite(priv, priv->phyaddr, GMII_KSZ90x1_ICS, 0xff00); ret = sam_phywrite(priv, priv->phyaddr,
GMII_KSZ90X1_ICS, 0xff00);
#endif #endif
/* Set the Auto_negotiation Advertisement Register, MII advertising for /* Set the Auto_negotiation Advertisement Register, MII advertising for
+70 -54
View File
@@ -168,8 +168,8 @@
/* Timing *******************************************************************/ /* Timing *******************************************************************/
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per /* TX poll delay = 1 seconds.
* second * CLK_TCK is the number of clock ticks per second
*/ */
#define SAM_WDDELAY (1*CLK_TCK) #define SAM_WDDELAY (1*CLK_TCK)
@@ -194,7 +194,7 @@
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
/* The sam_gmac_s encapsulates all state information for the GMAC peripheral */ /* The sam_gmac_s encapsulates all state information for GMAC peripheral */
struct sam_gmac_s struct sam_gmac_s
{ {
@@ -264,9 +264,9 @@ static struct gmac_rxdesc_s g_rxdesc[CONFIG_SAMD5E5_GMAC_NRXBUFFERS]
/* Transmit Buffers /* Transmit Buffers
* *
* Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K Boundaries. * Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K
* Receive buffer manager writes are burst of 2 words => 3 lsb bits of the address * Boundaries. Receive buffer manager writes are burst of 2 words => 3
* shall be set to 0 * lsb bits of the address shall be set to 0
*/ */
static uint8_t g_txbuffer[CONFIG_SAMD5E5_GMAC_NTXBUFFERS * GMAC_TX_UNITSIZE] static uint8_t g_txbuffer[CONFIG_SAMD5E5_GMAC_NTXBUFFERS * GMAC_TX_UNITSIZE]
@@ -288,7 +288,8 @@ static uint8_t g_rxbuffer[CONFIG_SAMD5E5_GMAC_NRXBUFFERS * GMAC_RX_UNITSIZE]
static bool sam_checkreg(struct sam_gmac_s *priv, bool wr, static bool sam_checkreg(struct sam_gmac_s *priv, bool wr,
uint32_t regval, uintptr_t address); uint32_t regval, uintptr_t address);
static uint32_t sam_getreg(struct sam_gmac_s *priv, uintptr_t addr); static uint32_t sam_getreg(struct sam_gmac_s *priv, uintptr_t addr);
static void sam_putreg(struct sam_gmac_s *priv, uintptr_t addr, uint32_t val); static void sam_putreg(struct sam_gmac_s *priv,
uintptr_t addr, uint32_t val);
#else #else
# define sam_getreg(priv,addr) getreg32(addr) # define sam_getreg(priv,addr) getreg32(addr)
# define sam_putreg(priv,addr,val) putreg32(val,addr) # define sam_putreg(priv,addr,val) putreg32(val,addr)
@@ -472,8 +473,8 @@ static uint32_t sam_getreg(struct sam_gmac_s *priv, uintptr_t address)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SAMD5E5_GMAC_REGDEBUG #ifdef CONFIG_SAMD5E5_GMAC_REGDEBUG
static void sam_putreg(struct sam_gmac_s *priv, uintptr_t address, static void sam_putreg(struct sam_gmac_s *priv,
uint32_t regval) uintptr_t address, uint32_t regval)
{ {
if (sam_checkreg(priv, true, regval, address)) if (sam_checkreg(priv, true, regval, address))
{ {
@@ -781,8 +782,9 @@ static int sam_transmit(struct sam_gmac_s *priv)
* Function: sam_txpoll * Function: sam_txpoll
* *
* Description: * Description:
* The transmitter is available, check if the network has any outgoing packets ready * The transmitter is available, check if the network has any outgoing
* to send. This is a callback from devif_poll(). devif_poll() may be called: * packets ready to send. This is a callback from devif_poll().
* devif_poll() may be called:
* *
* 1. When the preceding TX packet send is complete, * 1. When the preceding TX packet send is complete,
* 2. When the preceding TX packet send timesout and the interface is reset * 2. When the preceding TX packet send timesout and the interface is reset
@@ -854,8 +856,8 @@ static int sam_txpoll(struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -870,7 +872,8 @@ static int sam_txpoll(struct net_driver_s *dev)
* *
* 1. After completion of a transmission (sam_txdone), * 1. After completion of a transmission (sam_txdone),
* 2. When new TX data is available (sam_txavail), and * 2. When new TX data is available (sam_txavail), and
* 3. After a TX timeout to restart the sending process (sam_txtimeout_expiry). * 3. After a TX timeout to restart the sending process
* (sam_txtimeout_expiry).
* *
* Input Parameters: * Input Parameters:
* priv - Reference to the driver state structure * priv - Reference to the driver state structure
@@ -893,7 +896,9 @@ static void sam_dopoll(struct sam_gmac_s *priv)
if (sam_txfree(priv) > 0) if (sam_txfree(priv) > 0)
{ {
/* If we have the descriptor, then poll the network for new XMIT data. */ /* If we have the descriptor,
* then poll the network for new XMIT data.
*/
devif_poll(dev, sam_txpoll); devif_poll(dev, sam_txpoll);
} }
@@ -1099,7 +1104,8 @@ static int sam_recvframe(struct sam_gmac_s *priv)
if (pktlen < dev->d_len) if (pktlen < dev->d_len)
{ {
nerr("ERROR: Buffer size %d; frame size %d\n", dev->d_len, pktlen); nerr("ERROR: Buffer size %d; frame size %d\n",
dev->d_len, pktlen);
return -E2BIG; return -E2BIG;
} }
@@ -1107,7 +1113,9 @@ static int sam_recvframe(struct sam_gmac_s *priv)
} }
} }
/* We have not encount the SOF yet... discard this fragment and keep looking */ /* We have not encount the SOF yet...
* discard this fragment and keep looking
*/
else else
{ {
@@ -1185,7 +1193,7 @@ static void sam_receive(struct sam_gmac_s *priv)
{ {
sam_dumppacket("Received packet", dev->d_buf, dev->d_len); sam_dumppacket("Received packet", dev->d_buf, dev->d_len);
/* Check if the packet is a valid size for the network buffer configuration /* Check if the packet is a valid size for the network buffer
* (this should not happen) * (this should not happen)
*/ */
@@ -1196,7 +1204,7 @@ static void sam_receive(struct sam_gmac_s *priv)
} }
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -1216,7 +1224,7 @@ static void sam_receive(struct sam_gmac_s *priv)
ipv4_input(&priv->dev); ipv4_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1253,7 +1261,7 @@ static void sam_receive(struct sam_gmac_s *priv)
ipv6_input(&priv->dev); ipv6_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1290,7 +1298,7 @@ static void sam_receive(struct sam_gmac_s *priv)
arp_arpin(&priv->dev); arp_arpin(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1348,8 +1356,8 @@ static void sam_txdone(struct sam_gmac_s *priv)
/* Yes.. the descriptor is still in use. However, I have seen a /* Yes.. the descriptor is still in use. However, I have seen a
* case (only repeatable on start-up) where the USED bit is never * case (only repeatable on start-up) where the USED bit is never
* set. Yikes! If we have encountered the first still busy * set. Yikes! If we have encountered the first still busy
* descriptor, then we should also have TQBD equal to the descriptor * descriptor, then we should also have TQBD equal to the
* address. If it is not, then treat is as used anyway. * descriptor address. If it is not, then treat is as used anyway.
*/ */
#warning REVISIT #warning REVISIT
@@ -1432,8 +1440,8 @@ static void sam_interrupt_work(FAR void *arg)
ninfo("isr: %08x pending: %08x\n", isr, pending); ninfo("isr: %08x pending: %08x\n", isr, pending);
/* Check for the completion of a transmission. This should be done before /* Check for the completion of a transmission. This should be done before
* checking for received data (because receiving can cause another transmission * checking for received data (because receiving can cause another
* before we had a chance to handle the last one). * transmission before we had a chance to handle the last one).
* *
* ISR:TCOMP is set when a frame has been transmitted. Cleared on read. * ISR:TCOMP is set when a frame has been transmitted. Cleared on read.
* TSR:COMP is set when a frame has been transmitted. Cleared by writing a * TSR:COMP is set when a frame has been transmitted. Cleared by writing a
@@ -1583,7 +1591,8 @@ static void sam_interrupt_work(FAR void *arg)
#ifdef CONFIG_DEBUG_NET #ifdef CONFIG_DEBUG_NET
/* Check for PAUSE Frame received (PFRE). /* Check for PAUSE Frame received (PFRE).
* *
* ISR:PFRE indicates that a pause frame has been received. Cleared on a read. * ISR:PFRE indicates that a pause frame has been received.
* Cleared on a read.
*/ */
if ((pending & GMAC_INT_PFNZ) != 0) if ((pending & GMAC_INT_PFNZ) != 0)
@@ -1642,8 +1651,8 @@ static int sam_gmac_interrupt(int irq, void *context, FAR void *arg)
* *
* ISR:TCOMP is set when a frame has been transmitted. Cleared on read (so * ISR:TCOMP is set when a frame has been transmitted. Cleared on read (so
* we cannot read it here). * we cannot read it here).
* TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing a * TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing
* one to this bit. * a one to this bit.
*/ */
tsr = sam_getreg(priv, SAM_GMAC_TSR_OFFSET); tsr = sam_getreg(priv, SAM_GMAC_TSR_OFFSET);
@@ -2208,8 +2217,8 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac)
* Function: sam_rmmac * Function: sam_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
@@ -2306,9 +2315,9 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac)
* specified using the req->reg_no struct field and then write its output * specified using the req->reg_no struct field and then write its output
* to the req->val_out field. * to the req->val_out field.
* *
* When called with SIOCSMIIREG it will write to a register of the PHY that * When called with SIOCSMIIREG it will write to a register of the PHY
* is specified using the req->reg_no struct field and use req->val_in as * that is specified using the req->reg_no struct field and use req->
* its input. * val_in as its input.
* *
* Input Parameters: * Input Parameters:
* dev - Ethernet device structure * dev - Ethernet device structure
@@ -2351,7 +2360,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCGMIIPHY: /* Get MII PHY address */ case SIOCGMIIPHY: /* Get MII PHY address */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->phy_id = priv->phyaddr; req->phy_id = priv->phyaddr;
ret = OK; ret = OK;
} }
@@ -2359,7 +2369,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCGMIIREG: /* Get register from MII PHY */ case SIOCGMIIREG: /* Get register from MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
/* Enable the management port */ /* Enable the management port */
@@ -2377,7 +2388,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCSMIIREG: /* Set register in MII PHY */ case SIOCSMIIREG: /* Set register in MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
/* Enable the management port */ /* Enable the management port */
@@ -2478,13 +2490,13 @@ static int sam_phyintenable(struct sam_gmac_s *priv)
* interrupts * interrupts
*/ */
ret = sam_phyread(priv, priv->phyaddr, GMII_KSZ90x1_ICS, &phyval); ret = sam_phyread(priv, priv->phyaddr, GMII_KSZ90X1_ICS, &phyval);
if (ret == OK) if (ret == OK)
{ {
/* Enable link up/down interrupts */ /* Enable link up/down interrupts */
ret = sam_phywrite(priv, priv->phyaddr, GMII_KSZ90x1_ICS, ret = sam_phywrite(priv, priv->phyaddr, GMII_KSZ90X1_ICS,
(GMII_KSZ90x1_INT_LDEN | GMII_KSZ90x1_INT_LUEN)); (GMII_KSZ90X1_INT_LDEN | GMII_KSZ90X1_INT_LUEN));
} }
/* Disable the management port */ /* Disable the management port */
@@ -2913,15 +2925,16 @@ static int sam_autonegotiate(struct sam_gmac_s *priv)
#ifdef SAMD5E5_GMAC_PHY_KSZ90x1 #ifdef SAMD5E5_GMAC_PHY_KSZ90x1
/* Set up the KSZ9020/31 PHY */ /* Set up the KSZ9020/31 PHY */
phyval = GMII_KSZ90x1_RCCPSR | GMII_ERCR_WRITE; phyval = GMII_KSZ90X1_RCCPSR | GMII_ERCR_WRITE;
sam_phywrite(priv, priv->phyaddr, GMII_ERCR, phyval); sam_phywrite(priv, priv->phyaddr, GMII_ERCR, phyval);
sam_phywrite(priv, priv->phyaddr, GMII_ERDWR, 0xf2f4); sam_phywrite(priv, priv->phyaddr, GMII_ERDWR, 0xf2f4);
phyval = GMII_KSZ90x1_RRDPSR | GMII_ERCR_WRITE; phyval = GMII_KSZ90X1_RRDPSR | GMII_ERCR_WRITE;
sam_phywrite(priv, priv->phyaddr, GMII_ERCR, phyval); sam_phywrite(priv, priv->phyaddr, GMII_ERCR, phyval);
sam_phywrite(priv, priv->phyaddr, GMII_ERDWR, 0x2222); sam_phywrite(priv, priv->phyaddr, GMII_ERDWR, 0x2222);
ret = sam_phywrite(priv, priv->phyaddr, GMII_KSZ90x1_ICS, 0xff00); ret = sam_phywrite(priv, priv->phyaddr,
GMII_KSZ90X1_ICS, 0xff00);
#endif #endif
/* Set the Auto_negotiation Advertisement Register, MII advertising for /* Set the Auto_negotiation Advertisement Register, MII advertising for
@@ -3353,8 +3366,7 @@ static void sam_txreset(struct sam_gmac_s *priv)
/* Flush the entire TX descriptor table to RAM */ /* Flush the entire TX descriptor table to RAM */
up_clean_dcache((uintptr_t)txdesc, up_clean_dcache((uintptr_t)txdesc, (uintptr_t)txdesc +
(uintptr_t)txdesc +
CONFIG_SAMD5E5_GMAC_NTXBUFFERS * sizeof(struct gmac_txdesc_s)); CONFIG_SAMD5E5_GMAC_NTXBUFFERS * sizeof(struct gmac_txdesc_s));
/* Set the Transmit Buffer Queue Base Register */ /* Set the Transmit Buffer Queue Base Register */
@@ -3417,8 +3429,7 @@ static void sam_rxreset(struct sam_gmac_s *priv)
/* Flush the entire RX descriptor table to RAM */ /* Flush the entire RX descriptor table to RAM */
up_clean_dcache((uintptr_t)rxdesc, up_clean_dcache((uintptr_t)rxdesc, (uintptr_t)rxdesc +
(uintptr_t)rxdesc +
CONFIG_SAMD5E5_GMAC_NRXBUFFERS * sizeof(struct gmac_rxdesc_s)); CONFIG_SAMD5E5_GMAC_NRXBUFFERS * sizeof(struct gmac_rxdesc_s));
/* Set the Receive Buffer Queue Base Register */ /* Set the Receive Buffer Queue Base Register */
@@ -3509,9 +3520,12 @@ static void sam_macaddress(struct sam_gmac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname, dev->d_ifname,
dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1], dev->d_mac.ether.ether_addr_octet[0],
dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3], dev->d_mac.ether.ether_addr_octet[1],
dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]); dev->d_mac.ether.ether_addr_octet[2],
dev->d_mac.ether.ether_addr_octet[3],
dev->d_mac.ether.ether_addr_octet[4],
dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address */ /* Set the MAC address */
@@ -3704,8 +3718,8 @@ static int sam_gmac_configure(struct sam_gmac_s *priv)
GMAC_INT_TUR | GMAC_INT_RLEX | GMAC_INT_TFC | GMAC_INT_TCOMP | GMAC_INT_TUR | GMAC_INT_RLEX | GMAC_INT_TFC | GMAC_INT_TCOMP |
GMAC_INT_ROVR | GMAC_INT_HRESP | GMAC_INT_PFNZ | GMAC_INT_PTZ | GMAC_INT_ROVR | GMAC_INT_HRESP | GMAC_INT_PFNZ | GMAC_INT_PTZ |
GMAC_INT_PFTR | GMAC_INT_EXINT | GMAC_INT_DRQFR | GMAC_INT_SFR | GMAC_INT_PFTR | GMAC_INT_EXINT | GMAC_INT_DRQFR | GMAC_INT_SFR |
GMAC_INT_DRQFT | GMAC_INT_SFT | GMAC_INT_PDRQFR | GMAC_INT_PDRSFR | GMAC_INT_DRQFT | GMAC_INT_SFT | GMAC_INT_PDRQFR |
GMAC_INT_PDRQFT | GMAC_INT_PDRSFT; GMAC_INT_PDRSFR | GMAC_INT_PDRQFT | GMAC_INT_PDRSFT;
sam_putreg(priv, SAM_GMAC_IER, regval); sam_putreg(priv, SAM_GMAC_IER, regval);
return OK; return OK;
} }
@@ -3790,7 +3804,8 @@ int sam_gmac_initialize(void)
ret = irq_attach(SAM_IRQ_GMAL, sam_gmac_interrupt, NULL); ret = irq_attach(SAM_IRQ_GMAL, sam_gmac_interrupt, NULL);
if (ret < 0) if (ret < 0)
{ {
nerr("ERROR: Failed to attach the handler to the IRQ%d\n", SAM_IRQ_GMAL); nerr("ERROR: Failed to attach the handler to the IRQ%d\n",
SAM_IRQ_GMAL);
goto errout_with_buffers; goto errout_with_buffers;
} }
@@ -3804,7 +3819,8 @@ int sam_gmac_initialize(void)
ret = sam_ifdown(&priv->dev); ret = sam_ifdown(&priv->dev);
if (ret < 0) if (ret < 0)
{ {
nerr("ERROR: Failed to put the interface in the down state: %d\n", ret); nerr("ERROR: Failed to put the interface in the down state: %d\n",
ret);
goto errout_with_buffers; goto errout_with_buffers;
} }
+93 -65
View File
@@ -97,6 +97,7 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/* If processing is not done at the interrupt level, then work queue support /* If processing is not done at the interrupt level, then work queue support
@@ -410,8 +411,9 @@
#define EMAC1_TX_BUFSIZE (CONFIG_SAMV7_EMAC1_NTXBUFFERS * EMAC_TX_UNITSIZE) #define EMAC1_TX_BUFSIZE (CONFIG_SAMV7_EMAC1_NTXBUFFERS * EMAC_TX_UNITSIZE)
/* Timing *******************************************************************/ /* Timing *******************************************************************/
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per
* second /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/ */
#define SAM_WDDELAY (1*CLK_TCK) #define SAM_WDDELAY (1*CLK_TCK)
@@ -425,6 +427,7 @@
#define PHY_RETRY_MAX 1000000 #define PHY_RETRY_MAX 1000000
/* Helpers ******************************************************************/ /* Helpers ******************************************************************/
/* This is a helper pointer for accessing the contents of the EMAC /* This is a helper pointer for accessing the contents of the EMAC
* header * header
*/ */
@@ -434,6 +437,7 @@
/**************************************************************************** /****************************************************************************
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
/* This structure defines the constant an configured attributes of an EMAC */ /* This structure defines the constant an configured attributes of an EMAC */
struct sam_emacattr_s struct sam_emacattr_s
@@ -452,7 +456,7 @@ struct sam_emacattr_s
uint8_t lsoui; /* LS 2 bits of the 18-bit OUI */ uint8_t lsoui; /* LS 2 bits of the 18-bit OUI */
bool rmii; /* True: RMII vs. False: MII */ bool rmii; /* True: RMII vs. False: MII */
bool clause45; /* True: Clause 45 behavior */ bool clause45; /* True: Clause 45 behavior */
//bool autoneg; /* True: Autonegotiate rate and *plex */ bool autoneg; /* True: Autonegotiate rate and *plex */
bool sralt; /* True: Alternate PHYSR bit access */ bool sralt; /* True: Alternate PHYSR bit access */
union union
@@ -520,7 +524,7 @@ struct sam_queue_s
uint16_t txtail; /* Buffer tail pointer */ uint16_t txtail; /* Buffer tail pointer */
}; };
/* The sam_emac_s encapsulates all state information for the EMAC peripheral */ /* The sam_emac_s encapsulates all state information for EMAC peripheral */
struct sam_emac_s struct sam_emac_s
{ {
@@ -562,6 +566,7 @@ struct sam_emac_s
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
/* Register operations ******************************************************/ /* Register operations ******************************************************/
#ifdef CONFIG_SAMV7_EMAC_REGDEBUG #ifdef CONFIG_SAMV7_EMAC_REGDEBUG
@@ -570,7 +575,8 @@ static bool sam_checkreg(struct sam_emac_s *priv, bool wr,
#endif #endif
static uint32_t sam_getreg(struct sam_emac_s *priv, uint16_t offset); static uint32_t sam_getreg(struct sam_emac_s *priv, uint16_t offset);
static void sam_putreg(struct sam_emac_s *priv, uint16_t offset, uint32_t val); static void sam_putreg(struct sam_emac_s *priv,
uint16_t offset, uint32_t val);
/* Buffer management */ /* Buffer management */
@@ -704,9 +710,9 @@ static struct emac_rxdesc_s g_emac0_rx1desc[DUMMY_NBUFFERS]
/* EMAC0 Transmit Buffers /* EMAC0 Transmit Buffers
* *
* Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K Boundaries. * Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K
* Receive buffer manager writes are burst of 2 words => 3 lsb bits of the address * Boundaries. Receive buffer manager writes are burst of 2 words => 3
* shall be set to 0 * lsb bits of the address shall be set to 0
*/ */
static uint8_t g_emac0_tx0buffer[EMAC0_TX_BUFSIZE] static uint8_t g_emac0_tx0buffer[EMAC0_TX_BUFSIZE]
@@ -720,9 +726,6 @@ static uint8_t g_emac0_tx1buffer[DUMMY_NBUFFERS * DUMMY_BUFSIZE]
static uint8_t g_emac0_rx0buffer[EMAC0_RX_BUFSIZE] static uint8_t g_emac0_rx0buffer[EMAC0_RX_BUFSIZE]
__attribute__((aligned(EMAC_ALIGN))); __attribute__((aligned(EMAC_ALIGN)));
static uint8_t pRxDummyBuffer[DUMMY_NBUFFERS * DUMMY_BUFSIZE]
__attribute__((aligned(EMAC_ALIGN)));
#endif #endif
#ifdef CONFIG_SAMV7_EMAC1 #ifdef CONFIG_SAMV7_EMAC1
@@ -752,9 +755,9 @@ static struct emac_rxdesc_s g_emac1_rx1desc[DUMMY_NBUFFERS]
/* EMAC1 Transmit Buffers /* EMAC1 Transmit Buffers
* *
* Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K Boundaries. * Section 3.6 of AMBA 2.0 spec states that burst should not cross 1K
* Receive buffer manager writes are burst of 2 words => 3 lsb bits of the address * Boundaries. Receive buffer manager writes are burst of 2 words => 3
* shall be set to 0 * lsb bits of the address shall be set to 0
*/ */
static uint8_t g_emac1_tx1buffer[EMAC1_TX_BUFSIZE] static uint8_t g_emac1_tx1buffer[EMAC1_TX_BUFSIZE]
@@ -798,7 +801,7 @@ static const struct sam_emacattr_s g_emac0_attr =
.clause45 = true, .clause45 = true,
#endif #endif
#ifdef CONFIG_SAMV7_EMAC0_AUTONEG #ifdef CONFIG_SAMV7_EMAC0_AUTONEG
//.autoneg = true, .autoneg = true,
#endif #endif
#ifdef CONFIG_SAMV7_EMAC0_PHYSR_ALTCONFIG #ifdef CONFIG_SAMV7_EMAC0_PHYSR_ALTCONFIG
.sralt = true, .sralt = true,
@@ -818,7 +821,8 @@ static const struct sam_emacattr_s g_emac0_attr =
#else #else
.std = .std =
{ {
.stdmask = (CONFIG_SAMV7_EMAC0_PHYSR_SPEED | CONFIG_SAMV7_EMAC0_PHYSR_MODE), .stdmask = CONFIG_SAMV7_EMAC0_PHYSR_SPEED |
CONFIG_SAMV7_EMAC0_PHYSR_MODE,
.speed100 = CONFIG_SAMV7_EMAC0_PHYSR_100MBPS, .speed100 = CONFIG_SAMV7_EMAC0_PHYSR_100MBPS,
.fduplex = CONFIG_SAMV7_EMAC0_PHYSR_FULLDUPLEX, .fduplex = CONFIG_SAMV7_EMAC0_PHYSR_FULLDUPLEX,
}, },
@@ -878,7 +882,7 @@ static const struct sam_emacattr_s g_emac1_attr =
.clause45 = true, .clause45 = true,
#endif #endif
#ifdef CONFIG_SAMV7_EMAC1_AUTONEG #ifdef CONFIG_SAMV7_EMAC1_AUTONEG
//.autoneg = true, .autoneg = true,
#endif #endif
#ifdef CONFIG_SAMV7_EMAC1_PHYSR_ALTCONFIG #ifdef CONFIG_SAMV7_EMAC1_PHYSR_ALTCONFIG
.sralt = true, .sralt = true,
@@ -898,7 +902,8 @@ static const struct sam_emacattr_s g_emac1_attr =
#else #else
.std = .std =
{ {
.stdmask = (CONFIG_SAMV7_EMAC1_PHYSR_SPEED | CONFIG_SAMV7_EMAC1_PHYSR_MODE), .stdmask = CONFIG_SAMV7_EMAC1_PHYSR_SPEED |
CONFIG_SAMV7_EMAC1_PHYSR_MODE,
.speed100 = CONFIG_SAMV7_EMAC1_PHYSR_100MBPS, .speed100 = CONFIG_SAMV7_EMAC1_PHYSR_100MBPS,
.fduplex = CONFIG_SAMV7_EMAC1_PHYSR_FULLDUPLEX, .fduplex = CONFIG_SAMV7_EMAC1_PHYSR_FULLDUPLEX,
}, },
@@ -947,6 +952,7 @@ static uint8_t g_emac_nqueues = EMAC_NQUEUES_REVA; /* Assume Rev A */
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: sam_checkreg * Name: sam_checkreg
* *
@@ -1033,8 +1039,8 @@ static uint32_t sam_getreg(struct sam_emac_s *priv, uint16_t offset)
* *
****************************************************************************/ ****************************************************************************/
static void sam_putreg(struct sam_emac_s *priv, uint16_t offset, static void sam_putreg(struct sam_emac_s *priv,
uint32_t regval) uint16_t offset, uint32_t regval)
{ {
uintptr_t regaddr = priv->attr->base + (uintptr_t)offset; uintptr_t regaddr = priv->attr->base + (uintptr_t)offset;
@@ -1161,8 +1167,9 @@ static int sam_buffer_allocate(struct sam_emac_s *priv)
/* Allocate Queue 0 buffers */ /* Allocate Queue 0 buffers */
allocsize = EMAC_ALIGN_UP(priv->attr->ntxbuffers * sizeof(struct emac_txdesc_s)); allocsize = EMAC_ALIGN_UP(priv->attr->ntxbuffers *
priv->xfrq[0].txdesc = (struct emac_txdesc_s *)kmm_memalign(EMAC_ALIGN, allocsize); sizeof(struct emac_txdesc_s));
priv->xfrq[0].txdesc = kmm_memalign(EMAC_ALIGN, allocsize);
if (!priv->xfrq[0].txdesc) if (!priv->xfrq[0].txdesc)
{ {
nerr("ERROR: Failed to allocate TX descriptors\n"); nerr("ERROR: Failed to allocate TX descriptors\n");
@@ -1172,8 +1179,9 @@ static int sam_buffer_allocate(struct sam_emac_s *priv)
memset(priv->xfrq[0].txdesc, 0, allocsize); memset(priv->xfrq[0].txdesc, 0, allocsize);
priv->xfrq[0].ntxbuffers = priv->attr->ntxbuffers; priv->xfrq[0].ntxbuffers = priv->attr->ntxbuffers;
allocsize = EMAC_ALIGN_UP(priv->attr->nrxbuffers * sizeof(struct emac_rxdesc_s)); allocsize = EMAC_ALIGN_UP(priv->attr->nrxbuffers *
priv->xfrq[0].rxdesc = (struct emac_rxdesc_s *)kmm_memalign(EMAC_ALIGN, allocsize); sizeof(struct emac_rxdesc_s));
priv->xfrq[0].rxdesc = kmm_memalign(EMAC_ALIGN, allocsize);
if (!priv->xfrq[0].rxdesc) if (!priv->xfrq[0].rxdesc)
{ {
nerr("ERROR: Failed to allocate RX descriptors\n"); nerr("ERROR: Failed to allocate RX descriptors\n");
@@ -1209,7 +1217,7 @@ static int sam_buffer_allocate(struct sam_emac_s *priv)
/* Allocate Queue 1 buffers */ /* Allocate Queue 1 buffers */
allocsize = EMAC_ALIGN_UP(DUMMY_NBUFFERS * sizeof(struct emac_txdesc_s)); allocsize = EMAC_ALIGN_UP(DUMMY_NBUFFERS * sizeof(struct emac_txdesc_s));
priv->xfrq[1].txdesc = (struct emac_txdesc_s *)kmm_memalign(EMAC_ALIGN, allocsize); priv->xfrq[1].txdesc = kmm_memalign(EMAC_ALIGN, allocsize);
if (!priv->xfrq[1].txdesc) if (!priv->xfrq[1].txdesc)
{ {
nerr("ERROR: Failed to allocate TX descriptors\n"); nerr("ERROR: Failed to allocate TX descriptors\n");
@@ -1220,7 +1228,7 @@ static int sam_buffer_allocate(struct sam_emac_s *priv)
priv->xfrq[1].ntxbuffers = DUMMY_NBUFFERS; priv->xfrq[1].ntxbuffers = DUMMY_NBUFFERS;
allocsize = EMAC_ALIGN_UP(DUMMY_NBUFFERS * sizeof(struct emac_rxdesc_s)); allocsize = EMAC_ALIGN_UP(DUMMY_NBUFFERS * sizeof(struct emac_rxdesc_s));
priv->xfrq[1].rxdesc = (struct emac_rxdesc_s *)kmm_memalign(EMAC_ALIGN, allocsize); priv->xfrq[1].rxdesc = kmm_memalign(EMAC_ALIGN, allocsize);
if (!priv->xfrq[1].rxdesc) if (!priv->xfrq[1].rxdesc)
{ {
nerr("ERROR: Failed to allocate RX descriptors\n"); nerr("ERROR: Failed to allocate RX descriptors\n");
@@ -1563,8 +1571,8 @@ static int sam_txpoll(struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -1605,7 +1613,9 @@ static void sam_dopoll(struct sam_emac_s *priv, int qid)
if (sam_txfree(priv, qid) > 0) if (sam_txfree(priv, qid) > 0)
{ {
/* If we have the descriptor, then poll the network for new XMIT data. */ /* If we have the descriptor,
* then poll the network for new XMIT data.
*/
devif_poll(dev, sam_txpoll); devif_poll(dev, sam_txpoll);
} }
@@ -1937,7 +1947,7 @@ static void sam_receive(struct sam_emac_s *priv, int qid)
} }
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -1958,7 +1968,7 @@ static void sam_receive(struct sam_emac_s *priv, int qid)
ipv4_input(&priv->dev); ipv4_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1996,7 +2006,7 @@ static void sam_receive(struct sam_emac_s *priv, int qid)
ipv6_input(&priv->dev); ipv6_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -2034,7 +2044,7 @@ static void sam_receive(struct sam_emac_s *priv, int qid)
arp_arpin(&priv->dev); arp_arpin(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -2389,17 +2399,18 @@ static void sam_interrupt_work(FAR void *arg)
} }
/* Check for the completion of a transmission. This should be done before /* Check for the completion of a transmission. This should be done before
* checking for received data (because receiving can cause another transmission * checking for received data (because receiving can cause another
* before we had a chance to handle the last one). * transmission before we had a chance to handle the last one).
* *
* ISR:TCOMP is set when a frame has been transmitted. Cleared on read. * ISR:TCOMP is set when a frame has been transmitted. Cleared on read.
* TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing a * TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing
* one to this bit. * a one to this bit.
*/ */
if ((pending & EMAC_INT_TCOMP) != 0 || (tsr & EMAC_TSR_TXCOMP) != 0) if ((pending & EMAC_INT_TCOMP) != 0 || (tsr & EMAC_TSR_TXCOMP) != 0)
{ {
/* A frame has been transmitted */ /* A frame has been transmitted */
/* Check for Retry Limit Exceeded (RLE) */ /* Check for Retry Limit Exceeded (RLE) */
if ((tsr & EMAC_TSR_RLE) != 0) if ((tsr & EMAC_TSR_RLE) != 0)
@@ -2428,7 +2439,8 @@ static void sam_interrupt_work(FAR void *arg)
if ((tsr & EMAC_TSR_TFC) != 0) if ((tsr & EMAC_TSR_TFC) != 0)
{ {
nerr("ERROR: Transmit Frame Corruption due to AHB error: %08x\n", tsr); nerr("ERROR: Transmit Frame Corruption due to AHB error: %08x\n",
tsr);
NETDEV_TXERRORS(&priv->dev); NETDEV_TXERRORS(&priv->dev);
} }
@@ -2512,8 +2524,8 @@ static int sam_emac_interrupt(int irq, void *context, FAR void *arg)
* *
* ISR:TCOMP is set when a frame has been transmitted. Cleared on read (so * ISR:TCOMP is set when a frame has been transmitted. Cleared on read (so
* we cannot read it here). * we cannot read it here).
* TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing a * TSR:TXCOMP is set when a frame has been transmitted. Cleared by writing
* one to this bit. * a one to this bit.
*/ */
tsr = sam_getreg(priv, SAM_EMAC_TSR_OFFSET); tsr = sam_getreg(priv, SAM_EMAC_TSR_OFFSET);
@@ -2924,7 +2936,8 @@ static unsigned int sam_hashindx(const uint8_t *mac)
unsigned int ndx; unsigned int ndx;
/* Isolate: mac[0] /* Isolate: mac[0]
* ... 05 04 03 02 01 00] */ * ... 05 04 03 02 01 00]
*/
ndx = mac[0]; ndx = mac[0];
@@ -3094,8 +3107,8 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac)
* Function: sam_rmmac * Function: sam_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
@@ -3191,9 +3204,9 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac)
* specified using the req->reg_no struct field and then write its output * specified using the req->reg_no struct field and then write its output
* to the req->val_out field. * to the req->val_out field.
* *
* When called with SIOCSMIIREG it will write to a register of the PHY that * When called with SIOCSMIIREG it will write to a register of the PHY
* is specified using the req->reg_no struct field and use req->val_in as * that is specified using the req->reg_no struct field and use req->
* its input. * val_in as its input.
* *
* Input Parameters: * Input Parameters:
* dev - Ethernet device structure * dev - Ethernet device structure
@@ -3220,7 +3233,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
#ifdef CONFIG_ARCH_PHY_INTERRUPT #ifdef CONFIG_ARCH_PHY_INTERRUPT
case SIOCMIINOTIFY: /* Set up for PHY event notifications */ case SIOCMIINOTIFY: /* Set up for PHY event notifications */
{ {
struct mii_ioctl_notify_s *req = (struct mii_ioctl_notify_s *)((uintptr_t)arg); struct mii_ioctl_notify_s *req =
(struct mii_ioctl_notify_s *)((uintptr_t)arg);
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event); ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
if (ret == OK) if (ret == OK)
@@ -3235,7 +3249,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCGMIIPHY: /* Get MII PHY address */ case SIOCGMIIPHY: /* Get MII PHY address */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->phy_id = priv->phyaddr; req->phy_id = priv->phyaddr;
ret = OK; ret = OK;
} }
@@ -3243,7 +3258,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCGMIIREG: /* Get register from MII PHY */ case SIOCGMIIREG: /* Get register from MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
uint32_t regval; uint32_t regval;
/* Enable management port */ /* Enable management port */
@@ -3263,7 +3279,8 @@ static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
case SIOCSMIIREG: /* Set register in MII PHY */ case SIOCSMIIREG: /* Set register in MII PHY */
{ {
struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
uint32_t regval; uint32_t regval;
/* Enable management port */ /* Enable management port */
@@ -3744,7 +3761,7 @@ static int sam_phyread(struct sam_emac_s *priv, uint8_t phyaddr,
/* Return data */ /* Return data */
*phyval = (uint16_t)(sam_getreg(priv, SAM_EMAC_MAN_OFFSET) & EMAC_MAN_DATA_MASK); *phyval = sam_getreg(priv, SAM_EMAC_MAN_OFFSET) & EMAC_MAN_DATA_MASK;
return OK; return OK;
} }
@@ -4037,6 +4054,7 @@ static int sam_autonegotiate(struct sam_emac_s *priv)
sam_putreg(priv, SAM_EMAC_NCR_OFFSET, ncr); sam_putreg(priv, SAM_EMAC_NCR_OFFSET, ncr);
errout: errout:
/* Disable management port */ /* Disable management port */
regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET);
@@ -4133,6 +4151,7 @@ static bool sam_linkup(struct sam_emac_s *priv)
linkup = true; linkup = true;
errout: errout:
/* Disable management port */ /* Disable management port */
regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET);
@@ -4168,28 +4187,28 @@ static int sam_phyinit(struct sam_emac_s *priv)
regval &= ~EMAC_NCFGR_CLK_MASK; regval &= ~EMAC_NCFGR_CLK_MASK;
mck = BOARD_MCK_FREQUENCY; mck = BOARD_MCK_FREQUENCY;
if (mck > (240*1000*1000)) if (mck > (240 * 1000 * 1000))
{ {
nerr("ERROR: Cannot realize PHY clock\n"); nerr("ERROR: Cannot realize PHY clock\n");
return -EINVAL; return -EINVAL;
} }
else if (mck > (160*1000*1000)) else if (mck > (160 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV96; /* MCK divided by 64 (MCK up to 240 MHz) */ regval |= EMAC_NCFGR_CLK_DIV96; /* MCK divided by 64 (MCK up to 240 MHz) */
} }
else if (mck > (120*1000*1000)) else if (mck > (120 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV64; /* MCK divided by 64 (MCK up to 160 MHz) */ regval |= EMAC_NCFGR_CLK_DIV64; /* MCK divided by 64 (MCK up to 160 MHz) */
} }
else if (mck > (80*1000*1000)) else if (mck > (80 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV48; /* MCK divided by 64 (MCK up to 120 MHz) */ regval |= EMAC_NCFGR_CLK_DIV48; /* MCK divided by 64 (MCK up to 120 MHz) */
} }
else if (mck > (40*1000*1000)) else if (mck > (40 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV32; /* MCK divided by 32 (MCK up to 80 MHz) */ regval |= EMAC_NCFGR_CLK_DIV32; /* MCK divided by 32 (MCK up to 80 MHz) */
} }
else if (mck > (20*1000*1000)) else if (mck > (20 * 1000 * 1000))
{ {
regval |= EMAC_NCFGR_CLK_DIV16; /* MCK divided by 16 (MCK up to 40 MHz) */ regval |= EMAC_NCFGR_CLK_DIV16; /* MCK divided by 16 (MCK up to 40 MHz) */
} }
@@ -4373,7 +4392,9 @@ static void sam_txreset(struct sam_emac_s *priv, int qid)
{ {
bufaddr = (uintptr_t)&txbuffer[ndx * xfrq->txbufsize]; bufaddr = (uintptr_t)&txbuffer[ndx * xfrq->txbufsize];
/* Set the buffer address and mark the descriptor as in used by firmware */ /* Set the buffer address and mark the descriptor
* as in used by firmware
*/
txdesc[ndx].addr = bufaddr; txdesc[ndx].addr = bufaddr;
txdesc[ndx].status = EMACTXD_STA_USED; txdesc[ndx].status = EMACTXD_STA_USED;
@@ -4674,9 +4695,12 @@ static void sam_macaddress(struct sam_emac_s *priv)
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname, dev->d_ifname,
dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1], dev->d_mac.ether.ether_addr_octet[0],
dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3], dev->d_mac.ether.ether_addr_octet[1],
dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]); dev->d_mac.ether.ether_addr_octet[2],
dev->d_mac.ether.ether_addr_octet[3],
dev->d_mac.ether.ether_addr_octet[4],
dev->d_mac.ether.ether_addr_octet[5]);
/* Set the MAC address */ /* Set the MAC address */
@@ -5077,7 +5101,8 @@ int sam_emac_initialize(int intf)
ret = sam_ifdown(&priv->dev); ret = sam_ifdown(&priv->dev);
if (ret < 0) if (ret < 0)
{ {
nerr("ERROR: Failed to put the interface in the down state: %d\n", ret); nerr("ERROR: Failed to put the interface in the down state: %d\n",
ret);
goto errout_with_buffers; goto errout_with_buffers;
} }
@@ -5163,9 +5188,12 @@ int sam_emac_setmacaddr(int intf, uint8_t mac[6])
ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", ninfo("%s MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
dev->d_ifname, dev->d_ifname,
dev->d_mac.ether.ether_addr_octet[0], dev->d_mac.ether.ether_addr_octet[1], dev->d_mac.ether.ether_addr_octet[0],
dev->d_mac.ether.ether_addr_octet[2], dev->d_mac.ether.ether_addr_octet[3], dev->d_mac.ether.ether_addr_octet[1],
dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]); dev->d_mac.ether.ether_addr_octet[2],
dev->d_mac.ether.ether_addr_octet[3],
dev->d_mac.ether.ether_addr_octet[4],
dev->d_mac.ether.ether_addr_octet[5]);
return OK; return OK;
} }
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+20 -19
View File
@@ -269,8 +269,8 @@
/* Timing *******************************************************************/ /* Timing *******************************************************************/
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per /* TX poll delay = 1 seconds.
* second * CLK_TCK is the number of clock ticks per second
*/ */
#define STM32_WDDELAY (1*CLK_TCK) #define STM32_WDDELAY (1*CLK_TCK)
@@ -1355,8 +1355,8 @@ static int stm32_txpoll(struct net_driver_s *dev)
* CPU. We cannot perform the TX poll if we are unable to accept * CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission. * another packet for transmission.
* *
* In a race condition, ETH_TDES3_OWN may be cleared BUT still not * In a race condition, ETH_TDES3_OWN may be cleared BUT still
* available because stm32_freeframe() has not yet run. If * not available because stm32_freeframe() has not yet run. If
* stm32_freeframe() has run, the buffer1 pointer (tdes2) will be * stm32_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_STM32H7_ETH_NTXDESC). * nullified (and inflight should be < CONFIG_STM32H7_ETH_NTXDESC).
*/ */
@@ -1429,8 +1429,8 @@ static void stm32_dopoll(struct stm32_ethmac_s *priv)
* CPU. We cannot perform the TX poll if we are unable to accept * CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission. * another packet for transmission.
* *
* In a race condition, ETH_TDES3_RD_OWN may be cleared BUT still not * In a race condition, ETH_TDES3_RD_OWN may be cleared BUT still
* available because stm32_freeframe() has not yet run. If * not available because stm32_freeframe() has not yet run. If
* stm32_freeframe() has run, the buffer1 pointer (des0) will be * stm32_freeframe() has run, the buffer1 pointer (des0) will be
* nullified (and inflight should be < CONFIG_STM32H7_ETH_NTXDESC). * nullified (and inflight should be < CONFIG_STM32H7_ETH_NTXDESC).
*/ */
@@ -1848,8 +1848,8 @@ static int stm32_recvframe(struct stm32_ethmac_s *priv)
} }
/* We get here after all of the descriptors have been scanned or when /* We get here after all of the descriptors have been scanned or when
* rxdesc points to the first descriptor owned by the DMA. Remember where * rxdesc points to the first descriptor owned by the DMA. Remember
* we left off. * where we left off.
*/ */
priv->rxhead = rxdesc; priv->rxhead = rxdesc;
@@ -2114,9 +2114,9 @@ static void stm32_freeframe(struct stm32_ethmac_s *priv)
priv->inflight--; priv->inflight--;
/* If all of the TX descriptors were in-flight, then RX /* If all of the TX descriptors were in-flight,
* interrupts may have been disabled... we can re-enable them * then RX interrupts may have been disabled...
* now. * we can re-enable them now.
*/ */
stm32_enableint(priv, ETH_DMACIER_RIE); stm32_enableint(priv, ETH_DMACIER_RIE);
@@ -2454,15 +2454,16 @@ static void stm32_poll_work(void *arg)
struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg; struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)arg;
struct net_driver_s *dev = &priv->dev; struct net_driver_s *dev = &priv->dev;
/* Check if the next TX descriptor is owned by the Ethernet DMA or CPU. /* Check if the next TX descriptor is owned by the Ethernet DMA or
* We cannot perform the timer poll if we are unable to accept another * CPU. We cannot perform the timer poll if we are unable to accept
* packet for transmission. Hmmm.. might be bug here. Does this mean if * another packet for transmission. Hmmm.. might be bug here.
* there is a transmit in progress, we will miss TCP time state updates? * Does this mean if there is a transmit in progress, we will miss
* TCP time state updates?
* *
* In a race condition, ETH_TDES3_OWN may be cleared BUT still not * In a race condition, ETH_TDES3_OWN may be cleared BUT still
* available because stm32_freeframe() has not yet run. If * not available because stm32_freeframe() has not yet run. If
* stm32_freeframe() has run, the buffer1 pointer (des2) will be nullified * stm32_freeframe() has run, the buffer1 pointer (des2) will be
* (and inflight should be < CONFIG_STM32H7_ETH_NTXDESC). * nullified (and inflight should be < CONFIG_STM32H7_ETH_NTXDESC).
*/ */
net_lock(); net_lock();
+65 -46
View File
@@ -103,7 +103,9 @@
# define TIVA_DUPLEX_CLRBITS 0 # define TIVA_DUPLEX_CLRBITS 0
#endif #endif
/* Auto CRC generation can be suppressed if CONFIG_TIVA_ETHNOAUTOCRC is definde */ /* Auto CRC generation can be suppressed
* if CONFIG_TIVA_ETHNOAUTOCRC is defined
*/
#ifdef CONFIG_TIVA_ETHNOAUTOCRC #ifdef CONFIG_TIVA_ETHNOAUTOCRC
# define TIVA_CRC_SETBITS 0 # define TIVA_CRC_SETBITS 0
@@ -159,7 +161,7 @@
#define TIVA_RCTCL_SETBITS (TIVA_AMUL_SETBITS|TIVA_PRMS_SETBITS|TIVA_BADCRC_SETBITS) #define TIVA_RCTCL_SETBITS (TIVA_AMUL_SETBITS|TIVA_PRMS_SETBITS|TIVA_BADCRC_SETBITS)
#define TIVA_RCTCL_CLRBITS (TIVA_AMUL_CLRBITS|TIVA_PRMS_CLRBITS|TIVA_BADCRC_CLRBITS) #define TIVA_RCTCL_CLRBITS (TIVA_AMUL_CLRBITS|TIVA_PRMS_CLRBITS|TIVA_BADCRC_CLRBITS)
/* CONFIG_TIVA_DUMPPACKET will dump the contents of each packet to the console. */ /* CONFIG_TIVA_DUMPPACKET will dump the contents of each packet. */
#ifdef CONFIG_TIVA_DUMPPACKET #ifdef CONFIG_TIVA_DUMPPACKET
# define tiva_dumppacket(m,a,n) lib_dumpbuffer(m,a,n) # define tiva_dumppacket(m,a,n) lib_dumpbuffer(m,a,n)
@@ -167,7 +169,9 @@
# define tiva_dumppacket(m,a,n) # define tiva_dumppacket(m,a,n)
#endif #endif
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll deley = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define TIVA_WDDELAY (1*CLK_TCK) #define TIVA_WDDELAY (1*CLK_TCK)
@@ -175,7 +179,7 @@
#define TIVA_TXTIMEOUT (60*CLK_TCK) #define TIVA_TXTIMEOUT (60*CLK_TCK)
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* This is a helper pointer for accessing the contents of Ethernet header */
#define ETHBUF ((struct eth_hdr_s *)priv->ld_dev.d_buf) #define ETHBUF ((struct eth_hdr_s *)priv->ld_dev.d_buf)
@@ -231,14 +235,17 @@ static struct tiva_driver_s g_lm3sdev[TIVA_NETHCONTROLLERS];
#if TIVA_NETHCONTROLLERS > 1 #if TIVA_NETHCONTROLLERS > 1
static uint32_t tiva_ethin(struct tiva_driver_s *priv, int offset); static uint32_t tiva_ethin(struct tiva_driver_s *priv, int offset);
static void tiva_ethout(struct tiva_driver_s *priv, int offset, uint32_t value); static void tiva_ethout(struct tiva_driver_s *priv,
int offset, uint32_t value);
#else #else
static inline uint32_t tiva_ethin(struct tiva_driver_s *priv, int offset); static inline uint32_t tiva_ethin(struct tiva_driver_s *priv, int offset);
static inline void tiva_ethout(struct tiva_driver_s *priv, int offset, uint32_t value); static inline void tiva_ethout(struct tiva_driver_s *priv,
int offset, uint32_t value);
#endif #endif
static void tiva_ethreset(struct tiva_driver_s *priv); static void tiva_ethreset(struct tiva_driver_s *priv);
#if 0 /* Not used */ #if 0 /* Not used */
static void tiva_phywrite(struct tiva_driver_s *priv, int regaddr, uint16_t value); static void tiva_phywrite(struct tiva_driver_s *priv,
int regaddr, uint16_t value);
#endif #endif
#ifndef CONFIG_TIVA_WITH_QEMU #ifndef CONFIG_TIVA_WITH_QEMU
static uint16_t tiva_phyread(struct tiva_driver_s *priv, int regaddr); static uint16_t tiva_phyread(struct tiva_driver_s *priv, int regaddr);
@@ -326,12 +333,14 @@ static inline uint32_t tiva_ethin(struct tiva_driver_s *priv, int offset)
****************************************************************************/ ****************************************************************************/
#if TIVA_NETHCONTROLLERS > 1 #if TIVA_NETHCONTROLLERS > 1
static void tiva_ethout(struct tiva_driver_s *priv, int offset, uint32_t value) static void tiva_ethout(struct tiva_driver_s *priv,
int offset, uint32_t value)
{ {
putreg32(value, priv->ld_base + offset); putreg32(value, priv->ld_base + offset);
} }
#else #else
static inline void tiva_ethout(struct tiva_driver_s *priv, int offset, uint32_t value) static inline void tiva_ethout(struct tiva_driver_s *priv,
int offset, uint32_t value)
{ {
putreg32(value, TIVA_ETHCON_BASE + offset); putreg32(value, TIVA_ETHCON_BASE + offset);
} }
@@ -362,7 +371,7 @@ static void tiva_ethreset(struct tiva_driver_s *priv)
# error "If multiple interfaces are supported, this function would have to be redesigned" # error "If multiple interfaces are supported, this function would have to be redesigned"
#endif #endif
/* Make sure that clocking is enabled for the Ethernet (and PHY) peripherals */ /* Make sure that clocking is enabled for the Ethernet&PHY peripherals */
flags = enter_critical_section(); flags = enter_critical_section();
regval = getreg32(TIVA_SYSCON_RCGC2); regval = getreg32(TIVA_SYSCON_RCGC2);
@@ -386,7 +395,9 @@ static void tiva_ethreset(struct tiva_driver_s *priv)
putreg32(regval, TIVA_SYSCON_SRCR2); putreg32(regval, TIVA_SYSCON_SRCR2);
ninfo("SRCR2: %08x\n", regval); ninfo("SRCR2: %08x\n", regval);
/* Wait just a bit, again. If we touch the ethernet too soon, we may busfault. */ /* Wait just a bit, again.
* If we touch the ethernet too soon, we may busfault.
*/
up_mdelay(2); up_mdelay(2);
@@ -429,7 +440,8 @@ static void tiva_ethreset(struct tiva_driver_s *priv)
****************************************************************************/ ****************************************************************************/
#if 0 /* Not used */ #if 0 /* Not used */
static void tiva_phywrite(struct tiva_driver_s *priv, int regaddr, uint16_t value) static void tiva_phywrite(struct tiva_driver_s *priv,
int regaddr, uint16_t value)
{ {
/* Wait for any MII transactions in progress to complete */ /* Wait for any MII transactions in progress to complete */
@@ -444,7 +456,8 @@ static void tiva_phywrite(struct tiva_driver_s *priv, int regaddr, uint16_t valu
regaddr <<= MAC_MCTL_REGADR_SHIFT; regaddr <<= MAC_MCTL_REGADR_SHIFT;
DEBUGASSERT((regaddr & MAC_MTXD_MASK) == regaddr); DEBUGASSERT((regaddr & MAC_MTXD_MASK) == regaddr);
tiva_ethout(priv, TIVA_MAC_MCTL_OFFSET, regaddr | MAC_MCTL_WRITE | MAC_MCTL_START); tiva_ethout(priv, TIVA_MAC_MCTL_OFFSET,
regaddr | MAC_MCTL_WRITE | MAC_MCTL_START);
/* Wait for the write transaction to complete */ /* Wait for the write transaction to complete */
@@ -523,7 +536,8 @@ static int tiva_transmit(struct tiva_driver_s *priv)
/* Increment statistics */ /* Increment statistics */
NETDEV_TXPACKETS(&priv->ld_dev); NETDEV_TXPACKETS(&priv->ld_dev);
tiva_dumppacket("Transmit packet", priv->ld_dev.d_buf, priv->ld_dev.d_len); tiva_dumppacket("Transmit packet",
priv->ld_dev.d_buf, priv->ld_dev.d_len);
/* Transfer the packet into the Tx FIFO. The LS 16-bits of the first /* Transfer the packet into the Tx FIFO. The LS 16-bits of the first
* 32-bit word written to the Tx FIFO contains the Ethernet payload * 32-bit word written to the Tx FIFO contains the Ethernet payload
@@ -596,8 +610,9 @@ static int tiva_transmit(struct tiva_driver_s *priv)
* Function: tiva_txpoll * Function: tiva_txpoll
* *
* Description: * Description:
* The transmitter is available, check if the network has any outgoing packets ready * The transmitter is available, check if the network has any outgoing
* to send. This is a callback from devif_poll(). devif_poll() may be called: * packets ready to send. This is a callback from devif_poll().
* devif_poll() may be called:
* *
* 1. When the preceding TX packet send is complete, * 1. When the preceding TX packet send is complete,
* 2. When the preceding TX packet send timesout and the interface is reset * 2. When the preceding TX packet send timesout and the interface is reset
@@ -625,7 +640,7 @@ static int tiva_txpoll(struct net_driver_s *dev)
ninfo("Poll result: d_len=%d\n", priv->ld_dev.d_len); ninfo("Poll result: d_len=%d\n", priv->ld_dev.d_len);
if (priv->ld_dev.d_len > 0) if (priv->ld_dev.d_len > 0)
{ {
DEBUGASSERT((tiva_ethin(priv, TIVA_MAC_TR_OFFSET) & MAC_TR_NEWTX) == 0); DEBUGASSERT(!!(tiva_ethin(priv, TIVA_MAC_TR_OFFSET) & MAC_TR_NEWTX));
/* Look up the destination MAC address and add it to the Ethernet /* Look up the destination MAC address and add it to the Ethernet
* header. * header.
@@ -659,8 +674,8 @@ static int tiva_txpoll(struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return ret; return ret;
@@ -721,7 +736,7 @@ static void tiva_receive(struct tiva_driver_s *priv)
* and 4 byte FCS that are not copied into the network packet. * and 4 byte FCS that are not copied into the network packet.
*/ */
if (pktlen > (CONFIG_NET_ETH_PKTSIZE + 6) || pktlen <= (ETH_HDRLEN + 6)) if (pktlen > CONFIG_NET_ETH_PKTSIZE + 6 || pktlen <= ETH_HDRLEN + 6)
{ {
int wordlen; int wordlen;
@@ -730,8 +745,9 @@ static void tiva_receive(struct tiva_driver_s *priv)
nwarn("WARNING: Bad packet size dropped (%d)\n", pktlen); nwarn("WARNING: Bad packet size dropped (%d)\n", pktlen);
NETDEV_RXERRORS(&priv->ld_dev); NETDEV_RXERRORS(&priv->ld_dev);
/* The number of bytes and words left to read is pktlen - 4 (including, /* The number of bytes and words left to read is pktlen - 4
* the final, possibly partial word) because we've already read 4 bytes. * (including, the final, possibly partial word) because we've
* already read 4 bytes.
*/ */
wordlen = (pktlen - 1) >> 2; wordlen = (pktlen - 1) >> 2;
@@ -793,15 +809,16 @@ static void tiva_receive(struct tiva_driver_s *priv)
} }
} }
/* Pass the packet length to the network MINUS 2 bytes for the length and /* Pass the packet length to the network MINUS 2 bytes for the length
* 4 bytes for the FCS. * and 4 bytes for the FCS.
*/ */
priv->ld_dev.d_len = pktlen - 6; priv->ld_dev.d_len = pktlen - 6;
tiva_dumppacket("Received packet", priv->ld_dev.d_buf, priv->ld_dev.d_len); tiva_dumppacket("Received packet",
priv->ld_dev.d_buf, priv->ld_dev.d_len);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->ld_dev); pkt_input(&priv->ld_dev);
#endif #endif
@@ -822,7 +839,7 @@ static void tiva_receive(struct tiva_driver_s *priv)
ipv4_input(&priv->ld_dev); ipv4_input(&priv->ld_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->ld_dev.d_len > 0) if (priv->ld_dev.d_len > 0)
@@ -861,7 +878,7 @@ static void tiva_receive(struct tiva_driver_s *priv)
ipv6_input(&priv->ld_dev); ipv6_input(&priv->ld_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -897,7 +914,7 @@ static void tiva_receive(struct tiva_driver_s *priv)
arp_arpin(&priv->ld_dev); arp_arpin(&priv->ld_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->ld_dev.d_len > 0) if (priv->ld_dev.d_len > 0)
@@ -1312,8 +1329,8 @@ static int tiva_ifup(struct net_driver_s *dev)
/* Then configure the Ethernet Controller for normal operation /* Then configure the Ethernet Controller for normal operation
* *
* Setup the transmit control register (Full duplex, TX CRC Auto Generation, * Setup the transmit control register (Full duplex, TX CRC Auto
* TX Padding Enabled). * Generation, TX Padding Enabled).
*/ */
regval = tiva_ethin(priv, TIVA_MAC_TCTL_OFFSET); regval = tiva_ethin(priv, TIVA_MAC_TCTL_OFFSET);
@@ -1534,10 +1551,11 @@ static void tiva_txavail_work(void *arg)
*/ */
net_lock(); net_lock();
if (priv->ld_bifup && (tiva_ethin(priv, TIVA_MAC_TR_OFFSET) & MAC_TR_NEWTX) == 0) if (priv->ld_bifup &&
(tiva_ethin(priv, TIVA_MAC_TR_OFFSET) & MAC_TR_NEWTX) == 0)
{ {
/* If the interface is up and we can use the Tx FIFO, then poll the network /* If the interface is up and we can use the Tx FIFO, then poll the
* for new Tx data * network for new Tx data
*/ */
devif_poll(&priv->ld_dev, tiva_txpoll); devif_poll(&priv->ld_dev, tiva_txpoll);
@@ -1618,8 +1636,8 @@ static int tiva_addmac(struct net_driver_s *dev, const uint8_t *mac)
* Function: tiva_rmmac * Function: tiva_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
@@ -1680,7 +1698,8 @@ static inline int tiva_ethinitialize(int intf)
#if TIVA_NETHCONTROLLERS > 1 #if TIVA_NETHCONTROLLERS > 1
# error "This debug check only works with one interface" # error "This debug check only works with one interface"
#else #else
DEBUGASSERT((getreg32(TIVA_SYSCON_DC4) & (SYSCON_DC4_EMAC0 | SYSCON_DC4_EPHY0)) == DEBUGASSERT((getreg32(TIVA_SYSCON_DC4) &
(SYSCON_DC4_EMAC0 | SYSCON_DC4_EPHY0)) ==
(SYSCON_DC4_EMAC0 | SYSCON_DC4_EPHY0)); (SYSCON_DC4_EMAC0 | SYSCON_DC4_EPHY0));
#endif #endif
DEBUGASSERT((unsigned)intf < TIVA_NETHCONTROLLERS); DEBUGASSERT((unsigned)intf < TIVA_NETHCONTROLLERS);
@@ -1717,9 +1736,9 @@ static inline int tiva_ethinitialize(int intf)
tiva_ethernetmac(&priv->ld_dev.d_mac.ether); tiva_ethernetmac(&priv->ld_dev.d_mac.ether);
#endif #endif
/* Perform minimal, one-time initialization -- just reset the controller and /* Perform minimal, one-time initialization -- just reset the controller
* leave it disabled. The Ethernet controller will be reset and properly * and leave it disabled. The Ethernet controller will be reset and
* re-initialized each time tiva_ifup() is called. * properly re-initialized each time tiva_ifup() is called.
*/ */
tiva_ethreset(priv); tiva_ethreset(priv);
@@ -1745,16 +1764,16 @@ static inline int tiva_ethinitialize(int intf)
return OK; return OK;
} }
/****************************************************************************
/************************************************************************************
* Name: arm_netinitialize * Name: arm_netinitialize
* *
* Description: * Description:
* Initialize the first network interface. If there are more than one interface * Initialize the first network interface. If there are more than one
* in the chip, then board-specific logic will have to provide this function to * interface in the chip, then board-specific logic will have to provide
* determine which, if any, Ethernet controllers should be initialized. * this function to determine which, if any, Ethernet controllers should
* be initialized.
* *
************************************************************************************/ ****************************************************************************/
#if TIVA_NETHCONTROLLERS == 1 && !defined(CONFIG_NETDEV_LATEINIT) #if TIVA_NETHCONTROLLERS == 1 && !defined(CONFIG_NETDEV_LATEINIT)
void arm_netinitialize(void) void arm_netinitialize(void)
File diff suppressed because it is too large Load Diff
+38 -26
View File
@@ -71,7 +71,9 @@
# define CONFIG_HCS12_NINTERFACES 1 # define CONFIG_HCS12_NINTERFACES 1
#endif #endif
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll deley = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define HCS12_WDDELAY (1*CLK_TCK) #define HCS12_WDDELAY (1*CLK_TCK)
@@ -79,7 +81,7 @@
#define HCS12_TXTIMEOUT (60*CLK_TCK) #define HCS12_TXTIMEOUT (60*CLK_TCK)
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* This is a helper pointer for accessing the contents of Ethernet header */
#define BUF ((struct eth_hdr_s *)priv->d_dev.d_buf) #define BUF ((struct eth_hdr_s *)priv->d_dev.d_buf)
@@ -215,7 +217,8 @@ static int emac_transmit(FAR struct emac_driver_s *priv)
static int emac_txpoll(struct net_driver_s *dev) static int emac_txpoll(struct net_driver_s *dev)
{ {
FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)dev->d_private; FAR struct emac_driver_s *priv =
(FAR struct emac_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network, /* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0. * the field d_len is set to a value > 0.
@@ -251,14 +254,14 @@ static int emac_txpoll(struct net_driver_s *dev)
emac_transmit(priv); emac_transmit(priv);
/* Check if there is room in the device to hold another packet. If not, /* Check if there is room in the device to hold another packet.
* return a non-zero value to terminate the poll. * If not, return a non-zero value to terminate the poll.
*/ */
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -287,14 +290,16 @@ static void emac_receive(FAR struct emac_driver_s *priv)
{ {
/* Check for errors and update statistics */ /* Check for errors and update statistics */
/* Check if the packet is a valid size for the network buffer configuration */ /* Check if the packet is a valid size for the network buffer
* configuration
*/
/* Copy the data data from the hardware to priv->d_dev.d_buf. Set /* Copy the data data from the hardware to priv->d_dev.d_buf. Set
* amount of data in priv->d_dev.d_len * amount of data in priv->d_dev.d_len
*/ */
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->d_dev); pkt_input(&priv->d_dev);
#endif #endif
@@ -314,7 +319,7 @@ static void emac_receive(FAR struct emac_driver_s *priv)
ipv4_input(&priv->d_dev); ipv4_input(&priv->d_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->d_dev.d_len > 0) if (priv->d_dev.d_len > 0)
@@ -351,7 +356,7 @@ static void emac_receive(FAR struct emac_driver_s *priv)
ipv6_input(&priv->d_dev); ipv6_input(&priv->d_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->d_dev.d_len > 0) if (priv->d_dev.d_len > 0)
@@ -384,7 +389,7 @@ static void emac_receive(FAR struct emac_driver_s *priv)
arp_arpin(&priv->d_dev); arp_arpin(&priv->d_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->d_dev.d_len > 0) if (priv->d_dev.d_len > 0)
@@ -526,9 +531,9 @@ static void emac_polltimer(int argc, wdparm_t arg, ...)
* the TX poll if he are unable to accept another packet for transmission. * the TX poll if he are unable to accept another packet for transmission.
*/ */
/* If so, update TCP timing states and poll the network for new XMIT data. Hmmm.. /* If so, update TCP timing states and poll the network for new XMIT data.
* might be bug here. Does this mean if there is a transmit in progress, * Hmmm.. might be bug here. Does this mean if there is a transmit in
* we will missing TCP time state updates? * progress, we will missing TCP time state updates?
*/ */
devif_timer(&priv->d_dev, HCS12_WDDELAY, emac_txpoll); devif_timer(&priv->d_dev, HCS12_WDDELAY, emac_txpoll);
@@ -557,13 +562,14 @@ static void emac_polltimer(int argc, wdparm_t arg, ...)
static int emac_ifup(struct net_driver_s *dev) static int emac_ifup(struct net_driver_s *dev)
{ {
FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)dev->d_private; FAR struct emac_driver_s *priv =
(FAR struct emac_driver_s *)dev->d_private;
ninfo("Bringing up: %d.%d.%d.%d\n", ninfo("Bringing up: %d.%d.%d.%d\n",
dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
(dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 ); (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24);
/* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ /* Initialize PHYs, Ethernet interface, and setup up Ethernet interrupts */
/* Set and activate a timer process */ /* Set and activate a timer process */
@@ -594,7 +600,8 @@ static int emac_ifup(struct net_driver_s *dev)
static int emac_ifdown(struct net_driver_s *dev) static int emac_ifdown(struct net_driver_s *dev)
{ {
FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)dev->d_private; FAR struct emac_driver_s *priv =
(FAR struct emac_driver_s *)dev->d_private;
irqstate_t flags; irqstate_t flags;
/* Disable the Ethernet interrupt */ /* Disable the Ethernet interrupt */
@@ -640,7 +647,8 @@ static int emac_ifdown(struct net_driver_s *dev)
static int emac_txavail(struct net_driver_s *dev) static int emac_txavail(struct net_driver_s *dev)
{ {
FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)dev->d_private; FAR struct emac_driver_s *priv =
(FAR struct emac_driver_s *)dev->d_private;
irqstate_t flags; irqstate_t flags;
/* Disable interrupts because this function may be called from interrupt /* Disable interrupts because this function may be called from interrupt
@@ -653,7 +661,7 @@ static int emac_txavail(struct net_driver_s *dev)
if (priv->d_bifup) if (priv->d_bifup)
{ {
/* Check if there is room in the hardware to hold another outgoing packet. */ /* Check if there is room in the hardware to hold another packet. */
/* If so, then poll the network for new XMIT data */ /* If so, then poll the network for new XMIT data */
@@ -685,7 +693,8 @@ static int emac_txavail(struct net_driver_s *dev)
#ifdef CONFIG_NET_MCASTGROUP #ifdef CONFIG_NET_MCASTGROUP
static int emac_addmac(struct net_driver_s *dev, FAR const uint8_t *mac) static int emac_addmac(struct net_driver_s *dev, FAR const uint8_t *mac)
{ {
FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)dev->d_private; FAR struct emac_driver_s *priv =
(FAR struct emac_driver_s *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */ /* Add the MAC address to the hardware multicast routing table */
@@ -697,8 +706,8 @@ static int emac_addmac(struct net_driver_s *dev, FAR const uint8_t *mac)
* Function: emac_rmmac * Function: emac_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
@@ -714,7 +723,8 @@ static int emac_addmac(struct net_driver_s *dev, FAR const uint8_t *mac)
#ifdef CONFIG_NET_MCASTGROUP #ifdef CONFIG_NET_MCASTGROUP
static int emac_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac) static int emac_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac)
{ {
FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)dev->d_private; FAR struct emac_driver_s *priv =
(FAR struct emac_driver_s *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */ /* Add the MAC address to the hardware multicast routing table */
@@ -785,7 +795,9 @@ int emac_initialize(int intf)
* the device and/or calling emac_ifdown(). * the device and/or calling emac_ifdown().
*/ */
/* Read the MAC address from the hardware into priv->d_dev.d_mac.ether.ether_addr_octet */ /* Read the MAC address from the hardware into
* priv->d_dev.d_mac.ether.ether_addr_octet
*/
/* Register the device with the OS so that socket IOCTLs can be performed */ /* Register the device with the OS so that socket IOCTLs can be performed */
+50 -41
View File
@@ -114,8 +114,8 @@
#endif #endif
/* The logic here has a few hooks for support for multiple interfaces, but /* The logic here has a few hooks for support for multiple interfaces, but
* that capability is not yet in place (and I won't worry about it until I get * that capability is not yet in place (and I won't worry about it until I
* the first multi-interface PIC32MX). * get the first multi-interface PIC32MX).
*/ */
#if CONFIG_PIC32MX_NINTERFACES > 1 #if CONFIG_PIC32MX_NINTERFACES > 1
@@ -159,7 +159,7 @@
#define PIC32MX_NBUFFERS (CONFIG_PIC32MX_ETH_NRXDESC + \ #define PIC32MX_NBUFFERS (CONFIG_PIC32MX_ETH_NRXDESC + \
CONFIG_PIC32MX_ETH_NTXDESC + 1) CONFIG_PIC32MX_ETH_NTXDESC + 1)
/* Debug Configuration *****************************************************/ /* Debug Configuration ******************************************************/
/* CONFIG_NET_DUMPPACKET will dump the contents of each packet to the /* CONFIG_NET_DUMPPACKET will dump the contents of each packet to the
* console. * console.
@@ -225,7 +225,7 @@
#define ETH_RXINTS (ETH_INT_RXOVFLW | ETH_INT_RXBUFNA | ETH_INT_RXDONE | ETH_INT_RXBUSE) #define ETH_RXINTS (ETH_INT_RXOVFLW | ETH_INT_RXBUFNA | ETH_INT_RXDONE | ETH_INT_RXBUSE)
#define ETH_TXINTS (ETH_INT_TXABORT | ETH_INT_TXDONE | ETH_INT_TXBUSE) #define ETH_TXINTS (ETH_INT_TXABORT | ETH_INT_TXDONE | ETH_INT_TXBUSE)
/* Misc. Helpers ***********************************************************/ /* Misc. Helpers ************************************************************/
/* This is a helper pointer for accessing the contents of the Ethernet /* This is a helper pointer for accessing the contents of the Ethernet
* header * header
@@ -395,7 +395,8 @@ static inline struct pic32mx_txdesc_s *
pic32mx_txdesc(struct pic32mx_driver_s *priv); pic32mx_txdesc(struct pic32mx_driver_s *priv);
static inline void pic32mx_txnext(struct pic32mx_driver_s *priv); static inline void pic32mx_txnext(struct pic32mx_driver_s *priv);
static inline void pic32mx_rxreturn(struct pic32mx_rxdesc_s *rxdesc); static inline void pic32mx_rxreturn(struct pic32mx_rxdesc_s *rxdesc);
static struct pic32mx_rxdesc_s *pic32mx_rxdesc(struct pic32mx_driver_s *priv); static struct pic32mx_rxdesc_s *
pic32mx_rxdesc(struct pic32mx_driver_s *priv);
/* Common TX logic */ /* Common TX logic */
@@ -714,7 +715,8 @@ static uint8_t *pic32mx_allocbuffer(struct pic32mx_driver_s *priv)
* *
****************************************************************************/ ****************************************************************************/
static void pic32mx_freebuffer(struct pic32mx_driver_s *priv, uint8_t *buffer) static void pic32mx_freebuffer(struct pic32mx_driver_s *priv,
uint8_t *buffer)
{ {
/* Add the buffer to the end of the free buffer list */ /* Add the buffer to the end of the free buffer list */
@@ -989,8 +991,8 @@ static struct pic32mx_rxdesc_s *pic32mx_rxdesc(struct pic32mx_driver_s *priv)
int i; int i;
/* Inspect the list of RX descriptors to see if the EOWN bit is cleared. /* Inspect the list of RX descriptors to see if the EOWN bit is cleared.
* If it is, this descriptor is now under software control and a message was * If it is, this descriptor is now under software control and a message
* received. Use SOP and EOP to extract the message, use BYTE_COUNT, * was received. Use SOP and EOP to extract the message, use BYTE_COUNT,
* RXF_RSV, RSV and PKT_CHECKSUM to get the message characteristics. * RXF_RSV, RSV and PKT_CHECKSUM to get the message characteristics.
*/ */
@@ -1055,9 +1057,9 @@ static int pic32mx_transmit(struct pic32mx_driver_s *priv)
* *
* The SOP, EOP, DATA_BUFFER_ADDRESS and BYTE_COUNT will be updated when a * The SOP, EOP, DATA_BUFFER_ADDRESS and BYTE_COUNT will be updated when a
* particular message has to be transmitted. The DATA_BUFFER_ADDRESS will * particular message has to be transmitted. The DATA_BUFFER_ADDRESS will
* contain the physical address of the message, the BYTE_COUNT message size. * contain the physical address of the message, the BYTE_COUNT message
* SOP and EOP are set depending on how many packets are needed to transmit * size. SOP and EOP are set depending on how many packets are needed to
* the message. * transmit the message.
*/ */
/* Find the next available TX descriptor. We are guaranteed that is will /* Find the next available TX descriptor. We are guaranteed that is will
@@ -1083,9 +1085,9 @@ static int pic32mx_transmit(struct pic32mx_driver_s *priv)
status = ((uint32_t)priv->pd_dev.d_len << TXDESC_STATUS_BYTECOUNT_SHIFT); status = ((uint32_t)priv->pd_dev.d_len << TXDESC_STATUS_BYTECOUNT_SHIFT);
priv->pd_dev.d_len = 0; priv->pd_dev.d_len = 0;
/* Set EOWN = 1 to indicate that the packet belongs to Ethernet and set both /* Set EOWN = 1 to indicate that the packet belongs to Ethernet and set
* SOP and EOP to indicate that the packet both begins and ends with this * both SOP and EOP to indicate that the packet both begins and ends with
* frame. * this frame.
*/ */
status |= (TXDESC_STATUS_EOWN | TXDESC_STATUS_NPV | status |= (TXDESC_STATUS_EOWN | TXDESC_STATUS_NPV |
@@ -1188,7 +1190,9 @@ static int pic32mx_txpoll(struct net_driver_s *dev)
if (pic32mx_txdesc(priv) == NULL) if (pic32mx_txdesc(priv) == NULL)
{ {
/* There are no more TX descriptors/buffers available.. stop the poll */ /* There are no more TX descriptors/buffers available..
* stop the poll
*/
return -EAGAIN; return -EAGAIN;
} }
@@ -1207,8 +1211,8 @@ static int pic32mx_txpoll(struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return ret; return ret;
@@ -1313,7 +1317,7 @@ static void pic32mx_timerpoll(struct pic32mx_driver_s *priv)
* *
* Description: * Description:
* While processing an RxDone event, higher logic decides to send a packet, * While processing an RxDone event, higher logic decides to send a packet,
* possibly a response to the incoming packet (but probably not, in reality) * possibly a response to the incoming packet(but probably not, in reality)
* However, since the Rx and Tx operations are decoupled, there is no * However, since the Rx and Tx operations are decoupled, there is no
* guarantee that there will be a Tx descriptor available at that time. * guarantee that there will be a Tx descriptor available at that time.
* This function will perform that check and, if no Tx descriptor is * This function will perform that check and, if no Tx descriptor is
@@ -1499,7 +1503,7 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv)
if (priv->pd_dev.d_len > 0) if (priv->pd_dev.d_len > 0)
{ {
/* Update the Ethernet header with the correct MAC address */ /* Update Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->pd_dev.d_flags)) if (IFF_IS_IPv4(priv->pd_dev.d_flags))
@@ -1538,7 +1542,7 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv)
if (priv->pd_dev.d_len > 0) if (priv->pd_dev.d_len > 0)
{ {
/* Update the Ethernet header with the correct MAC address */ /* Update Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv4
if (IFF_IS_IPv4(priv->pd_dev.d_flags)) if (IFF_IS_IPv4(priv->pd_dev.d_flags))
@@ -1660,7 +1664,8 @@ static void pic32mx_txdone(struct pic32mx_driver_s *priv)
/* Free the TX buffer */ /* Free the TX buffer */
pic32mx_freebuffer(priv, (uint8_t *)VIRT_ADDR(txdesc->address)); pic32mx_freebuffer(priv,
(uint8_t *)VIRT_ADDR(txdesc->address));
txdesc->address = 0; txdesc->address = 0;
/* Reset status */ /* Reset status */
@@ -1759,7 +1764,8 @@ static void pic32mx_interrupt_work(void *arg)
if ((status & ETH_INT_RXBUFNA) != 0) if ((status & ETH_INT_RXBUFNA) != 0)
{ {
nerr("ERROR: RX buffer descriptor overrun. status: %08x\n", status); nerr("ERROR: RX buffer descriptor overrun. status: %08x\n",
status);
NETDEV_RXERRORS(&priv->pd_dev); NETDEV_RXERRORS(&priv->pd_dev);
} }
@@ -1851,15 +1857,15 @@ static void pic32mx_interrupt_work(void *arg)
/* EWMARK: Empty Watermark Interrupt. This bit is set when the RX /* EWMARK: Empty Watermark Interrupt. This bit is set when the RX
* Descriptor Buffer Count is less than or equal to the value in the * Descriptor Buffer Count is less than or equal to the value in the
* RXEWM bit (ETHRXWM:0-7) value. It is cleared by BUFCNT bit * RXEWM bit (ETHRXWM:0-7) value. It is cleared by BUFCNT bit
* (ETHSTAT:16-23) being incremented by hardware. Writing a 0 or a 1 * (ETHSTAT:16-23) being incremented by hardware. Writing a 0 or
* has no effect. * a 1 has no effect.
*/ */
/* FWMARK: Full Watermark Interrupt. This bit is set when the RX /* FWMARK: Full Watermark Interrupt. This bit is set when the RX
* escriptor Buffer Count is greater than or equal to the value in the * escriptor Buffer Count is greater than or equal to the value in the
* RXFWM bit (ETHRXWM:16-23) field. It is cleared by writing the BUFCDEC * RXFWM bit (ETHRXWM:16-23) field. It is cleared by writing the
* (ETHCON1:0) bit to decrement the BUFCNT counter. Writing a 0 or a * BUFCDEC (ETHCON1:0) bit to decrement the BUFCNT counter. Writing a
* 1 has no effect. * 0 or a 1 has no effect.
*/ */
} }
@@ -2138,8 +2144,9 @@ static int pic32mx_ifup(struct net_driver_s *dev)
/* Pin Configuration: /* Pin Configuration:
* *
* No GPIO pin configuration is required. Enabling the Ethernet Controller * No GPIO pin configuration is required. Enabling the Ethernet Controller
* will configure the IO pin direction as defined by the Ethernet Controller * will configure the IO pin direction as defined by the Ethernet
* control bits. The port TRIS and LATCH registers will be overridden. * Controller control bits. The port TRIS and LATCH registers will be
* overridden.
* *
* I/O Pin MII RMII Pin Description * I/O Pin MII RMII Pin Description
* Name Required Required Type * Name Required Required Type
@@ -2155,7 +2162,8 @@ static int pic32mx_ifup(struct net_driver_s *dev)
* ERXCLK Yes No I Ethernet MII RX Clock * ERXCLK Yes No I Ethernet MII RX Clock
* EREF_CLK No Yes I Ethernet RMII Ref Clock * EREF_CLK No Yes I Ethernet RMII Ref Clock
* ERXDV Yes No I Ethernet MII Receive Data Valid * ERXDV Yes No I Ethernet MII Receive Data Valid
* ECRS_DV No Yes I Ethernet RMII Carrier Sense/Receive Data Valid * ECRS_DV No Yes I Ethernet RMII Carrier Sense/
* Receive Data Valid
* ERXD0 Yes Yes I Ethernet Data Receive 0 * ERXD0 Yes Yes I Ethernet Data Receive 0
* ERXD1 Yes Yes I Ethernet Data Receive 1 * ERXD1 Yes Yes I Ethernet Data Receive 1
* ERXD2 Yes No I Ethernet Data Receive 2 * ERXD2 Yes No I Ethernet Data Receive 2
@@ -2200,7 +2208,8 @@ static int pic32mx_ifup(struct net_driver_s *dev)
* preamble, no scan increment. * preamble, no scan increment.
*/ */
regval &= ~(EMAC1_MCFG_CLKSEL_MASK | EMAC1_MCFG_NOPRE | EMAC1_MCFG_SCANINC); regval &= ~(EMAC1_MCFG_CLKSEL_MASK |
EMAC1_MCFG_NOPRE | EMAC1_MCFG_SCANINC);
regval |= EMAC1_MCFG_CLKSEL_DIV; regval |= EMAC1_MCFG_CLKSEL_DIV;
pic32mx_putreg(regval, PIC32MX_EMAC1_MCFG); pic32mx_putreg(regval, PIC32MX_EMAC1_MCFG);
@@ -2281,16 +2290,16 @@ static int pic32mx_ifup(struct net_driver_s *dev)
pic32mx_putreg(regval, PIC32MX_EMAC1_SA2); pic32mx_putreg(regval, PIC32MX_EMAC1_SA2);
#else #else
regval = pic32mx_getreg(PIC32MX_EMAC1_SA0); regval = pic32mx_getreg(PIC32MX_EMAC1_SA0);
priv->pd_dev.d_mac.ether.ether_addr_octet[4] = (uint32_t)(regval & 0xff); priv->pd_dev.d_mac.ether.ether_addr_octet[4] = regval & 0xff;
priv->pd_dev.d_mac.ether.ether_addr_octet[5] = (uint32_t)((regval >> 8) & 0xff); priv->pd_dev.d_mac.ether.ether_addr_octet[5] = (regval >> 8) & 0xff;
regval = pic32mx_getreg(PIC32MX_EMAC1_SA1); regval = pic32mx_getreg(PIC32MX_EMAC1_SA1);
priv->pd_dev.d_mac.ether.ether_addr_octet[2] = (uint32_t)(regval & 0xff); priv->pd_dev.d_mac.ether.ether_addr_octet[2] = regval & 0xff;
priv->pd_dev.d_mac.ether.ether_addr_octet[3] = (uint32_t)((regval >> 8) & 0xff); priv->pd_dev.d_mac.ether.ether_addr_octet[3] = (regval >> 8) & 0xff;
regval = pic32mx_getreg(PIC32MX_EMAC1_SA2); regval = pic32mx_getreg(PIC32MX_EMAC1_SA2);
priv->pd_dev.d_mac.ether.ether_addr_octet[0] = (uint32_t)(regval & 0xff); priv->pd_dev.d_mac.ether.ether_addr_octet[0] = regval & 0xff;
priv->pd_dev.d_mac.ether.ether_addr_octet[1] = (uint32_t)((regval >> 8) & 0xff); priv->pd_dev.d_mac.ether.ether_addr_octet[1] = (regval >> 8) & 0xff;
#endif #endif
/* Continue Ethernet Controller Initialization ****************************/ /* Continue Ethernet Controller Initialization ****************************/
@@ -2950,8 +2959,8 @@ static inline int pic32mx_phyinit(struct pic32mx_driver_s *priv)
#endif #endif
#else #else
/* Set the MII/ operation mode. This usually requires access to a vendor- /* Set the MII/ operation mode. This usually requires access to a vendor
* specific control register. * -specific control register.
*/ */
#ifdef CONFIG_ETH0_PHY_DP83848C #ifdef CONFIG_ETH0_PHY_DP83848C
@@ -3080,8 +3089,8 @@ static inline int pic32mx_phyinit(struct pic32mx_driver_s *priv)
/* Set up the fixed PHY configuration /* Set up the fixed PHY configuration
* *
* If auto-negotiation is not supported/selected, update the PHY Duplex and * If auto-negotiation is not supported/selected, update the PHY Duplex and
* Speed settings directly (use Control Register 0 and possibly some vendor- * Speed settings directly (use Control Register 0 and possibly some vendor
* pecific registers). * -pecific registers).
*/ */
ret = pic32mx_phymode(phyaddr, PIC32MX_MODE_DEFLT); ret = pic32mx_phymode(phyaddr, PIC32MX_MODE_DEFLT);
+46 -32
View File
@@ -79,7 +79,7 @@
*/ */
#if !defined(CONFIG_SCHED_HPWORK) #if !defined(CONFIG_SCHED_HPWORK)
/* REVISIT: The low priority work queue would be preferred if it is available */ /* REVISIT: The low priority work queue would be preferred if available */
# error High priority work queue support is required # error High priority work queue support is required
#endif #endif
@@ -92,7 +92,9 @@
# define CONFIG_MISOC_NET_NINTERFACES 1 # define CONFIG_MISOC_NET_NINTERFACES 1
#endif #endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define MISOC_NET_WDDELAY (1*CLK_TCK) #define MISOC_NET_WDDELAY (1*CLK_TCK)
@@ -100,7 +102,7 @@
#define MISOC_NET_TXTIMEOUT (60*CLK_TCK) #define MISOC_NET_TXTIMEOUT (60*CLK_TCK)
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* This is a helper pointer for accessing the contents of Ethernet header */
#define BUF ((struct eth_hdr_s *)priv->misoc_net_dev.d_buf) #define BUF ((struct eth_hdr_s *)priv->misoc_net_dev.d_buf)
@@ -108,8 +110,8 @@
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
/* The misoc_net_driver_s encapsulates all state information for a single hardware /* The misoc_net_driver_s encapsulates all state information for a single
* interface * hardware interface
*/ */
struct misoc_net_driver_s struct misoc_net_driver_s
@@ -177,9 +179,11 @@ static void misoc_net_txavail_work(FAR void *arg);
static int misoc_net_txavail(FAR struct net_driver_s *dev); static int misoc_net_txavail(FAR struct net_driver_s *dev);
#if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6) #if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6)
static int misoc_net_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac); static int misoc_net_addmac(FAR struct net_driver_s *dev,
FAR const uint8_t *mac);
#ifdef CONFIG_NET_MCASTGROUP #ifdef CONFIG_NET_MCASTGROUP
static int misoc_net_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac); static int misoc_net_rmmac(FAR struct net_driver_s *dev,
FAR const uint8_t *mac);
#endif #endif
#ifdef CONFIG_NET_ICMPv6 #ifdef CONFIG_NET_ICMPv6
static void misoc_net_ipv6multicast(FAR struct misoc_net_driver_s *priv); static void misoc_net_ipv6multicast(FAR struct misoc_net_driver_s *priv);
@@ -337,14 +341,14 @@ static int misoc_net_txpoll(FAR struct net_driver_s *dev)
misoc_net_transmit(priv); misoc_net_transmit(priv);
/* Check if there is room in the device to hold another packet. If not, /* Check if there is room in the device to hold another packet.
* return a non-zero value to terminate the poll. * If not, return a non-zero value to terminate the poll.
*/ */
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -388,8 +392,8 @@ static void misoc_net_receive(FAR struct misoc_net_driver_s *priv)
rxlen = ethmac_sram_writer_length_read(); rxlen = ethmac_sram_writer_length_read();
/* Copy the data data from the hardware to priv->misoc_net_dev.d_buf. Set /* Copy the data data from the hardware to priv->misoc_net_dev.d_buf.
* amount of data in priv->misoc_net_dev.d_len * Set amount of data in priv->misoc_net_dev.d_len
* *
* NOTE: These memcpy's could be avoided by simply setting the d_buf * NOTE: These memcpy's could be avoided by simply setting the d_buf
* pointer to the rx*_buf containing the received data. Some additional * pointer to the rx*_buf containing the received data. Some additional
@@ -414,7 +418,7 @@ static void misoc_net_receive(FAR struct misoc_net_driver_s *priv)
priv->misoc_net_dev.d_len = rxlen; priv->misoc_net_dev.d_len = rxlen;
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->misoc_net_dev); pkt_input(&priv->misoc_net_dev);
#endif #endif
@@ -435,7 +439,7 @@ static void misoc_net_receive(FAR struct misoc_net_driver_s *priv)
ipv4_input(&priv->misoc_net_dev); ipv4_input(&priv->misoc_net_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->misoc_net_dev.d_len > 0) if (priv->misoc_net_dev.d_len > 0)
@@ -473,7 +477,7 @@ static void misoc_net_receive(FAR struct misoc_net_driver_s *priv)
ipv6_input(&priv->misoc_net_dev); ipv6_input(&priv->misoc_net_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->misoc_net_dev.d_len > 0) if (priv->misoc_net_dev.d_len > 0)
@@ -507,7 +511,7 @@ static void misoc_net_receive(FAR struct misoc_net_driver_s *priv)
NETDEV_RXARP(&priv->misoc_net_dev); NETDEV_RXARP(&priv->misoc_net_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->misoc_net_dev.d_len > 0) if (priv->misoc_net_dev.d_len > 0)
@@ -589,16 +593,18 @@ static void misoc_net_interrupt_work(FAR void *arg)
net_lock(); net_lock();
/* Check if we received an incoming packet, if so, call misoc_net_receive() */ /* Check if we received an incoming packet,
* if so, call misoc_net_receive()
*/
if (ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) if (ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER)
{ {
misoc_net_receive(priv); misoc_net_receive(priv);
} }
/* Check if a packet transmission just completed. If so, call misoc_net_txdone. /* Check if a packet transmission just completed. If so, call
* This may disable further Tx interrupts if there are no pending * misoc_net_txdone. This may disable further Tx interrupts if there are no
* transmissions. * pending transmissions.
*/ */
if (ethmac_sram_reader_ev_pending_read() & ETHMAC_EV_SRAM_READER) if (ethmac_sram_reader_ev_pending_read() & ETHMAC_EV_SRAM_READER)
@@ -660,7 +666,8 @@ static int misoc_net_interrupt(int irq, FAR void *context, FAR void *arg)
/* Schedule to perform the interrupt processing on the worker thread. */ /* Schedule to perform the interrupt processing on the worker thread. */
work_queue(HPWORK, &priv->misoc_net_irqwork, misoc_net_interrupt_work, priv, 0); work_queue(HPWORK, &priv->misoc_net_irqwork,
misoc_net_interrupt_work, priv, 0);
return OK; return OK;
} }
@@ -732,7 +739,8 @@ static void misoc_net_txtimeout_expiry(int argc, wdparm_t arg, ...)
/* Schedule to perform the TX timeout processing on the worker thread. */ /* Schedule to perform the TX timeout processing on the worker thread. */
work_queue(HPWORK, &priv->misoc_net_irqwork, misoc_net_txtimeout_work, priv, 0); work_queue(HPWORK, &priv->misoc_net_irqwork,
misoc_net_txtimeout_work, priv, 0);
} }
/**************************************************************************** /****************************************************************************
@@ -803,7 +811,8 @@ static void misoc_net_poll_expiry(int argc, wdparm_t arg, ...)
/* Schedule to perform the interrupt processing on the worker thread. */ /* Schedule to perform the interrupt processing on the worker thread. */
work_queue(HPWORK, &priv->misoc_net_pollwork, misoc_net_poll_work, priv, 0); work_queue(HPWORK, &priv->misoc_net_pollwork,
misoc_net_poll_work, priv, 0);
} }
/**************************************************************************** /****************************************************************************
@@ -841,9 +850,11 @@ static int misoc_net_ifup(FAR struct net_driver_s *dev)
dev->d_ipv6addr[6], dev->d_ipv6addr[7]); dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
#endif #endif
/* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ /* Initialize PHYs, Ethernet interface, and setup up Ethernet interrupts */
/* Instantiate the MAC address from priv->misoc_net_dev.d_mac.ether.ether_addr_octet */ /* Instantiate the MAC address from
* priv->misoc_net_dev.d_mac.ether.ether_addr_octet
*/
#ifdef CONFIG_NET_ICMPv6 #ifdef CONFIG_NET_ICMPv6
/* Set up IPv6 multicast address filtering */ /* Set up IPv6 multicast address filtering */
@@ -942,7 +953,7 @@ static void misoc_net_txavail_work(FAR void *arg)
net_lock(); net_lock();
if (priv->misoc_net_bifup) if (priv->misoc_net_bifup)
{ {
/* Check if there is room in the hardware to hold another outgoing packet. */ /* Check if there is room in the hardware to hold another packet. */
if (!ethmac_sram_reader_ready_read()) if (!ethmac_sram_reader_ready_read())
{ {
@@ -988,7 +999,8 @@ static int misoc_net_txavail(FAR struct net_driver_s *dev)
{ {
/* Schedule to serialize the poll on the worker thread. */ /* Schedule to serialize the poll on the worker thread. */
work_queue(HPWORK, &priv->misoc_net_pollwork, misoc_net_txavail_work, priv, 0); work_queue(HPWORK, &priv->misoc_net_pollwork,
misoc_net_txavail_work, priv, 0);
} }
return OK; return OK;
@@ -1013,7 +1025,8 @@ static int misoc_net_txavail(FAR struct net_driver_s *dev)
****************************************************************************/ ****************************************************************************/
#if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6) #if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6)
static int misoc_net_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) static int misoc_net_addmac(FAR struct net_driver_s *dev,
FAR const uint8_t *mac)
{ {
FAR struct misoc_net_driver_s *priv = FAR struct misoc_net_driver_s *priv =
(FAR struct misoc_net_driver_s *)dev->d_private; (FAR struct misoc_net_driver_s *)dev->d_private;
@@ -1028,8 +1041,8 @@ static int misoc_net_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac
* Function: misoc_net_rmmac * Function: misoc_net_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
@@ -1043,7 +1056,8 @@ static int misoc_net_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NET_MCASTGROUP #ifdef CONFIG_NET_MCASTGROUP
static int misoc_net_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) static int misoc_net_rmmac(FAR struct net_driver_s *dev,
FAR const uint8_t *mac)
{ {
FAR struct misoc_net_driver_s *priv = FAR struct misoc_net_driver_s *priv =
(FAR struct misoc_net_driver_s *)dev->d_private; (FAR struct misoc_net_driver_s *)dev->d_private;
+21 -26
View File
@@ -1088,17 +1088,14 @@ static int rx65n_txpoll(struct net_driver_s *dev)
rx65n_transmit(priv); rx65n_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL); DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the next TX descriptor is owned by the /* Check if the next TX descriptor is owned by the Ethernet DMA or
* Ethernet DMA or CPU. * CPU. We cannot perform the TX poll if we are unable to accept
* We cannot perform the TX poll if we are unable to accept
* another packet fo transmission. * another packet fo transmission.
* In a race condition, TACT may be cleared *
* BUT still not available * In a race condition, TACT may be cleared BUT still not available
* because rx65n_freeframe() has not yet run. * because rx65n_freeframe() has not yet run. If rx65n_freeframe()
* If rx65n_freeframe() has run, * has run, the buffer1 pointer (tdes2) will be nullified (and
* the buffer1 pointer (tdes2) will be nullified * inflight should be CONFIG_RX65N_ETH_NTXDESC).
* (and inflight should
* be CONFIG_RX65N_ETH_NTXDESC).
*/ */
if ((priv->txhead->tdes0 & TACT) != 0 || if ((priv->txhead->tdes0 & TACT) != 0 ||
@@ -1167,9 +1164,9 @@ static void rx65n_dopoll(FAR struct rx65n_ethmac_s *priv)
* another packet for transmission. * another packet for transmission.
* *
* In a race condition, TACT may be cleared BUT still not available * In a race condition, TACT may be cleared BUT still not available
* because rx65n_freeframe() has not yet run. If rx65n_freeframe() has * because rx65n_freeframe() has not yet run. If rx65n_freeframe()
* run, the buffer1 pointer (tdes2) will be nullified (and inflight * has run, the buffer1 pointer (tdes2) will be nullified (and
* should be < CONFIG_RX65N_ETH_NTXDESC). * inflight should be < CONFIG_RX65N_ETH_NTXDESC).
*/ */
if ((priv->txhead->tdes0 & TACT) == 0 && if ((priv->txhead->tdes0 & TACT) == 0 &&
@@ -1481,10 +1478,9 @@ static int rx65n_recvframe(FAR struct rx65n_ethmac_s *priv)
rxdesc = (struct eth_rxdesc_s *)rxdesc->rdes3; rxdesc = (struct eth_rxdesc_s *)rxdesc->rdes3;
} }
/* We get here after all of the descriptors have been scanned or /* We get here after all of the descriptors have been scanned or when
* when rxdesc points * rxdesc points to the first descriptor owned by the DMA. Remember
* to the first descriptor owned by the DMA. * where we left off.
* Remember where we left off.
*/ */
priv->rxhead = rxdesc; priv->rxhead = rxdesc;
@@ -1755,8 +1751,8 @@ static void rx65n_freeframe(FAR struct rx65n_ethmac_s *priv)
priv->inflight--; priv->inflight--;
/* If all of the TX descriptors were in-flight, /* If all of the TX descriptors were in-flight,
* then RX interrupts may have been disabled... we * then RX interrupts may have been disabled...
* can re-enable them now. * we can re-enable them now.
*/ */
/* Need to check this and update the arguments of the /* Need to check this and update the arguments of the
@@ -2116,15 +2112,14 @@ static void rx65n_poll_work(FAR void *arg)
FAR struct rx65n_ethmac_s *priv = (FAR struct rx65n_ethmac_s *)arg; FAR struct rx65n_ethmac_s *priv = (FAR struct rx65n_ethmac_s *)arg;
FAR struct net_driver_s *dev = &priv->dev; FAR struct net_driver_s *dev = &priv->dev;
/* Check if the next TX descriptor is owned by the Ethernet DMA or CPU. We /* Check if the next TX descriptor is owned by the Ethernet DMA or
* cannot perform the timer poll if we are unable to accept another packet * CPU. We cannot perform the TX poll if we are unable to accept
* for transmission. Hmmm.. might be bug here. Does this mean if there is * another packet for transmission.
* a transmit in progress, we will miss TCP time state updates?
* *
* In a race condition, TACT may be cleared BUT still not available * In a race condition, TACT may be cleared BUT still not available
* because rx65n_freeframe() has not yet run. If rx65n_freeframe() has * because rx65n_freeframe() has not yet run. If rx65n_freeframe()
* run, the buffer1 pointer (tdes2) will be nullified (and inflight * has run, the buffer1 pointer (tdes2) will be nullified (and
* should be < CONFIG_RX65N_ETH_NTXDESC). * inflight should be < CONFIG_RX65N_ETH_NTXDESC).
*/ */
net_lock(); net_lock();
+13 -7
View File
@@ -243,7 +243,9 @@ extern uintptr_t __RAM_ADDR_U_INIT_PARAM;
#define EMAC_EIN_HANDLED \ #define EMAC_EIN_HANDLED \
(EMAC_ISTAT_RXEVENTS | EMAC_ISTAT_TXEVENTS | EMAC_ISTAT_SYSEVENTS) (EMAC_ISTAT_RXEVENTS | EMAC_ISTAT_TXEVENTS | EMAC_ISTAT_SYSEVENTS)
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll deley = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define EMAC_WDDELAY (1*CLK_TCK) #define EMAC_WDDELAY (1*CLK_TCK)
@@ -251,7 +253,7 @@ extern uintptr_t __RAM_ADDR_U_INIT_PARAM;
#define EMAC_TXTIMEOUT (60*CLK_TCK) #define EMAC_TXTIMEOUT (60*CLK_TCK)
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* This is a helper pointer for accessing the contents of Ethernet header */
#define ETHBUF ((struct eth_hdr_s *)priv->dev.d_buf) #define ETHBUF ((struct eth_hdr_s *)priv->dev.d_buf)
@@ -1081,7 +1083,9 @@ static int ez80emac_transmit(struct ez80emac_driver_s *priv)
txnext->pktsize = 0; txnext->pktsize = 0;
txnext->stat = 0; /* Bit 15: 0=Host (eZ80 CPU) owns, 1=EMAC owns. */ txnext->stat = 0; /* Bit 15: 0=Host (eZ80 CPU) owns, 1=EMAC owns. */
/* Copy the data to the next packet in the Tx buffer (handling wraparound) */ /* Copy the data to the next packet in the Tx buffer
* (handling wraparound)
*/
psrc = priv->dev.d_buf; psrc = priv->dev.d_buf;
pdest = (uint8_t *)txdesc + SIZEOF_EMACSDESC; pdest = (uint8_t *)txdesc + SIZEOF_EMACSDESC;
@@ -1388,7 +1392,7 @@ static int ez80emac_receive(struct ez80emac_driver_s *priv)
inp(EZ80_EMAC_BLKSLFT_H), inp(EZ80_EMAC_BLKSLFT_L)); inp(EZ80_EMAC_BLKSLFT_H), inp(EZ80_EMAC_BLKSLFT_L));
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -1556,7 +1560,7 @@ static void ez80emac_txinterrupt_work(FAR void *arg)
txhead, txhead->np, txhead->pktsize, txhead->stat, txhead, txhead->np, txhead->pktsize, txhead->stat,
inp(EZ80_EMAC_TRP_H), inp(EZ80_EMAC_TRP_L), istat); inp(EZ80_EMAC_TRP_H), inp(EZ80_EMAC_TRP_L), istat);
/* Handle all packets in the list that are no longer owned by the hardware */ /* Handle all packets in the list that are no longer owned by hardware */
while (txhead && (txhead->stat & EMAC_TXDESC_OWNER) == 0) while (txhead && (txhead->stat & EMAC_TXDESC_OWNER) == 0)
{ {
@@ -2217,7 +2221,7 @@ static void ez80emac_txavail_work(FAR void *arg)
net_lock(); net_lock();
if (priv->bifup) if (priv->bifup)
{ {
/* Check if there is room in the hardware to hold another outgoing packet. */ /* Check if there is room in the hardware to hold another packet. */
/* If so, then poll the network for new XMIT data */ /* If so, then poll the network for new XMIT data */
@@ -2623,7 +2627,9 @@ int up_netinitialize(void)
priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txpoll = wd_create(); /* Create periodic poll timer */
priv->txtimeout = wd_create(); /* Create TX timeout timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */
/* Read the MAC address from the hardware into priv->dev.d_mac.ether.ether_addr_octet */ /* Read the MAC address from the hardware into
* priv->dev.d_mac.ether.ether_addr_octet
*/
/* Register the device with the OS so that socket IOCTLs can be performed */ /* Register the device with the OS so that socket IOCTLs can be performed */
+2 -1
View File
@@ -363,7 +363,8 @@ static void ft5x06_data_worker(FAR void *arg)
#ifdef CONFIG_FT5X06_POLLMODE #ifdef CONFIG_FT5X06_POLLMODE
/* Exit, re-starting the poll. */ /* Exit, re-starting the poll. */
wd_start(priv->polltimer, priv->delay, ft5x06_poll_timeout, 1, (wdparm_t)priv); wd_start(priv->polltimer, priv->delay,
ft5x06_poll_timeout, 1, (wdparm_t)priv);
#else #else
/* Exit, re-enabling FT5x06 interrupts */ /* Exit, re-enabling FT5x06 interrupts */
+33 -34
View File
@@ -5,7 +5,7 @@
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* References: * References:
* "STMPE811 S-Touch advanced resistive touchscreen controller with 8-bit * "STMPE811 S-Touch advanced resistive touchscreen controller with 8-bit
* GPIO expander," Doc ID 14489 Rev 6, CD00186725, STMicroelectronics" * GPIO expander," Doc ID 14489 Rev 6, CD00186725, STMicroelectronics"
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -75,14 +75,6 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#define Direction_IN 0x00
#define Direction_OUT 0x01
#define Polarity_Low 0x00
#define Polarity_High 0x04
#define Type_Level 0x00
#define Type_Edge 0x02
#define IO_IT_0 0x01 #define IO_IT_0 0x01
#define IO_IT_1 0x02 #define IO_IT_1 0x02
#define IO_IT_2 0x04 #define IO_IT_2 0x04
@@ -98,8 +90,8 @@
#define EDGE_FALLING 0x01 #define EDGE_FALLING 0x01
#define EDGE_RISING 0x02 #define EDGE_RISING 0x02
/* <! The value of the maximal timeout for I2C waiting loops */
#define TIMEOUT_MAX 0x3000 /*<! The value of the maximal timeout for I2C waiting loops */ #define TIMEOUT_MAX 0x3000
/**************************************************************************** /****************************************************************************
* Private Types * Private Types
@@ -108,6 +100,7 @@
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
/* Internal logic */ /* Internal logic */
static void stmpe811_notify(FAR struct stmpe811_dev_s *priv); static void stmpe811_notify(FAR struct stmpe811_dev_s *priv);
@@ -151,6 +144,7 @@ static const struct file_operations g_stmpe811fops =
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: stmpe811_notify * Name: stmpe811_notify
* *
@@ -177,10 +171,10 @@ static void stmpe811_notify(FAR struct stmpe811_dev_s *priv)
nxsem_post(&priv->waitsem); nxsem_post(&priv->waitsem);
} }
/* If there are threads waiting on poll() for STMPE811 data to become available, /* If there are threads waiting on poll() for STMPE811 data to become
* then wake them up now. NOTE: we wake up all waiting threads because we * available, then wake them up now. NOTE: we wake up all waiting threads
* do not know that they are going to do. If they all try to read the data, * because we do not know that they are going to do. If they all try to
* then some make end up blocking after all. * read the data, then some make end up blocking after all.
*/ */
for (i = 0; i < CONFIG_STMPE811_NPOLLWAITERS; i++) for (i = 0; i < CONFIG_STMPE811_NPOLLWAITERS; i++)
@@ -241,8 +235,8 @@ static int stmpe811_sample(FAR struct stmpe811_dev_s *priv,
{ {
/* The sampling logic has detected pen-up in some condition other /* The sampling logic has detected pen-up in some condition other
* than CONTACT_MOVE. Set the next state to CONTACT_MOVE: Further * than CONTACT_MOVE. Set the next state to CONTACT_MOVE: Further
* samples collected while the pen is down will reported as movement * samples collected while the pen is down will reported as
* events. * movement events.
*/ */
priv->sample.contact = CONTACT_MOVE; priv->sample.contact = CONTACT_MOVE;
@@ -432,7 +426,8 @@ static int stmpe811_close(FAR struct file *filep)
* *
****************************************************************************/ ****************************************************************************/
static ssize_t stmpe811_read(FAR struct file *filep, FAR char *buffer, size_t len) static ssize_t stmpe811_read(FAR struct file *filep,
FAR char *buffer, size_t len)
{ {
FAR struct inode *inode; FAR struct inode *inode;
FAR struct stmpe811_dev_s *priv; FAR struct stmpe811_dev_s *priv;
@@ -755,7 +750,8 @@ static void stmpe811_timeout(int argc, wdparm_t arg1, ...)
* action should be required to protect the work queue. * action should be required to protect the work queue.
*/ */
ret = work_queue(HPWORK, &priv->timeout, stmpe811_timeoutworker, priv, 0); ret = work_queue(HPWORK, &priv->timeout,
stmpe811_timeoutworker, priv, 0);
if (ret != 0) if (ret != 0)
{ {
ierr("ERROR: Failed to queue work: %d\n", ret); ierr("ERROR: Failed to queue work: %d\n", ret);
@@ -811,8 +807,8 @@ static inline void stmpe811_tscinitialize(FAR struct stmpe811_dev_s *priv)
/* Select 2 nF filter capacitor */ /* Select 2 nF filter capacitor */
stmpe811_putreg8(priv, STMPE811_TSC_CFG, stmpe811_putreg8(priv, STMPE811_TSC_CFG, TSC_CFG_AVE_CTRL_4SAMPLES |
(TSC_CFG_AVE_CTRL_4SAMPLES | TSC_CFG_TOUCH_DELAY_500US | TSC_CFG_SETTLING_500US)); TSC_CFG_TOUCH_DELAY_500US | TSC_CFG_SETTLING_500US);
/* Select single point reading */ /* Select single point reading */
@@ -955,23 +951,23 @@ void stmpe811_tscworker(FAR struct stmpe811_dev_s *priv, uint8_t intsta)
wd_cancel(priv->wdog); wd_cancel(priv->wdog);
/* Check for pen up or down from the TSC_STA ibit n the STMPE811_TSC_CTRL register. */ /* Check for pen up or down from the TSC_STA bit in STMPE811_TSC_CTRL. */
pendown = (stmpe811_getreg8(priv, STMPE811_TSC_CTRL) & TSC_CTRL_TSC_STA) != 0; pendown = !!(stmpe811_getreg8(priv, STMPE811_TSC_CTRL) & TSC_CTRL_TSC_STA);
/* Handle the change from pen down to pen up */ /* Handle the change from pen down to pen up */
if (!pendown) if (!pendown)
{ {
/* The pen is up.. reset thresholding variables. FIFOs will read zero if /* The pen is up.. reset thresholding variables. FIFOs will read zero
* there is no data available (hence the choice of (0,0)) * if there is no data available (hence the choice of (0,0))
*/ */
priv->threshx = 0; priv->threshx = 0;
priv->threshy = 0; priv->threshy = 0;
/* Ignore the interrupt if the pen was already up (CONTACT_NONE == pen up and /* Ignore the interrupt if the pen was already up (CONTACT_NONE == pen
* already reported; CONTACT_UP == pen up, but not reported) * up and already reported; CONTACT_UP == pen up, but not reported)
*/ */
if (priv->sample.contact == CONTACT_NONE || if (priv->sample.contact == CONTACT_NONE ||
@@ -980,9 +976,9 @@ void stmpe811_tscworker(FAR struct stmpe811_dev_s *priv, uint8_t intsta)
goto ignored; goto ignored;
} }
/* A pen-down to up transition has been detected. CONTACT_UP indicates the /* A pen-down to up transition has been detected. CONTACT_UP indicates
* initial loss of contact. The state will be changed to CONTACT_NONE * the initial loss of contact. The state will be changed to
* after the loss of contact is sampled. * CONTACT_NONE after the loss of contact is sampled.
*/ */
priv->sample.contact = CONTACT_UP; priv->sample.contact = CONTACT_UP;
@@ -1021,9 +1017,10 @@ void stmpe811_tscworker(FAR struct stmpe811_dev_s *priv, uint8_t intsta)
goto ignored; goto ignored;
} }
/* Perform a thresholding operation so that the results will be more stable. /* Perform a thresholding operation so that the results will be more
* If the difference from the last sample is small, then ignore the event. * stable. If the difference from the last sample is small, then ignore
* REVISIT: Should a large change in pressure also generate a event? * the event. REVISIT: Should a large change in pressure also generate
* a event?
*/ */
xdiff = x > priv->threshx ? (x - priv->threshx) : (priv->threshx - x); xdiff = x > priv->threshx ? (x - priv->threshx) : (priv->threshx - x);
@@ -1031,7 +1028,9 @@ void stmpe811_tscworker(FAR struct stmpe811_dev_s *priv, uint8_t intsta)
if (xdiff < CONFIG_STMPE811_THRESHX && ydiff < CONFIG_STMPE811_THRESHY) if (xdiff < CONFIG_STMPE811_THRESHX && ydiff < CONFIG_STMPE811_THRESHY)
{ {
/* Little or no change in either direction ... don't report anything. */ /* Little or no change in either direction ...
* don't report anything.
*/
goto ignored; goto ignored;
} }
+44 -31
View File
@@ -284,7 +284,9 @@
# define CONFIG_DM9X_MODE_AUTO 1 # define CONFIG_DM9X_MODE_AUTO 1
#endif #endif
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll deley = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define DM9X_WDDELAY (1*CLK_TCK) #define DM9X_WDDELAY (1*CLK_TCK)
@@ -292,7 +294,7 @@
#define DM6X_TXTIMEOUT (60*CLK_TCK) #define DM6X_TXTIMEOUT (60*CLK_TCK)
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* This is a helper pointer for accessing the contents of Ethernet header */
#define BUF ((struct eth_hdr_s *)priv->dm_dev.d_buf) #define BUF ((struct eth_hdr_s *)priv->dm_dev.d_buf)
@@ -798,7 +800,8 @@ static int dm9x_transmit(FAR struct dm9x_driver_s *priv)
static int dm9x_txpoll(FAR struct net_driver_s *dev) static int dm9x_txpoll(FAR struct net_driver_s *dev)
{ {
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)dev->d_private; FAR struct dm9x_driver_s *priv =
(FAR struct dm9x_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network, /* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0. * the field d_len is set to a value > 0.
@@ -841,15 +844,15 @@ static int dm9x_txpoll(FAR struct net_driver_s *dev)
if (priv->dm_ntxpending > 1 || !priv->dm_b100m) if (priv->dm_ntxpending > 1 || !priv->dm_b100m)
{ {
/* Returning a non-zero value will terminate the poll operation */ /* Returning a non-zero value terminate the poll operation */
return 1; return 1;
} }
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -920,7 +923,7 @@ static void dm9x_receive(FAR struct dm9x_driver_s *priv)
priv->dm_discard(rx.desc.rx_len); priv->dm_discard(rx.desc.rx_len);
} }
/* Also check if the packet is a valid size for the network configuration */ /* Also check if the packet is a valid size for the configuration */
else if (rx.desc.rx_len < ETH_HDRLEN || else if (rx.desc.rx_len < ETH_HDRLEN ||
rx.desc.rx_len > (CONFIG_NET_ETH_PKTSIZE + 2)) rx.desc.rx_len > (CONFIG_NET_ETH_PKTSIZE + 2))
@@ -934,18 +937,20 @@ static void dm9x_receive(FAR struct dm9x_driver_s *priv)
} }
else else
{ {
/* Good packet... Copy the packet data out of SRAM and pass it one to the network */ /* Good packet...
* Copy the packet data out of SRAM and pass it one to the network
*/
priv->dm_dev.d_len = rx.desc.rx_len; priv->dm_dev.d_len = rx.desc.rx_len;
priv->dm_read(priv->dm_dev.d_buf, rx.desc.rx_len); priv->dm_read(priv->dm_dev.d_buf, rx.desc.rx_len);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dm_dev); pkt_input(&priv->dm_dev);
#endif #endif
/* We only accept IP packets of the configured type and ARP packets */ /* We accept IP packets of the configured type and ARP packets */
#ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv4
if (BUF->type == HTONS(ETHTYPE_IP)) if (BUF->type == HTONS(ETHTYPE_IP))
@@ -960,14 +965,14 @@ static void dm9x_receive(FAR struct dm9x_driver_s *priv)
arp_ipin(&priv->dm_dev); arp_ipin(&priv->dm_dev);
ipv4_input(&priv->dm_dev); ipv4_input(&priv->dm_dev);
/* If the above function invocation resulted in data that should /* If the above function invocation resulted in data that
* be sent out on the network, the field d_len will set to a * should be sent out on the network, the field d_len will
* value > 0. * set to a value > 0.
*/ */
if (priv->dm_dev.d_len > 0) if (priv->dm_dev.d_len > 0)
{ {
/* Update the Ethernet header with the correct MAC address */ /* Update Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dm_dev.d_flags)) if (IFF_IS_IPv4(priv->dm_dev.d_flags))
@@ -999,14 +1004,14 @@ static void dm9x_receive(FAR struct dm9x_driver_s *priv)
ipv6_input(&priv->dm_dev); ipv6_input(&priv->dm_dev);
/* If the above function invocation resulted in data that should /* If the above function invocation resulted in data that
* be sent out on the network, the field d_len will set to a * should be sent out on the network, the field d_len will
* value > 0. * set to a value > 0.
*/ */
if (priv->dm_dev.d_len > 0) if (priv->dm_dev.d_len > 0)
{ {
/* Update the Ethernet header with the correct MAC address */ /* Update Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv4
if (IFF_IS_IPv4(priv->dm_dev.d_flags)) if (IFF_IS_IPv4(priv->dm_dev.d_flags))
@@ -1034,9 +1039,9 @@ static void dm9x_receive(FAR struct dm9x_driver_s *priv)
arp_arpin(&priv->dm_dev); arp_arpin(&priv->dm_dev);
NETDEV_RXARP(&priv->dm_dev); NETDEV_RXARP(&priv->dm_dev);
/* If the above function invocation resulted in data that should /* If the above function invocation resulted in data that
* be sent out on the network, the field d_len will set to a * should be sent out on the network, the field d_len will set
* value > 0. * to a value > 0.
*/ */
if (priv->dm_dev.d_len > 0) if (priv->dm_dev.d_len > 0)
@@ -1054,7 +1059,8 @@ static void dm9x_receive(FAR struct dm9x_driver_s *priv)
NETDEV_RXPACKETS(&priv->dm_dev); NETDEV_RXPACKETS(&priv->dm_dev);
priv->ncrxpackets++; priv->ncrxpackets++;
} }
while ((rxbyte & 0x01) == DM9X_PKTRDY && priv->ncrxpackets < DM9X_CRXTHRES); while ((rxbyte & 0x01) == DM9X_PKTRDY &&
priv->ncrxpackets < DM9X_CRXTHRES);
ninfo("All RX packets processed\n"); ninfo("All RX packets processed\n");
} }
@@ -1414,7 +1420,7 @@ static void dm9x_poll_work(FAR void *arg)
if (priv->dm_ntxpending < 1 || (priv->dm_b100m && priv->dm_ntxpending < 2)) if (priv->dm_ntxpending < 1 || (priv->dm_b100m && priv->dm_ntxpending < 2))
{ {
/* If so, update TCP timing states and poll the network for new XMIT data */ /* Update TCP timing states and poll the network for new XMIT data */
devif_timer(&priv->dm_dev, DM9X_WDDELAY, dm9x_txpoll); devif_timer(&priv->dm_dev, DM9X_WDDELAY, dm9x_txpoll);
} }
@@ -1516,7 +1522,8 @@ static inline void dm9x_phymode(FAR struct dm9x_driver_s *priv)
static int dm9x_ifup(FAR struct net_driver_s *dev) static int dm9x_ifup(FAR struct net_driver_s *dev)
{ {
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)dev->d_private; FAR struct dm9x_driver_s *priv =
(FAR struct dm9x_driver_s *)dev->d_private;
uint8_t netstatus; uint8_t netstatus;
int i; int i;
@@ -1584,7 +1591,8 @@ static int dm9x_ifup(FAR struct net_driver_s *dev)
static int dm9x_ifdown(FAR struct net_driver_s *dev) static int dm9x_ifdown(FAR struct net_driver_s *dev)
{ {
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)dev->d_private; FAR struct dm9x_driver_s *priv =
(FAR struct dm9x_driver_s *)dev->d_private;
irqstate_t flags; irqstate_t flags;
ninfo("Stopping\n"); ninfo("Stopping\n");
@@ -1631,7 +1639,8 @@ static int dm9x_ifdown(FAR struct net_driver_s *dev)
static void dm9x_txavail_work(FAR void *arg) static void dm9x_txavail_work(FAR void *arg)
{ {
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)arg; FAR struct dm9x_driver_s *priv =
(FAR struct dm9x_driver_s *)arg;
ninfo("Polling\n"); ninfo("Polling\n");
@@ -1677,7 +1686,8 @@ static void dm9x_txavail_work(FAR void *arg)
static int dm9x_txavail(FAR struct net_driver_s *dev) static int dm9x_txavail(FAR struct net_driver_s *dev)
{ {
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)dev->d_private; FAR struct dm9x_driver_s *priv =
(FAR struct dm9x_driver_s *)dev->d_private;
/* Is our single work structure available? It may not be if there are /* Is our single work structure available? It may not be if there are
* pending interrupt actions and we will have to ignore the Tx * pending interrupt actions and we will have to ignore the Tx
@@ -1715,7 +1725,8 @@ static int dm9x_txavail(FAR struct net_driver_s *dev)
#ifdef CONFIG_NET_MCASTGROUP #ifdef CONFIG_NET_MCASTGROUP
static int dm9x_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) static int dm9x_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
{ {
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)dev->d_private; FAR struct dm9x_driver_s *priv =
(FAR struct dm9x_driver_s *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */ /* Add the MAC address to the hardware multicast routing table */
@@ -1745,7 +1756,8 @@ static int dm9x_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
#ifdef CONFIG_NET_MCASTGROUP #ifdef CONFIG_NET_MCASTGROUP
static int dm9x_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) static int dm9x_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
{ {
FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)dev->d_private; FAR struct dm9x_driver_s *priv =
(FAR struct dm9x_driver_s *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */ /* Add the MAC address to the hardware multicast routing table */
@@ -1826,7 +1838,8 @@ static void dm9x_bringup(FAR struct dm9x_driver_s *priv)
putreg(DM9X_TXC, 0x00); /* Clear TX Polling */ putreg(DM9X_TXC, 0x00); /* Clear TX Polling */
putreg(DM9X_BPTHRES, 0x3f); /* Less 3kb, 600us */ putreg(DM9X_BPTHRES, 0x3f); /* Less 3kb, 600us */
putreg(DM9X_SMODEC, 0x00); /* Special mode */ putreg(DM9X_SMODEC, 0x00); /* Special mode */
putreg(DM9X_NETS, (DM9X_NETS_WAKEST | DM9X_NETS_TX1END | DM9X_NETS_TX2END)); /* Clear TX status */ /* Clear TX status */
putreg(DM9X_NETS, DM9X_NETS_WAKEST | DM9X_NETS_TX1END | DM9X_NETS_TX2END);
putreg(DM9X_ISR, DM9X_INT_ALL); /* Clear interrupt status */ putreg(DM9X_ISR, DM9X_INT_ALL); /* Clear interrupt status */
#if defined(CONFIG_DM9X_CHECKSUM) #if defined(CONFIG_DM9X_CHECKSUM)
@@ -1947,7 +1960,7 @@ int dm9x_initialize(void)
if (vid != DM9X_DAVICOMVID || if (vid != DM9X_DAVICOMVID ||
(pid != DM9X_DM9000PID && pid != DM9X_DM9010PID)) (pid != DM9X_DM9000PID && pid != DM9X_DM9010PID))
{ {
nerr("ERROR: DM90x0 vendor/product ID not found at this base address\n"); nerr("ERROR: vendor/product ID not found at this base address\n");
return -ENODEV; return -ENODEV;
} }
+4 -4
View File
@@ -1387,7 +1387,7 @@ static void enc_rxerif(FAR struct enc_driver_s *priv)
static void enc_rxdispatch(FAR struct enc_driver_s *priv) static void enc_rxdispatch(FAR struct enc_driver_s *priv)
{ {
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -1408,7 +1408,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv)
ipv4_input(&priv->dev); ipv4_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1446,7 +1446,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv)
ipv6_input(&priv->dev); ipv6_input(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
@@ -1482,7 +1482,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv)
arp_arpin(&priv->dev); arp_arpin(&priv->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
+21 -11
View File
@@ -83,7 +83,9 @@
# define lan91c111_dumppacket(m, b, l) # define lan91c111_dumppacket(m, b, l)
#endif #endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define LAN91C111_WDDELAY (1*CLK_TCK) #define LAN91C111_WDDELAY (1*CLK_TCK)
@@ -187,7 +189,8 @@ static uint8_t getreg8(FAR struct lan91c111_driver_s *priv, uint16_t offset)
return *(FAR volatile uint8_t *)(priv->base + offset); return *(FAR volatile uint8_t *)(priv->base + offset);
} }
static uint16_t getreg16(FAR struct lan91c111_driver_s *priv, uint16_t offset) static uint16_t getreg16(FAR struct lan91c111_driver_s *priv,
uint16_t offset)
{ {
offset = updatebank(priv, offset); offset = updatebank(priv, offset);
return *(FAR volatile uint16_t *)(priv->base + offset); return *(FAR volatile uint16_t *)(priv->base + offset);
@@ -559,8 +562,8 @@ static int lan91c111_txpoll(FAR struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -691,7 +694,7 @@ static void lan91c111_receive(FAR struct net_driver_s *dev)
NETDEV_RXPACKETS(dev); NETDEV_RXPACKETS(dev);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(dev); pkt_input(dev);
#endif #endif
@@ -904,7 +907,9 @@ static void lan91c111_interrupt_work(FAR void *arg)
/* Handle interrupts according to status bit settings */ /* Handle interrupts according to status bit settings */
/* Check if we received an incoming packet, if so, call lan91c111_receive() */ /* Check if we received an incoming packet,
* if so, call lan91c111_receive()
*/
if (status & IM_RCV_INT) if (status & IM_RCV_INT)
{ {
@@ -916,14 +921,18 @@ static void lan91c111_interrupt_work(FAR void *arg)
NETDEV_RXERRORS(dev); NETDEV_RXERRORS(dev);
} }
/* Check if a packet transmission just completed. If so, call lan91c111_txdone. */ /* Check if a packet transmission just completed.
* If so, call lan91c111_txdone.
*/
if (status & IM_TX_INT) if (status & IM_TX_INT)
{ {
lan91c111_txdone(dev); lan91c111_txdone(dev);
} }
/* Check if we have the phy interrupt, if so, call lan91c111_phy_notify() */ /* Check if we have the phy interrupt,
* if so, call lan91c111_phy_notify()
*/
if (status & IM_MDINT) if (status & IM_MDINT)
{ {
@@ -1102,7 +1111,7 @@ static int lan91c111_ifup(FAR struct net_driver_s *dev)
net_lock(); net_lock();
/* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ /* Initialize PHYs, Ethernet interface, and setup up Ethernet interrupts */
putreg16(priv, CONFIG_REG, CONFIG_DEFAULT); putreg16(priv, CONFIG_REG, CONFIG_DEFAULT);
putreg16(priv, CTL_REG, CTL_DEFAULT); putreg16(priv, CTL_REG, CTL_DEFAULT);
@@ -1580,7 +1589,8 @@ int lan91c111_initialize(uintptr_t base, int irq)
macrev = getreg16(priv, REV_REG); macrev = getreg16(priv, REV_REG);
phyid = getphy(priv, MII_PHYID1) << 16; phyid = getphy(priv, MII_PHYID1) << 16;
phyid |= getphy(priv, MII_PHYID2); phyid |= getphy(priv, MII_PHYID2);
ninfo("base: %08x irq: %d rev: %04x phy: %08x\n", base, irq, macrev, phyid); ninfo("base: %08x irq: %d rev: %04x phy: %08x\n",
base, irq, macrev, phyid);
if ((macrev >> 4 & 0x0f) != CHIP_91111FD || phyid != PHY_LAN83C183) if ((macrev >> 4 & 0x0f) != CHIP_91111FD || phyid != PHY_LAN83C183)
{ {
@@ -1636,7 +1646,7 @@ int lan91c111_initialize(uintptr_t base, int irq)
/* Loop, reset don't finish yet */ /* Loop, reset don't finish yet */
} }
/* Read the MAC address from the hardware into dev->d_mac.ether.ether_addr_octet */ /* Read MAC address from the hardware into dev->d_mac.ether */
copyfrom16(priv, ADDR0_REG, &dev->d_mac.ether, sizeof(dev->d_mac.ether)); copyfrom16(priv, ADDR0_REG, &dev->d_mac.ether, sizeof(dev->d_mac.ether));
+5 -3
View File
@@ -75,7 +75,9 @@
# error Worker thread support is required (CONFIG_SCHED_WORKQUEUE) # error Worker thread support is required (CONFIG_SCHED_WORKQUEUE)
#endif #endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define LO_WDDELAY (1*CLK_TCK) #define LO_WDDELAY (1*CLK_TCK)
@@ -172,7 +174,7 @@ static int lo_txpoll(FAR struct net_driver_s *dev)
NETDEV_RXPACKETS(&priv->lo_dev); NETDEV_RXPACKETS(&priv->lo_dev);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->lo_dev); pkt_input(&priv->lo_dev);
#endif #endif
@@ -521,7 +523,7 @@ int localhost_initialize(void)
priv->lo_dev.d_rmmac = lo_rmmac; /* Remove multicast MAC address */ priv->lo_dev.d_rmmac = lo_rmmac; /* Remove multicast MAC address */
#endif #endif
priv->lo_dev.d_buf = g_iobuffer; /* Attach the IO buffer */ priv->lo_dev.d_buf = g_iobuffer; /* Attach the IO buffer */
priv->lo_dev.d_private = (FAR void *)priv; /* Used to recover private state from dev */ priv->lo_dev.d_private = priv; /* Used to recover private state from dev */
/* Create a watchdog for timing polling for and timing of transmissions */ /* Create a watchdog for timing polling for and timing of transmissions */
+1 -1
View File
@@ -637,7 +637,7 @@ static int net_rpmsg_drv_transfer_handler(FAR struct rpmsg_endpoint *ept,
dev->d_len = msg->length; dev->d_len = msg->length;
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(dev); pkt_input(dev);
#endif #endif
+42 -33
View File
@@ -83,23 +83,25 @@
#define ETHWORK LPWORK #define ETHWORK LPWORK
/* CONFIG_skeleton_NINTERFACES determines the number of physical interfaces /* CONFIG_SKELETON_NINTERFACES determines the number of physical interfaces
* that will be supported. * that will be supported.
*/ */
#ifndef CONFIG_skeleton_NINTERFACES #ifndef CONFIG_SKELETON_NINTERFACES
# define CONFIG_skeleton_NINTERFACES 1 # define CONFIG_SKELETON_NINTERFACES 1
#endif #endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define skeleton_WDDELAY (1*CLK_TCK) #define SKELETON_WDDELAY (1*CLK_TCK)
/* TX timeout = 1 minute */ /* TX timeout = 1 minute */
#define skeleton_TXTIMEOUT (60*CLK_TCK) #define SKELETON_TXTIMEOUT (60*CLK_TCK)
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* This is a helper pointer for accessing the contents of Ethernet header */
#define BUF ((struct eth_hdr_s *)priv->sk_dev.d_buf) #define BUF ((struct eth_hdr_s *)priv->sk_dev.d_buf)
@@ -139,7 +141,7 @@ struct skel_driver_s
* descriptors in rings to implement such a pipeline. This example assumes * descriptors in rings to implement such a pipeline. This example assumes
* much simpler hardware that simply handles one packet at a time. * much simpler hardware that simply handles one packet at a time.
* *
* NOTE that if CONFIG_skeleton_NINTERFACES were greater than 1, you would * NOTE that if CONFIG_SKELETON_NINTERFACES were greater than 1, you would
* need a minimum on one packet buffer per instance. Much better to be * need a minimum on one packet buffer per instance. Much better to be
* allocated dynamically in cases where more than one are needed. * allocated dynamically in cases where more than one are needed.
*/ */
@@ -148,7 +150,7 @@ static uint8_t g_pktbuf[MAX_NETDEV_PKTSIZE + CONFIG_NET_GUARDSIZE];
/* Driver state structure */ /* Driver state structure */
static struct skel_driver_s g_skel[CONFIG_skeleton_NINTERFACES]; static struct skel_driver_s g_skel[CONFIG_SKELETON_NINTERFACES];
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
@@ -239,7 +241,7 @@ static int skel_transmit(FAR struct skel_driver_s *priv)
/* Setup the TX timeout watchdog (perhaps restarting the timer) */ /* Setup the TX timeout watchdog (perhaps restarting the timer) */
wd_start(priv->sk_txtimeout, skeleton_TXTIMEOUT, wd_start(priv->sk_txtimeout, SKELETON_TXTIMEOUT,
skel_txtimeout_expiry, 1, (wdparm_t)priv); skel_txtimeout_expiry, 1, (wdparm_t)priv);
return OK; return OK;
} }
@@ -269,7 +271,8 @@ static int skel_transmit(FAR struct skel_driver_s *priv)
static int skel_txpoll(FAR struct net_driver_s *dev) static int skel_txpoll(FAR struct net_driver_s *dev)
{ {
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)dev->d_private; FAR struct skel_driver_s *priv =
(FAR struct skel_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network, /* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0. * the field d_len is set to a value > 0.
@@ -316,8 +319,8 @@ static int skel_txpoll(FAR struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -412,7 +415,7 @@ static void skel_receive(FAR struct skel_driver_s *priv)
*/ */
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->sk_dev); pkt_input(&priv->sk_dev);
#endif #endif
@@ -574,7 +577,7 @@ static void skel_interrupt_work(FAR void *arg)
/* Re-enable Ethernet interrupts */ /* Re-enable Ethernet interrupts */
up_enable_irq(CONFIG_skeleton_IRQ); up_enable_irq(CONFIG_SKELETON_IRQ);
} }
/**************************************************************************** /****************************************************************************
@@ -607,7 +610,7 @@ static int skel_interrupt(int irq, FAR void *context, FAR void *arg)
* condition here. * condition here.
*/ */
up_disable_irq(CONFIG_skeleton_IRQ); up_disable_irq(CONFIG_SKELETON_IRQ);
/* TODO: Determine if a TX transfer just completed */ /* TODO: Determine if a TX transfer just completed */
@@ -693,7 +696,7 @@ static void skel_txtimeout_expiry(int argc, wdparm_t arg, ...)
* condition with interrupt work that is already queued and in progress. * condition with interrupt work that is already queued and in progress.
*/ */
up_disable_irq(CONFIG_skeleton_IRQ); up_disable_irq(CONFIG_SKELETON_IRQ);
/* Schedule to perform the TX timeout processing on the worker thread. */ /* Schedule to perform the TX timeout processing on the worker thread. */
@@ -740,11 +743,11 @@ static void skel_poll_work(FAR void *arg)
* progress, we will missing TCP time state updates? * progress, we will missing TCP time state updates?
*/ */
devif_timer(&priv->sk_dev, skeleton_WDDELAY, skel_txpoll); devif_timer(&priv->sk_dev, SKELETON_WDDELAY, skel_txpoll);
/* Setup the watchdog poll timer again */ /* Setup the watchdog poll timer again */
wd_start(priv->sk_txpoll, skeleton_WDDELAY, wd_start(priv->sk_txpoll, SKELETON_WDDELAY,
skel_poll_expiry, 1, (wdparm_t)priv); skel_poll_expiry, 1, (wdparm_t)priv);
net_unlock(); net_unlock();
} }
@@ -797,7 +800,8 @@ static void skel_poll_expiry(int argc, wdparm_t arg, ...)
static int skel_ifup(FAR struct net_driver_s *dev) static int skel_ifup(FAR struct net_driver_s *dev)
{ {
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)dev->d_private; FAR struct skel_driver_s *priv =
(FAR struct skel_driver_s *)dev->d_private;
#ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv4
ninfo("Bringing up: %d.%d.%d.%d\n", ninfo("Bringing up: %d.%d.%d.%d\n",
@@ -811,9 +815,9 @@ static int skel_ifup(FAR struct net_driver_s *dev)
dev->d_ipv6addr[6], dev->d_ipv6addr[7]); dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
#endif #endif
/* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ /* Initialize PHYs, Ethernet interface, and setup up Ethernet interrupts */
/* Instantiate the MAC address from priv->sk_dev.d_mac.ether.ether_addr_octet */ /* Instantiate MAC address from priv->sk_dev.d_mac.ether.ether_addr_octet */
#ifdef CONFIG_NET_ICMPv6 #ifdef CONFIG_NET_ICMPv6
/* Set up IPv6 multicast address filtering */ /* Set up IPv6 multicast address filtering */
@@ -823,13 +827,13 @@ static int skel_ifup(FAR struct net_driver_s *dev)
/* Set and activate a timer process */ /* Set and activate a timer process */
wd_start(priv->sk_txpoll, skeleton_WDDELAY, wd_start(priv->sk_txpoll, SKELETON_WDDELAY,
skel_poll_expiry, 1, (wdparm_t)priv); skel_poll_expiry, 1, (wdparm_t)priv);
/* Enable the Ethernet interrupt */ /* Enable the Ethernet interrupt */
priv->sk_bifup = true; priv->sk_bifup = true;
up_enable_irq(CONFIG_skeleton_IRQ); up_enable_irq(CONFIG_SKELETON_IRQ);
return OK; return OK;
} }
@@ -852,13 +856,14 @@ static int skel_ifup(FAR struct net_driver_s *dev)
static int skel_ifdown(FAR struct net_driver_s *dev) static int skel_ifdown(FAR struct net_driver_s *dev)
{ {
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)dev->d_private; FAR struct skel_driver_s *priv =
(FAR struct skel_driver_s *)dev->d_private;
irqstate_t flags; irqstate_t flags;
/* Disable the Ethernet interrupt */ /* Disable the Ethernet interrupt */
flags = enter_critical_section(); flags = enter_critical_section();
up_disable_irq(CONFIG_skeleton_IRQ); up_disable_irq(CONFIG_SKELETON_IRQ);
/* Cancel the TX poll timer and TX timeout timers */ /* Cancel the TX poll timer and TX timeout timers */
@@ -910,7 +915,7 @@ static void skel_txavail_work(FAR void *arg)
if (priv->sk_bifup) if (priv->sk_bifup)
{ {
/* Check if there is room in the hardware to hold another outgoing packet. */ /* Check if there is room in the hardware to hold another packet. */
/* If so, then poll the network for new XMIT data */ /* If so, then poll the network for new XMIT data */
@@ -941,7 +946,8 @@ static void skel_txavail_work(FAR void *arg)
static int skel_txavail(FAR struct net_driver_s *dev) static int skel_txavail(FAR struct net_driver_s *dev)
{ {
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)dev->d_private; FAR struct skel_driver_s *priv =
(FAR struct skel_driver_s *)dev->d_private;
/* Is our single work structure available? It may not be if there are /* Is our single work structure available? It may not be if there are
* pending interrupt actions and we will have to ignore the Tx * pending interrupt actions and we will have to ignore the Tx
@@ -977,7 +983,8 @@ static int skel_txavail(FAR struct net_driver_s *dev)
#if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6) #if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6)
static int skel_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) static int skel_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
{ {
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)dev->d_private; FAR struct skel_driver_s *priv =
(FAR struct skel_driver_s *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */ /* Add the MAC address to the hardware multicast routing table */
@@ -1004,7 +1011,8 @@ static int skel_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
#ifdef CONFIG_NET_MCASTGROUP #ifdef CONFIG_NET_MCASTGROUP
static int skel_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) static int skel_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
{ {
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)dev->d_private; FAR struct skel_driver_s *priv =
(FAR struct skel_driver_s *)dev->d_private;
/* Add the MAC address to the hardware multicast routing table */ /* Add the MAC address to the hardware multicast routing table */
@@ -1107,7 +1115,8 @@ static void skel_ipv6multicast(FAR struct skel_driver_s *priv)
static int skel_ioctl(FAR struct net_driver_s *dev, int cmd, static int skel_ioctl(FAR struct net_driver_s *dev, int cmd,
unsigned long arg) unsigned long arg)
{ {
FAR struct skel_driver_s *priv = (FAR struct skel_driver_s *)dev->d_private; FAR struct skel_driver_s *priv =
(FAR struct skel_driver_s *)dev->d_private;
int ret; int ret;
/* Decode and dispatch the driver-specific IOCTL command */ /* Decode and dispatch the driver-specific IOCTL command */
@@ -1153,14 +1162,14 @@ int skel_initialize(int intf)
/* Get the interface structure associated with this interface number. */ /* Get the interface structure associated with this interface number. */
DEBUGASSERT(intf < CONFIG_skeleton_NINTERFACES); DEBUGASSERT(intf < CONFIG_SKELETON_NINTERFACES);
priv = &g_skel[intf]; priv = &g_skel[intf];
/* Check if a Ethernet chip is recognized at its I/O base */ /* Check if a Ethernet chip is recognized at its I/O base */
/* Attach the IRQ to the driver */ /* Attach the IRQ to the driver */
if (irq_attach(CONFIG_skeleton_IRQ, skel_interrupt, priv)) if (irq_attach(CONFIG_SKELETON_IRQ, skel_interrupt, priv))
{ {
/* We could not attach the ISR to the interrupt */ /* We could not attach the ISR to the interrupt */
+5 -5
View File
@@ -105,8 +105,8 @@
#define NET_TUN_PKTSIZE ((CONFIG_NET_TUN_PKTSIZE + CONFIG_NET_GUARDSIZE + 1) & ~1) #define NET_TUN_PKTSIZE ((CONFIG_NET_TUN_PKTSIZE + CONFIG_NET_GUARDSIZE + 1) & ~1)
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per /* TX poll delay = 1 seconds.
* second * CLK_TCK is the number of clock ticks per second
*/ */
#define TUN_WDDELAY (1 * CLK_TCK) #define TUN_WDDELAY (1 * CLK_TCK)
@@ -572,7 +572,7 @@ static void tun_net_receive_tap(FAR struct tun_device_s *priv)
NETDEV_RXPACKETS(&priv->dev); NETDEV_RXPACKETS(&priv->dev);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -684,7 +684,7 @@ static void tun_net_receive_tun(FAR struct tun_device_s *priv)
NETDEV_RXPACKETS(&priv->dev); NETDEV_RXPACKETS(&priv->dev);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev); pkt_input(&priv->dev);
#endif #endif
@@ -721,7 +721,7 @@ static void tun_net_receive_tun(FAR struct tun_device_s *priv)
} }
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->dev.d_len > 0) if (priv->dev.d_len > 0)
+3 -3
View File
@@ -84,8 +84,8 @@
#define AK09912_ASAX 0x60 #define AK09912_ASAX 0x60
/* REGISTER: CNTL1 /* REGISTER: CNTL1
* Enable or disable temparator measure or enable or disable Noise suppression * Enable or disable temparator measure or enable or disable Noise
* filter. * suppression filter.
*/ */
#define AK09912_CTRL1 0x30 #define AK09912_CTRL1 0x30
@@ -676,7 +676,7 @@ int ak09912_register(FAR const char *devpath, FAR struct i2c_master_s *i2c)
/* Initialize the AK09912 device structure */ /* Initialize the AK09912 device structure */
priv = (FAR struct ak09912_dev_s *)kmm_malloc(sizeof(struct ak09912_dev_s)); priv = kmm_malloc(sizeof(struct ak09912_dev_s));
if (!priv) if (!priv)
{ {
snerr("Failed to allocate instance\n"); snerr("Failed to allocate instance\n");
+20 -16
View File
@@ -177,20 +177,20 @@ static int cdcacm_requeue_rdrequest(FAR struct cdcacm_dev_s *priv,
static int cdcacm_release_rxpending(FAR struct cdcacm_dev_s *priv); static int cdcacm_release_rxpending(FAR struct cdcacm_dev_s *priv);
static void cdcacm_rxtimeout(int argc, wdparm_t arg1, ...); static void cdcacm_rxtimeout(int argc, wdparm_t arg1, ...);
/* Request helpers *********************************************************/ /* Request helpers **********************************************************/
static struct usbdev_req_s *cdcacm_allocreq(FAR struct usbdev_ep_s *ep, static struct usbdev_req_s *cdcacm_allocreq(FAR struct usbdev_ep_s *ep,
uint16_t len); uint16_t len);
static void cdcacm_freereq(FAR struct usbdev_ep_s *ep, static void cdcacm_freereq(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *req); FAR struct usbdev_req_s *req);
/* Flow Control ************************************************************/ /* Flow Control *************************************************************/
#ifdef CONFIG_CDCACM_IFLOWCONTROL #ifdef CONFIG_CDCACM_IFLOWCONTROL
static int cdcacm_serialstate(FAR struct cdcacm_dev_s *priv); static int cdcacm_serialstate(FAR struct cdcacm_dev_s *priv);
#endif #endif
/* Configuration ***********************************************************/ /* Configuration ************************************************************/
static void cdcacm_resetconfig(FAR struct cdcacm_dev_s *priv); static void cdcacm_resetconfig(FAR struct cdcacm_dev_s *priv);
static int cdcacm_epconfigure(FAR struct usbdev_ep_s *ep, static int cdcacm_epconfigure(FAR struct usbdev_ep_s *ep,
@@ -200,7 +200,7 @@ static int cdcacm_epconfigure(FAR struct usbdev_ep_s *ep,
static int cdcacm_setconfig(FAR struct cdcacm_dev_s *priv, static int cdcacm_setconfig(FAR struct cdcacm_dev_s *priv,
uint8_t config); uint8_t config);
/* Completion event handlers ***********************************************/ /* Completion event handlers ************************************************/
static void cdcacm_ep0incomplete(FAR struct usbdev_ep_s *ep, static void cdcacm_ep0incomplete(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *req); FAR struct usbdev_req_s *req);
@@ -209,7 +209,7 @@ static void cdcacm_rdcomplete(FAR struct usbdev_ep_s *ep,
static void cdcacm_wrcomplete(FAR struct usbdev_ep_s *ep, static void cdcacm_wrcomplete(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *req); FAR struct usbdev_req_s *req);
/* USB class device ********************************************************/ /* USB class device *********************************************************/
static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver, static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
FAR struct usbdev_s *dev); FAR struct usbdev_s *dev);
@@ -520,7 +520,7 @@ static int cdcacm_recvpacket(FAR struct cdcacm_dev_s *priv,
* and that the actual capacity of the RX buffer is (recv->size - 1). * and that the actual capacity of the RX buffer is (recv->size - 1).
*/ */
watermark = (CONFIG_SERIAL_IFLOWCONTROL_UPPER_WATERMARK * recv->size) / 100; watermark = CONFIG_SERIAL_IFLOWCONTROL_UPPER_WATERMARK * recv->size / 100;
DEBUGASSERT(watermark > 0 && watermark < (recv->size - 1)); DEBUGASSERT(watermark > 0 && watermark < (recv->size - 1));
#endif #endif
@@ -558,8 +558,8 @@ static int cdcacm_recvpacket(FAR struct cdcacm_dev_s *priv,
if (nbuffered >= watermark) if (nbuffered >= watermark)
{ {
/* Let the lower level driver know that the watermark level has been /* Let the lower level driver know that the watermark level has
* crossed. It will probably activate RX flow control. * been crossed. It will probably activate RX flow control.
*/ */
if (cdcuart_rxflowcontrol(&priv->serdev, nbuffered, true)) if (cdcuart_rxflowcontrol(&priv->serdev, nbuffered, true))
@@ -1311,7 +1311,8 @@ static void cdcacm_wrcomplete(FAR struct usbdev_ep_s *ep,
static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver, static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
FAR struct usbdev_s *dev) FAR struct usbdev_s *dev)
{ {
FAR struct cdcacm_dev_s *priv = ((FAR struct cdcacm_driver_s *)driver)->dev; FAR struct cdcacm_dev_s *priv =
((FAR struct cdcacm_driver_s *)driver)->dev;
FAR struct cdcacm_wrreq_s *wrcontainer; FAR struct cdcacm_wrreq_s *wrcontainer;
FAR struct cdcacm_rdreq_s *rdcontainer; FAR struct cdcacm_rdreq_s *rdcontainer;
irqstate_t flags; irqstate_t flags;
@@ -1458,7 +1459,9 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
leave_critical_section(flags); leave_critical_section(flags);
} }
/* Report if we are selfpowered (unless we are part of a composite device) */ /* Report if we are selfpowered (unless we are part of a
* composite device)
*/
#ifndef CONFIG_CDCACM_COMPOSITE #ifndef CONFIG_CDCACM_COMPOSITE
#ifdef CONFIG_USBDEV_SELFPOWERED #ifdef CONFIG_USBDEV_SELFPOWERED
@@ -1876,7 +1879,8 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
if (dataout && len <= SIZEOF_CDC_LINECODING) /* REVISIT */ if (dataout && len <= SIZEOF_CDC_LINECODING) /* REVISIT */
{ {
memcpy(&priv->linecoding, dataout, SIZEOF_CDC_LINECODING); memcpy(&priv->linecoding,
dataout, SIZEOF_CDC_LINECODING);
} }
/* Respond with a zero length packet */ /* Respond with a zero length packet */
@@ -2564,8 +2568,8 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* and cdcuart_attach are called called) * and cdcuart_attach are called called)
* 2. With enable==false while transferring data from the RX buffer * 2. With enable==false while transferring data from the RX buffer
* 2. With enable==true while waiting for more incoming data * 2. With enable==true while waiting for more incoming data
* 3. With enable==false when the port is closed (just before cdcuart_detach * 3. With enable==false when the port is closed (just before
* and cdcuart_shutdown are called). * cdcuart_detach and cdcuart_shutdown are called).
* *
* Assumptions: * Assumptions:
* Called from the serial upper-half driver running on the thread of * Called from the serial upper-half driver running on the thread of
@@ -3100,8 +3104,8 @@ int cdcacm_initialize(int minor, FAR void **handle)
* *
* Input Parameters: * Input Parameters:
* There is one parameter, it differs in typing depending upon whether the * There is one parameter, it differs in typing depending upon whether the
* CDC/ACM driver is an internal part of a composite device, or a standalone * CDC/ACM driver is an internal part of a composite device, or a
* USB driver: * standalone USB driver:
* *
* classdev - The class object returned by cdcacm_classobject() * classdev - The class object returned by cdcacm_classobject()
* handle - The opaque handle representing the class object returned by * handle - The opaque handle representing the class object returned by
@@ -3217,7 +3221,7 @@ void cdcacm_get_composite_devdesc(struct composite_devdesc_s *dev)
dev->nconfigs = CDCACM_NCONFIGS; /* Number of configurations supported */ dev->nconfigs = CDCACM_NCONFIGS; /* Number of configurations supported */
dev->configid = CDCACM_CONFIGID; /* The only supported configuration ID */ dev->configid = CDCACM_CONFIGID; /* The only supported configuration ID */
/* Let the construction function calculate the size of the config descriptor */ /* Let the construction function calculate the size of config descriptor */
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
dev->cfgdescsize = cdcacm_mkcfgdesc(NULL, NULL, USB_SPEED_UNKNOWN, 0); dev->cfgdescsize = cdcacm_mkcfgdesc(NULL, NULL, USB_SPEED_UNKNOWN, 0);
+48 -39
View File
@@ -111,7 +111,9 @@
# define CONFIG_CDCECM_NINTERFACES 1 # define CONFIG_CDCECM_NINTERFACES 1
#endif #endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define CDCECM_WDDELAY (1*CLK_TCK) #define CDCECM_WDDELAY (1*CLK_TCK)
@@ -119,7 +121,7 @@
#define CDCECM_TXTIMEOUT (60*CLK_TCK) #define CDCECM_TXTIMEOUT (60*CLK_TCK)
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* This is a helper pointer for accessing the contents of Ethernet header */
#define BUF ((struct eth_hdr_s *)self->dev.d_buf) #define BUF ((struct eth_hdr_s *)self->dev.d_buf)
@@ -127,8 +129,8 @@
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
/* The cdcecm_driver_s encapsulates all state information for a single hardware /* The cdcecm_driver_s encapsulates all state information for a single
* interface * hardware interface
*/ */
struct cdcecm_driver_s struct cdcecm_driver_s
@@ -143,7 +145,8 @@ struct cdcecm_driver_s
FAR struct usbdev_ep_s *epbulkout; /* Bulk OUT endpoint */ FAR struct usbdev_ep_s *epbulkout; /* Bulk OUT endpoint */
uint8_t config; /* Selected configuration number */ uint8_t config; /* Selected configuration number */
uint8_t pktbuf[CONFIG_NET_ETH_PKTSIZE + CONFIG_NET_GUARDSIZE]; uint8_t pktbuf[CONFIG_NET_ETH_PKTSIZE +
CONFIG_NET_GUARDSIZE];
struct usbdev_req_s *rdreq; /* Single read request */ struct usbdev_req_s *rdreq; /* Single read request */
bool rxpending; /* Packet available in rdreq */ bool rxpending; /* Packet available in rdreq */
@@ -323,8 +326,8 @@ static const struct usb_devdesc_s g_devdesc =
static int cdcecm_transmit(FAR struct cdcecm_driver_s *self) static int cdcecm_transmit(FAR struct cdcecm_driver_s *self)
{ {
/* Wait until the USB device request for Ethernet frame transmissions becomes /* Wait until the USB device request for Ethernet frame transmissions
* available. * becomes available.
*/ */
while (nxsem_wait(&self->wrreq_idle) != OK) while (nxsem_wait(&self->wrreq_idle) != OK)
@@ -352,7 +355,8 @@ static int cdcecm_transmit(FAR struct cdcecm_driver_s *self)
* devif_poll() may be called: * devif_poll() may be called:
* *
* 1. When the preceding TX packet send is complete, * 1. When the preceding TX packet send is complete,
* 2. When the preceding TX packet send times out and the interface is reset * 2. When the preceding TX packet send times out and the interface is
* reset
* 3. During normal TX polling * 3. During normal TX polling
* *
* Input Parameters: * Input Parameters:
@@ -510,7 +514,7 @@ static void cdcecm_receive(FAR struct cdcecm_driver_s *self)
self->dev.d_len = self->rdreq->xfrd; self->dev.d_len = self->rdreq->xfrd;
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&self->dev); pkt_input(&self->dev);
#endif #endif
@@ -561,7 +565,7 @@ static void cdcecm_receive(FAR struct cdcecm_driver_s *self)
NETDEV_RXARP(&self->dev); NETDEV_RXARP(&self->dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (self->dev.d_len > 0) if (self->dev.d_len > 0)
@@ -646,9 +650,9 @@ static void cdcecm_interrupt_work(FAR void *arg)
leave_critical_section(flags); leave_critical_section(flags);
} }
/* Check if a packet transmission just completed. If so, call cdcecm_txdone. /* Check if a packet transmission just completed. If so, call
* This may disable further Tx interrupts if there are no pending * cdcecm_txdone. This may disable further Tx interrupts if there
* transmissions. * are no pending transmissions.
*/ */
if (self->txdone) if (self->txdone)
@@ -772,9 +776,9 @@ static int cdcecm_ifup(FAR struct net_driver_s *dev)
dev->d_ipv6addr[6], dev->d_ipv6addr[7]); dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
#endif #endif
/* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */ /* Initialize PHYs, Ethernet interface, and setup up Ethernet interrupts */
/* Instantiate the MAC address from priv->dev.d_mac.ether.ether_addr_octet */ /* Instantiate MAC address from priv->dev.d_mac.ether.ether_addr_octet */
#ifdef CONFIG_NET_ICMPv6 #ifdef CONFIG_NET_ICMPv6
/* Set up IPv6 multicast address filtering */ /* Set up IPv6 multicast address filtering */
@@ -929,7 +933,8 @@ static int cdcecm_txavail(FAR struct net_driver_s *dev)
****************************************************************************/ ****************************************************************************/
#if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6) #if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6)
static int cdcecm_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) static int cdcecm_addmac(FAR struct net_driver_s *dev,
FAR const uint8_t *mac)
{ {
FAR struct cdcecm_driver_s *priv = FAR struct cdcecm_driver_s *priv =
(FAR struct cdcecm_driver_s *)dev->d_private; (FAR struct cdcecm_driver_s *)dev->d_private;
@@ -945,8 +950,8 @@ static int cdcecm_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
* Name: cdcecm_rmmac * Name: cdcecm_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
@@ -1123,7 +1128,8 @@ static void cdcecm_rdcomplete(FAR struct usbdev_ep_s *ep,
{ {
DEBUGASSERT(!self->rxpending); DEBUGASSERT(!self->rxpending);
self->rxpending = true; self->rxpending = true;
work_queue(ETHWORK, &self->irqwork, cdcecm_interrupt_work, self, 0); work_queue(ETHWORK, &self->irqwork,
cdcecm_interrupt_work, self, 0);
} }
break; break;
@@ -1227,13 +1233,13 @@ static void cdcecm_freereq(FAR struct usbdev_ep_s *ep,
} }
} }
/****************************************************************************** /****************************************************************************
* Name: cdcecm_resetconfig * Name: cdcecm_resetconfig
* *
* Description: * Description:
* Mark the device as not configured and disable all endpoints. * Mark the device as not configured and disable all endpoints.
* *
******************************************************************************/ ****************************************************************************/
static void cdcecm_resetconfig(FAR struct cdcecm_driver_s *self) static void cdcecm_resetconfig(FAR struct cdcecm_driver_s *self)
{ {
@@ -1259,7 +1265,7 @@ static void cdcecm_resetconfig(FAR struct cdcecm_driver_s *self)
} }
} }
/****************************************************************************** /****************************************************************************
* Name: cdcecm_setconfig * Name: cdcecm_setconfig
* *
* Set the device configuration by allocating and configuring endpoints and * Set the device configuration by allocating and configuring endpoints and
@@ -1300,7 +1306,8 @@ static int cdcecm_setconfig(FAR struct cdcecm_driver_s *self, uint8_t config)
self->epint->priv = self; self->epint->priv = self;
bool is_high_speed = (self->usbdev.speed == USB_SPEED_HIGH); bool is_high_speed = (self->usbdev.speed == USB_SPEED_HIGH);
cdcecm_mkepdesc(CDCECM_EP_BULKIN_IDX, &epdesc, &self->devinfo, is_high_speed); cdcecm_mkepdesc(CDCECM_EP_BULKIN_IDX,
&epdesc, &self->devinfo, is_high_speed);
ret = EP_CONFIGURE(self->epbulkin, &epdesc, false); ret = EP_CONFIGURE(self->epbulkin, &epdesc, false);
if (ret < 0) if (ret < 0)
@@ -1310,7 +1317,8 @@ static int cdcecm_setconfig(FAR struct cdcecm_driver_s *self, uint8_t config)
self->epbulkin->priv = self; self->epbulkin->priv = self;
cdcecm_mkepdesc(CDCECM_EP_BULKOUT_IDX, &epdesc, &self->devinfo, is_high_speed); cdcecm_mkepdesc(CDCECM_EP_BULKOUT_IDX,
&epdesc, &self->devinfo, is_high_speed);
ret = EP_CONFIGURE(self->epbulkout, &epdesc, true); ret = EP_CONFIGURE(self->epbulkout, &epdesc, true);
if (ret < 0) if (ret < 0)
@@ -1355,7 +1363,7 @@ error:
return ret; return ret;
} }
/****************************************************************************** /****************************************************************************
* Name: cdcecm_setinterface * Name: cdcecm_setinterface
* *
****************************************************************************/ ****************************************************************************/
@@ -1734,7 +1742,7 @@ static int16_t cdcecm_mkcfgdesc(FAR uint8_t *desc,
return len; return len;
} }
/******************************************************************************* /****************************************************************************
* Name: cdcecm_getdescriptor * Name: cdcecm_getdescriptor
* *
* Description: * Description:
@@ -1752,10 +1760,10 @@ static int16_t cdcecm_mkcfgdesc(FAR uint8_t *desc,
* The size in bytes of the requested USB Descriptor or a negated errno in * The size in bytes of the requested USB Descriptor or a negated errno in
* case of failure. * case of failure.
* *
******************************************************************************/ ****************************************************************************/
static int cdcecm_getdescriptor(FAR struct cdcecm_driver_s *self, uint8_t type, static int cdcecm_getdescriptor(FAR struct cdcecm_driver_s *self,
uint8_t index, FAR void *desc) uint8_t type, uint8_t index, FAR void *desc)
{ {
uinfo("type: 0x%02hhx, index: 0x%02hhx\n", type, index); uinfo("type: 0x%02hhx, index: 0x%02hhx\n", type, index);
@@ -2035,12 +2043,12 @@ static int cdcecm_setup(FAR struct usbdevclass_driver_s *driver,
/* SetEthernetPacketFilter is the only required CDCECM subclass /* SetEthernetPacketFilter is the only required CDCECM subclass
* specific request, but it is still ok to always operate in * specific request, but it is still ok to always operate in
* promiscuous mode and rely on the host to do the filtering. This * promiscuous mode and rely on the host to do the filtering.
* is especially true for our case: A simulated point-to-point * This is especially true for our case:
* connection. * A simulated point-to-point connection.
*/ */
uinfo("ECM_SET_PACKET_FILTER. wValue: 0x%04hx, wIndex: 0x%04hx\n", uinfo("ECM_SET_PACKET_FILTER wValue: 0x%04hx, wIndex: 0x%04hx\n",
GETUINT16(ctrl->value), GETUINT16(ctrl->index)); GETUINT16(ctrl->value), GETUINT16(ctrl->index));
ret = OK; ret = OK;
@@ -2093,7 +2101,8 @@ static void cdcecm_disconnect(FAR struct usbdevclass_driver_s *driver,
* *
****************************************************************************/ ****************************************************************************/
static int cdcecm_classobject(int minor, FAR struct usbdev_devinfo_s *devinfo, static int cdcecm_classobject(int minor,
FAR struct usbdev_devinfo_s *devinfo,
FAR struct usbdevclass_driver_s **classdev) FAR struct usbdevclass_driver_s **classdev)
{ {
FAR struct cdcecm_driver_s *self; FAR struct cdcecm_driver_s *self;
@@ -2180,8 +2189,8 @@ static int cdcecm_classobject(int minor, FAR struct usbdev_devinfo_s *devinfo,
* *
* Input Parameters: * Input Parameters:
* There is one parameter, it differs in typing depending upon whether the * There is one parameter, it differs in typing depending upon whether the
* CDC/ECM driver is an internal part of a composite device, or a standalone * CDC/ECM driver is an internal part of a composite device, or a
* USB driver: * standalone USB driver:
* *
* classdev - The class object returned by cdcacm_classobject() * classdev - The class object returned by cdcacm_classobject()
* handle - The opaque handle representing the class object returned by * handle - The opaque handle representing the class object returned by
@@ -2266,8 +2275,8 @@ void cdcecm_uninitialize(FAR void *handle)
* Name: cdcecm_initialize * Name: cdcecm_initialize
* *
* Description: * Description:
* Register CDC/ECM USB device interface. Register the corresponding network * Register CDC/ECM USB device interface. Register the corresponding
* driver to NuttX and bring up the network. * network driver to NuttX and bring up the network.
* *
* Input Parameters: * Input Parameters:
* minor - Device minor number. * minor - Device minor number.
@@ -2348,7 +2357,7 @@ void cdcecm_get_composite_devdesc(struct composite_devdesc_s *dev)
dev->nconfigs = CDCECM_NCONFIGS; /* Number of configurations supported */ dev->nconfigs = CDCECM_NCONFIGS; /* Number of configurations supported */
dev->configid = CDCECM_CONFIGID; /* The only supported configuration ID */ dev->configid = CDCECM_CONFIGID; /* The only supported configuration ID */
/* Let the construction function calculate the size of the config descriptor */ /* Let the construction function calculate the size of config descriptor */
#ifdef CONFIG_USBDEV_DUALSPEED #ifdef CONFIG_USBDEV_DUALSPEED
dev->cfgdescsize = cdcecm_mkcfgdesc(NULL, NULL, USB_SPEED_UNKNOWN, 0); dev->cfgdescsize = cdcecm_mkcfgdesc(NULL, NULL, USB_SPEED_UNKNOWN, 0);
+56 -35
View File
@@ -101,7 +101,9 @@
#define RNDIS_BUFFER_SIZE CONFIG_NET_ETH_PKTSIZE #define RNDIS_BUFFER_SIZE CONFIG_NET_ETH_PKTSIZE
#define RNDIS_BUFFER_COUNT 4 #define RNDIS_BUFFER_COUNT 4
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define RNDIS_WDDELAY (1*CLK_TCK) #define RNDIS_WDDELAY (1*CLK_TCK)
@@ -394,8 +396,8 @@ static uint8_t g_rndis_default_mac_addr[6] =
}; };
/* These lists give dummy responses to be returned to PC. The values are /* These lists give dummy responses to be returned to PC. The values are
* chosen so that Windows is happy - other operating systems don't really care * chosen so that Windows is happy - other operating systems don't really
* much. * care much.
*/ */
static const uint32_t g_rndis_supported_oids[] = static const uint32_t g_rndis_supported_oids[] =
@@ -474,8 +476,8 @@ static const struct rndis_oid_value_s g_rndis_oid_values[] =
* When the reception of an Ethernet packet is complete, a worker to process * When the reception of an Ethernet packet is complete, a worker to process
* the packet is scheduled and bulk OUT endpoint is set to NAK. * the packet is scheduled and bulk OUT endpoint is set to NAK.
* *
* The processing worker passes the buffer to the network. When the network is * The processing worker passes the buffer to the network. When the network
* done processing the packet, the buffer might contain data to be sent. * is done processing the packet, the buffer might contain data to be sent.
* If so, the corresponding write request is queued on the bulk IN endpoint. * If so, the corresponding write request is queued on the bulk IN endpoint.
* The NAK state on bulk OUT endpoint is cleared to allow new packets to * The NAK state on bulk OUT endpoint is cleared to allow new packets to
* arrive. If there's no data to send, the request is returned to the list of * arrive. If there's no data to send, the request is returned to the list of
@@ -832,7 +834,8 @@ static uint16_t rndis_fillrequest(FAR struct rndis_dev_s *priv,
{ {
/* Send the required headers */ /* Send the required headers */
FAR struct rndis_packet_msg *msg = (FAR struct rndis_packet_msg *)req->buf; FAR struct rndis_packet_msg *msg =
(FAR struct rndis_packet_msg *)req->buf;
memset(msg, 0, RNDIS_PACKET_HDR_SIZE); memset(msg, 0, RNDIS_PACKET_HDR_SIZE);
msg->msgtype = RNDIS_PACKET_MSG; msg->msgtype = RNDIS_PACKET_MSG;
@@ -959,7 +962,8 @@ static void rndis_rxdispatch(FAR void *arg)
else else
#endif #endif
{ {
uerr("ERROR: Unsupported packet type dropped (%02x)\n", htons(hdr->type)); uerr("ERROR: Unsupported packet type dropped (%02x)\n",
htons(hdr->type));
NETDEV_RXDROPPED(&priv->netdev); NETDEV_RXDROPPED(&priv->netdev);
priv->netdev.d_len = 0; priv->netdev.d_len = 0;
} }
@@ -1035,8 +1039,8 @@ static int rndis_txpoll(FAR struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return ret; return ret;
@@ -1204,7 +1208,7 @@ static int rndis_txavail(FAR struct net_driver_s *dev)
return OK; return OK;
} }
/************************************************************************************ /****************************************************************************
* Name: rndis_recvpacket * Name: rndis_recvpacket
* *
* Description: * Description:
@@ -1213,7 +1217,7 @@ static int rndis_txavail(FAR struct net_driver_s *dev)
* Assumptions: * Assumptions:
* Called from the USB interrupt handler with interrupts disabled. * Called from the USB interrupt handler with interrupts disabled.
* *
************************************************************************************/ ****************************************************************************/
static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv, static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
FAR uint8_t *reqbuf, uint16_t reqlen) FAR uint8_t *reqbuf, uint16_t reqlen)
@@ -1238,7 +1242,8 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
{ {
/* The packet contains a RNDIS packet message header */ /* The packet contains a RNDIS packet message header */
FAR struct rndis_packet_msg *msg = (FAR struct rndis_packet_msg *)reqbuf; FAR struct rndis_packet_msg *msg =
(FAR struct rndis_packet_msg *)reqbuf;
if (msg->msgtype == RNDIS_PACKET_MSG) if (msg->msgtype == RNDIS_PACKET_MSG)
{ {
priv->current_rx_received = reqlen; priv->current_rx_received = reqlen;
@@ -1247,16 +1252,17 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
/* According to RNDIS-over-USB send, if the message length is a /* According to RNDIS-over-USB send, if the message length is a
* multiple of endpoint max packet size, the host must send an * multiple of endpoint max packet size, the host must send an
* additional single-byte zero packet. Take that in account here. * additional single-byte zero packet. Take that in account
* here.
*/ */
if ((priv->current_rx_msglen % priv->epbulkout->maxpacket) == 0) if (!(priv->current_rx_msglen % priv->epbulkout->maxpacket))
{ {
priv->current_rx_msglen += 1; priv->current_rx_msglen += 1;
} }
/* Data offset is defined as an offset from the beginning of the /* Data offset is defined as an offset from the beginning of
* offset field itself * the offset field itself
*/ */
priv->current_rx_datagram_offset = msg->dataoffset + 8; priv->current_rx_datagram_offset = msg->dataoffset + 8;
@@ -1279,19 +1285,22 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
priv->current_rx_received <= priv->current_rx_datagram_size + priv->current_rx_received <= priv->current_rx_datagram_size +
priv->current_rx_datagram_offset) priv->current_rx_datagram_offset)
{ {
size_t index = priv->current_rx_received - priv->current_rx_datagram_offset; size_t index = priv->current_rx_received -
size_t copysize = min(reqlen, priv->current_rx_datagram_size - index); priv->current_rx_datagram_offset;
size_t copysize = min(reqlen,
priv->current_rx_datagram_size - index);
/* Check if the received packet exceeds request buffer */ /* Check if the received packet exceeds request buffer */
if ((index + copysize) <= CONFIG_NET_ETH_PKTSIZE) if ((index + copysize) <= CONFIG_NET_ETH_PKTSIZE)
{ {
memcpy(&priv->rx_req->req->buf[RNDIS_PACKET_HDR_SIZE + index], reqbuf, memcpy(&priv->rx_req->req->buf[RNDIS_PACKET_HDR_SIZE + index],
copysize); reqbuf, copysize);
} }
else else
{ {
uerr("The packet exceeds request buffer (reqlen=%d) \n", reqlen); uerr("The packet exceeds request buffer (reqlen=%d) \n",
reqlen);
} }
} }
priv->current_rx_received += reqlen; priv->current_rx_received += reqlen;
@@ -1342,7 +1351,8 @@ static inline int rndis_recvpacket(FAR struct rndis_dev_s *priv,
* *
****************************************************************************/ ****************************************************************************/
static bool rndis_prepare_response(FAR struct rndis_dev_s *priv, size_t size, static bool
rndis_prepare_response(FAR struct rndis_dev_s *priv, size_t size,
FAR struct rndis_command_header *request_hdr) FAR struct rndis_command_header *request_hdr)
{ {
FAR struct rndis_response_header *hdr = FAR struct rndis_response_header *hdr =
@@ -1403,7 +1413,8 @@ static int rndis_send_encapsulated_response(FAR struct rndis_dev_s *priv)
****************************************************************************/ ****************************************************************************/
static int rndis_handle_control_message(FAR struct rndis_dev_s *priv, static int rndis_handle_control_message(FAR struct rndis_dev_s *priv,
FAR uint8_t *dataout, uint16_t outlen) FAR uint8_t *dataout,
uint16_t outlen)
{ {
FAR struct rndis_command_header *cmd_hdr = FAR struct rndis_command_header *cmd_hdr =
(FAR struct rndis_command_header *)dataout; (FAR struct rndis_command_header *)dataout;
@@ -1453,7 +1464,8 @@ static int rndis_handle_control_message(FAR struct rndis_dev_s *priv,
resp->hdr.status = RNDIS_STATUS_NOT_SUPPORTED; resp->hdr.status = RNDIS_STATUS_NOT_SUPPORTED;
for (i = 0; for (i = 0;
i < sizeof(g_rndis_oid_values) / sizeof(g_rndis_oid_values[0]); i < sizeof(g_rndis_oid_values) /
sizeof(g_rndis_oid_values[0]);
i++) i++)
{ {
bool match = (g_rndis_oid_values[i].objid == req->objid); bool match = (g_rndis_oid_values[i].objid == req->objid);
@@ -1642,7 +1654,8 @@ static void rndis_rdcomplete(FAR struct usbdev_ep_s *ep,
return; return;
default: /* Some other error occurred */ default: /* Some other error occurred */
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED), (uint16_t)-req->result); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED),
(uint16_t)-req->result);
break; break;
}; };
@@ -2074,7 +2087,8 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
/* Pre-allocate the IN interrupt endpoint */ /* Pre-allocate the IN interrupt endpoint */
priv->epintin = DEV_ALLOCEP(dev, USB_EPIN(priv->devinfo.epno[RNDIS_EP_INTIN_IDX]), priv->epintin = DEV_ALLOCEP(dev,
USB_EPIN(priv->devinfo.epno[RNDIS_EP_INTIN_IDX]),
true, USB_EP_ATTR_XFER_INT); true, USB_EP_ATTR_XFER_INT);
if (!priv->epintin) if (!priv->epintin)
{ {
@@ -2098,7 +2112,8 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
/* Pre-allocate the IN bulk endpoint */ /* Pre-allocate the IN bulk endpoint */
priv->epbulkin = DEV_ALLOCEP(dev, USB_EPIN(priv->devinfo.epno[RNDIS_EP_BULKIN_IDX]), priv->epbulkin = DEV_ALLOCEP(dev,
USB_EPIN(priv->devinfo.epno[RNDIS_EP_BULKIN_IDX]),
true, USB_EP_ATTR_XFER_BULK); true, USB_EP_ATTR_XFER_BULK);
if (!priv->epbulkin) if (!priv->epbulkin)
{ {
@@ -2376,8 +2391,9 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
{ {
case USB_REQ_GETDESCRIPTOR: case USB_REQ_GETDESCRIPTOR:
{ {
/* The value field specifies the descriptor type in the MS byte and the /* The value field specifies the descriptor type in the MS byte
* descriptor index in the LS byte (order is little endian) * and the descriptor index in the LS byte (order is little
* endian)
*/ */
switch (ctrl->value[1]) switch (ctrl->value[1])
@@ -2408,7 +2424,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
default: default:
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_GETUNKNOWNDESC), value); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_GETUNKNOWNDESC),
value);
} }
break; break;
} }
@@ -2435,7 +2452,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
break; break;
default: default:
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDSTDREQ),
ctrl->req);
break; break;
} }
} }
@@ -2445,7 +2463,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver,
case USB_REQ_TYPE_CLASS: case USB_REQ_TYPE_CLASS:
{ {
if ((ctrl->type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_INTERFACE) if ((ctrl->type & USB_REQ_RECIPIENT_MASK) ==
USB_REQ_RECIPIENT_INTERFACE)
{ {
if (ctrl->req == RNDIS_SEND_ENCAPSULATED_COMMAND) if (ctrl->req == RNDIS_SEND_ENCAPSULATED_COMMAND)
{ {
@@ -2657,7 +2676,8 @@ static int usbclass_setconfig(FAR struct rndis_dev_s *priv, uint8_t config)
/* Configure the IN bulk endpoint */ /* Configure the IN bulk endpoint */
usbclass_copy_epdesc(RNDIS_EP_BULKIN_IDX, &epdesc, &priv->devinfo, hispeed); usbclass_copy_epdesc(RNDIS_EP_BULKIN_IDX,
&epdesc, &priv->devinfo, hispeed);
ret = EP_CONFIGURE(priv->epbulkin, &epdesc, false); ret = EP_CONFIGURE(priv->epbulkin, &epdesc, false);
if (ret < 0) if (ret < 0)
@@ -2670,7 +2690,8 @@ static int usbclass_setconfig(FAR struct rndis_dev_s *priv, uint8_t config)
/* Configure the OUT bulk endpoint */ /* Configure the OUT bulk endpoint */
usbclass_copy_epdesc(RNDIS_EP_BULKOUT_IDX, &epdesc, &priv->devinfo, hispeed); usbclass_copy_epdesc(RNDIS_EP_BULKOUT_IDX,
&epdesc, &priv->devinfo, hispeed);
ret = EP_CONFIGURE(priv->epbulkout, &epdesc, true); ret = EP_CONFIGURE(priv->epbulkout, &epdesc, true);
if (ret < 0) if (ret < 0)
@@ -2728,7 +2749,7 @@ static int usbclass_classobject(int minor,
/* Allocate the structures needed */ /* Allocate the structures needed */
alloc = (FAR struct rndis_alloc_s *)kmm_zalloc(sizeof(struct rndis_alloc_s)); alloc = kmm_zalloc(sizeof(struct rndis_alloc_s));
if (!alloc) if (!alloc)
{ {
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCDEVSTRUCT), 0); usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCDEVSTRUCT), 0);
@@ -90,15 +90,17 @@
#define BCMFWORK LPWORK #define BCMFWORK LPWORK
/* CONFIG_IEEE80211_BROADCOM_NINTERFACES determines the number of physical interfaces /* CONFIG_IEEE80211_BROADCOM_NINTERFACES determines the number of physical
* that will be supported. * interfaces that will be supported.
*/ */
#ifndef CONFIG_IEEE80211_BROADCOM_NINTERFACES #ifndef CONFIG_IEEE80211_BROADCOM_NINTERFACES
# define CONFIG_IEEE80211_BROADCOM_NINTERFACES 1 # define CONFIG_IEEE80211_BROADCOM_NINTERFACES 1
#endif #endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define BCMF_WDDELAY (1*CLK_TCK) #define BCMF_WDDELAY (1*CLK_TCK)
@@ -106,7 +108,7 @@
#define BCMF_TXTIMEOUT (60*CLK_TCK) #define BCMF_TXTIMEOUT (60*CLK_TCK)
/* This is a helper pointer for accessing the contents of the Ethernet header */ /* This is a helper pointer for accessing the contents of Ethernet header */
#define BUF ((struct eth_hdr_s *)priv->bc_dev.d_buf) #define BUF ((struct eth_hdr_s *)priv->bc_dev.d_buf)
@@ -166,7 +168,8 @@ int bcmf_netdev_alloc_tx_frame(FAR struct bcmf_dev_s *priv)
/* Allocate frame for TX */ /* Allocate frame for TX */
priv->cur_tx_frame = bcmf_bdc_allocate_frame(priv, MAX_NETDEV_PKTSIZE, true); priv->cur_tx_frame = bcmf_bdc_allocate_frame(priv,
MAX_NETDEV_PKTSIZE, true);
if (!priv->cur_tx_frame) if (!priv->cur_tx_frame)
{ {
wlerr("ERROR: Cannot allocate TX frame\n"); wlerr("ERROR: Cannot allocate TX frame\n");
@@ -259,12 +262,12 @@ static void bcmf_receive(FAR struct bcmf_dev_s *priv)
} }
priv->bc_dev.d_buf = frame->data; priv->bc_dev.d_buf = frame->data;
priv->bc_dev.d_len = frame->len - (uint32_t)(frame->data - frame->base); priv->bc_dev.d_len = frame->len - (frame->data - frame->base);
wlinfo("Got frame %p %d\n", frame, priv->bc_dev.d_len); wlinfo("Got frame %p %d\n", frame, priv->bc_dev.d_len);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->bc_dev); pkt_input(&priv->bc_dev);
#endif #endif
@@ -303,7 +306,7 @@ static void bcmf_receive(FAR struct bcmf_dev_s *priv)
ipv4_input(&priv->bc_dev); ipv4_input(&priv->bc_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->bc_dev.d_len > 0) if (priv->bc_dev.d_len > 0)
@@ -347,7 +350,7 @@ static void bcmf_receive(FAR struct bcmf_dev_s *priv)
ipv6_input(&priv->bc_dev); ipv6_input(&priv->bc_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->bc_dev.d_len > 0) if (priv->bc_dev.d_len > 0)
@@ -387,7 +390,7 @@ static void bcmf_receive(FAR struct bcmf_dev_s *priv)
NETDEV_RXARP(&priv->bc_dev); NETDEV_RXARP(&priv->bc_dev);
/* If the above function invocation resulted in data that should be /* If the above function invocation resulted in data that should be
* sent out on the network, the field d_len will set to a value > 0. * sent out on the network, d_len field will set to a value > 0.
*/ */
if (priv->bc_dev.d_len > 0) if (priv->bc_dev.d_len > 0)
@@ -479,8 +482,8 @@ static int bcmf_txpoll(FAR struct net_driver_s *dev)
bcmf_transmit(priv, priv->cur_tx_frame); bcmf_transmit(priv, priv->cur_tx_frame);
/* TODO: Check if there is room in the device to hold another packet. /* TODO: Check if there is room in the device to hold another
* If not, return a non-zero value to terminate the poll. * packet. If not, return a non-zero value to terminate the poll.
*/ */
priv->cur_tx_frame = NULL; priv->cur_tx_frame = NULL;
@@ -488,8 +491,8 @@ static int bcmf_txpoll(FAR struct net_driver_s *dev)
} }
} }
/* If zero is returned, the polling will continue until all connections have /* If zero is returned, the polling will continue until all connections
* been examined. * have been examined.
*/ */
return 0; return 0;
@@ -688,7 +691,7 @@ static int bcmf_ifup(FAR struct net_driver_s *dev)
dev->d_ipv6addr[6], dev->d_ipv6addr[7]); dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
#endif #endif
/* Instantiate the MAC address from priv->bc_dev.d_mac.ether.ether_addr_octet */ /* Instantiate MAC address from priv->bc_dev.d_mac.ether.ether_addr_octet */
#ifdef CONFIG_NET_ICMPv6 #ifdef CONFIG_NET_ICMPv6
/* Set up IPv6 multicast address filtering */ /* Set up IPv6 multicast address filtering */
@@ -782,7 +785,7 @@ static void bcmf_txavail_work(FAR void *arg)
if (priv->bc_bifup) if (priv->bc_bifup)
{ {
/* Check if there is room in the hardware to hold another outgoing packet. */ /* Check if there is room in the hardware to hold another packet. */
if (bcmf_netdev_alloc_tx_frame(priv)) if (bcmf_netdev_alloc_tx_frame(priv))
{ {
@@ -871,8 +874,8 @@ static int bcmf_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
* Name: bcmf_rmmac * Name: bcmf_rmmac
* *
* Description: * Description:
* NuttX Callback: Remove the specified MAC address from the hardware multicast * NuttX Callback: Remove the specified MAC address from the hardware
* address filtering * multicast address filtering
* *
* Input Parameters: * Input Parameters:
* dev - Reference to the NuttX driver state structure * dev - Reference to the NuttX driver state structure
+40 -33
View File
@@ -89,10 +89,10 @@ static void xbee_assocworker(FAR void *arg);
* Name: xbee_assoctimer * Name: xbee_assoctimer
* *
* Description: * Description:
* This function is used to schedule * an associatioin indication poll. When * This function is used to schedule * an associatioin indication poll.
* association first gets triggered, a watchdog timer is started. This function * When association first gets triggered, a watchdog timer is started. This
* is called when it expires. The watchdog timer is scheduled again until * function is called when it expires. The watchdog timer is scheduled
* the association is either successful or fails. * again until the association is either successful or fails.
* *
* Input Parameters: * Input Parameters:
* argc - The number of available arguments * argc - The number of available arguments
@@ -123,7 +123,8 @@ static void xbee_assoctimer(int argc, wdparm_t arg, ...)
* occur until we restart the poll timeout watchdog. * occur until we restart the poll timeout watchdog.
*/ */
ret = work_queue(HPWORK, &priv->assocwork, xbee_assocworker, (FAR void *)priv, 0); ret = work_queue(HPWORK, &priv->assocwork,
xbee_assocworker, (FAR void *)priv, 0);
UNUSED(ret); UNUSED(ret);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
} }
@@ -133,8 +134,8 @@ static void xbee_assoctimer(int argc, wdparm_t arg, ...)
* *
* Description: * Description:
* Poll the device for the assosciation status. This function is indirectly * Poll the device for the assosciation status. This function is indirectly
* scheduled rom xbee_req_associate in order to poll the device for association * scheduled rom xbee_req_associate in order to poll the device for
* progress. * association progress.
* *
* Input Parameters: * Input Parameters:
* arg - The reference to the driver structure (cast to void*) * arg - The reference to the driver structure (cast to void*)
@@ -163,11 +164,11 @@ static void xbee_assocworker(FAR void *arg)
* Name: xbee_reqdata_timeout * Name: xbee_reqdata_timeout
* *
* Description: * Description:
* This function runs when a send request has timed out waiting for a response * This function runs when a send request has timed out waiting for a
* from the XBee module. This really should never happen, but if it does, * response from the XBee module. This really should never happen, but if
* handle it gracefully by retrying the query. Although I still think this * it does, handle it gracefully by retrying the query. Although I still
* should not happen, it does seem to happen. The XBee seemingly randomly drops * think this should not happen, it does seem to happen. The XBee seemingly
* the request and never sends a response. * randomly drops the request and never sends a response.
* *
* Parameters: * Parameters:
* argc - The number of available arguments * argc - The number of available arguments
@@ -263,12 +264,13 @@ int xbee_bind(XBEEHANDLE xbee, FAR struct xbee_maccb_s *cb)
* Description: * Description:
* Calculate the MAC header length given the frame meta-data. For the XBee, * Calculate the MAC header length given the frame meta-data. For the XBee,
* we use the header to store the entire API frame for the TX request. The * we use the header to store the entire API frame for the TX request. The
* size we need is fixed based on the address mode we are using as it changes * size we need is fixed based on the address mode we are using as it
* which API frame we need to issue. * changes which API frame we need to issue.
* *
****************************************************************************/ ****************************************************************************/
int xbee_get_mhrlen(XBEEHANDLE xbee, FAR const struct ieee802154_frame_meta_s *meta) int xbee_get_mhrlen(XBEEHANDLE xbee,
FAR const struct ieee802154_frame_meta_s *meta)
{ {
int ret = 9; /* Smallest possible header size */ int ret = 9; /* Smallest possible header size */
@@ -388,15 +390,17 @@ int xbee_req_data(XBEEHANDLE xbee,
xbee_send_apiframe(priv, &frame->io_data[frame->io_offset], xbee_send_apiframe(priv, &frame->io_data[frame->io_offset],
(frame->io_len - frame->io_offset)); (frame->io_len - frame->io_offset));
/* Wait for a transmit status to be received. Does not necessarily mean success */ /* Wait for a transmit status to be received. Does not necessarily mean
* success
*/
while (nxsem_wait(&priv->txdone_sem) < 0); while (nxsem_wait(&priv->txdone_sem) < 0);
/* If the transmit timeout has occurred, and there are no IOBs available, /* If the transmit timeout has occurred, and there are no IOBs
* we may be blocking the context needed to free the IOBs. We cannot receive * available, we may be blocking the context needed to free the IOBs.
* the Tx status because it requires an IOB. Therefore, if we have hit the * We cannot receive the Tx status because it requires an IOB.
* timeout, and there are no IOBs, let's move on assuming the transmit was * Therefore, if we have hit the timeout, and there are no IOBs, let's
* a success * move on assuming the transmit was a success
*/ */
if (!priv->txdone && iob_navail(false) <= 0) if (!priv->txdone && iob_navail(false) <= 0)
@@ -430,8 +434,8 @@ int xbee_req_data(XBEEHANDLE xbee,
* *
* NOTE: The standard specifies that the attribute value should be returned * NOTE: The standard specifies that the attribute value should be returned
* via the asynchronous MLME-GET.confirm primitive. However, in our * via the asynchronous MLME-GET.confirm primitive. However, in our
* implementation, we synchronously return the value immediately.Therefore, we * implementation, we synchronously return the value immediately.Therefore,
* merge the functionality of the MLME-GET.request and MLME-GET.confirm * we merge the functionality of the MLME-GET.request and MLME-GET.confirm
* primitives together. * primitives together.
* *
****************************************************************************/ ****************************************************************************/
@@ -494,8 +498,9 @@ int xbee_req_get(XBEEHANDLE xbee, enum ieee802154_attr_e attr,
case IEEE802154_ATTR_PHY_TX_POWER: case IEEE802154_ATTR_PHY_TX_POWER:
{ {
/* TODO: Convert pwrlvl and boost mode settings to int32_t dbm. This /* TODO: Convert pwrlvl and boost mode settings to int32_t dbm.
* depends on whether device is XBee or XBee Pro to do this look-up. * This depends on whether device is XBee or XBee Pro to do this
* look-up.
*/ */
xbee_query_powerlevel(priv); xbee_query_powerlevel(priv);
@@ -535,10 +540,10 @@ int xbee_req_get(XBEEHANDLE xbee, enum ieee802154_attr_e attr,
* indicated MAC PIB attribute. * indicated MAC PIB attribute.
* *
* NOTE: The standard specifies that confirmation should be indicated via * NOTE: The standard specifies that confirmation should be indicated via
* the asynchronous MLME-SET.confirm primitive. However, in our implementation * the asynchronous MLME-SET.confirm primitive. However, in our
* we synchronously return the status from the request. Therefore, we do merge * implementation we synchronously return the status from the request.
* the functionality of the MLME-SET.request and MLME-SET.confirm primitives * Therefore, we do merge the functionality of the MLME-SET.request and
* together. * MLME-SET.confirm primitives together.
* *
****************************************************************************/ ****************************************************************************/
@@ -578,7 +583,8 @@ int xbee_req_set(XBEEHANDLE xbee, enum ieee802154_attr_e attr,
{ {
if (attrval->mac.assocpermit) if (attrval->mac.assocpermit)
{ {
xbee_set_coordassocflags(priv, XBEE_COORDASSOCFLAGS_ALLOWASSOC); xbee_set_coordassocflags(priv,
XBEE_COORDASSOCFLAGS_ALLOWASSOC);
} }
else else
{ {
@@ -589,8 +595,8 @@ int xbee_req_set(XBEEHANDLE xbee, enum ieee802154_attr_e attr,
case IEEE802154_ATTR_PHY_TX_POWER: case IEEE802154_ATTR_PHY_TX_POWER:
{ {
/* TODO: Convert int32_t dbm input to closest PM/PL settings. Need to /* TODO: Convert int32_t dbm input to closest PM/PL settings. Need
* know whether device is XBee or XBee Pro to do this look-up. * to know whether device is XBee or XBee Pro to do this look-up.
*/ */
xbee_set_powerlevel(priv, attrval->phy.txpwr); xbee_set_powerlevel(priv, attrval->phy.txpwr);
@@ -676,7 +682,8 @@ int xbee_req_start(XBEEHANDLE xbee, FAR struct ieee802154_start_req_s *req)
* *
****************************************************************************/ ****************************************************************************/
int xbee_req_associate(XBEEHANDLE xbee, FAR struct ieee802154_assoc_req_s *req) int xbee_req_associate(XBEEHANDLE xbee,
FAR struct ieee802154_assoc_req_s *req)
{ {
FAR struct xbee_priv_s *priv = (FAR struct xbee_priv_s *)xbee; FAR struct xbee_priv_s *priv = (FAR struct xbee_priv_s *)xbee;
@@ -215,7 +215,9 @@
#define SPIRIT_RXFIFO_ALMOSTFULL (3 * SPIRIT_MAX_FIFO_LEN / 4) #define SPIRIT_RXFIFO_ALMOSTFULL (3 * SPIRIT_MAX_FIFO_LEN / 4)
#define SPIRIT_TXFIFO_ALMOSTEMPTY (1 * SPIRIT_MAX_FIFO_LEN / 4) #define SPIRIT_TXFIFO_ALMOSTEMPTY (1 * SPIRIT_MAX_FIFO_LEN / 4)
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */ /* TX poll delay = 1 seconds.
* CLK_TCK is the number of clock ticks per second
*/
#define SPIRIT_WDDELAY (1*CLK_TCK) #define SPIRIT_WDDELAY (1*CLK_TCK)
@@ -580,7 +582,7 @@ static void spirit_set_ipaddress(FAR struct net_driver_s *dev)
{ {
FAR struct netdev_varaddr_s *addr; FAR struct netdev_varaddr_s *addr;
/* Get a convenient pointer to the PktRadio variable length address struct */ /* Get a convenient pointer to the variable length address struct */
addr = (FAR struct netdev_varaddr_s *)&dev->d_mac.radio; addr = (FAR struct netdev_varaddr_s *)&dev->d_mac.radio;
@@ -2861,7 +2863,7 @@ int spirit_netdev_initialize(FAR struct spi_dev_s *spi,
priv->radio.r_dev.d_buf = g_iobuffer.rb_buf; priv->radio.r_dev.d_buf = g_iobuffer.rb_buf;
#endif #endif
/* Register the device with the OS so that socket IOCTLs can be performed. */ /* Register the device with the OS so that IOCTLs can be performed. */
ret = netdev_register(dev, NET_LL_PKTRADIO); ret = netdev_register(dev, NET_LL_PKTRADIO);
if (ret < 0) if (ret < 0)
+7 -5
View File
@@ -79,7 +79,7 @@
#define GMII_KSZ90x1_LINKMD 18 /* LinkMD(c) cable diagnostic */ #define GMII_KSZ90x1_LINKMD 18 /* LinkMD(c) cable diagnostic */
#define GMII_KSZ90x1_PMAPCS 19 /* Digital PMA/PCS status */ #define GMII_KSZ90x1_PMAPCS 19 /* Digital PMA/PCS status */
#define GMII_KSZ90x1_RXERR 21 /* RXER counter */ #define GMII_KSZ90x1_RXERR 21 /* RXER counter */
#define GMII_KSZ90x1_ICS 27 /* Interrupt control/status */ #define GMII_KSZ90X1_ICS 27 /* Interrupt control/status */
#define GMII_KSZ90x1_DBGCTRL1 28 /* Digital debug control 1 */ #define GMII_KSZ90x1_DBGCTRL1 28 /* Digital debug control 1 */
#define GMII_KSZ90x1_PHYCTRL 31 /* PHY control */ #define GMII_KSZ90x1_PHYCTRL 31 /* PHY control */
@@ -89,8 +89,8 @@
#define GMII_KSZ90x1_SSR 257 /* Strap status */ #define GMII_KSZ90x1_SSR 257 /* Strap status */
#define GMII_KSZ90x1_OMSOR 258 /* Operation mode strap override */ #define GMII_KSZ90x1_OMSOR 258 /* Operation mode strap override */
#define GMII_KSZ90x1_OMSSR 259 /* Operation mode strap status */ #define GMII_KSZ90x1_OMSSR 259 /* Operation mode strap status */
#define GMII_KSZ90x1_RCCPSR 260 /* RGMII clock and control pad skew */ #define GMII_KSZ90X1_RCCPSR 260 /* RGMII clock and control pad skew */
#define GMII_KSZ90x1_RRDPSR 261 /* RGMII RX data pad skew */ #define GMII_KSZ90X1_RRDPSR 261 /* RGMII RX data pad skew */
#define GMII_KSZ90x1_ATR 263 /* Analog test register */ #define GMII_KSZ90x1_ATR 263 /* Analog test register */
/* MII register bit settings *****************************************************************/ /* MII register bit settings *****************************************************************/
@@ -233,6 +233,7 @@
#define GMII_ESTATUS_1000BASEXFULL MII_ESTATUS_1000BASEXFULL #define GMII_ESTATUS_1000BASEXFULL MII_ESTATUS_1000BASEXFULL
/* 1000BASE-T Control Register */ /* 1000BASE-T Control Register */
/* Bits 0-7: Reserved */ /* Bits 0-7: Reserved */
#define GMII_1000BTCR_1000BASETHALF (1 << 8) /* Bit 8: 1000Base-T half duplex able */ #define GMII_1000BTCR_1000BASETHALF (1 << 8) /* Bit 8: 1000Base-T half duplex able */
#define GMII_1000BTCR_1000BASETFULL (1 << 9) /* Bit 9: 1000Base-T full duplex able */ #define GMII_1000BTCR_1000BASETFULL (1 << 9) /* Bit 9: 1000Base-T full duplex able */
@@ -267,6 +268,7 @@
#define GMII_ERCR_WRITE (1 << 15) /* Bit 15: 1=Write extended register */ #define GMII_ERCR_WRITE (1 << 15) /* Bit 15: 1=Write extended register */
/* Extend Register - Data Write Register (16-bit data value) */ /* Extend Register - Data Write Register (16-bit data value) */
/* Extend Register - Data Read Register (16-bit data value) */ /* Extend Register - Data Read Register (16-bit data value) */
/* Micrel KSZ9021/31 Vendor Specific Register Bit Definitions ********************************/ /* Micrel KSZ9021/31 Vendor Specific Register Bit Definitions ********************************/
@@ -278,9 +280,9 @@
#define GMII_KSZ90x1_INT_PREN (1 << 13) /* Page received interrupt enable */ #define GMII_KSZ90x1_INT_PREN (1 << 13) /* Page received interrupt enable */
#define GMII_KSZ90x1_INT_PDFEN (1 << 12) /* Parallel detect fault interrupt enable */ #define GMII_KSZ90x1_INT_PDFEN (1 << 12) /* Parallel detect fault interrupt enable */
#define GMII_KSZ90x1_INT_LPAEN (1 << 11) /* Link partner acknowledge interrupt enable */ #define GMII_KSZ90x1_INT_LPAEN (1 << 11) /* Link partner acknowledge interrupt enable */
#define GMII_KSZ90x1_INT_LDEN (1 << 10) /* Link down fault interrupt enable */ #define GMII_KSZ90X1_INT_LDEN (1 << 10) /* Link down fault interrupt enable */
#define GMII_KSZ90x1_INT_RFEN (1 << 9) /* Remote fault interrupt enable */ #define GMII_KSZ90x1_INT_RFEN (1 << 9) /* Remote fault interrupt enable */
#define GMII_KSZ90x1_INT_LUEN (1 << 8) /* Link up interrupt enable */ #define GMII_KSZ90X1_INT_LUEN (1 << 8) /* Link up interrupt enable */
#define GMII_KSZ90x1_INT_J (1 << 7) /* Jabber interrupt */ #define GMII_KSZ90x1_INT_J (1 << 7) /* Jabber interrupt */
#define GMII_KSZ90x1_INT_RE (1 << 6) /* Receive error interrupt */ #define GMII_KSZ90x1_INT_RE (1 << 6) /* Receive error interrupt */
+5 -3
View File
@@ -222,8 +222,8 @@
* Address Compatibility Mode for a specific multicast * Address Compatibility Mode for a specific multicast
* address. When an MLDv1 report is received for that * address. When an MLDv1 report is received for that
* multicast address, routers set their Older Version * multicast address, routers set their Older Version
* Host Present Timer to the Older Version Host Present * Host Present Timer to the Older Version Host
* Timeout. * Present Timeout.
*/ */
#define MLD_ROBUSTNESS (2) #define MLD_ROBUSTNESS (2)
@@ -247,7 +247,8 @@
****************************************************************************/ ****************************************************************************/
/* Multicast Listener Queries are sent by multicast routers in Querier State /* Multicast Listener Queries are sent by multicast routers in Querier State
* to query the multicast listening state of neighboring interfaces (RFC 3810). * to query the multicast listening state of neighboring interfaces
* (RFC 3810).
* *
* There are three variants of the Query message: * There are three variants of the Query message:
* *
@@ -315,6 +316,7 @@ struct mld_mcast_listen_report_v1_s
}; };
/* Version 2 Multicast Listener Report (RFC 3810). */ /* Version 2 Multicast Listener Report (RFC 3810). */
/* This is the form of the address record used in the listener report */ /* This is the form of the address record used in the listener report */
struct mld_mcast_addrec_v2_s struct mld_mcast_addrec_v2_s
+4 -4
View File
@@ -88,9 +88,9 @@ static bool is_loopback(FAR struct net_driver_s *dev)
* *
* Description: * Description:
* This function should be called before sending out a packet. The function * This function should be called before sending out a packet. The function
* checks the destination address of the packet to see whether the target of * checks the destination address of the packet to see whether the target
* packet is ourself and then consume the packet directly by calling input * of packet is ourself and then consume the packet directly by calling
* process functions. * input process functions.
* *
* Returned Value: * Returned Value:
* Zero is returned if the packet don't loop back to ourself, otherwise * Zero is returned if the packet don't loop back to ourself, otherwise
@@ -115,7 +115,7 @@ int devif_loopback(FAR struct net_driver_s *dev)
NETDEV_RXPACKETS(dev); NETDEV_RXPACKETS(dev);
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */ /* When packet sockets are enabled, feed the frame into the tap */
pkt_input(dev); pkt_input(dev);
#endif #endif
+24 -22
View File
@@ -19,21 +19,21 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors * 3. Neither the name of CITEL Technologies Ltd nor the names of its
* may be used to endorse or promote products derived from this software * contributors may be used to endorse or promote products derived from
* without specific prior written permission. * this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
* *
****************************************************************************/ ****************************************************************************/
@@ -121,7 +121,8 @@ void igmp_input(struct net_driver_s *dev)
uint16_t iphdrlen; uint16_t iphdrlen;
unsigned int ticks; unsigned int ticks;
ninfo("IGMP message: %04x%04x\n", ipv4->destipaddr[1], ipv4->destipaddr[0]); ninfo("IGMP message: %04x%04x\n",
ipv4->destipaddr[1], ipv4->destipaddr[0]);
/* Get the IP header length (accounting for possible options). */ /* Get the IP header length (accounting for possible options). */
@@ -166,10 +167,11 @@ void igmp_input(struct net_driver_s *dev)
{ {
case IGMP_MEMBERSHIP_QUERY: case IGMP_MEMBERSHIP_QUERY:
/* RFC 2236, 2.2. ax Response Time /* RFC 2236, 2.2. ax Response Time
* "The Max Response Time field is meaningful only in Membership Query * "The Max Response Time field is meaningful only in Membership
* messages, and specifies the maximum allowed time before sending a * Query messages, and specifies the maximum allowed time before
* responding report in units of 1/10 second. In all other messages, * sending a responding report in units of 1/10 second. In all
* it is set to zero by the sender and ignored by receivers. * other messages, it is set to zero by the sender and ignored by
* receivers.
*/ */
/* Check if the query was sent to all systems */ /* Check if the query was sent to all systems */
@@ -210,13 +212,13 @@ void igmp_input(struct net_driver_s *dev)
IGMP_STATINCR(g_netstats.igmp.query_received); IGMP_STATINCR(g_netstats.igmp.query_received);
for (member = (FAR struct igmp_group_s *)dev->d_igmp_grplist.head; member = (FAR struct igmp_group_s *)dev->d_igmp_grplist.head;
member; for (; member; member = member->next)
member = member->next)
{ {
/* Skip over the all systems group entry */ /* Skip over the all systems group entry */
if (!net_ipv4addr_cmp(member->grpaddr, g_ipv4_allsystems)) if (!net_ipv4addr_cmp(member->grpaddr,
g_ipv4_allsystems))
{ {
ticks = net_dsec2tick((int)igmp->maxresp); ticks = net_dsec2tick((int)igmp->maxresp);
if (IS_IDLEMEMBER(member->flags) || if (IS_IDLEMEMBER(member->flags) ||
@@ -232,8 +234,8 @@ void igmp_input(struct net_driver_s *dev)
{ {
ninfo("Group-specific multicast query\n"); ninfo("Group-specific multicast query\n");
/* We first need to re-lookup the group since we used dest last time. /* We first need to re-lookup the group since we used dest
* Use the incoming IPaddress! * last time. Use the incoming IPaddress!
*/ */
IGMP_STATINCR(g_netstats.igmp.ucast_query); IGMP_STATINCR(g_netstats.igmp.ucast_query);
+16 -16
View File
@@ -19,21 +19,21 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors * 3. Neither the name of CITEL Technologies Ltd nor the names of its
* may be used to endorse or promote products derived from this software * contributors may be used to endorse or promote products derived from
* without specific prior written permission. * this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
****************************************************************************/ ****************************************************************************/
@@ -138,10 +138,10 @@ int igmp_leavegroup(struct net_driver_s *dev,
ninfo("Leaving group: %p\n", group); ninfo("Leaving group: %p\n", group);
if (group) if (group)
{ {
/* Cancel the timer and discard any queued Membership Reports. Canceling /* Cancel the timer and discard any queued Membership Reports.
* the timer will prevent any new Membership Reports from being sent; * Canceling the timer will prevent any new Membership Reports from
* clearing the flags will discard any pending Membership Reports that * being sent; clearing the flags will discard any pending Membership
* could interfere with the Leave Group. * Reports that could interfere with the Leave Group.
*/ */
wd_cancel(group->wdog); wd_cancel(group->wdog);
@@ -168,7 +168,7 @@ int igmp_leavegroup(struct net_driver_s *dev,
igmp_grpfree(dev, group); igmp_grpfree(dev, group);
/* And remove the group address from the ethernet drivers MAC filter set */ /* And remove the group address from the drivers MAC filter set */
igmp_removemcastmac(dev, (FAR in_addr_t *)&grpaddr->s_addr); igmp_removemcastmac(dev, (FAR in_addr_t *)&grpaddr->s_addr);
return OK; return OK;

Some files were not shown because too many files have changed in this diff Show More