|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
/*
|
|
|
|
|
* Combined Ethernet driver for Motorola MPC8xx and MPC82xx.
|
|
|
|
|
*
|
|
|
|
@ -9,10 +10,6 @@
|
|
|
|
|
*
|
|
|
|
|
* Heavily based on original FEC driver by Dan Malek <dan@embeddededge.com>
|
|
|
|
|
* and modifications by Joakim Tjernlund <joakim.tjernlund@lumentis.se>
|
|
|
|
|
*
|
|
|
|
|
* This file is licensed under the terms of the GNU General Public License
|
|
|
|
|
* version 2. This program is licensed "as is" without any warranty of any
|
|
|
|
|
* kind, whether express or implied.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
@ -29,17 +26,18 @@
|
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
|
#include <linux/mii.h>
|
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
#include <linux/phy.h>
|
|
|
|
|
#include <linux/phylink.h>
|
|
|
|
|
#include <linux/property.h>
|
|
|
|
|
#include <linux/of.h>
|
|
|
|
|
#include <linux/of_mdio.h>
|
|
|
|
|
#include <linux/of_net.h>
|
|
|
|
|
#include <linux/pgtable.h>
|
|
|
|
|
#include <linux/rtnetlink.h>
|
|
|
|
|
|
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
|
#include <asm/irq.h>
|
|
|
|
@ -72,6 +70,13 @@ static void fs_set_multicast_list(struct net_device *dev)
|
|
|
|
|
(*fep->ops->set_multicast_list)(dev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int fs_eth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(dev);
|
|
|
|
|
|
|
|
|
|
return phylink_mii_ioctl(fep->phylink, ifr, cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void skb_align(struct sk_buff *skb, int align)
|
|
|
|
|
{
|
|
|
|
|
int off = ((unsigned long)skb->data) & (align - 1);
|
|
|
|
@ -84,15 +89,14 @@ static void skb_align(struct sk_buff *skb, int align)
|
|
|
|
|
static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = container_of(napi, struct fs_enet_private, napi);
|
|
|
|
|
struct net_device *dev = fep->ndev;
|
|
|
|
|
const struct fs_platform_info *fpi = fep->fpi;
|
|
|
|
|
cbd_t __iomem *bdp;
|
|
|
|
|
struct sk_buff *skb, *skbn;
|
|
|
|
|
int received = 0;
|
|
|
|
|
u16 pkt_len, sc;
|
|
|
|
|
int curidx;
|
|
|
|
|
int dirtyidx, do_wake, do_restart;
|
|
|
|
|
struct net_device *dev = fep->ndev;
|
|
|
|
|
int curidx, dirtyidx, received = 0;
|
|
|
|
|
int do_wake = 0, do_restart = 0;
|
|
|
|
|
int tx_left = TX_RING_SIZE;
|
|
|
|
|
struct sk_buff *skb, *skbn;
|
|
|
|
|
cbd_t __iomem *bdp;
|
|
|
|
|
u16 pkt_len, sc;
|
|
|
|
|
|
|
|
|
|
spin_lock(&fep->tx_lock);
|
|
|
|
|
bdp = fep->dirty_tx;
|
|
|
|
@ -100,7 +104,6 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
/* clear status bits for napi*/
|
|
|
|
|
(*fep->ops->napi_clear_event)(dev);
|
|
|
|
|
|
|
|
|
|
do_wake = do_restart = 0;
|
|
|
|
|
while (((sc = CBDR_SC(bdp)) & BD_ENET_TX_READY) == 0 && tx_left) {
|
|
|
|
|
dirtyidx = bdp - fep->tx_bd_base;
|
|
|
|
|
|
|
|
|
@ -109,12 +112,9 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
|
|
|
|
|
skb = fep->tx_skbuff[dirtyidx];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check for errors.
|
|
|
|
|
*/
|
|
|
|
|
/* Check for errors. */
|
|
|
|
|
if (sc & (BD_ENET_TX_HB | BD_ENET_TX_LC |
|
|
|
|
|
BD_ENET_TX_RL | BD_ENET_TX_UN | BD_ENET_TX_CSL)) {
|
|
|
|
|
|
|
|
|
|
if (sc & BD_ENET_TX_HB) /* No heartbeat */
|
|
|
|
|
dev->stats.tx_heartbeat_errors++;
|
|
|
|
|
if (sc & BD_ENET_TX_LC) /* Late collision */
|
|
|
|
@ -130,16 +130,16 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
dev->stats.tx_errors++;
|
|
|
|
|
do_restart = 1;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
} else {
|
|
|
|
|
dev->stats.tx_packets++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sc & BD_ENET_TX_READY) {
|
|
|
|
|
dev_warn(fep->dev,
|
|
|
|
|
"HEY! Enet xmit interrupt and TX_READY.\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Deferred means some collisions occurred during transmit,
|
|
|
|
|
/* Deferred means some collisions occurred during transmit,
|
|
|
|
|
* but we eventually sent the packet OK.
|
|
|
|
|
*/
|
|
|
|
|
if (sc & BD_ENET_TX_DEF)
|
|
|
|
@ -153,25 +153,20 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
dma_unmap_single(fep->dev, CBDR_BUFADDR(bdp),
|
|
|
|
|
CBDR_DATLEN(bdp), DMA_TO_DEVICE);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Free the sk buffer associated with this last transmit.
|
|
|
|
|
*/
|
|
|
|
|
/* Free the sk buffer associated with this last transmit. */
|
|
|
|
|
if (skb) {
|
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
|
fep->tx_skbuff[dirtyidx] = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Update pointer to next buffer descriptor to be transmitted.
|
|
|
|
|
/* Update pointer to next buffer descriptor to be transmitted.
|
|
|
|
|
*/
|
|
|
|
|
if ((sc & BD_ENET_TX_WRAP) == 0)
|
|
|
|
|
bdp++;
|
|
|
|
|
else
|
|
|
|
|
bdp = fep->tx_bd_base;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Since we have freed up a buffer, the ring is no longer
|
|
|
|
|
* full.
|
|
|
|
|
/* Since we have freed up a buffer, the ring is no longer full.
|
|
|
|
|
*/
|
|
|
|
|
if (++fep->tx_free == MAX_SKB_FRAGS)
|
|
|
|
|
do_wake = 1;
|
|
|
|
@ -188,8 +183,7 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
if (do_wake)
|
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* First, grab all of the stats for the incoming packet.
|
|
|
|
|
/* First, grab all of the stats for the incoming packet.
|
|
|
|
|
* These get messed up if we get called due to a busy condition.
|
|
|
|
|
*/
|
|
|
|
|
bdp = fep->cur_rx;
|
|
|
|
@ -198,16 +192,13 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
received < budget) {
|
|
|
|
|
curidx = bdp - fep->rx_bd_base;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Since we have allocated space to hold a complete frame,
|
|
|
|
|
/* Since we have allocated space to hold a complete frame,
|
|
|
|
|
* the last indicator should be set.
|
|
|
|
|
*/
|
|
|
|
|
if ((sc & BD_ENET_RX_LAST) == 0)
|
|
|
|
|
dev_warn(fep->dev, "rcv is not +last\n");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check for errors.
|
|
|
|
|
*/
|
|
|
|
|
/* Check for errors. */
|
|
|
|
|
if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_CL |
|
|
|
|
|
BD_ENET_RX_NO | BD_ENET_RX_CR | BD_ENET_RX_OV)) {
|
|
|
|
|
dev->stats.rx_errors++;
|
|
|
|
@ -228,9 +219,7 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
} else {
|
|
|
|
|
skb = fep->rx_skbuff[curidx];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Process the incoming frame.
|
|
|
|
|
*/
|
|
|
|
|
/* Process the incoming frame */
|
|
|
|
|
dev->stats.rx_packets++;
|
|
|
|
|
pkt_len = CBDR_DATLEN(bdp) - 4; /* remove CRC */
|
|
|
|
|
dev->stats.rx_bytes += pkt_len + 4;
|
|
|
|
@ -238,10 +227,10 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
if (pkt_len <= fpi->rx_copybreak) {
|
|
|
|
|
/* +2 to make IP header L1 cache aligned */
|
|
|
|
|
skbn = netdev_alloc_skb(dev, pkt_len + 2);
|
|
|
|
|
if (skbn != NULL) {
|
|
|
|
|
if (skbn) {
|
|
|
|
|
skb_reserve(skbn, 2); /* align IP header */
|
|
|
|
|
skb_copy_from_linear_data(skb,
|
|
|
|
|
skbn->data, pkt_len);
|
|
|
|
|
skb_copy_from_linear_data(skb, skbn->data,
|
|
|
|
|
pkt_len);
|
|
|
|
|
swap(skb, skbn);
|
|
|
|
|
dma_sync_single_for_cpu(fep->dev,
|
|
|
|
|
CBDR_BUFADDR(bdp),
|
|
|
|
@ -256,20 +245,18 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
|
|
|
|
|
skb_align(skbn, ENET_RX_ALIGN);
|
|
|
|
|
|
|
|
|
|
dma_unmap_single(fep->dev,
|
|
|
|
|
CBDR_BUFADDR(bdp),
|
|
|
|
|
dma_unmap_single(fep->dev, CBDR_BUFADDR(bdp),
|
|
|
|
|
L1_CACHE_ALIGN(PKT_MAXBUF_SIZE),
|
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
|
|
|
|
|
|
dma = dma_map_single(fep->dev,
|
|
|
|
|
skbn->data,
|
|
|
|
|
dma = dma_map_single(fep->dev, skbn->data,
|
|
|
|
|
L1_CACHE_ALIGN(PKT_MAXBUF_SIZE),
|
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
|
CBDW_BUFADDR(bdp, dma);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (skbn != NULL) {
|
|
|
|
|
if (skbn) {
|
|
|
|
|
skb_put(skb, pkt_len); /* Make room */
|
|
|
|
|
skb->protocol = eth_type_trans(skb, dev);
|
|
|
|
|
received++;
|
|
|
|
@ -284,9 +271,7 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
CBDW_DATLEN(bdp, 0);
|
|
|
|
|
CBDW_SC(bdp, (sc & ~BD_ENET_RX_STATS) | BD_ENET_RX_EMPTY);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Update BD pointer to next entry.
|
|
|
|
|
*/
|
|
|
|
|
/* Update BD pointer to next entry */
|
|
|
|
|
if ((sc & BD_ENET_RX_WRAP) == 0)
|
|
|
|
|
bdp++;
|
|
|
|
|
else
|
|
|
|
@ -308,19 +293,16 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
|
|
|
|
|
return budget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The interrupt handler.
|
|
|
|
|
/* The interrupt handler.
|
|
|
|
|
* This is called from the MPC core interrupt.
|
|
|
|
|
*/
|
|
|
|
|
static irqreturn_t
|
|
|
|
|
fs_enet_interrupt(int irq, void *dev_id)
|
|
|
|
|
{
|
|
|
|
|
struct net_device *dev = dev_id;
|
|
|
|
|
u32 int_events, int_clr_events;
|
|
|
|
|
struct fs_enet_private *fep;
|
|
|
|
|
u32 int_events;
|
|
|
|
|
u32 int_clr_events;
|
|
|
|
|
int nr, napi_ok;
|
|
|
|
|
int handled;
|
|
|
|
|
int nr, napi_ok, handled;
|
|
|
|
|
|
|
|
|
|
fep = netdev_priv(dev);
|
|
|
|
|
|
|
|
|
@ -342,12 +324,12 @@ fs_enet_interrupt(int irq, void *dev_id)
|
|
|
|
|
(*fep->ops->napi_disable)(dev);
|
|
|
|
|
(*fep->ops->clear_int_events)(dev, fep->ev_napi);
|
|
|
|
|
|
|
|
|
|
/* NOTE: it is possible for FCCs in NAPI mode */
|
|
|
|
|
/* to submit a spurious interrupt while in poll */
|
|
|
|
|
/* NOTE: it is possible for FCCs in NAPI mode
|
|
|
|
|
* to submit a spurious interrupt while in poll
|
|
|
|
|
*/
|
|
|
|
|
if (napi_ok)
|
|
|
|
|
__napi_schedule(&fep->napi);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handled = nr > 0;
|
|
|
|
@ -357,45 +339,40 @@ fs_enet_interrupt(int irq, void *dev_id)
|
|
|
|
|
void fs_init_bds(struct net_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(dev);
|
|
|
|
|
cbd_t __iomem *bdp;
|
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
cbd_t __iomem *bdp;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
fs_cleanup_bds(dev);
|
|
|
|
|
|
|
|
|
|
fep->dirty_tx = fep->cur_tx = fep->tx_bd_base;
|
|
|
|
|
fep->dirty_tx = fep->tx_bd_base;
|
|
|
|
|
fep->cur_tx = fep->tx_bd_base;
|
|
|
|
|
fep->tx_free = fep->tx_ring;
|
|
|
|
|
fep->cur_rx = fep->rx_bd_base;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Initialize the receive buffer descriptors.
|
|
|
|
|
*/
|
|
|
|
|
/* Initialize the receive buffer descriptors */
|
|
|
|
|
for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) {
|
|
|
|
|
skb = netdev_alloc_skb(dev, ENET_RX_FRSIZE);
|
|
|
|
|
if (skb == NULL)
|
|
|
|
|
if (!skb)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
skb_align(skb, ENET_RX_ALIGN);
|
|
|
|
|
fep->rx_skbuff[i] = skb;
|
|
|
|
|
CBDW_BUFADDR(bdp,
|
|
|
|
|
dma_map_single(fep->dev, skb->data,
|
|
|
|
|
CBDW_BUFADDR(bdp, dma_map_single(fep->dev, skb->data,
|
|
|
|
|
L1_CACHE_ALIGN(PKT_MAXBUF_SIZE),
|
|
|
|
|
DMA_FROM_DEVICE));
|
|
|
|
|
CBDW_DATLEN(bdp, 0); /* zero */
|
|
|
|
|
CBDW_SC(bdp, BD_ENET_RX_EMPTY |
|
|
|
|
|
((i < fep->rx_ring - 1) ? 0 : BD_SC_WRAP));
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* if we failed, fillup remainder
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* if we failed, fillup remainder */
|
|
|
|
|
for (; i < fep->rx_ring; i++, bdp++) {
|
|
|
|
|
fep->rx_skbuff[i] = NULL;
|
|
|
|
|
CBDW_SC(bdp, (i < fep->rx_ring - 1) ? 0 : BD_SC_WRAP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ...and the same for transmit.
|
|
|
|
|
*/
|
|
|
|
|
/* ...and the same for transmit. */
|
|
|
|
|
for (i = 0, bdp = fep->tx_bd_base; i < fep->tx_ring; i++, bdp++) {
|
|
|
|
|
fep->tx_skbuff[i] = NULL;
|
|
|
|
|
CBDW_BUFADDR(bdp, 0);
|
|
|
|
@ -411,11 +388,10 @@ void fs_cleanup_bds(struct net_device *dev)
|
|
|
|
|
cbd_t __iomem *bdp;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Reset SKB transmit buffers.
|
|
|
|
|
*/
|
|
|
|
|
/* Reset SKB transmit buffers. */
|
|
|
|
|
for (i = 0, bdp = fep->tx_bd_base; i < fep->tx_ring; i++, bdp++) {
|
|
|
|
|
if ((skb = fep->tx_skbuff[i]) == NULL)
|
|
|
|
|
skb = fep->tx_skbuff[i];
|
|
|
|
|
if (!skb)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* unmap */
|
|
|
|
@ -426,11 +402,10 @@ void fs_cleanup_bds(struct net_device *dev)
|
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Reset SKB receive buffers
|
|
|
|
|
*/
|
|
|
|
|
/* Reset SKB receive buffers */
|
|
|
|
|
for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) {
|
|
|
|
|
if ((skb = fep->rx_skbuff[i]) == NULL)
|
|
|
|
|
skb = fep->rx_skbuff[i];
|
|
|
|
|
if (!skb)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* unmap */
|
|
|
|
@ -444,12 +419,8 @@ void fs_cleanup_bds(struct net_device *dev)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_FS_ENET_MPC5121_FEC
|
|
|
|
|
/*
|
|
|
|
|
* MPC5121 FEC requeries 4-byte alignment for TX data buffer!
|
|
|
|
|
*/
|
|
|
|
|
/* MPC5121 FEC requires 4-byte alignment for TX data buffer! */
|
|
|
|
|
static struct sk_buff *tx_skb_align_workaround(struct net_device *dev,
|
|
|
|
|
struct sk_buff *skb)
|
|
|
|
|
{
|
|
|
|
@ -481,15 +452,12 @@ static netdev_tx_t
|
|
|
|
|
fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(dev);
|
|
|
|
|
int curidx, nr_frags, len;
|
|
|
|
|
cbd_t __iomem *bdp;
|
|
|
|
|
int curidx;
|
|
|
|
|
u16 sc;
|
|
|
|
|
int nr_frags;
|
|
|
|
|
skb_frag_t *frag;
|
|
|
|
|
int len;
|
|
|
|
|
u16 sc;
|
|
|
|
|
#ifdef CONFIG_FS_ENET_MPC5121_FEC
|
|
|
|
|
int is_aligned = 1;
|
|
|
|
|
int i;
|
|
|
|
|
int i, is_aligned = 1;
|
|
|
|
|
|
|
|
|
|
if (!IS_ALIGNED((unsigned long)skb->data, 4)) {
|
|
|
|
|
is_aligned = 0;
|
|
|
|
@ -507,8 +475,7 @@ fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
|
if (!is_aligned) {
|
|
|
|
|
skb = tx_skb_align_workaround(dev, skb);
|
|
|
|
|
if (!skb) {
|
|
|
|
|
/*
|
|
|
|
|
* We have lost packet due to memory allocation error
|
|
|
|
|
/* We have lost packet due to memory allocation error
|
|
|
|
|
* in tx_skb_align_workaround(). Hopefully original
|
|
|
|
|
* skb is still valid, so try transmit it later.
|
|
|
|
|
*/
|
|
|
|
@ -519,9 +486,7 @@ fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
|
|
|
|
|
|
spin_lock(&fep->tx_lock);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Fill in a Tx ring entry
|
|
|
|
|
*/
|
|
|
|
|
/* Fill in a Tx ring entry */
|
|
|
|
|
bdp = fep->cur_tx;
|
|
|
|
|
|
|
|
|
|
nr_frags = skb_shinfo(skb)->nr_frags;
|
|
|
|
@ -529,8 +494,7 @@ fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
spin_unlock(&fep->tx_lock);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Ooops. All transmit buffers are full. Bail out.
|
|
|
|
|
/* Ooops. All transmit buffers are full. Bail out.
|
|
|
|
|
* This should not happen, since the tx queue should be stopped.
|
|
|
|
|
*/
|
|
|
|
|
dev_warn(fep->dev, "tx queue full!.\n");
|
|
|
|
@ -543,9 +507,9 @@ fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
|
dev->stats.tx_bytes += len;
|
|
|
|
|
if (nr_frags)
|
|
|
|
|
len -= skb->data_len;
|
|
|
|
|
|
|
|
|
|
fep->tx_free -= nr_frags + 1;
|
|
|
|
|
/*
|
|
|
|
|
* Push the data cache so the CPM does not get stale memory data.
|
|
|
|
|
/* Push the data cache so the CPM does not get stale memory data.
|
|
|
|
|
*/
|
|
|
|
|
CBDW_BUFADDR(bdp, dma_map_single(fep->dev,
|
|
|
|
|
skb->data, len, DMA_TO_DEVICE));
|
|
|
|
@ -585,9 +549,11 @@ fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
|
|
|
|
|
|
/* note that while FEC does not have this bit
|
|
|
|
|
* it marks it as available for software use
|
|
|
|
|
* yay for hw reuse :) */
|
|
|
|
|
* yay for hw reuse :)
|
|
|
|
|
*/
|
|
|
|
|
if (skb->len <= 60)
|
|
|
|
|
sc |= BD_ENET_TX_PAD;
|
|
|
|
|
|
|
|
|
|
CBDC_SC(bdp, BD_ENET_TX_STATS);
|
|
|
|
|
CBDS_SC(bdp, sc);
|
|
|
|
|
|
|
|
|
@ -599,6 +565,7 @@ fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
|
bdp++;
|
|
|
|
|
else
|
|
|
|
|
bdp = fep->tx_bd_base;
|
|
|
|
|
|
|
|
|
|
fep->cur_tx = bdp;
|
|
|
|
|
|
|
|
|
|
if (fep->tx_free < MAX_SKB_FRAGS)
|
|
|
|
@ -623,15 +590,21 @@ static void fs_timeout_work(struct work_struct *work)
|
|
|
|
|
|
|
|
|
|
dev->stats.tx_errors++;
|
|
|
|
|
|
|
|
|
|
/* In the event a timeout was detected, but the netdev is brought down
|
|
|
|
|
* shortly after, it no longer makes sense to try to recover from the
|
|
|
|
|
* timeout. netif_running() will return false when called from the
|
|
|
|
|
* .ndo_close() callback. Calling the following recovery code while
|
|
|
|
|
* called from .ndo_close() could deadlock on rtnl.
|
|
|
|
|
*/
|
|
|
|
|
if (!netif_running(dev))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
rtnl_lock();
|
|
|
|
|
phylink_stop(fep->phylink);
|
|
|
|
|
phylink_start(fep->phylink);
|
|
|
|
|
rtnl_unlock();
|
|
|
|
|
|
|
|
|
|
spin_lock_irqsave(&fep->lock, flags);
|
|
|
|
|
|
|
|
|
|
if (dev->flags & IFF_UP) {
|
|
|
|
|
phy_stop(dev->phydev);
|
|
|
|
|
(*fep->ops->stop)(dev);
|
|
|
|
|
(*fep->ops->restart)(dev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
phy_start(dev->phydev);
|
|
|
|
|
wake = fep->tx_free >= MAX_SKB_FRAGS &&
|
|
|
|
|
!(CBDR_SC(fep->cur_tx) & BD_ENET_TX_READY);
|
|
|
|
|
spin_unlock_irqrestore(&fep->lock, flags);
|
|
|
|
@ -647,82 +620,37 @@ static void fs_timeout(struct net_device *dev, unsigned int txqueue)
|
|
|
|
|
schedule_work(&fep->timeout_work);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
|
|
|
* generic link-change handler - should be sufficient for most cases
|
|
|
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
|
static void generic_adjust_link(struct net_device *dev)
|
|
|
|
|
static void fs_mac_link_up(struct phylink_config *config,
|
|
|
|
|
struct phy_device *phy,
|
|
|
|
|
unsigned int mode, phy_interface_t interface,
|
|
|
|
|
int speed, int duplex,
|
|
|
|
|
bool tx_pause, bool rx_pause)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(dev);
|
|
|
|
|
struct phy_device *phydev = dev->phydev;
|
|
|
|
|
int new_state = 0;
|
|
|
|
|
|
|
|
|
|
if (phydev->link) {
|
|
|
|
|
/* adjust to duplex mode */
|
|
|
|
|
if (phydev->duplex != fep->oldduplex) {
|
|
|
|
|
new_state = 1;
|
|
|
|
|
fep->oldduplex = phydev->duplex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (phydev->speed != fep->oldspeed) {
|
|
|
|
|
new_state = 1;
|
|
|
|
|
fep->oldspeed = phydev->speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!fep->oldlink) {
|
|
|
|
|
new_state = 1;
|
|
|
|
|
fep->oldlink = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (new_state)
|
|
|
|
|
fep->ops->restart(dev);
|
|
|
|
|
} else if (fep->oldlink) {
|
|
|
|
|
new_state = 1;
|
|
|
|
|
fep->oldlink = 0;
|
|
|
|
|
fep->oldspeed = 0;
|
|
|
|
|
fep->oldduplex = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (new_state && netif_msg_link(fep))
|
|
|
|
|
phy_print_status(phydev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void fs_adjust_link(struct net_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(dev);
|
|
|
|
|
struct net_device *ndev = to_net_dev(config->dev);
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(ndev);
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
spin_lock_irqsave(&fep->lock, flags);
|
|
|
|
|
|
|
|
|
|
if(fep->ops->adjust_link)
|
|
|
|
|
fep->ops->adjust_link(dev);
|
|
|
|
|
else
|
|
|
|
|
generic_adjust_link(dev);
|
|
|
|
|
|
|
|
|
|
fep->ops->restart(ndev, interface, speed, duplex);
|
|
|
|
|
spin_unlock_irqrestore(&fep->lock, flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int fs_init_phy(struct net_device *dev)
|
|
|
|
|
static void fs_mac_link_down(struct phylink_config *config,
|
|
|
|
|
unsigned int mode, phy_interface_t interface)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(dev);
|
|
|
|
|
struct phy_device *phydev;
|
|
|
|
|
phy_interface_t iface;
|
|
|
|
|
struct net_device *ndev = to_net_dev(config->dev);
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(ndev);
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
fep->oldlink = 0;
|
|
|
|
|
fep->oldspeed = 0;
|
|
|
|
|
fep->oldduplex = -1;
|
|
|
|
|
|
|
|
|
|
iface = fep->fpi->use_rmii ?
|
|
|
|
|
PHY_INTERFACE_MODE_RMII : PHY_INTERFACE_MODE_MII;
|
|
|
|
|
|
|
|
|
|
phydev = of_phy_connect(dev, fep->fpi->phy_node, &fs_adjust_link, 0,
|
|
|
|
|
iface);
|
|
|
|
|
if (!phydev) {
|
|
|
|
|
dev_err(&dev->dev, "Could not attach to PHY\n");
|
|
|
|
|
return -ENODEV;
|
|
|
|
|
spin_lock_irqsave(&fep->lock, flags);
|
|
|
|
|
fep->ops->stop(ndev);
|
|
|
|
|
spin_unlock_irqrestore(&fep->lock, flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
static void fs_mac_config(struct phylink_config *config, unsigned int mode,
|
|
|
|
|
const struct phylink_link_state *state)
|
|
|
|
|
{
|
|
|
|
|
/* Nothing to do */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int fs_enet_open(struct net_device *dev)
|
|
|
|
@ -731,8 +659,9 @@ static int fs_enet_open(struct net_device *dev)
|
|
|
|
|
int r;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
/* to initialize the fep->cur_rx,... */
|
|
|
|
|
/* not doing this, will cause a crash in fs_enet_napi */
|
|
|
|
|
/* to initialize the fep->cur_rx,...
|
|
|
|
|
* not doing this, will cause a crash in fs_enet_napi
|
|
|
|
|
*/
|
|
|
|
|
fs_init_bds(fep->ndev);
|
|
|
|
|
|
|
|
|
|
napi_enable(&fep->napi);
|
|
|
|
@ -746,13 +675,13 @@ static int fs_enet_open(struct net_device *dev)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = fs_init_phy(dev);
|
|
|
|
|
err = phylink_of_phy_connect(fep->phylink, fep->dev->of_node, 0);
|
|
|
|
|
if (err) {
|
|
|
|
|
free_irq(fep->interrupt, dev);
|
|
|
|
|
napi_disable(&fep->napi);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
phy_start(dev->phydev);
|
|
|
|
|
phylink_start(fep->phylink);
|
|
|
|
|
|
|
|
|
|
netif_start_queue(dev);
|
|
|
|
|
|
|
|
|
@ -765,26 +694,23 @@ static int fs_enet_close(struct net_device *dev)
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
netif_carrier_off(dev);
|
|
|
|
|
napi_disable(&fep->napi);
|
|
|
|
|
cancel_work_sync(&fep->timeout_work);
|
|
|
|
|
phy_stop(dev->phydev);
|
|
|
|
|
cancel_work(&fep->timeout_work);
|
|
|
|
|
phylink_stop(fep->phylink);
|
|
|
|
|
|
|
|
|
|
spin_lock_irqsave(&fep->lock, flags);
|
|
|
|
|
spin_lock(&fep->tx_lock);
|
|
|
|
|
(*fep->ops->stop)(dev);
|
|
|
|
|
spin_unlock(&fep->tx_lock);
|
|
|
|
|
spin_unlock_irqrestore(&fep->lock, flags);
|
|
|
|
|
phylink_disconnect_phy(fep->phylink);
|
|
|
|
|
|
|
|
|
|
/* release any irqs */
|
|
|
|
|
phy_disconnect(dev->phydev);
|
|
|
|
|
free_irq(fep->interrupt, dev);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void fs_get_drvinfo(struct net_device *dev,
|
|
|
|
|
struct ethtool_drvinfo *info)
|
|
|
|
|
{
|
|
|
|
@ -818,12 +744,14 @@ static void fs_get_regs(struct net_device *dev, struct ethtool_regs *regs,
|
|
|
|
|
static u32 fs_get_msglevel(struct net_device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(dev);
|
|
|
|
|
|
|
|
|
|
return fep->msg_enable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void fs_set_msglevel(struct net_device *dev, u32 value)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(dev);
|
|
|
|
|
|
|
|
|
|
fep->msg_enable = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -865,6 +793,22 @@ static int fs_set_tunable(struct net_device *dev,
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int fs_ethtool_set_link_ksettings(struct net_device *dev,
|
|
|
|
|
const struct ethtool_link_ksettings *cmd)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(dev);
|
|
|
|
|
|
|
|
|
|
return phylink_ethtool_ksettings_set(fep->phylink, cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int fs_ethtool_get_link_ksettings(struct net_device *dev,
|
|
|
|
|
struct ethtool_link_ksettings *cmd)
|
|
|
|
|
{
|
|
|
|
|
struct fs_enet_private *fep = netdev_priv(dev);
|
|
|
|
|
|
|
|
|
|
return phylink_ethtool_ksettings_get(fep->phylink, cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct ethtool_ops fs_ethtool_ops = {
|
|
|
|
|
.get_drvinfo = fs_get_drvinfo,
|
|
|
|
|
.get_regs_len = fs_get_regs_len,
|
|
|
|
@ -874,14 +818,12 @@ static const struct ethtool_ops fs_ethtool_ops = {
|
|
|
|
|
.set_msglevel = fs_set_msglevel,
|
|
|
|
|
.get_regs = fs_get_regs,
|
|
|
|
|
.get_ts_info = ethtool_op_get_ts_info,
|
|
|
|
|
.get_link_ksettings = phy_ethtool_get_link_ksettings,
|
|
|
|
|
.set_link_ksettings = phy_ethtool_set_link_ksettings,
|
|
|
|
|
.get_link_ksettings = fs_ethtool_get_link_ksettings,
|
|
|
|
|
.set_link_ksettings = fs_ethtool_set_link_ksettings,
|
|
|
|
|
.get_tunable = fs_get_tunable,
|
|
|
|
|
.set_tunable = fs_set_tunable,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**************************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_FS_ENET_HAS_FEC
|
|
|
|
|
#define IS_FEC(ops) ((ops) == &fs_fec_ops)
|
|
|
|
|
#else
|
|
|
|
@ -894,7 +836,7 @@ static const struct net_device_ops fs_enet_netdev_ops = {
|
|
|
|
|
.ndo_start_xmit = fs_enet_start_xmit,
|
|
|
|
|
.ndo_tx_timeout = fs_timeout,
|
|
|
|
|
.ndo_set_rx_mode = fs_set_multicast_list,
|
|
|
|
|
.ndo_eth_ioctl = phy_do_ioctl_running,
|
|
|
|
|
.ndo_eth_ioctl = fs_eth_ioctl,
|
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
|
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
|
|
|
#ifdef CONFIG_NET_POLL_CONTROLLER
|
|
|
|
@ -902,17 +844,23 @@ static const struct net_device_ops fs_enet_netdev_ops = {
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct phylink_mac_ops fs_enet_phylink_mac_ops = {
|
|
|
|
|
.mac_config = fs_mac_config,
|
|
|
|
|
.mac_link_down = fs_mac_link_down,
|
|
|
|
|
.mac_link_up = fs_mac_link_up,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int fs_enet_probe(struct platform_device *ofdev)
|
|
|
|
|
{
|
|
|
|
|
int privsize, len, ret = -ENODEV;
|
|
|
|
|
struct fs_platform_info *fpi;
|
|
|
|
|
struct fs_enet_private *fep;
|
|
|
|
|
phy_interface_t phy_mode;
|
|
|
|
|
const struct fs_ops *ops;
|
|
|
|
|
struct net_device *ndev;
|
|
|
|
|
struct fs_enet_private *fep;
|
|
|
|
|
struct fs_platform_info *fpi;
|
|
|
|
|
struct phylink *phylink;
|
|
|
|
|
const u32 *data;
|
|
|
|
|
struct clk *clk;
|
|
|
|
|
int err;
|
|
|
|
|
const char *phy_connection_type;
|
|
|
|
|
int privsize, len, ret = -ENODEV;
|
|
|
|
|
|
|
|
|
|
ops = device_get_match_data(&ofdev->dev);
|
|
|
|
|
if (!ops)
|
|
|
|
@ -930,41 +878,26 @@ static int fs_enet_probe(struct platform_device *ofdev)
|
|
|
|
|
fpi->cp_command = *data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = of_get_phy_mode(ofdev->dev.of_node, &phy_mode);
|
|
|
|
|
if (ret) {
|
|
|
|
|
/* For compatibility, if the mode isn't specified in DT,
|
|
|
|
|
* assume MII
|
|
|
|
|
*/
|
|
|
|
|
phy_mode = PHY_INTERFACE_MODE_MII;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fpi->rx_ring = RX_RING_SIZE;
|
|
|
|
|
fpi->tx_ring = TX_RING_SIZE;
|
|
|
|
|
fpi->rx_copybreak = 240;
|
|
|
|
|
fpi->napi_weight = 17;
|
|
|
|
|
fpi->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0);
|
|
|
|
|
if (!fpi->phy_node && of_phy_is_fixed_link(ofdev->dev.of_node)) {
|
|
|
|
|
err = of_phy_register_fixed_link(ofdev->dev.of_node);
|
|
|
|
|
if (err)
|
|
|
|
|
goto out_free_fpi;
|
|
|
|
|
|
|
|
|
|
/* In the case of a fixed PHY, the DT node associated
|
|
|
|
|
* to the PHY is the Ethernet MAC DT node.
|
|
|
|
|
*/
|
|
|
|
|
fpi->phy_node = of_node_get(ofdev->dev.of_node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc5125-fec")) {
|
|
|
|
|
phy_connection_type = of_get_property(ofdev->dev.of_node,
|
|
|
|
|
"phy-connection-type", NULL);
|
|
|
|
|
if (phy_connection_type && !strcmp("rmii", phy_connection_type))
|
|
|
|
|
fpi->use_rmii = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* make clock lookup non-fatal (the driver is shared among platforms),
|
|
|
|
|
* but require enable to succeed when a clock was specified/found,
|
|
|
|
|
* keep a reference to the clock upon successful acquisition
|
|
|
|
|
*/
|
|
|
|
|
clk = devm_clk_get(&ofdev->dev, "per");
|
|
|
|
|
if (!IS_ERR(clk)) {
|
|
|
|
|
ret = clk_prepare_enable(clk);
|
|
|
|
|
if (ret)
|
|
|
|
|
goto out_deregister_fixed_link;
|
|
|
|
|
|
|
|
|
|
fpi->clk_per = clk;
|
|
|
|
|
}
|
|
|
|
|
clk = devm_clk_get_enabled(&ofdev->dev, "per");
|
|
|
|
|
if (IS_ERR(clk))
|
|
|
|
|
goto out_free_fpi;
|
|
|
|
|
|
|
|
|
|
privsize = sizeof(*fep) +
|
|
|
|
|
sizeof(struct sk_buff **) *
|
|
|
|
@ -974,7 +907,7 @@ static int fs_enet_probe(struct platform_device *ofdev)
|
|
|
|
|
ndev = alloc_etherdev(privsize);
|
|
|
|
|
if (!ndev) {
|
|
|
|
|
ret = -ENOMEM;
|
|
|
|
|
goto out_put;
|
|
|
|
|
goto out_free_fpi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SET_NETDEV_DEV(ndev, &ofdev->dev);
|
|
|
|
@ -986,9 +919,29 @@ static int fs_enet_probe(struct platform_device *ofdev)
|
|
|
|
|
fep->fpi = fpi;
|
|
|
|
|
fep->ops = ops;
|
|
|
|
|
|
|
|
|
|
fep->phylink_config.dev = &ndev->dev;
|
|
|
|
|
fep->phylink_config.type = PHYLINK_NETDEV;
|
|
|
|
|
fep->phylink_config.mac_capabilities = MAC_10 | MAC_100;
|
|
|
|
|
|
|
|
|
|
__set_bit(PHY_INTERFACE_MODE_MII,
|
|
|
|
|
fep->phylink_config.supported_interfaces);
|
|
|
|
|
|
|
|
|
|
if (of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc5125-fec"))
|
|
|
|
|
__set_bit(PHY_INTERFACE_MODE_RMII,
|
|
|
|
|
fep->phylink_config.supported_interfaces);
|
|
|
|
|
|
|
|
|
|
phylink = phylink_create(&fep->phylink_config, dev_fwnode(fep->dev),
|
|
|
|
|
phy_mode, &fs_enet_phylink_mac_ops);
|
|
|
|
|
if (IS_ERR(phylink)) {
|
|
|
|
|
ret = PTR_ERR(phylink);
|
|
|
|
|
goto out_free_dev;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fep->phylink = phylink;
|
|
|
|
|
|
|
|
|
|
ret = fep->ops->setup_data(ndev);
|
|
|
|
|
if (ret)
|
|
|
|
|
goto out_free_dev;
|
|
|
|
|
goto out_phylink;
|
|
|
|
|
|
|
|
|
|
fep->rx_skbuff = (struct sk_buff **)&fep[1];
|
|
|
|
|
fep->tx_skbuff = fep->rx_skbuff + fpi->rx_ring;
|
|
|
|
@ -1018,8 +971,6 @@ static int fs_enet_probe(struct platform_device *ofdev)
|
|
|
|
|
|
|
|
|
|
ndev->ethtool_ops = &fs_ethtool_ops;
|
|
|
|
|
|
|
|
|
|
netif_carrier_off(ndev);
|
|
|
|
|
|
|
|
|
|
ndev->features |= NETIF_F_SG;
|
|
|
|
|
|
|
|
|
|
ret = register_netdev(ndev);
|
|
|
|
@ -1034,14 +985,10 @@ out_free_bd:
|
|
|
|
|
fep->ops->free_bd(ndev);
|
|
|
|
|
out_cleanup_data:
|
|
|
|
|
fep->ops->cleanup_data(ndev);
|
|
|
|
|
out_phylink:
|
|
|
|
|
phylink_destroy(fep->phylink);
|
|
|
|
|
out_free_dev:
|
|
|
|
|
free_netdev(ndev);
|
|
|
|
|
out_put:
|
|
|
|
|
clk_disable_unprepare(fpi->clk_per);
|
|
|
|
|
out_deregister_fixed_link:
|
|
|
|
|
of_node_put(fpi->phy_node);
|
|
|
|
|
if (of_phy_is_fixed_link(ofdev->dev.of_node))
|
|
|
|
|
of_phy_deregister_fixed_link(ofdev->dev.of_node);
|
|
|
|
|
out_free_fpi:
|
|
|
|
|
kfree(fpi);
|
|
|
|
|
return ret;
|
|
|
|
@ -1057,10 +1004,7 @@ static void fs_enet_remove(struct platform_device *ofdev)
|
|
|
|
|
fep->ops->free_bd(ndev);
|
|
|
|
|
fep->ops->cleanup_data(ndev);
|
|
|
|
|
dev_set_drvdata(fep->dev, NULL);
|
|
|
|
|
of_node_put(fep->fpi->phy_node);
|
|
|
|
|
clk_disable_unprepare(fep->fpi->clk_per);
|
|
|
|
|
if (of_phy_is_fixed_link(ofdev->dev.of_node))
|
|
|
|
|
of_phy_deregister_fixed_link(ofdev->dev.of_node);
|
|
|
|
|
phylink_destroy(fep->phylink);
|
|
|
|
|
free_netdev(ndev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|