[OpenWrt-Devel] [RFC 5/9] mt7621: enable mainline driver
Bjørn Mork
bjorn at mork.no
Mon Oct 15 06:24:59 EDT 2018
Signed-off-by: Bjørn Mork <bjorn at mork.no>
---
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.
+
--
2.11.0
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list