|
@@ -10,16 +10,16 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
--- a/drivers/net/ethernet/lantiq_etop.c
|
|
|
+++ b/drivers/net/ethernet/lantiq_etop.c
|
|
|
-@@ -11,7 +11,7 @@
|
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
+@@ -1,7 +1,7 @@
|
|
|
+ // SPDX-License-Identifier: GPL-2.0-only
|
|
|
+ /*
|
|
|
*
|
|
|
- * Copyright (C) 2011 John Crispin <[email protected]>
|
|
|
+ * Copyright (C) 2011-12 John Crispin <[email protected]>
|
|
|
*/
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
-@@ -30,11 +30,16 @@
|
|
|
+@@ -20,11 +20,16 @@
|
|
|
#include <linux/mm.h>
|
|
|
#include <linux/platform_device.h>
|
|
|
#include <linux/ethtool.h>
|
|
@@ -36,7 +36,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
#include <asm/checksum.h>
|
|
|
|
|
|
-@@ -42,7 +47,7 @@
|
|
|
+@@ -32,7 +37,7 @@
|
|
|
#include <xway_dma.h>
|
|
|
#include <lantiq_platform.h>
|
|
|
|
|
@@ -45,7 +45,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
#define MDIO_REQUEST 0x80000000
|
|
|
#define MDIO_READ 0x40000000
|
|
|
#define MDIO_ADDR_MASK 0x1f
|
|
|
-@@ -51,44 +56,91 @@
|
|
|
+@@ -41,44 +46,91 @@
|
|
|
#define MDIO_REG_OFFSET 0x10
|
|
|
#define MDIO_VAL_MASK 0xffff
|
|
|
|
|
@@ -152,7 +152,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
struct net_device *netdev;
|
|
|
struct napi_struct napi;
|
|
|
struct ltq_dma_channel dma;
|
|
|
-@@ -98,23 +150,36 @@ struct ltq_etop_chan {
|
|
|
+@@ -88,23 +140,36 @@ struct ltq_etop_chan {
|
|
|
struct ltq_etop_priv {
|
|
|
struct net_device *netdev;
|
|
|
struct platform_device *pdev;
|
|
@@ -194,7 +194,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
if (!ch->skb[ch->dma.desc])
|
|
|
return -ENOMEM;
|
|
|
ch->dma.desc_base[ch->dma.desc].addr = dma_map_single(&priv->pdev->dev,
|
|
|
-@@ -149,8 +214,11 @@ ltq_etop_hw_receive(struct ltq_etop_chan
|
|
|
+@@ -139,8 +204,11 @@ ltq_etop_hw_receive(struct ltq_etop_chan
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
skb_put(skb, len);
|
|
@@ -206,7 +206,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
}
|
|
|
|
|
|
static int
|
|
|
-@@ -158,7 +226,9 @@ ltq_etop_poll_rx(struct napi_struct *nap
|
|
|
+@@ -148,7 +216,9 @@ ltq_etop_poll_rx(struct napi_struct *nap
|
|
|
{
|
|
|
struct ltq_etop_chan *ch = container_of(napi,
|
|
|
struct ltq_etop_chan, napi);
|
|
@@ -216,7 +216,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
while (work_done < budget) {
|
|
|
struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->dma.desc];
|
|
|
-@@ -170,7 +240,9 @@ ltq_etop_poll_rx(struct napi_struct *nap
|
|
|
+@@ -160,7 +230,9 @@ ltq_etop_poll_rx(struct napi_struct *nap
|
|
|
}
|
|
|
if (work_done < budget) {
|
|
|
napi_complete_done(&ch->napi, work_done);
|
|
@@ -226,7 +226,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
}
|
|
|
return work_done;
|
|
|
}
|
|
|
-@@ -182,12 +254,14 @@ ltq_etop_poll_tx(struct napi_struct *nap
|
|
|
+@@ -172,12 +244,14 @@ ltq_etop_poll_tx(struct napi_struct *nap
|
|
|
container_of(napi, struct ltq_etop_chan, napi);
|
|
|
struct ltq_etop_priv *priv = netdev_priv(ch->netdev);
|
|
|
struct netdev_queue *txq =
|
|
@@ -242,7 +242,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
dev_kfree_skb_any(ch->skb[ch->tx_free]);
|
|
|
ch->skb[ch->tx_free] = NULL;
|
|
|
memset(&ch->dma.desc_base[ch->tx_free], 0,
|
|
|
-@@ -200,7 +274,9 @@ ltq_etop_poll_tx(struct napi_struct *nap
|
|
|
+@@ -190,7 +264,9 @@ ltq_etop_poll_tx(struct napi_struct *nap
|
|
|
if (netif_tx_queue_stopped(txq))
|
|
|
netif_tx_start_queue(txq);
|
|
|
napi_complete(&ch->napi);
|
|
@@ -252,7 +252,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-@@ -208,9 +284,10 @@ static irqreturn_t
|
|
|
+@@ -198,9 +274,10 @@ static irqreturn_t
|
|
|
ltq_etop_dma_irq(int irq, void *_priv)
|
|
|
{
|
|
|
struct ltq_etop_priv *priv = _priv;
|
|
@@ -266,7 +266,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
return IRQ_HANDLED;
|
|
|
}
|
|
|
|
|
|
-@@ -222,7 +299,7 @@ ltq_etop_free_channel(struct net_device
|
|
|
+@@ -212,7 +289,7 @@ ltq_etop_free_channel(struct net_device
|
|
|
ltq_dma_free(&ch->dma);
|
|
|
if (ch->dma.irq)
|
|
|
free_irq(ch->dma.irq, priv);
|
|
@@ -275,7 +275,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
int desc;
|
|
|
for (desc = 0; desc < LTQ_DESC_NUM; desc++)
|
|
|
dev_kfree_skb_any(ch->skb[ch->dma.desc]);
|
|
|
-@@ -233,66 +310,135 @@ static void
|
|
|
+@@ -223,66 +300,135 @@ static void
|
|
|
ltq_etop_hw_exit(struct net_device *dev)
|
|
|
{
|
|
|
struct ltq_etop_priv *priv = netdev_priv(dev);
|
|
@@ -331,10 +331,11 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
struct ltq_etop_priv *priv = netdev_priv(dev);
|
|
|
- int i;
|
|
|
+ int mii_mode = priv->mii_mode;
|
|
|
-+
|
|
|
-+ clk_enable(priv->clk_ppe);
|
|
|
|
|
|
- ltq_pmu_enable(PMU_PPE);
|
|
|
++ clk_enable(priv->clk_ppe);
|
|
|
+
|
|
|
+- switch (priv->pldata->mii_mode) {
|
|
|
+ if (of_machine_is_compatible("lantiq,ar9")) {
|
|
|
+ ltq_etop_gbit_init(dev);
|
|
|
+ /* force the etops link to the gbit to MII */
|
|
@@ -343,8 +344,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
+ ltq_etop_w32_mask(MDIO_CFG_MASK, 0, LTQ_ETOP_MDIO_CFG);
|
|
|
+ ltq_etop_w32_mask(MAC_CFG_MASK, MAC_CFG_CGEN | MAC_CFG_DUPLEX |
|
|
|
+ MAC_CFG_SPEED | MAC_CFG_LINK, LTQ_ETOP_MAC_CFG);
|
|
|
-
|
|
|
-- switch (priv->pldata->mii_mode) {
|
|
|
++
|
|
|
+ switch (mii_mode) {
|
|
|
case PHY_INTERFACE_MODE_RMII:
|
|
|
- ltq_etop_w32_mask(ETOP_MII_MASK,
|
|
@@ -446,7 +446,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
}
|
|
|
|
|
|
static void
|
|
|
-@@ -311,6 +457,39 @@ static const struct ethtool_ops ltq_etop
|
|
|
+@@ -301,6 +447,39 @@ static const struct ethtool_ops ltq_etop
|
|
|
};
|
|
|
|
|
|
static int
|
|
@@ -486,7 +486,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
ltq_etop_mdio_wr(struct mii_bus *bus, int phy_addr, int phy_reg, u16 phy_data)
|
|
|
{
|
|
|
u32 val = MDIO_REQUEST |
|
|
|
-@@ -318,9 +497,9 @@ ltq_etop_mdio_wr(struct mii_bus *bus, in
|
|
|
+@@ -308,9 +487,9 @@ ltq_etop_mdio_wr(struct mii_bus *bus, in
|
|
|
((phy_reg & MDIO_REG_MASK) << MDIO_REG_OFFSET) |
|
|
|
phy_data;
|
|
|
|
|
@@ -498,7 +498,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-@@ -331,12 +510,12 @@ ltq_etop_mdio_rd(struct mii_bus *bus, in
|
|
|
+@@ -321,12 +500,12 @@ ltq_etop_mdio_rd(struct mii_bus *bus, in
|
|
|
((phy_addr & MDIO_ADDR_MASK) << MDIO_ADDR_OFFSET) |
|
|
|
((phy_reg & MDIO_REG_MASK) << MDIO_REG_OFFSET);
|
|
|
|
|
@@ -515,17 +515,9 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
return val;
|
|
|
}
|
|
|
|
|
|
-@@ -351,8 +530,18 @@ ltq_etop_mdio_probe(struct net_device *d
|
|
|
- {
|
|
|
+@@ -342,7 +521,10 @@ ltq_etop_mdio_probe(struct net_device *d
|
|
|
struct ltq_etop_priv *priv = netdev_priv(dev);
|
|
|
struct phy_device *phydev;
|
|
|
-+ u32 phy_supported = (SUPPORTED_10baseT_Half
|
|
|
-+ | SUPPORTED_10baseT_Full
|
|
|
-+ | SUPPORTED_100baseT_Half
|
|
|
-+ | SUPPORTED_100baseT_Full
|
|
|
-+ | SUPPORTED_Autoneg
|
|
|
-+ | SUPPORTED_MII
|
|
|
-+ | SUPPORTED_TP);
|
|
|
|
|
|
- phydev = phy_find_first(priv->mii_bus);
|
|
|
+ if (of_machine_is_compatible("lantiq,ase"))
|
|
@@ -535,7 +527,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
if (!phydev) {
|
|
|
netdev_err(dev, "no PHY found\n");
|
|
|
-@@ -360,21 +549,18 @@ ltq_etop_mdio_probe(struct net_device *d
|
|
|
+@@ -350,14 +532,17 @@ ltq_etop_mdio_probe(struct net_device *d
|
|
|
}
|
|
|
|
|
|
phydev = phy_connect(dev, phydev_name(phydev),
|
|
@@ -547,22 +539,15 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
return PTR_ERR(phydev);
|
|
|
}
|
|
|
|
|
|
-- phydev->supported &= (SUPPORTED_10baseT_Half
|
|
|
-- | SUPPORTED_10baseT_Full
|
|
|
-- | SUPPORTED_100baseT_Half
|
|
|
-- | SUPPORTED_100baseT_Full
|
|
|
-- | SUPPORTED_Autoneg
|
|
|
-- | SUPPORTED_MII
|
|
|
-- | SUPPORTED_TP);
|
|
|
+- phy_set_max_speed(phydev, SPEED_100);
|
|
|
+ if (of_machine_is_compatible("lantiq,ar9"))
|
|
|
-+ phy_supported |= SUPPORTED_1000baseT_Half
|
|
|
-+ | SUPPORTED_1000baseT_Full;
|
|
|
++ phy_set_max_speed(phydev, SPEED_1000);
|
|
|
++ else
|
|
|
++ phy_set_max_speed(phydev, SPEED_100);
|
|
|
|
|
|
-+ phydev->supported &= phy_supported;
|
|
|
- phydev->advertising = phydev->supported;
|
|
|
phy_attached_info(phydev);
|
|
|
|
|
|
-@@ -395,8 +581,13 @@ ltq_etop_mdio_init(struct net_device *de
|
|
|
+@@ -378,8 +563,13 @@ ltq_etop_mdio_init(struct net_device *de
|
|
|
}
|
|
|
|
|
|
priv->mii_bus->priv = dev;
|
|
@@ -578,7 +563,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
priv->mii_bus->name = "ltq_mii";
|
|
|
snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
|
|
|
priv->pdev->name, priv->pdev->id);
|
|
|
-@@ -433,17 +624,19 @@ static int
|
|
|
+@@ -416,18 +606,21 @@ static int
|
|
|
ltq_etop_open(struct net_device *dev)
|
|
|
{
|
|
|
struct ltq_etop_priv *priv = netdev_priv(dev);
|
|
@@ -592,7 +577,9 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
+
|
|
|
+ spin_lock_irqsave(&priv->lock, flags);
|
|
|
+ ltq_dma_open(&priv->txch.dma);
|
|
|
++ ltq_dma_enable_irq(&priv->txch.dma);
|
|
|
+ ltq_dma_open(&priv->rxch.dma);
|
|
|
++ ltq_dma_enable_irq(&priv->rxch.dma);
|
|
|
+ spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
+
|
|
|
+ if (dev->phydev)
|
|
@@ -601,13 +588,14 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
- if (!IS_TX(i) && (!IS_RX(i)))
|
|
|
- continue;
|
|
|
- ltq_dma_open(&ch->dma);
|
|
|
+- ltq_dma_enable_irq(&ch->dma);
|
|
|
- napi_enable(&ch->napi);
|
|
|
- }
|
|
|
- phy_start(dev->phydev);
|
|
|
netif_tx_start_all_queues(dev);
|
|
|
return 0;
|
|
|
}
|
|
|
-@@ -452,18 +645,19 @@ static int
|
|
|
+@@ -436,18 +629,19 @@ static int
|
|
|
ltq_etop_stop(struct net_device *dev)
|
|
|
{
|
|
|
struct ltq_etop_priv *priv = netdev_priv(dev);
|
|
@@ -637,7 +625,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-@@ -473,16 +667,16 @@ ltq_etop_tx(struct sk_buff *skb, struct
|
|
|
+@@ -457,16 +651,16 @@ ltq_etop_tx(struct sk_buff *skb, struct
|
|
|
int queue = skb_get_queue_mapping(skb);
|
|
|
struct netdev_queue *txq = netdev_get_tx_queue(dev, queue);
|
|
|
struct ltq_etop_priv *priv = netdev_priv(dev);
|
|
@@ -659,7 +647,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
netdev_err(dev, "tx ring full\n");
|
|
|
netif_tx_stop_queue(txq);
|
|
|
return NETDEV_TX_BUSY;
|
|
|
-@@ -490,7 +684,7 @@ ltq_etop_tx(struct sk_buff *skb, struct
|
|
|
+@@ -474,7 +668,7 @@ ltq_etop_tx(struct sk_buff *skb, struct
|
|
|
|
|
|
/* dma needs to start on a 16 byte aligned address */
|
|
|
byte_offset = CPHYSADDR(skb->data) % 16;
|
|
@@ -668,7 +656,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
netif_trans_update(dev);
|
|
|
|
|
|
-@@ -500,11 +694,11 @@ ltq_etop_tx(struct sk_buff *skb, struct
|
|
|
+@@ -484,11 +678,11 @@ ltq_etop_tx(struct sk_buff *skb, struct
|
|
|
wmb();
|
|
|
desc->ctl = LTQ_DMA_OWN | LTQ_DMA_SOP | LTQ_DMA_EOP |
|
|
|
LTQ_DMA_TX_OFFSET(byte_offset) | (len & LTQ_DMA_SIZE_MASK);
|
|
@@ -683,7 +671,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
netif_tx_stop_queue(txq);
|
|
|
|
|
|
return NETDEV_TX_OK;
|
|
|
-@@ -515,11 +709,14 @@ ltq_etop_change_mtu(struct net_device *d
|
|
|
+@@ -499,11 +693,14 @@ ltq_etop_change_mtu(struct net_device *d
|
|
|
{
|
|
|
struct ltq_etop_priv *priv = netdev_priv(dev);
|
|
|
unsigned long flags;
|
|
@@ -699,7 +687,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
return 0;
|
|
|
-@@ -579,6 +776,9 @@ ltq_etop_init(struct net_device *dev)
|
|
|
+@@ -563,6 +760,9 @@ ltq_etop_init(struct net_device *dev)
|
|
|
if (err)
|
|
|
goto err_hw;
|
|
|
ltq_etop_change_mtu(dev, 1500);
|
|
@@ -709,7 +697,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
memcpy(&mac, &priv->pldata->mac, sizeof(struct sockaddr));
|
|
|
if (!is_valid_ether_addr(mac.sa_data)) {
|
|
|
-@@ -596,9 +796,10 @@ ltq_etop_init(struct net_device *dev)
|
|
|
+@@ -580,9 +780,10 @@ ltq_etop_init(struct net_device *dev)
|
|
|
dev->addr_assign_type = NET_ADDR_RANDOM;
|
|
|
|
|
|
ltq_etop_set_multicast_list(dev);
|
|
@@ -723,7 +711,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
return 0;
|
|
|
|
|
|
err_netdev:
|
|
|
-@@ -618,6 +819,9 @@ ltq_etop_tx_timeout(struct net_device *d
|
|
|
+@@ -602,6 +803,9 @@ ltq_etop_tx_timeout(struct net_device *d
|
|
|
err = ltq_etop_hw_init(dev);
|
|
|
if (err)
|
|
|
goto err_hw;
|
|
@@ -733,7 +721,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
netif_trans_update(dev);
|
|
|
netif_wake_queue(dev);
|
|
|
return;
|
|
|
-@@ -641,14 +845,19 @@ static const struct net_device_ops ltq_e
|
|
|
+@@ -625,14 +829,19 @@ static const struct net_device_ops ltq_e
|
|
|
.ndo_tx_timeout = ltq_etop_tx_timeout,
|
|
|
};
|
|
|
|
|
@@ -757,7 +745,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
if (!res) {
|
|
|
-@@ -674,31 +883,62 @@ ltq_etop_probe(struct platform_device *p
|
|
|
+@@ -658,31 +867,62 @@ ltq_etop_probe(struct platform_device *p
|
|
|
goto err_out;
|
|
|
}
|
|
|
|
|
@@ -835,7 +823,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
err = register_netdev(dev);
|
|
|
if (err)
|
|
|
-@@ -727,31 +967,22 @@ ltq_etop_remove(struct platform_device *
|
|
|
+@@ -711,31 +951,22 @@ ltq_etop_remove(struct platform_device *
|
|
|
return 0;
|
|
|
}
|
|
|
|