ar71xx: change PHY select logic, and update phy_masks
authorGabor Juhos <juhosg@openwrt.org>
Sun, 21 Mar 2010 18:16:07 +0000 (18:16 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sun, 21 Mar 2010 18:16:07 +0000 (18:16 +0000)
SVN-Revision: 20358

22 files changed:
target/linux/ar71xx/files/arch/mips/ar71xx/dev-ap91-eth.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap81.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap83.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-aw-nr580.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-dir-615-c1.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-mzk-w04nu.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-mzk-w300nh.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb42.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-pb44.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-rb4xx.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-tew-632brp.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr1043nd.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr841n.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr941nd.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-ubnt.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-wnr2000.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-wp543.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt400n.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c
target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx.h
target/linux/ar71xx/files/drivers/net/ag71xx/ag71xx_phy.c

index 571901e..c48af45 100644 (file)
@@ -48,7 +48,6 @@ void __init ap91_eth_init(u8 *mac_addr, const char *port_names[])
 
        /* WAN port */
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth0_data.phy_mask = 0x0;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
        ar71xx_eth0_data.fifo_cfg1 = 0x0fff0000;
@@ -57,7 +56,6 @@ void __init ap91_eth_init(u8 *mac_addr, const char *port_names[])
 
        /* LAN ports */
        ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth1_data.phy_mask = 0x0;
        ar71xx_eth1_data.speed = SPEED_1000;
        ar71xx_eth1_data.duplex = DUPLEX_FULL;
        ar71xx_eth1_data.fifo_cfg1 = 0x0fff0000;
index 6fa950f..cd865b0 100644 (file)
@@ -113,7 +113,6 @@ static void __init ap81_setup(void)
        ar71xx_add_device_mdio(0x0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth0_data.phy_mask = 0xf;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
        ar71xx_eth0_data.has_ar8216 = 1;
index 72c0016..9aa17dc 100644 (file)
@@ -206,7 +206,6 @@ static void __init ap83_generic_setup(void)
        ar71xx_add_device_eth(0);
 
        ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
-       ar71xx_eth1_data.phy_mask = 0x0;
        ar71xx_eth1_data.speed = SPEED_1000;
        ar71xx_eth1_data.duplex = DUPLEX_FULL;
 
index a6f1daf..b9b037a 100644 (file)
@@ -80,7 +80,6 @@ static void __init aw_nr580_setup(void)
        ar71xx_add_device_mdio(0x0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
-       ar71xx_eth0_data.phy_mask = 0xf;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
 
index 5eb594c..f5eb7b2 100644 (file)
@@ -144,7 +144,6 @@ static void __init dir_615c1_setup(void)
        ar71xx_add_device_mdio(0x0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth0_data.phy_mask = 0xf;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
 
index 1e5a933..42d0f81 100644 (file)
@@ -135,7 +135,6 @@ static void __init mzk_w04nu_setup(void)
        ar71xx_add_device_mdio(0x0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth0_data.phy_mask = 0xf;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
        ar71xx_eth0_data.has_ar8216 = 1;
index 3a38c82..ed431d8 100644 (file)
@@ -134,7 +134,6 @@ static void __init mzk_w300nh_setup(void)
        ar71xx_add_device_mdio(0x0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth0_data.phy_mask = 0xf;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
        ar71xx_eth0_data.has_ar8216 = 1;
index 96a976f..576da4b 100644 (file)
@@ -55,7 +55,6 @@ static void __init pb42_init(void)
        ar71xx_eth0_data.phy_mask = PB42_WAN_PHYMASK;
 
        ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth1_data.phy_mask = PB42_LAN_PHYMASK;
        ar71xx_eth1_data.speed = SPEED_100;
        ar71xx_eth1_data.duplex = DUPLEX_FULL;
 
index 052884f..aa74666 100644 (file)
@@ -179,7 +179,6 @@ static void __init pb44_init(void)
        ar71xx_add_device_eth(0);
 
        ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
-       ar71xx_eth1_data.phy_mask = PB44_LAN_PHYMASK;
        ar71xx_eth1_data.speed = SPEED_1000;
        ar71xx_eth1_data.duplex = DUPLEX_FULL;
        ar71xx_eth1_pll_data.pll_1000 = 0x110000;
index bf1a39f..0527e13 100644 (file)
@@ -177,10 +177,10 @@ static void __init rb411_setup(void)
        rb4xx_generic_setup();
        rb4xx_add_device_spi();
 
-       ar71xx_add_device_mdio(0xfffffffe);
+       ar71xx_add_device_mdio(0xfffffffc);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
-       ar71xx_eth0_data.phy_mask = 0x00000001;
+       ar71xx_eth0_data.phy_mask = 0x00000003;
 
        ar71xx_add_device_eth(0);
 
@@ -216,7 +216,6 @@ static void __init rb433_setup(void)
        ar71xx_add_device_mdio(0xffffffe9);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
-       ar71xx_eth0_data.phy_mask = 0x00000006;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
 
@@ -249,7 +248,6 @@ static void __init rb450_generic_setup(int gige)
        ar71xx_add_device_mdio(0xffffffe0);
 
        ar71xx_eth0_data.phy_if_mode = (gige) ? PHY_INTERFACE_MODE_RGMII : PHY_INTERFACE_MODE_MII;
-       ar71xx_eth0_data.phy_mask = 0x0000000f;
        ar71xx_eth0_data.speed = (gige) ? SPEED_1000 : SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
 
@@ -284,7 +282,6 @@ static void __init rb493_setup(void)
        ar71xx_add_device_mdio(0x3fffff00);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
-       ar71xx_eth0_data.phy_mask = 0;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
 
index 4abb8e4..2bf9ad9 100644 (file)
@@ -120,7 +120,6 @@ static void __init tew_632brp_setup(void)
        ar71xx_add_device_mdio(0x0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth0_data.phy_mask = 0xf;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
 
index fd8e5fc..3b7b764 100644 (file)
@@ -130,7 +130,6 @@ static void __init tl_wr1043nd_setup(void)
 
        ar71xx_eth0_data.mii_bus_dev = &tl_wr1043nd_rtl8366rb_device.dev;
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
-       ar71xx_eth0_data.phy_mask = 0x0;
        ar71xx_eth0_data.speed = SPEED_1000;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
        ar71xx_eth0_pll_data.pll_1000 = 0x1a000000;
index 9f9e3c6..1b849e1 100644 (file)
@@ -120,7 +120,6 @@ static void __init tl_wr841n_v1_setup(void)
        ar71xx_add_device_mdio(0x0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth0_data.phy_mask = 0x0;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
 
index 67af5b0..0c64893 100644 (file)
@@ -121,7 +121,6 @@ static void __init tl_wr941nd_setup(void)
        ar71xx_add_device_mdio(0x0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth0_data.phy_mask = 0x0;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
 
index 5b1c504..3cd5a63 100644 (file)
@@ -136,9 +136,6 @@ static void __init ubnt_generic_setup(void)
 #define UBNT_RS_WAN_PHYMASK    (1 << 20)
 #define UBNT_RS_LAN_PHYMASK    ((1 << 16) | (1 << 17) | (1 << 18) | (1 << 19))
 
-#define UBNT_RSPRO_WAN_PHYMASK (1 << 4)
-#define UBNT_RSPRO_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3))
-
 static void __init ubnt_rs_setup(void)
 {
        ubnt_generic_setup();
@@ -149,8 +146,6 @@ static void __init ubnt_rs_setup(void)
        ar71xx_eth0_data.phy_mask = UBNT_RS_WAN_PHYMASK;
 
        ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth1_data.phy_mask = UBNT_RS_LAN_PHYMASK;
-
        ar71xx_eth1_data.speed = SPEED_100;
        ar71xx_eth1_data.duplex = DUPLEX_FULL;
 
@@ -169,6 +164,9 @@ MIPS_MACHINE(AR71XX_MACH_UBNT_RS, "UBNT-RS", "Ubiquiti RouterStation",
 MIPS_MACHINE(AR71XX_MACH_UBNT_AR71XX, "Ubiquiti AR71xx-based board",
             "Ubiquiti RouterStation", ubnt_rs_setup);
 
+#define UBNT_RSPRO_WAN_PHYMASK (1 << 4)
+#define UBNT_RSPRO_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3))
+
 static void __init ubnt_rspro_setup(void)
 {
        ubnt_generic_setup();
@@ -179,8 +177,6 @@ static void __init ubnt_rspro_setup(void)
        ar71xx_eth0_data.phy_mask = UBNT_RSPRO_WAN_PHYMASK;
 
        ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
-       ar71xx_eth1_data.phy_mask = UBNT_RSPRO_LAN_PHYMASK;
-
        ar71xx_eth1_data.speed = SPEED_1000;
        ar71xx_eth1_data.duplex = DUPLEX_FULL;
 
@@ -235,7 +231,6 @@ static void __init ubnt_m_setup(void)
        ar71xx_add_device_mdio(~0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
-       ar71xx_eth0_data.phy_mask = 0;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
        ar71xx_eth0_data.fifo_cfg1 = 0x0010ffff;
@@ -272,7 +267,6 @@ static void __init ubnt_nano_m_setup(void)
        ubnt_m_setup();
 
        ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth1_data.phy_mask = 0;
        ar71xx_eth1_data.speed = SPEED_1000;
        ar71xx_eth1_data.duplex = DUPLEX_FULL;
        ar71xx_eth1_data.fifo_cfg1 = 0x0010ffff;
index 3dd9778..62931e6 100644 (file)
@@ -173,7 +173,6 @@ static void __init wndr3700_setup(void)
        ar71xx_eth0_pll_data.pll_1000 = 0x11110000;
        ar71xx_eth0_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
-       ar71xx_eth0_data.phy_mask = 0xf;
        ar71xx_eth0_data.speed = SPEED_1000;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
 
index bf4be89..73422d6 100644 (file)
@@ -122,7 +122,6 @@ static void __init wnr2000_setup(void)
        ar71xx_add_device_mdio(0x0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth0_data.phy_mask = 0xf;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
        ar71xx_eth0_data.has_ar8216 = 1;
index bf8b9f5..2258584 100644 (file)
@@ -79,7 +79,7 @@ static void __init wp543_setup(void)
        ar71xx_add_device_mdio(0xfffffff7);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
-       ar71xx_eth0_data.phy_mask = 0x00000008;
+       ar71xx_eth0_data.phy_mask = 0x08;
        ar71xx_eth0_data.reset_bit = RESET_MODULE_GE0_MAC |
                                     RESET_MODULE_GE0_PHY;
        ar71xx_add_device_eth(0);
index 3d50afc..886f947 100644 (file)
@@ -143,7 +143,6 @@ static void __init wrt400n_setup(void)
        ar71xx_add_device_mdio(0x0);
 
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
-       ar71xx_eth0_data.phy_mask = 0xf;
        ar71xx_eth0_data.speed = SPEED_100;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
        ar71xx_eth0_data.has_ar8216 = 1;
index c6fb241..b52cc60 100644 (file)
@@ -234,7 +234,6 @@ static void __init wzrhpg300nh_setup(void)
        ar71xx_eth0_pll_data.pll_1000 = 0x1e000100;
        ar71xx_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev;
        ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
-       ar71xx_eth0_data.phy_mask = 0xf;
        ar71xx_eth0_data.speed = SPEED_1000;
        ar71xx_eth0_data.duplex = DUPLEX_FULL;
 
index 841c67f..5be8998 100644 (file)
@@ -38,7 +38,7 @@
 #define ETH_FCS_LEN    4
 
 #define AG71XX_DRV_NAME                "ag71xx"
-#define AG71XX_DRV_VERSION     "0.5.32"
+#define AG71XX_DRV_VERSION     "0.5.33"
 
 #define AG71XX_NAPI_WEIGHT     64
 #define AG71XX_OOM_REFILL      (1 + HZ/10)
index 4425b74..9c76544 100644 (file)
@@ -47,10 +47,6 @@ void ag71xx_phy_start(struct ag71xx *ag)
        if (ag->phy_dev) {
                phy_start(ag->phy_dev);
        } else {
-               struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
-
-               ag->duplex = pdata->duplex;
-               ag->speed = pdata->speed;
                ag->link = 1;
                ag71xx_link_adjust(ag);
        }
@@ -61,9 +57,7 @@ void ag71xx_phy_stop(struct ag71xx *ag)
        if (ag->phy_dev) {
                phy_stop(ag->phy_dev);
        } else {
-               ag->duplex = -1;
                ag->link = 0;
-               ag->speed = 0;
                ag71xx_link_adjust(ag);
        }
 }
@@ -81,12 +75,16 @@ static int ag71xx_phy_connect_fixed(struct ag71xx *ag)
        case SPEED_1000:
                break;
        default:
-               printk(KERN_ERR "%s: invalid speed specified\n",
-                       dev->name);
+               printk(KERN_ERR "%s: invalid speed specified\n", dev->name);
                ret = -EINVAL;
                break;
        }
 
+       printk(KERN_DEBUG "%s: using fixed link parameters\n", dev->name);
+
+       ag->duplex = pdata->duplex;
+       ag->speed = pdata->speed;
+
        return ret;
 }
 
@@ -95,7 +93,6 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag)
        struct net_device *dev = ag->dev;
        struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
        struct phy_device *phydev = NULL;
-       int phy_count = 0;
        int phy_addr;
        int ret = 0;
 
@@ -113,50 +110,39 @@ static int ag71xx_phy_connect_multi(struct ag71xx *ag)
 
                if (phydev == NULL)
                        phydev = ag->mii_bus->phy_map[phy_addr];
-
-               phy_count++;
        }
 
-       switch (phy_count) {
-       case 0:
+       if (!phydev) {
                printk(KERN_ERR "%s: no PHY found with phy_mask=%08x\n",
                        dev->name, pdata->phy_mask);
-               ret = -ENODEV;
-               break;
-       case 1:
-               ag->phy_dev = phy_connect(dev, dev_name(&phydev->dev),
-                       &ag71xx_phy_link_adjust, 0, pdata->phy_if_mode);
-
-               if (IS_ERR(ag->phy_dev)) {
-                       printk(KERN_ERR "%s: could not connect to PHY at %s\n",
-                               dev->name, dev_name(&phydev->dev));
-                       return PTR_ERR(ag->phy_dev);
-               }
+               return -ENODEV;
+       }
 
-               /* mask with MAC supported features */
-               if (pdata->has_gbit)
-                       phydev->supported &= PHY_GBIT_FEATURES;
-               else
-                       phydev->supported &= PHY_BASIC_FEATURES;
+       ag->phy_dev = phy_connect(dev, dev_name(&phydev->dev),
+                                 &ag71xx_phy_link_adjust, 0,
+                                 pdata->phy_if_mode);
 
-               phydev->advertising = phydev->supported;
+       if (IS_ERR(ag->phy_dev)) {
+               printk(KERN_ERR "%s: could not connect to PHY at %s\n",
+                       dev->name, dev_name(&phydev->dev));
+               return PTR_ERR(ag->phy_dev);
+       }
 
-               printk(KERN_DEBUG "%s: connected to PHY at %s "
-                       "[uid=%08x, driver=%s]\n",
-                       dev->name, dev_name(&phydev->dev),
-                       phydev->phy_id, phydev->drv->name);
+       /* mask with MAC supported features */
+       if (pdata->has_gbit)
+               phydev->supported &= PHY_GBIT_FEATURES;
+       else
+               phydev->supported &= PHY_BASIC_FEATURES;
 
-               ag->link = 0;
-               ag->speed = 0;
-               ag->duplex = -1;
-               break;
+       phydev->advertising = phydev->supported;
 
-       default:
-               printk(KERN_DEBUG "%s: connected to %d PHYs\n",
-                       dev->name, phy_count);
-               ret = ag71xx_phy_connect_fixed(ag);
-               break;
-       }
+       printk(KERN_DEBUG "%s: connected to PHY at %s [uid=%08x, driver=%s]\n",
+               dev->name, dev_name(&phydev->dev),
+               phydev->phy_id, phydev->drv->name);
+
+       ag->link = 0;
+       ag->speed = 0;
+       ag->duplex = -1;
 
        return ret;
 }