From patchwork Mon Oct 15 10:24:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 984079 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KNOcrT95"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="Sty9LhVo"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YZQj1ZBcz9s3q for ; Mon, 15 Oct 2018 21:28:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ugWgdutiNandN9Oh86CcG68sQR4mG0G9odE1E+W+bgc=; b=KNOcrT95RCjyhn M8QnLKx3KSgrKVWnQrUaovsS5WdoVnz+Eok+oLclCVxU8ptbTh5eVtJJ+eE3trqhK3bz5L0OdnqiC V7g7AUQh/mOGVuDwqHWinwZKR70mE9an6+v2nVGjXyq3vOVNPG/RC2Co6r9S3egKh17P1TESNpw3B Tgpr2Z5IQd91Kxn+h/GrlmcuUHl2NRXBXrDgH0+CnvvwBSTW9FWN3821Nys7BwIUl5KuDS3rEkgg0 0qmnnnKDRM3YIdeg9yBHgc1ATBaGcOTOjMcq27qM2ZbXUPkU5HVqK+y3uA7drA8lcucxzrCEYdhl7 wVegeKGcaeAbEdfJN/RQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC06X-0003cr-0x; Mon, 15 Oct 2018 10:28:05 +0000 Received: from canardo.mork.no ([2001:4641::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04D-0002X0-0S for openwrt-devel@lists.openwrt.org; Mon, 15 Oct 2018 10:25:47 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w9FAPNMr030847 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 12:25:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1539599123; bh=85LWt/WS+UAy6uCVphYOKJHRmjixrPtEudb4FSSN1ms=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=Sty9LhVofof2IEYWdOSDv+9Dbh9vdguDsM6UPVnYl6sBCKOJS1KqU+pCooYg8EPOX L4ZYmkBddgCXMZt9AbwSOdcS0IXFa78m1zd5rXElHumJzh1fLEHLTOESXGeHEhcq0u U4A85m5fJt6FzzuHPz+zGwrjIFrHxUwgP/DRfzaw= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w9FAPNAV030840; Mon, 15 Oct 2018 12:25:23 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: OpenWrt Development List Date: Mon, 15 Oct 2018 12:24:59 +0200 Message-Id: <20181015102503.30731-6-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181015102503.30731-1-bjorn@mork.no> References: <20181015102503.30731-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.100.1 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_032542_009353_0BE4AE41 X-CRM114-Status: GOOD ( 17.51 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches 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 Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [RFC 5/9] mt7621: enable mainline driver X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Bjørn Mork --- target/linux/ramips/mt7621/config-4.14 | 1 + .../ramips/patches-4.14/2200-mt7621-eth-dsa.patch | 121 +++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 target/linux/ramips/patches-4.14/2200-mt7621-eth-dsa.patch diff --git a/target/linux/ramips/mt7621/config-4.14 b/target/linux/ramips/mt7621/config-4.14 index 07e0ec5038c5..cf05b22bf930 100644 --- a/target/linux/ramips/mt7621/config-4.14 +++ b/target/linux/ramips/mt7621/config-4.14 @@ -191,6 +191,7 @@ CONFIG_NET_RALINK_MDIO=y CONFIG_NET_RALINK_MDIO_MT7620=y CONFIG_NET_RALINK_MT7621=y CONFIG_NET_RALINK_SOC=y +# CONFIG_NET_VENDOR_MEDIATEK is not set CONFIG_NET_VENDOR_RALINK=y CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y # CONFIG_NO_IOPORT_MAP is not set diff --git a/target/linux/ramips/patches-4.14/2200-mt7621-eth-dsa.patch b/target/linux/ramips/patches-4.14/2200-mt7621-eth-dsa.patch new file mode 100644 index 000000000000..51a610264e82 --- /dev/null +++ b/target/linux/ramips/patches-4.14/2200-mt7621-eth-dsa.patch @@ -0,0 +1,121 @@ +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1792,6 +1792,19 @@ static irqreturn_t mtk_handle_irq_tx(int + return IRQ_HANDLED; + } + ++static irqreturn_t mtk_handle_irq(int irq, void *_eth) ++{ ++ struct mtk_eth *eth = _eth; ++ ++ if (mtk_r32(eth, MTK_PDMA_INT_STATUS) & MTK_RX_DONE_INT) ++ mtk_handle_irq_rx(irq, _eth); ++ ++ if (mtk_r32(eth, MTK_QMTK_INT_STATUS) & MTK_TX_DONE_INT) ++ mtk_handle_irq_tx(irq, _eth); ++ ++ return IRQ_HANDLED; ++} ++ + #ifdef CONFIG_NET_POLL_CONTROLLER + static void mtk_poll_controller(struct net_device *dev) + { +@@ -2579,8 +2592,12 @@ static int mtk_probe(struct platform_dev + } + } + +- for (i = 0; i < 3; i++) { +- eth->irq[i] = platform_get_irq(pdev, i); ++ for (i = 0; i < 3; i++) ++ { ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) ++ eth->irq[i] = eth->irq[0]; ++ else ++ eth->irq[i] = platform_get_irq(pdev, i); + if (eth->irq[i] < 0) { + dev_err(&pdev->dev, "no IRQ%d resource found\n", i); + return -ENXIO; +@@ -2627,13 +2644,18 @@ static int mtk_probe(struct platform_dev + goto err_deinit_hw; + } + +- err = devm_request_irq(eth->dev, eth->irq[1], mtk_handle_irq_tx, 0, +- dev_name(eth->dev), eth); +- if (err) +- goto err_free_dev; ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) { ++ err = devm_request_irq(eth->dev, eth->irq[0], mtk_handle_irq, 0, ++ dev_name(eth->dev), eth); ++ } else { ++ err = devm_request_irq(eth->dev, eth->irq[1], mtk_handle_irq_tx, 0, ++ dev_name(eth->dev), eth); ++ if (err) ++ goto err_free_dev; + +- err = devm_request_irq(eth->dev, eth->irq[2], mtk_handle_irq_rx, 0, +- dev_name(eth->dev), eth); ++ err = devm_request_irq(eth->dev, eth->irq[2], mtk_handle_irq_rx, 0, ++ dev_name(eth->dev), eth); ++ } + if (err) + goto err_free_dev; + +@@ -2706,6 +2728,12 @@ static const struct mtk_soc_data mt2701_ + .required_pctl = true, + }; + ++static const struct mtk_soc_data mt7621_data = { ++ .caps = MTK_SHARED_INT, ++ .required_clks = MT7621_CLKS_BITMAP, ++ .required_pctl = false, ++}; ++ + static const struct mtk_soc_data mt7622_data = { + .caps = MTK_DUAL_GMAC_SHARED_SGMII | MTK_GMAC1_ESW, + .required_clks = MT7622_CLKS_BITMAP, +@@ -2720,6 +2748,7 @@ static const struct mtk_soc_data mt7623_ + + const struct of_device_id of_mtk_match[] = { + { .compatible = "mediatek,mt2701-eth", .data = &mt2701_data}, ++ { .compatible = "mediatek,mt7621-eth", .data = &mt7621_data}, + { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data}, + { .compatible = "mediatek,mt7623-eth", .data = &mt7623_data}, + {}, +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -364,6 +364,7 @@ + #define ETHSYS_CHIPID4_7 0x4 + #define MT7623_ETH 7623 + #define MT7622_ETH 7622 ++#define MT7621_ETH 7621 + + /* ethernet subsystem config register */ + #define ETHSYS_SYSCFG0 0x14 +@@ -489,6 +490,8 @@ enum mtk_clks_map { + BIT(MTK_CLK_SGMII_CDR_FB) | \ + BIT(MTK_CLK_SGMII_CK) | \ + BIT(MTK_CLK_ETH2PLL)) ++#define MT7621_CLKS_BITMAP (0) ++ + enum mtk_dev_state { + MTK_HW_INIT, + MTK_RESETTING +@@ -567,6 +570,8 @@ struct mtk_rx_ring { + #define MTK_GMAC2_SGMII (BIT(10) | MTK_SGMII) + #define MTK_DUAL_GMAC_SHARED_SGMII (BIT(11) | MTK_GMAC1_SGMII | \ + MTK_GMAC2_SGMII) ++#define MTK_SHARED_INT BIT(12) ++ + #define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x)) + + /* struct mtk_eth_data - This is the structure holding all differences +--- a/drivers/net/ethernet/mediatek/Kconfig ++++ b/drivers/net/ethernet/mediatek/Kconfig +@@ -1,6 +1,6 @@ + config NET_VENDOR_MEDIATEK + bool "MediaTek ethernet driver" +- depends on ARCH_MEDIATEK ++ depends on ARCH_MEDIATEK || SOC_MT7621 + ---help--- + If you have a Mediatek SoC with ethernet, say Y. +