atheros: in later kernels, vlan 0 no longer works as expected, switch to (1,2) instea...
[openwrt/svn-archive/archive.git] / target / linux / generic-2.6 / files / drivers / net / phy / mvswitch.c
index 78e5afe9bd4ac3a0f90da2c7b6a935e113b01d40..9a85411e0eb23663f4f6493b576b3a77eb57928f 100644 (file)
 
 /* Undefine this to use trailer mode instead.
  * I don't know if header mode works with all chips */
-#define HEADER_MODE    1
+//#define HEADER_MODE  1
 
 MODULE_DESCRIPTION("Marvell 88E6060 Switch driver");
 MODULE_AUTHOR("Felix Fietkau");
 MODULE_LICENSE("GPL");
 
+#define MVSWITCH_MAGIC 0x88E6060
+
 struct mvswitch_priv {
        /* the driver's tx function */
        int (*hardstart)(struct sk_buff *skb, struct net_device *dev);
@@ -249,7 +251,7 @@ mvswitch_config_init(struct phy_device *pdev)
 
        /* initialize default vlans */
        for (i = 0; i < MV_PORTS; i++)
-               priv->vlans[(i == MV_WANPORT ? 1 : 0)] |= (1 << i);
+               priv->vlans[(i == MV_WANPORT ? 2 : 1)] |= (1 << i);
 
        /* before entering reset, disable all ports */
        for (i = 0; i < MV_PORTS; i++)
@@ -338,6 +340,7 @@ mvswitch_config_init(struct phy_device *pdev)
        );
 
        /* hook into the tx function */
+       pdev->pkt_align = 2;
        priv->hardstart = dev->hard_start_xmit;
        pdev->netif_receive_skb = mvswitch_netif_receive_skb;
        pdev->netif_rx = mvswitch_netif_rx;
@@ -400,37 +403,6 @@ mvswitch_remove(struct phy_device *pdev)
        kfree(priv);
 }
 
-static bool
-mvswitch_detect(struct mii_bus *bus, int addr)
-{
-       u16 reg;
-       int i;
-
-       /* we attach to phy id 31 to make sure that the late probe works */
-       if (addr != 31)
-               return false;
-
-       /* look for the switch on the bus */
-       reg = bus->read(bus, MV_PORTREG(IDENT, 0)) & MV_IDENT_MASK;
-       if (reg != MV_IDENT_VALUE)
-               return false;
-
-       /* 
-        * Now that we've established that the switch actually exists, let's 
-        * get rid of the competition :)
-        */
-       for (i = 0; i < 31; i++) {
-               if (!bus->phy_map[i])
-                       continue;
-
-               device_unregister(&bus->phy_map[i]->dev);
-               kfree(bus->phy_map[i]);
-               bus->phy_map[i] = NULL;
-       }
-
-       return true;
-}
-
 static int
 mvswitch_probe(struct phy_device *pdev)
 {
@@ -445,11 +417,28 @@ mvswitch_probe(struct phy_device *pdev)
        return 0;
 }
 
+static int
+mvswitch_fixup(struct phy_device *dev)
+{
+       u16 reg;
+
+       if (dev->addr != 0x10)
+               return 0;
+
+       reg = dev->bus->read(dev->bus, MV_PORTREG(IDENT, 0)) & MV_IDENT_MASK;
+       if (reg != MV_IDENT_VALUE)
+               return 0;
+
+       dev->phy_id = MVSWITCH_MAGIC;
+       return 0;
+}
+
 
 static struct phy_driver mvswitch_driver = {
        .name           = "Marvell 88E6060",
+       .phy_id         = MVSWITCH_MAGIC,
+       .phy_id_mask    = 0xffffffff,
        .features       = PHY_BASIC_FEATURES,
-       .detect         = &mvswitch_detect,
        .probe          = &mvswitch_probe,
        .remove         = &mvswitch_remove,
        .config_init    = &mvswitch_config_init,
@@ -461,6 +450,7 @@ static struct phy_driver mvswitch_driver = {
 static int __init
 mvswitch_init(void)
 {
+       phy_register_fixup_for_id(PHY_ANY_ID, mvswitch_fixup);
        return phy_driver_register(&mvswitch_driver);
 }