aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorDavid Bauer <mail@david-bauer.net>2020-03-13 01:07:39 +0100
committerDavid Bauer <mail@david-bauer.net>2020-03-13 20:43:57 +0100
commit32726846c85985fbc320d123a7b26b32124cd47a (patch)
tree6c374c2f4825162ca58c65b2b1beba013ab2412b /target
parent0933d1363b262017a815a538a0017f301f34883b (diff)
downloadupstream-32726846c85985fbc320d123a7b26b32124cd47a.tar.gz
upstream-32726846c85985fbc320d123a7b26b32124cd47a.tar.bz2
upstream-32726846c85985fbc320d123a7b26b32124cd47a.zip
ath79: use downstream ag71xx for Kernel 5.4
The ag71xx driver from Linux 5.4 currently has various shortcomings when used with OpenWrt compared to our downstream version. For example, the upstream driver does not support modifying the ethernet clock and configuring RGMII delays on the MAC side. While we should certainly switch to the upstream driver, the amount of necessary patches would make it cumbersome to work with. It's also highly likely we won't be able to finish patching the upstream driver in time for a Linux 5.4 release. Tested on Siemens WS-AP3610. CC: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: David Bauer <mail@david-bauer.net> Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
Diffstat (limited to 'target')
-rw-r--r--target/linux/ath79/config-5.42
-rw-r--r--target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Kconfig (renamed from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Kconfig)0
-rw-r--r--target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Makefile (renamed from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Makefile)0
-rw-r--r--target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h (renamed from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx.h)0
-rw-r--r--target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c (renamed from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c)0
-rw-r--r--target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c (renamed from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c)0
-rw-r--r--target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c (renamed from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c)0
-rw-r--r--target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c (renamed from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c)10
-rw-r--r--target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c (renamed from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c)0
-rw-r--r--target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c (renamed from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c)0
-rw-r--r--target/linux/ath79/patches-5.4/200-ag71xx-Handle-allocation-errors-in-ag71xx_rings_init.patch61
-rw-r--r--target/linux/ath79/patches-5.4/201-ag71xx-Call-ag71xx_hw_disable-in-case-phy_conenct-fa.patch45
-rw-r--r--target/linux/ath79/patches-5.4/202-ag71xx-Run-ag71xx_link_adjust-only-when-needed.patch69
-rw-r--r--target/linux/ath79/patches-5.4/420-net-use-downstream-ag71xx.patch28
14 files changed, 37 insertions, 178 deletions
diff --git a/target/linux/ath79/config-5.4 b/target/linux/ath79/config-5.4
index 24475d9ae5..6f607ee7e4 100644
--- a/target/linux/ath79/config-5.4
+++ b/target/linux/ath79/config-5.4
@@ -1,4 +1,6 @@
CONFIG_AG71XX=y
+# CONFIG_AG71XX_DEBUG is not set
+CONFIG_AG71XX_DEBUG_FS=y
CONFIG_AR8216_PHY=y
CONFIG_AR8216_PHY_LEDS=y
CONFIG_ARCH_32BIT_OFF_T=y
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Kconfig b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Kconfig
index 4df2d21e34..4df2d21e34 100644
--- a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Kconfig
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Kconfig
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Makefile b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Makefile
index 87add0d208..87add0d208 100644
--- a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Makefile
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Makefile
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx.h b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
index fde9db3745..fde9db3745 100644
--- a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
index 20cf1c15c8..20cf1c15c8 100644
--- a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c
index 2cd7b1be83..2cd7b1be83 100644
--- a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c
index cc0a15d3a4..cc0a15d3a4 100644
--- a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index 2394ccc90d..edb026544c 100644
--- a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -1581,11 +1581,15 @@ static int ag71xx_probe(struct platform_device *pdev)
ag->stop_desc->next = (u32) ag->stop_desc_dma;
mac_addr = of_get_mac_address(np);
- if (mac_addr)
- memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
- if (!mac_addr || !is_valid_ether_addr(dev->dev_addr)) {
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0))
+ if (!mac_addr || !is_valid_ether_addr(mac_addr)) {
+#else
+ if (IS_ERR(mac_addr) || !is_valid_ether_addr(mac_addr)) {
+#endif
dev_err(&pdev->dev, "invalid MAC address, using random address\n");
eth_random_addr(dev->dev_addr);
+ } else {
+ memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
}
ag->phy_if_mode = of_get_phy_mode(np);
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
index a58ee3346b..a58ee3346b 100644
--- a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
index ac1af26860..ac1af26860 100644
--- a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
diff --git a/target/linux/ath79/patches-5.4/200-ag71xx-Handle-allocation-errors-in-ag71xx_rings_init.patch b/target/linux/ath79/patches-5.4/200-ag71xx-Handle-allocation-errors-in-ag71xx_rings_init.patch
deleted file mode 100644
index 6631cb8e17..0000000000
--- a/target/linux/ath79/patches-5.4/200-ag71xx-Handle-allocation-errors-in-ag71xx_rings_init.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From 2cee757eaf5cc6175bc0ac7b0b808794124ec40a Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Mon, 17 Feb 2020 23:40:14 +0100
-Subject: [PATCH 1/3] ag71xx: Handle allocation errors in ag71xx_rings_init()
-
-Free the allocated resources in ag71xx_rings_init() in case
-ag71xx_ring_rx_init() returns an error.
-
-This is only a potential problem, I did not ran into this one.
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
----
- drivers/net/ethernet/atheros/ag71xx.c | 22 ++++++++++++++++++----
- 1 file changed, 18 insertions(+), 4 deletions(-)
-
---- a/drivers/net/ethernet/atheros/ag71xx.c
-+++ b/drivers/net/ethernet/atheros/ag71xx.c
-@@ -1133,6 +1133,7 @@ static int ag71xx_rings_init(struct ag71
- struct ag71xx_ring *tx = &ag->tx_ring;
- struct ag71xx_ring *rx = &ag->rx_ring;
- int ring_size, tx_size;
-+ int ret;
-
- ring_size = BIT(tx->order) + BIT(rx->order);
- tx_size = BIT(tx->order);
-@@ -1145,9 +1146,8 @@ static int ag71xx_rings_init(struct ag71
- ring_size * AG71XX_DESC_SIZE,
- &tx->descs_dma, GFP_KERNEL);
- if (!tx->descs_cpu) {
-- kfree(tx->buf);
-- tx->buf = NULL;
-- return -ENOMEM;
-+ ret = -ENOMEM;
-+ goto err_free_buf;
- }
-
- rx->buf = &tx->buf[tx_size];
-@@ -1155,7 +1155,21 @@ static int ag71xx_rings_init(struct ag71
- rx->descs_dma = tx->descs_dma + tx_size * AG71XX_DESC_SIZE;
-
- ag71xx_ring_tx_init(ag);
-- return ag71xx_ring_rx_init(ag);
-+ ret = ag71xx_ring_rx_init(ag);
-+ if (ret)
-+ goto err_free_dma;
-+
-+ return 0;
-+
-+err_free_dma:
-+ dma_free_coherent(&ag->pdev->dev, ring_size * AG71XX_DESC_SIZE,
-+ tx->descs_cpu, tx->descs_dma);
-+ rx->buf = NULL;
-+err_free_buf:
-+ kfree(tx->buf);
-+ tx->buf = NULL;
-+
-+ return ret;
- }
-
- static void ag71xx_rings_free(struct ag71xx *ag)
diff --git a/target/linux/ath79/patches-5.4/201-ag71xx-Call-ag71xx_hw_disable-in-case-phy_conenct-fa.patch b/target/linux/ath79/patches-5.4/201-ag71xx-Call-ag71xx_hw_disable-in-case-phy_conenct-fa.patch
deleted file mode 100644
index 16d60a4e0c..0000000000
--- a/target/linux/ath79/patches-5.4/201-ag71xx-Call-ag71xx_hw_disable-in-case-phy_conenct-fa.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From 2f8c5a68d0030ae5e65fca1bf5ca44929d5b3b06 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Mon, 17 Feb 2020 23:50:23 +0100
-Subject: [PATCH 2/3] ag71xx: Call ag71xx_hw_disable() in case phy_conenct
- fails
-
-When the ag71xx_phy_connect() failed only parts of the actions done
-previously in this function wrere reverted, because only
-ag71xx_rings_cleanup() was called. My system crashed the next time
-open() was called because napi_disable() was not called again and this
-resulted in two calls to napi_enable(), which is not allowed.
-
-Fix this by disabling the device again.
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
----
- drivers/net/ethernet/atheros/ag71xx.c | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
---- a/drivers/net/ethernet/atheros/ag71xx.c
-+++ b/drivers/net/ethernet/atheros/ag71xx.c
-@@ -1263,18 +1263,18 @@ static int ag71xx_open(struct net_device
-
- ret = ag71xx_hw_enable(ag);
- if (ret)
-- goto err;
-+ return ret;
-
- ret = ag71xx_phy_connect(ag);
- if (ret)
-- goto err;
-+ goto err_hw_disable;
-
- phy_start(ndev->phydev);
-
- return 0;
-
--err:
-- ag71xx_rings_cleanup(ag);
-+err_hw_disable:
-+ ag71xx_hw_disable(ag);
- return ret;
- }
-
diff --git a/target/linux/ath79/patches-5.4/202-ag71xx-Run-ag71xx_link_adjust-only-when-needed.patch b/target/linux/ath79/patches-5.4/202-ag71xx-Run-ag71xx_link_adjust-only-when-needed.patch
deleted file mode 100644
index 00f34dffa1..0000000000
--- a/target/linux/ath79/patches-5.4/202-ag71xx-Run-ag71xx_link_adjust-only-when-needed.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-From d42c6bf2752a46bdf3931bd6e56db419742fbb20 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Mon, 17 Feb 2020 23:55:22 +0100
-Subject: [PATCH 3/3] ag71xx: Run ag71xx_link_adjust() only when needed
-
-My system printed this line every second:
- ag71xx 19000000.eth eth0: Link is Up - 1Gbps/Full - flow control off
-The function ag71xx_phy_link_adjust() was called by the PHY layer every
-second even when nothing changed.
-
-With this patch the old status is stored and the real
-ag71xx_link_adjust() function is only called when when something really
-changed. This way the update and also this print is only done once any
-more.
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
----
- drivers/net/ethernet/atheros/ag71xx.c | 24 +++++++++++++++++++++++-
- 1 file changed, 23 insertions(+), 1 deletion(-)
-
---- a/drivers/net/ethernet/atheros/ag71xx.c
-+++ b/drivers/net/ethernet/atheros/ag71xx.c
-@@ -307,6 +307,10 @@ struct ag71xx {
- u32 msg_enable;
- const struct ag71xx_dcfg *dcfg;
-
-+ unsigned int link;
-+ unsigned int speed;
-+ int duplex;
-+
- /* From this point onwards we're not looking at per-packet fields. */
- void __iomem *mac_base;
-
-@@ -854,6 +858,7 @@ static void ag71xx_link_adjust(struct ag
-
- if (!phydev->link && update) {
- ag71xx_hw_stop(ag);
-+ phy_print_status(phydev);
- return;
- }
-
-@@ -907,8 +912,25 @@ static void ag71xx_link_adjust(struct ag
- static void ag71xx_phy_link_adjust(struct net_device *ndev)
- {
- struct ag71xx *ag = netdev_priv(ndev);
-+ struct phy_device *phydev = ndev->phydev;
-+ int status_change = 0;
-+
-+ if (phydev->link) {
-+ if (ag->duplex != phydev->duplex
-+ || ag->speed != phydev->speed) {
-+ status_change = 1;
-+ }
-+ }
-+
-+ if (phydev->link != ag->link)
-+ status_change = 1;
-+
-+ ag->link = phydev->link;
-+ ag->duplex = phydev->duplex;
-+ ag->speed = phydev->speed;
-
-- ag71xx_link_adjust(ag, true);
-+ if (status_change)
-+ ag71xx_link_adjust(ag, true);
- }
-
- static int ag71xx_phy_connect(struct ag71xx *ag)
diff --git a/target/linux/ath79/patches-5.4/420-net-use-downstream-ag71xx.patch b/target/linux/ath79/patches-5.4/420-net-use-downstream-ag71xx.patch
new file mode 100644
index 0000000000..17cf3ea957
--- /dev/null
+++ b/target/linux/ath79/patches-5.4/420-net-use-downstream-ag71xx.patch
@@ -0,0 +1,28 @@
+--- a/drivers/net/ethernet/atheros/Kconfig
++++ b/drivers/net/ethernet/atheros/Kconfig
+@@ -17,13 +17,7 @@ config NET_VENDOR_ATHEROS
+
+ if NET_VENDOR_ATHEROS
+
+-config AG71XX
+- tristate "Atheros AR7XXX/AR9XXX built-in ethernet mac support"
+- depends on ATH79
+- select PHYLIB
+- help
+- If you wish to compile a kernel for AR7XXX/91XXX and enable
+- ethernet support, then you should always answer Y to this.
++source "drivers/net/ethernet/atheros/ag71xx/Kconfig"
+
+ config ATL2
+ tristate "Atheros L2 Fast Ethernet support"
+--- a/drivers/net/ethernet/atheros/Makefile
++++ b/drivers/net/ethernet/atheros/Makefile
+@@ -3,7 +3,7 @@
+ # Makefile for the Atheros network device drivers.
+ #
+
+-obj-$(CONFIG_AG71XX) += ag71xx.o
++obj-$(CONFIG_AG71XX) += ag71xx/
+ obj-$(CONFIG_ATL1) += atlx/
+ obj-$(CONFIG_ATL2) += atlx/
+ obj-$(CONFIG_ATL1E) += atl1e/