Update patch for sunxi-dev 4.5 - bananapi-r1 switch


WeeB

Recommended Posts

This patch modifies the sunxi-dev/bananapi-r1-switch-driver.patch to work with

the changed phy/mdio interface in 4.5.
It was also necessary to revert
commit

88f8b1bb41c6208f81b6a480244533ded7b59493 "stmmac: Fix 'eth0: No PHY found' regression"

because it breaks networking on all my sun7i-a20 boards (bananapi, cubietruck, and bananapi-r1)

 

From ce978c1235f68cf7bfeb81693d047afcee6df038 Mon Sep 17 00:00:00 2001
From: Werner Boellmann <WeeB@sample.net>
Date: Mon, 15 Feb 2016 12:22:08 +0100
Subject: [PATCH] bananapi-r1 switch driver: Modifications for Kernel v4.5

---
 drivers/net/phy/b53/b53_mdio.c      | 63 ++++++++++---------------------------
 drivers/net/phy/b53/b53_phy_fixup.c |  4 +--
 2 files changed, 19 insertions(+), 48 deletions(-)

diff --git a/drivers/net/phy/b53/b53_mdio.c b/drivers/net/phy/b53/b53_mdio.c
index 3c25f0e..fcf3a23 100644
--- a/drivers/net/phy/b53/b53_mdio.c
+++ b/drivers/net/phy/b53/b53_mdio.c
@@ -257,11 +257,11 @@ static int b53_phy_probe(struct phy_device *phydev)
     int ret;
 
     /* allow the generic phy driver to take over */
-    if (phydev->addr != B53_PSEUDO_PHY && phydev->addr != 0)
+    if (phydev->mdio.addr != B53_PSEUDO_PHY && phydev->mdio.addr != 0)
         return -ENODEV;
 
     dev.current_page = 0xff;
-    dev.priv = phydev->bus;
+    dev.priv = phydev->mdio.bus;
     dev.ops = &b53_mdio_ops;
     dev.pdata = NULL;
     mutex_init(&dev.reg_mutex);
@@ -285,7 +285,7 @@ static int b53_phy_config_init(struct phy_device *phydev)
     struct b53_device *dev;
     int ret;
 
-    dev = b53_switch_alloc(&phydev->dev, &b53_mdio_ops, phydev->bus);
+    dev = b53_switch_alloc(&phydev->mdio.dev, &b53_mdio_ops, phydev->mdio.bus);
     if (!dev)
         return -ENOMEM;
 
@@ -341,10 +341,10 @@ static int b53_phy_read_status(struct phy_device *phydev)
     return 0;
 }
 
-/* BCM5325, BCM539x */
-static struct phy_driver b53_phy_driver_id1 = {
-    .phy_id        = 0x0143bc00,
+static struct phy_driver b53_phy_drivers[] = {
+ { /* BCM5325, BCM539x */
     .name        = "Broadcom B53 (1)",
+    .phy_id        = 0x0143bc00,
     .phy_id_mask    = 0x1ffffc00,
     .features    = 0,
     .probe        = b53_phy_probe,
@@ -352,15 +352,10 @@ static struct phy_driver b53_phy_driver_id1 = {
     .config_aneg    = b53_phy_config_aneg,
     .config_init    = b53_phy_config_init,
     .read_status    = b53_phy_read_status,
-    .driver = {
-        .owner = THIS_MODULE,
-    },
-};
-
-/* BCM53125, BCM53128 */
-static struct phy_driver b53_phy_driver_id2 = {
-    .phy_id        = 0x03625c00,
+ },
+ { /* BCM53125, BCM53128 */
     .name        = "Broadcom B53 (2)",
+    .phy_id        = 0x03625c00,
     .phy_id_mask    = 0x1ffffc00,
     .features    = 0,
     .probe        = b53_phy_probe,
@@ -368,15 +363,10 @@ static struct phy_driver b53_phy_driver_id2 = {
     .config_aneg    = b53_phy_config_aneg,
     .config_init    = b53_phy_config_init,
     .read_status    = b53_phy_read_status,
-    .driver = {
-        .owner = THIS_MODULE,
-    },
-};
-
-/* BCM5365 */
-static struct phy_driver b53_phy_driver_id3 = {
-    .phy_id        = 0x00406000,
+ },
+ { /* BCM5365 */
     .name        = "Broadcom B53 (3)",
+    .phy_id        = 0x00406000,
     .phy_id_mask    = 0x1ffffc00,
     .features    = 0,
     .probe        = b53_phy_probe,
@@ -384,38 +374,19 @@ static struct phy_driver b53_phy_driver_id3 = {
     .config_aneg    = b53_phy_config_aneg,
     .config_init    = b53_phy_config_init,
     .read_status    = b53_phy_read_status,
-    .driver = {
-        .owner = THIS_MODULE,
-    },
+ }
 };
 
 int __init b53_phy_driver_register(void)
 {
-    int ret;
-
-    ret = phy_driver_register(&b53_phy_driver_id1);
-    if (ret)
-        return ret;
-
-    ret = phy_driver_register(&b53_phy_driver_id2);
-    if (ret)
-        goto err1;
-
-    ret = phy_driver_register(&b53_phy_driver_id3);
-    if (!ret)
-        return 0;
-
-    phy_driver_unregister(&b53_phy_driver_id2);
-err1:
-    phy_driver_unregister(&b53_phy_driver_id1);
-    return ret;
+    return phy_drivers_register(b53_phy_drivers,
+            ARRAY_SIZE(b53_phy_drivers), THIS_MODULE);
 }
 
 void __exit b53_phy_driver_unregister(void)
 {
-    phy_driver_unregister(&b53_phy_driver_id3);
-    phy_driver_unregister(&b53_phy_driver_id2);
-    phy_driver_unregister(&b53_phy_driver_id1);
+    phy_drivers_unregister(b53_phy_drivers,
+            ARRAY_SIZE(b53_phy_drivers));
 }
 
 module_init(b53_phy_driver_register);
diff --git a/drivers/net/phy/b53/b53_phy_fixup.c b/drivers/net/phy/b53/b53_phy_fixup.c
index 72d1373..ac3779e 100644
--- a/drivers/net/phy/b53/b53_phy_fixup.c
+++ b/drivers/net/phy/b53/b53_phy_fixup.c
@@ -29,9 +29,9 @@
 static int b53_phy_fixup(struct phy_device *dev)
 {
     u32 phy_id;
-    struct mii_bus *bus = dev->bus;
+    struct mii_bus *bus = dev->mdio.bus;
 
-    if (dev->addr != B53_PSEUDO_PHY)
+    if (dev->mdio.addr != B53_PSEUDO_PHY)
         return 0;
 
     /* read the first port's id */
--
2.7.0

 

Link to post
Share on other sites
Donate and support the project!

Guest
This topic is now closed to further replies.