From patchwork Thu Jan 29 06:18:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 2190614 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=L63wpXAG; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=TPNofqcZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4f29td31LVz1xsw for ; Fri, 30 Jan 2026 07:37:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:From:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eqV+U+hYWAxxx04+mvnTF+dmaEQxWYeSpkkhYqjGo4w=; b=L63wpXAGjO5Z01 2Y0XIgkOzzo6v9cqC9wgj1QRPrCuYaKK8DEfo6o0SSmj1JECbjyIultV7OKrQigIa5va5BatvLUZh IJwKz8Eo17p6SVd56lc+3uY/AaXu86RiNSLFJdpDB4c9C0YGOXiY/+I7IfjsdaWTkfG76odeO6cep mi6ORoJOFQRHPBiSApA69jJexsoAUWY/04+chwdEaQ3XJOeKJdFqCd28Ayz46E29gLcSrurjV3490 BaWYkkCJRznRkTT+mBNGHuG18/qHnuF8quXc5gqetl1/62PkkKzzhXdB1I5P1VlPAt/VoXla/1t2v oes82nC++GZHskK2YUbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vlYjX-00000000cHN-3Z5K; Thu, 29 Jan 2026 20:35:19 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vlVev-00000000Po3-0Dgq for openwrt-devel@lists.openwrt.org; Thu, 29 Jan 2026 17:18:22 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4806f9e61f9so6791355e9.1 for ; Thu, 29 Jan 2026 09:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769707099; x=1770311899; darn=lists.openwrt.org; h=content-transfer-encoding:cc:to:subject:from:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=P947yepk6pUF5VyzqiHdBuUEvIXyMAxqe9Rqeqp2Ilg=; b=TPNofqcZKaF4/+hzw0Jb48rk73X6OLdVtllUR7VRJm8WoeGyXFWCmVnXYS/Cv9O02i iE/Rp+nBjyAEkUTN9QLfL/Y9HbvRaWDvoOqQvxLXq6FVymGnwLUXgWP6by5ZKvp9W8PB MZRGCEp15kHC7arKUKmwjKtRw7EIlSSUlnxb+e5HiPifsU3GEBLUXIohr+olUQVn8ap2 dfLwDC7Y3NJjdrADg//YGeaX6iRWaIwXGoaP8313XhlooTXyNhbvm7UZTCDJz+k5o4VG GsTJXXQu1qW7xugZh1IB0skqUkApHd6Wp/rvGvrCr2dcGNb+zN2uDIK9aXRhiikj77Kv t5TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769707099; x=1770311899; h=content-transfer-encoding:cc:to:subject:from:content-language :user-agent:mime-version:date:message-id:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=P947yepk6pUF5VyzqiHdBuUEvIXyMAxqe9Rqeqp2Ilg=; b=cndMQZG9fKMbZJzNlyoOpR5z6Ns5CmhOUne9JsJk+IZ1mIZgXwGWTNfuc6tXVOmkIl 9GFRRgVI648hQ3R31CVVQVLcfZQ1exM0H/dxp53qV5Z8FXki/4nAmiU/kB3WMzvA0r40 Qr4t2ywwchZN/BUDwEyWv+b7fntu4fl8iK79QH2JpDZVh8oHbsA9Dyjfx6zs2YNYxmjS HG09gk+fNQQnJjVJFduCw2/kbS2QdTzsTWgLmbauEl93MctBXD0JnA5R6rcoH5c889Sr QZka6JYdOLefTVmZ6Q8zbu44psi3KfJzPUPw9QwyUrMsLlU614XeRBaeB6THcC/8gqeb U7Vw== X-Forwarded-Encrypted: i=1; AJvYcCW9xyxcWVMR2mK/6EehDM2I0gO+95CKU/fxEQYjvesh70Q5qmhoc6pIB36v5KwZoRBDONSR13b4hqlyy4Lv@lists.openwrt.org X-Gm-Message-State: AOJu0YzTp8SB05iuVdO4HqtaPZZNCw2KMe5T4LqZjUo95m/Ipry6mhFW 9Cbwzc+iy4coIlxuniP4kNkDYMmER3uwMR/Na5z/n9ZQZkptJcJj3lPk X-Gm-Gg: AZuq6aLdvRdM316A/7+m/n3q77f6xSyBm4cXsddfUvpI9ZMuB8QGHCDAprFb0E2+m0s 71lxpQfZ7Q8ogLWHjc1dymaePQlJFnbpGlP0IkokbXcOlzQVNTxe3DbQE6Dm7wA1tYuK4muBBpH D3F+Rlx85MIdqpEHousJYLt1F701gkaQP90aavmy0TiXj1m3unxZuJOvzd6msOjAUaRw9gTFPw9 bWpjxJ+bjTNogGtBpAvbfYEbFOYQSGQTPvqH0LH/srzFrUr/MSkStdKrsoKfU8+CP1Nhn8WCUGP qR5QTXMQf/3bK/gLGMbTPpbmMcK3SCSZSfvPz3uxsJcZP2rRblaac4Swda/2AjP4EYm/swSq20z hB46JcP1seISJDjVKreRyHsLZn21ed5XsG1IK+7H3E/fsJg1pqsTqmPiKOau7CdIEB0TObzmoH/ hhaZ05P6cxYfDBwXZm8HojGmjVAsuj0otNVVsXc6HTlnw5nFnJ533z37RJ5lPUqCiXzHSchF35G 1Voda8zca8KK0SKxFkYJlmHoVJgVQnrRDSVas5XoPK4N/o7T6fDrRYKeyvK7oL1 X-Received: by 2002:a05:600c:4fc4:b0:480:3338:292d with SMTP id 5b1f17b1804b1-48069c8b7demr138128205e9.31.1769707098257; Thu, 29 Jan 2026 09:18:18 -0800 (PST) Received: from ?IPV6:2003:ea:8f0b:f500:2d0a:8724:17dc:1df1? (p200300ea8f0bf5002d0a872417dc1df1.dip0.t-ipconnect.de. [2003:ea:8f0b:f500:2d0a:8724:17dc:1df1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-481a5dc81dcsm1283395e9.11.2026.01.29.09.18.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jan 2026 09:18:17 -0800 (PST) Message-ID: <7b2b53b6-d230-47bb-98d9-b7acfbfdd8ca@gmail.com> Date: Thu, 29 Jan 2026 18:18:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Heiner Kallweit Subject: [PATCH net-next] net: lantiq_etop: remove driver To: Jakub Kicinski , Paolo Abeni , David Miller , Eric Dumazet , Simon Horman , Andrew Lunn , Thomas Bogendoerfer , Vadim Fedorenko , Lorenzo Bianconi , Hauke Mehrtens Cc: "netdev@vger.kernel.org" , "linux-mips@vger.kernel.org" , OpenWrt Development List , Daniel Golle X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260129_091821_274900_D60FF9E7 X-CRM114-Status: GOOD ( 17.45 ) X-Spam-Score: -1.8 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This driver in mainline lost its in-tree user with commit cd93b4895ea5 ("MIPS: lantiq: drop mips_machine support") in 2012. Since then it has had no in-tree user. Only user seems to be OpenWRT, with s [...] Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:32d listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [hkallweit1(at)gmail.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [hkallweit1(at)gmail.com] X-Mailman-Approved-At: Thu, 29 Jan 2026 12:35:18 -0800 X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This driver in mainline lost its in-tree user with commit cd93b4895ea5 ("MIPS: lantiq: drop mips_machine support") in 2012. Since then it has had no in-tree user. Only user seems to be OpenWRT, with several changes to the in-tree driver version: target/linux/lantiq/patches-6.12/035-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch target/linux/lantiq/patches-6.12/028-NET-lantiq-various-etop-fixes.patch target/linux/lantiq/patches-6.12/701-NET-lantiq-etop-of-mido.patch So it seems the driver is maintained in OpenWrt only, except tree-wide in-tree changes. According to OpenWRT maintainers it would be ok to remove the driver in mainline and keep it downstream only (see linked conversation). Signed-off-by: Heiner Kallweit Link: https://lore.kernel.org/netdev/d80fef86-ba14-4bd4-bce5-4d61a75d591b@hauke-m.de/T/#t Reviewed-by: Jacob Keller --- .../include/asm/mach-lantiq/lantiq_platform.h | 18 - drivers/net/ethernet/Kconfig | 6 - drivers/net/ethernet/Makefile | 1 - drivers/net/ethernet/lantiq_etop.c | 745 ------------------ 4 files changed, 770 deletions(-) delete mode 100644 arch/mips/include/asm/mach-lantiq/lantiq_platform.h delete mode 100644 drivers/net/ethernet/lantiq_etop.c diff --git a/arch/mips/include/asm/mach-lantiq/lantiq_platform.h b/arch/mips/include/asm/mach-lantiq/lantiq_platform.h deleted file mode 100644 index 70ebb4d6f05..00000000000 --- a/arch/mips/include/asm/mach-lantiq/lantiq_platform.h +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * - * Copyright (C) 2010 John Crispin - */ - -#ifndef _LANTIQ_PLATFORM_H__ -#define _LANTIQ_PLATFORM_H__ - -#include - -/* struct used to pass info to network drivers */ -struct ltq_eth_data { - struct sockaddr mac; - int mii_mode; -}; - -#endif diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig index aa7103e7f47..9775fd401b0 100644 --- a/drivers/net/ethernet/Kconfig +++ b/drivers/net/ethernet/Kconfig @@ -93,12 +93,6 @@ config KORINA If you have a Mikrotik RouterBoard 500 or IDT RC32434 based system say Y. Otherwise say N. -config LANTIQ_ETOP - tristate "Lantiq SoC ETOP driver" - depends on SOC_TYPE_XWAY - help - Support for the MII0 inside the Lantiq SoC - config LANTIQ_XRX200 tristate "Lantiq / Intel xRX200 PMAC network driver" depends on SOC_TYPE_XWAY diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile index 6615a67a63d..743ec1b7e5f 100644 --- a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile @@ -53,7 +53,6 @@ obj-$(CONFIG_NET_VENDOR_MICROSOFT) += microsoft/ obj-$(CONFIG_NET_VENDOR_XSCALE) += xscale/ obj-$(CONFIG_JME) += jme.o obj-$(CONFIG_KORINA) += korina.o -obj-$(CONFIG_LANTIQ_ETOP) += lantiq_etop.o obj-$(CONFIG_LANTIQ_XRX200) += lantiq_xrx200.o obj-$(CONFIG_NET_VENDOR_LITEX) += litex/ obj-$(CONFIG_NET_VENDOR_MARVELL) += marvell/ diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c deleted file mode 100644 index 83ce3bfefa5..00000000000 --- a/drivers/net/ethernet/lantiq_etop.c +++ /dev/null @@ -1,745 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * - * Copyright (C) 2011 John Crispin - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#define LTQ_ETOP_MDIO 0x11804 -#define MDIO_REQUEST 0x80000000 -#define MDIO_READ 0x40000000 -#define MDIO_ADDR_MASK 0x1f -#define MDIO_ADDR_OFFSET 0x15 -#define MDIO_REG_MASK 0x1f -#define MDIO_REG_OFFSET 0x10 -#define MDIO_VAL_MASK 0xffff - -#define PPE32_CGEN 0x800 -#define LQ_PPE32_ENET_MAC_CFG 0x1840 - -#define LTQ_ETOP_ENETS0 0x11850 -#define LTQ_ETOP_MAC_DA0 0x1186C -#define LTQ_ETOP_MAC_DA1 0x11870 -#define LTQ_ETOP_CFG 0x16020 -#define LTQ_ETOP_IGPLEN 0x16080 - -#define MAX_DMA_CHAN 0x8 -#define MAX_DMA_CRC_LEN 0x4 -#define MAX_DMA_DATA_LEN 0x600 - -#define ETOP_FTCU BIT(28) -#define ETOP_MII_MASK 0xf -#define ETOP_MII_NORMAL 0xd -#define ETOP_MII_REVERSE 0xe -#define ETOP_PLEN_UNDER 0x40 -#define ETOP_CGEN 0x800 - -/* use 2 static channels for TX/RX */ -#define LTQ_ETOP_TX_CHANNEL 1 -#define LTQ_ETOP_RX_CHANNEL 6 -#define IS_TX(x) ((x) == LTQ_ETOP_TX_CHANNEL) -#define IS_RX(x) ((x) == LTQ_ETOP_RX_CHANNEL) - -#define ltq_etop_r32(x) ltq_r32(ltq_etop_membase + (x)) -#define ltq_etop_w32(x, y) ltq_w32(x, ltq_etop_membase + (y)) -#define ltq_etop_w32_mask(x, y, z) \ - ltq_w32_mask(x, y, ltq_etop_membase + (z)) - -#define DRV_VERSION "1.0" - -static void __iomem *ltq_etop_membase; - -struct ltq_etop_chan { - int idx; - int tx_free; - struct net_device *netdev; - struct napi_struct napi; - struct ltq_dma_channel dma; - struct sk_buff *skb[LTQ_DESC_NUM]; -}; - -struct ltq_etop_priv { - struct net_device *netdev; - struct platform_device *pdev; - struct ltq_eth_data *pldata; - - struct mii_bus *mii_bus; - - struct ltq_etop_chan ch[MAX_DMA_CHAN]; - - int tx_burst_len; - int rx_burst_len; - - spinlock_t lock; -}; - -static int -ltq_etop_alloc_skb(struct ltq_etop_chan *ch) -{ - struct ltq_etop_priv *priv = netdev_priv(ch->netdev); - - ch->skb[ch->dma.desc] = netdev_alloc_skb(ch->netdev, MAX_DMA_DATA_LEN); - if (!ch->skb[ch->dma.desc]) - return -ENOMEM; - ch->dma.desc_base[ch->dma.desc].addr = - dma_map_single(&priv->pdev->dev, ch->skb[ch->dma.desc]->data, - MAX_DMA_DATA_LEN, DMA_FROM_DEVICE); - ch->dma.desc_base[ch->dma.desc].addr = - CPHYSADDR(ch->skb[ch->dma.desc]->data); - ch->dma.desc_base[ch->dma.desc].ctl = - LTQ_DMA_OWN | LTQ_DMA_RX_OFFSET(NET_IP_ALIGN) | - MAX_DMA_DATA_LEN; - skb_reserve(ch->skb[ch->dma.desc], NET_IP_ALIGN); - return 0; -} - -static void -ltq_etop_hw_receive(struct ltq_etop_chan *ch) -{ - struct ltq_etop_priv *priv = netdev_priv(ch->netdev); - struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->dma.desc]; - struct sk_buff *skb = ch->skb[ch->dma.desc]; - int len = (desc->ctl & LTQ_DMA_SIZE_MASK) - MAX_DMA_CRC_LEN; - unsigned long flags; - - spin_lock_irqsave(&priv->lock, flags); - if (ltq_etop_alloc_skb(ch)) { - netdev_err(ch->netdev, - "failed to allocate new rx buffer, stopping DMA\n"); - ltq_dma_close(&ch->dma); - } - ch->dma.desc++; - ch->dma.desc %= LTQ_DESC_NUM; - spin_unlock_irqrestore(&priv->lock, flags); - - skb_put(skb, len); - skb->protocol = eth_type_trans(skb, ch->netdev); - netif_receive_skb(skb); -} - -static int -ltq_etop_poll_rx(struct napi_struct *napi, int budget) -{ - struct ltq_etop_chan *ch = container_of(napi, - struct ltq_etop_chan, napi); - int work_done = 0; - - while (work_done < budget) { - struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->dma.desc]; - - if ((desc->ctl & (LTQ_DMA_OWN | LTQ_DMA_C)) != LTQ_DMA_C) - break; - ltq_etop_hw_receive(ch); - work_done++; - } - if (work_done < budget) { - napi_complete_done(&ch->napi, work_done); - ltq_dma_ack_irq(&ch->dma); - } - return work_done; -} - -static int -ltq_etop_poll_tx(struct napi_struct *napi, int budget) -{ - struct ltq_etop_chan *ch = - container_of(napi, struct ltq_etop_chan, napi); - struct ltq_etop_priv *priv = netdev_priv(ch->netdev); - struct netdev_queue *txq = - netdev_get_tx_queue(ch->netdev, ch->idx >> 1); - unsigned long flags; - - spin_lock_irqsave(&priv->lock, flags); - while ((ch->dma.desc_base[ch->tx_free].ctl & - (LTQ_DMA_OWN | LTQ_DMA_C)) == LTQ_DMA_C) { - dev_kfree_skb_any(ch->skb[ch->tx_free]); - ch->skb[ch->tx_free] = NULL; - memset(&ch->dma.desc_base[ch->tx_free], 0, - sizeof(struct ltq_dma_desc)); - ch->tx_free++; - ch->tx_free %= LTQ_DESC_NUM; - } - spin_unlock_irqrestore(&priv->lock, flags); - - if (netif_tx_queue_stopped(txq)) - netif_tx_start_queue(txq); - napi_complete(&ch->napi); - ltq_dma_ack_irq(&ch->dma); - return 1; -} - -static irqreturn_t -ltq_etop_dma_irq(int irq, void *_priv) -{ - struct ltq_etop_priv *priv = _priv; - int ch = irq - LTQ_DMA_CH0_INT; - - napi_schedule(&priv->ch[ch].napi); - return IRQ_HANDLED; -} - -static void -ltq_etop_free_channel(struct net_device *dev, struct ltq_etop_chan *ch) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - - ltq_dma_free(&ch->dma); - if (ch->dma.irq) - free_irq(ch->dma.irq, priv); - if (IS_RX(ch->idx)) { - struct ltq_dma_channel *dma = &ch->dma; - - for (dma->desc = 0; dma->desc < LTQ_DESC_NUM; dma->desc++) - dev_kfree_skb_any(ch->skb[ch->dma.desc]); - } -} - -static void -ltq_etop_hw_exit(struct net_device *dev) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - int i; - - ltq_pmu_disable(PMU_PPE); - for (i = 0; i < MAX_DMA_CHAN; i++) - if (IS_TX(i) || IS_RX(i)) - ltq_etop_free_channel(dev, &priv->ch[i]); -} - -static int -ltq_etop_hw_init(struct net_device *dev) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - int i; - int err; - - ltq_pmu_enable(PMU_PPE); - - switch (priv->pldata->mii_mode) { - case PHY_INTERFACE_MODE_RMII: - ltq_etop_w32_mask(ETOP_MII_MASK, ETOP_MII_REVERSE, - LTQ_ETOP_CFG); - break; - - case PHY_INTERFACE_MODE_MII: - ltq_etop_w32_mask(ETOP_MII_MASK, ETOP_MII_NORMAL, - LTQ_ETOP_CFG); - break; - - default: - netdev_err(dev, "unknown mii mode %d\n", - priv->pldata->mii_mode); - return -ENOTSUPP; - } - - /* enable crc generation */ - ltq_etop_w32(PPE32_CGEN, LQ_PPE32_ENET_MAC_CFG); - - ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, priv->rx_burst_len); - - for (i = 0; i < MAX_DMA_CHAN; i++) { - int irq = LTQ_DMA_CH0_INT + i; - struct ltq_etop_chan *ch = &priv->ch[i]; - - ch->dma.nr = i; - ch->idx = ch->dma.nr; - ch->dma.dev = &priv->pdev->dev; - - if (IS_TX(i)) { - ltq_dma_alloc_tx(&ch->dma); - err = request_irq(irq, ltq_etop_dma_irq, 0, "etop_tx", priv); - if (err) { - netdev_err(dev, - "Unable to get Tx DMA IRQ %d\n", - irq); - return err; - } - } else if (IS_RX(i)) { - ltq_dma_alloc_rx(&ch->dma); - for (ch->dma.desc = 0; ch->dma.desc < LTQ_DESC_NUM; - ch->dma.desc++) - if (ltq_etop_alloc_skb(ch)) - return -ENOMEM; - ch->dma.desc = 0; - err = request_irq(irq, ltq_etop_dma_irq, 0, "etop_rx", priv); - if (err) { - netdev_err(dev, - "Unable to get Rx DMA IRQ %d\n", - irq); - return err; - } - } - ch->dma.irq = irq; - } - return 0; -} - -static void -ltq_etop_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) -{ - strscpy(info->driver, "Lantiq ETOP", sizeof(info->driver)); - strscpy(info->bus_info, "internal", sizeof(info->bus_info)); - strscpy(info->version, DRV_VERSION, sizeof(info->version)); -} - -static const struct ethtool_ops ltq_etop_ethtool_ops = { - .get_drvinfo = ltq_etop_get_drvinfo, - .nway_reset = phy_ethtool_nway_reset, - .get_link_ksettings = phy_ethtool_get_link_ksettings, - .set_link_ksettings = phy_ethtool_set_link_ksettings, -}; - -static int -ltq_etop_mdio_wr(struct mii_bus *bus, int phy_addr, int phy_reg, u16 phy_data) -{ - u32 val = MDIO_REQUEST | - ((phy_addr & MDIO_ADDR_MASK) << MDIO_ADDR_OFFSET) | - ((phy_reg & MDIO_REG_MASK) << MDIO_REG_OFFSET) | - phy_data; - - while (ltq_etop_r32(LTQ_ETOP_MDIO) & MDIO_REQUEST) - ; - ltq_etop_w32(val, LTQ_ETOP_MDIO); - return 0; -} - -static int -ltq_etop_mdio_rd(struct mii_bus *bus, int phy_addr, int phy_reg) -{ - u32 val = MDIO_REQUEST | MDIO_READ | - ((phy_addr & MDIO_ADDR_MASK) << MDIO_ADDR_OFFSET) | - ((phy_reg & MDIO_REG_MASK) << MDIO_REG_OFFSET); - - while (ltq_etop_r32(LTQ_ETOP_MDIO) & MDIO_REQUEST) - ; - ltq_etop_w32(val, LTQ_ETOP_MDIO); - while (ltq_etop_r32(LTQ_ETOP_MDIO) & MDIO_REQUEST) - ; - val = ltq_etop_r32(LTQ_ETOP_MDIO) & MDIO_VAL_MASK; - return val; -} - -static void -ltq_etop_mdio_link(struct net_device *dev) -{ - /* nothing to do */ -} - -static int -ltq_etop_mdio_probe(struct net_device *dev) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - struct phy_device *phydev; - - phydev = phy_find_first(priv->mii_bus); - - if (!phydev) { - netdev_err(dev, "no PHY found\n"); - return -ENODEV; - } - - phydev = phy_connect(dev, phydev_name(phydev), - <q_etop_mdio_link, priv->pldata->mii_mode); - - if (IS_ERR(phydev)) { - netdev_err(dev, "Could not attach to PHY\n"); - return PTR_ERR(phydev); - } - - phy_set_max_speed(phydev, SPEED_100); - - phy_attached_info(phydev); - - return 0; -} - -static int -ltq_etop_mdio_init(struct net_device *dev) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - int err; - - priv->mii_bus = mdiobus_alloc(); - if (!priv->mii_bus) { - netdev_err(dev, "failed to allocate mii bus\n"); - err = -ENOMEM; - goto err_out; - } - - priv->mii_bus->priv = dev; - priv->mii_bus->read = ltq_etop_mdio_rd; - priv->mii_bus->write = ltq_etop_mdio_wr; - priv->mii_bus->name = "ltq_mii"; - snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", - priv->pdev->name, priv->pdev->id); - if (mdiobus_register(priv->mii_bus)) { - err = -ENXIO; - goto err_out_free_mdiobus; - } - - if (ltq_etop_mdio_probe(dev)) { - err = -ENXIO; - goto err_out_unregister_bus; - } - return 0; - -err_out_unregister_bus: - mdiobus_unregister(priv->mii_bus); -err_out_free_mdiobus: - mdiobus_free(priv->mii_bus); -err_out: - return err; -} - -static void -ltq_etop_mdio_cleanup(struct net_device *dev) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - - phy_disconnect(dev->phydev); - mdiobus_unregister(priv->mii_bus); - mdiobus_free(priv->mii_bus); -} - -static int -ltq_etop_open(struct net_device *dev) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - int i; - - for (i = 0; i < MAX_DMA_CHAN; i++) { - struct ltq_etop_chan *ch = &priv->ch[i]; - - 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; -} - -static int -ltq_etop_stop(struct net_device *dev) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - int i; - - netif_tx_stop_all_queues(dev); - phy_stop(dev->phydev); - for (i = 0; i < MAX_DMA_CHAN; i++) { - struct ltq_etop_chan *ch = &priv->ch[i]; - - if (!IS_RX(i) && !IS_TX(i)) - continue; - napi_disable(&ch->napi); - ltq_dma_close(&ch->dma); - } - return 0; -} - -static netdev_tx_t -ltq_etop_tx(struct sk_buff *skb, struct net_device *dev) -{ - 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); - struct ltq_etop_chan *ch = &priv->ch[(queue << 1) | 1]; - struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->dma.desc]; - int len; - unsigned long flags; - u32 byte_offset; - - if (skb_put_padto(skb, ETH_ZLEN)) - return NETDEV_TX_OK; - len = skb->len; - - if ((desc->ctl & (LTQ_DMA_OWN | LTQ_DMA_C)) || ch->skb[ch->dma.desc]) { - netdev_err(dev, "tx ring full\n"); - netif_tx_stop_queue(txq); - return NETDEV_TX_BUSY; - } - - /* dma needs to start on a burst length value aligned address */ - byte_offset = CPHYSADDR(skb->data) % (priv->tx_burst_len * 4); - ch->skb[ch->dma.desc] = skb; - - netif_trans_update(dev); - - spin_lock_irqsave(&priv->lock, flags); - desc->addr = ((unsigned int)dma_map_single(&priv->pdev->dev, skb->data, len, - DMA_TO_DEVICE)) - byte_offset; - /* Make sure the address is written before we give it to HW */ - wmb(); - desc->ctl = LTQ_DMA_OWN | LTQ_DMA_SOP | LTQ_DMA_EOP | - LTQ_DMA_TX_OFFSET(byte_offset) | (len & LTQ_DMA_SIZE_MASK); - ch->dma.desc++; - ch->dma.desc %= LTQ_DESC_NUM; - spin_unlock_irqrestore(&priv->lock, flags); - - if (ch->dma.desc_base[ch->dma.desc].ctl & LTQ_DMA_OWN) - netif_tx_stop_queue(txq); - - return NETDEV_TX_OK; -} - -static int -ltq_etop_change_mtu(struct net_device *dev, int new_mtu) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - unsigned long flags; - - WRITE_ONCE(dev->mtu, new_mtu); - - spin_lock_irqsave(&priv->lock, flags); - ltq_etop_w32((ETOP_PLEN_UNDER << 16) | new_mtu, LTQ_ETOP_IGPLEN); - spin_unlock_irqrestore(&priv->lock, flags); - - return 0; -} - -static int -ltq_etop_set_mac_address(struct net_device *dev, void *p) -{ - int ret = eth_mac_addr(dev, p); - - if (!ret) { - struct ltq_etop_priv *priv = netdev_priv(dev); - unsigned long flags; - - /* store the mac for the unicast filter */ - spin_lock_irqsave(&priv->lock, flags); - ltq_etop_w32(*((u32 *)dev->dev_addr), LTQ_ETOP_MAC_DA0); - ltq_etop_w32(*((u16 *)&dev->dev_addr[4]) << 16, - LTQ_ETOP_MAC_DA1); - spin_unlock_irqrestore(&priv->lock, flags); - } - return ret; -} - -static void -ltq_etop_set_multicast_list(struct net_device *dev) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - unsigned long flags; - - /* ensure that the unicast filter is not enabled in promiscious mode */ - spin_lock_irqsave(&priv->lock, flags); - if ((dev->flags & IFF_PROMISC) || (dev->flags & IFF_ALLMULTI)) - ltq_etop_w32_mask(ETOP_FTCU, 0, LTQ_ETOP_ENETS0); - else - ltq_etop_w32_mask(0, ETOP_FTCU, LTQ_ETOP_ENETS0); - spin_unlock_irqrestore(&priv->lock, flags); -} - -static int -ltq_etop_init(struct net_device *dev) -{ - struct ltq_etop_priv *priv = netdev_priv(dev); - struct sockaddr mac; - int err; - bool random_mac = false; - - dev->watchdog_timeo = 10 * HZ; - err = ltq_etop_hw_init(dev); - if (err) - goto err_hw; - ltq_etop_change_mtu(dev, 1500); - - memcpy(&mac, &priv->pldata->mac, sizeof(struct sockaddr)); - if (!is_valid_ether_addr(mac.sa_data)) { - pr_warn("etop: invalid MAC, using random\n"); - eth_random_addr(mac.sa_data); - random_mac = true; - } - - err = ltq_etop_set_mac_address(dev, &mac); - if (err) - goto err_netdev; - - /* Set addr_assign_type here, ltq_etop_set_mac_address would reset it. */ - if (random_mac) - dev->addr_assign_type = NET_ADDR_RANDOM; - - ltq_etop_set_multicast_list(dev); - err = ltq_etop_mdio_init(dev); - if (err) - goto err_netdev; - return 0; - -err_netdev: - unregister_netdev(dev); - free_netdev(dev); -err_hw: - ltq_etop_hw_exit(dev); - return err; -} - -static void -ltq_etop_tx_timeout(struct net_device *dev, unsigned int txqueue) -{ - int err; - - ltq_etop_hw_exit(dev); - err = ltq_etop_hw_init(dev); - if (err) - goto err_hw; - netif_trans_update(dev); - netif_wake_queue(dev); - return; - -err_hw: - ltq_etop_hw_exit(dev); - netdev_err(dev, "failed to restart etop after TX timeout\n"); -} - -static const struct net_device_ops ltq_eth_netdev_ops = { - .ndo_open = ltq_etop_open, - .ndo_stop = ltq_etop_stop, - .ndo_start_xmit = ltq_etop_tx, - .ndo_change_mtu = ltq_etop_change_mtu, - .ndo_eth_ioctl = phy_do_ioctl, - .ndo_set_mac_address = ltq_etop_set_mac_address, - .ndo_validate_addr = eth_validate_addr, - .ndo_set_rx_mode = ltq_etop_set_multicast_list, - .ndo_select_queue = dev_pick_tx_zero, - .ndo_init = ltq_etop_init, - .ndo_tx_timeout = ltq_etop_tx_timeout, -}; - -static int __init -ltq_etop_probe(struct platform_device *pdev) -{ - struct net_device *dev; - struct ltq_etop_priv *priv; - int err; - int i; - - ltq_etop_membase = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(ltq_etop_membase)) { - dev_err(&pdev->dev, "failed to remap etop engine %d\n", - pdev->id); - err = PTR_ERR(ltq_etop_membase); - goto err_out; - } - - dev = alloc_etherdev_mq(sizeof(struct ltq_etop_priv), 4); - if (!dev) { - err = -ENOMEM; - goto err_out; - } - dev->netdev_ops = <q_eth_netdev_ops; - dev->ethtool_ops = <q_etop_ethtool_ops; - priv = netdev_priv(dev); - priv->pdev = pdev; - priv->pldata = dev_get_platdata(&pdev->dev); - priv->netdev = dev; - spin_lock_init(&priv->lock); - SET_NETDEV_DEV(dev, &pdev->dev); - - err = device_property_read_u32(&pdev->dev, "lantiq,tx-burst-length", &priv->tx_burst_len); - if (err < 0) { - dev_err(&pdev->dev, "unable to read tx-burst-length property\n"); - goto err_free; - } - - err = device_property_read_u32(&pdev->dev, "lantiq,rx-burst-length", &priv->rx_burst_len); - if (err < 0) { - dev_err(&pdev->dev, "unable to read rx-burst-length property\n"); - goto err_free; - } - - for (i = 0; i < MAX_DMA_CHAN; i++) { - if (IS_TX(i)) - netif_napi_add_weight(dev, &priv->ch[i].napi, - ltq_etop_poll_tx, 8); - else if (IS_RX(i)) - netif_napi_add_weight(dev, &priv->ch[i].napi, - ltq_etop_poll_rx, 32); - priv->ch[i].netdev = dev; - } - - err = register_netdev(dev); - if (err) - goto err_free; - - platform_set_drvdata(pdev, dev); - return 0; - -err_free: - free_netdev(dev); -err_out: - return err; -} - -static void ltq_etop_remove(struct platform_device *pdev) -{ - struct net_device *dev = platform_get_drvdata(pdev); - - if (dev) { - netif_tx_stop_all_queues(dev); - ltq_etop_hw_exit(dev); - ltq_etop_mdio_cleanup(dev); - unregister_netdev(dev); - } -} - -static struct platform_driver ltq_mii_driver = { - .remove = ltq_etop_remove, - .driver = { - .name = "ltq_etop", - }, -}; - -static int __init -init_ltq_etop(void) -{ - int ret = platform_driver_probe(<q_mii_driver, ltq_etop_probe); - - if (ret) - pr_err("ltq_etop: Error registering platform driver!"); - return ret; -} - -static void __exit -exit_ltq_etop(void) -{ - platform_driver_unregister(<q_mii_driver); -} - -module_init(init_ltq_etop); -module_exit(exit_ltq_etop); - -MODULE_AUTHOR("John Crispin "); -MODULE_DESCRIPTION("Lantiq SoC ETOP"); -MODULE_LICENSE("GPL");