fix strange LED behavior with Netgear WGT634U (#3552)
[openwrt/staging/dedeckeh.git] / package / switch / src / switch-robo.c
index 045dce1c4b7aad079cbc36dbffa5e069875ce8ef..46abc94e901f61d926c6c1b8efeab705b3920e59 100644 (file)
@@ -41,6 +41,7 @@
 
 #define ROBO_PHY_ADDR          0x1E    /* robo switch phy address */
 #define ROBO_PHY_ADDR_TG3      0x01    /* Tigon3 PHY address */
+#define ROBO_PHY_ADDR_BCM63XX  0x00    /* BCM63XX PHY address */
 
 /* MII registers */
 #define REG_MII_PAGE   0x10    /* MII Page register */
@@ -67,6 +68,9 @@
 #define bool int
 #endif
 
+
+extern char *nvram_get(const char *name);
+
 /* Data structure for a Roboswitch device. */
 struct robo_switch {
        char *device;                   /* The device name string (ethX) */
@@ -270,8 +274,9 @@ static int robo_switch_enable(void)
                        robo_write16(ROBO_CTRL_PAGE, i, 0);
        }
 
-       /* WAN port LED */
-       robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
+       /* WAN port LED, except for Netgear WGT634U */
+       if (strcmp(nvram_get("nvram_type"), "cfe"))
+               robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
 
        return 0;
 }
@@ -318,13 +323,14 @@ static int robo_probe(char *devname)
                /* got phy address check for robo address */
                struct mii_ioctl_data *mii = (struct mii_ioctl_data *) &robo.ifr.ifr_data;
                if ((mii->phy_id != ROBO_PHY_ADDR) &&
+                   (mii->phy_id != ROBO_PHY_ADDR_BCM63XX) &&
                    (mii->phy_id != ROBO_PHY_ADDR_TG3)) {
                        printk("Invalid phy address (%d)\n", mii->phy_id);
                        return 1;
                }
                robo.use_et = 0;
                /* The robo has a fixed PHY address that is different from the
-                * Tigon3 PHY address. */
+                * Tigon3 and BCM63xx PHY address. */
                robo.phy_addr = ROBO_PHY_ADDR;
        }
 
@@ -332,7 +338,7 @@ static int robo_probe(char *devname)
                (mdio_read(robo.phy_addr, 0x3) << 16);
 
        if (phyid == 0xffffffff || phyid == 0x55210022) {
-               printk("No Robo switch in managed mode found\n");
+               printk("No Robo switch in managed mode found, phy_id = 0x%08x\n", phyid);
                return 1;
        }
 
@@ -528,7 +534,8 @@ static int __init robo_init(void)
 
        device = strdup("ethX");
        for (device[3] = '0'; (device[3] <= '3') && notfound; device[3]++) {
-               notfound = robo_probe(device);
+               if (! switch_device_registered (device))
+                       notfound = robo_probe(device);
        }
        device[3]--;