net: Conditional COBJS inclusion of network drivers
[platform/kernel/u-boot.git] / drivers / net / tsec.c
index 504f3e5..6e0f2c6 100644 (file)
@@ -17,7 +17,6 @@
 #include <net.h>
 #include <command.h>
 
-#if defined(CONFIG_TSEC_ENET)
 #include "tsec.h"
 #include "miiphy.h"
 
@@ -575,6 +574,64 @@ uint mii_parse_88E1011_psr(uint mii_reg, struct tsec_private * priv)
        return 0;
 }
 
+/* Parse the RTL8211B's status register for speed and duplex
+ * information
+ */
+uint mii_parse_RTL8211B_sr(uint mii_reg, struct tsec_private * priv)
+{
+       uint speed;
+
+       mii_reg = read_phy_reg(priv, MIIM_RTL8211B_PHY_STATUS);
+       if (!(mii_reg & MIIM_RTL8211B_PHYSTAT_SPDDONE)) {
+               int i = 0;
+
+               /* in case of timeout ->link is cleared */
+               priv->link = 1;
+               puts("Waiting for PHY realtime link");
+               while (!(mii_reg & MIIM_RTL8211B_PHYSTAT_SPDDONE)) {
+                       /* Timeout reached ? */
+                       if (i > PHY_AUTONEGOTIATE_TIMEOUT) {
+                               puts(" TIMEOUT !\n");
+                               priv->link = 0;
+                               break;
+                       }
+
+                       if ((i++ % 1000) == 0) {
+                               putc('.');
+                       }
+                       udelay(1000);   /* 1 ms */
+                       mii_reg = read_phy_reg(priv, MIIM_RTL8211B_PHY_STATUS);
+               }
+               puts(" done\n");
+               udelay(500000); /* another 500 ms (results in faster booting) */
+       } else {
+               if (mii_reg & MIIM_RTL8211B_PHYSTAT_LINK)
+                       priv->link = 1;
+               else
+                       priv->link = 0;
+       }
+
+       if (mii_reg & MIIM_RTL8211B_PHYSTAT_DUPLEX)
+               priv->duplexity = 1;
+       else
+               priv->duplexity = 0;
+
+       speed = (mii_reg & MIIM_RTL8211B_PHYSTAT_SPEED);
+
+       switch (speed) {
+       case MIIM_RTL8211B_PHYSTAT_GBIT:
+               priv->speed = 1000;
+               break;
+       case MIIM_RTL8211B_PHYSTAT_100:
+               priv->speed = 100;
+               break;
+       default:
+               priv->speed = 10;
+       }
+
+       return 0;
+}
+
 /* Parse the cis8201's status register for speed and duplex
  * information
  */
@@ -1070,6 +1127,36 @@ struct phy_info phy_info_M88E1111S = {
                           },
 };
 
+struct phy_info phy_info_M88E1118 = {
+       0x01410e1,
+       "Marvell 88E1118",
+       4,
+       (struct phy_cmd[]){     /* config */
+               /* Reset and configure the PHY */
+               {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL},
+               {0x16, 0x0002, NULL}, /* Change Page Number */
+               {0x15, 0x1070, NULL}, /* Delay RGMII TX and RX */
+               {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL},
+               {MIIM_ANAR, MIIM_ANAR_INIT, NULL},
+               {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL},
+               {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init},
+               {miim_end,}
+               },
+       (struct phy_cmd[]){     /* startup */
+               {0x16, 0x0000, NULL}, /* Change Page Number */
+               /* Status is read once to clear old link state */
+               {MIIM_STATUS, miim_read, NULL},
+               /* Auto-negotiate */
+               /* Read the status */
+               {MIIM_88E1011_PHY_STATUS, miim_read,
+                &mii_parse_88E1011_psr},
+               {miim_end,}
+               },
+       (struct phy_cmd[]){     /* shutdown */
+               {miim_end,}
+               },
+};
+
 static unsigned int m88e1145_setmode(uint mii_reg, struct tsec_private *priv)
 {
        uint mii_data = read_phy_reg(priv, mii_reg);
@@ -1209,6 +1296,41 @@ struct phy_info phy_info_VSC8244 = {
                           },
 };
 
+struct phy_info phy_info_VSC8601 = {
+               0x00007042,
+               "Vitesse VSC8601",
+               4,
+               (struct phy_cmd[]){     /* config */
+                               /* Override PHY config settings */
+                               /* Configure some basic stuff */
+                               {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init},
+#ifdef CFG_VSC8601_SKEWFIX
+                               {MIIM_VSC8601_EPHY_CON,MIIM_VSC8601_EPHY_CON_INIT_SKEW,NULL},
+#if defined(CFG_VSC8601_SKEW_TX) && defined(CFG_VSC8601_SKEW_RX)
+                               {MIIM_EXT_PAGE_ACCESS,1,NULL},
+#define VSC8101_SKEW   (CFG_VSC8601_SKEW_TX<<14)|(CFG_VSC8601_SKEW_RX<<12)
+                               {MIIM_VSC8601_SKEW_CTRL,VSC8101_SKEW,NULL},
+                               {MIIM_EXT_PAGE_ACCESS,0,NULL},
+#endif
+#endif
+                               {miim_end,}
+                                },
+               (struct phy_cmd[]){     /* startup */
+                               /* Read the Status (2x to make sure link is right) */
+                               {MIIM_STATUS, miim_read, NULL},
+                               /* Auto-negotiate */
+                               {MIIM_STATUS, miim_read, &mii_parse_sr},
+                               /* Read the status */
+                               {MIIM_VSC8244_AUX_CONSTAT, miim_read,
+                                               &mii_parse_vsc8244},
+                               {miim_end,}
+                               },
+               (struct phy_cmd[]){     /* shutdown */
+                               {miim_end,}
+                               },
+};
+
+
 struct phy_info phy_info_dm9161 = {
        0x0181b88,
        "Davicom DM9161E",
@@ -1365,6 +1487,33 @@ struct phy_info phy_info_dp83865 = {
                           },
 };
 
+struct phy_info phy_info_rtl8211b = {
+       0x001cc91,
+       "RealTek RTL8211B",
+       4,
+       (struct phy_cmd[]){     /* config */
+               /* Reset and configure the PHY */
+               {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL},
+               {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL},
+               {MIIM_ANAR, MIIM_ANAR_INIT, NULL},
+               {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL},
+               {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init},
+               {miim_end,}
+       },
+       (struct phy_cmd[]){     /* startup */
+               /* Status is read once to clear old link state */
+               {MIIM_STATUS, miim_read, NULL},
+               /* Auto-negotiate */
+               {MIIM_STATUS, miim_read, &mii_parse_sr},
+               /* Read the status */
+               {MIIM_RTL8211B_PHY_STATUS, miim_read, &mii_parse_RTL8211B_sr},
+               {miim_end,}
+       },
+       (struct phy_cmd[]){     /* shutdown */
+               {miim_end,}
+       },
+};
+
 struct phy_info *phy_info[] = {
        &phy_info_cis8204,
        &phy_info_cis8201,
@@ -1372,12 +1521,15 @@ struct phy_info *phy_info[] = {
        &phy_info_BCM5464S,
        &phy_info_M88E1011S,
        &phy_info_M88E1111S,
+       &phy_info_M88E1118,
        &phy_info_M88E1145,
        &phy_info_M88E1149S,
        &phy_info_dm9161,
        &phy_info_lxt971,
        &phy_info_VSC8244,
+       &phy_info_VSC8601,
        &phy_info_dp83865,
+       &phy_info_rtl8211b,
        &phy_info_generic,
        NULL
 };
@@ -1588,5 +1740,3 @@ tsec_mcast_addr (struct eth_device *dev, u8 mcast_mac, u8 set)
        return 0;
 }
 #endif /* Multicast TFTP ? */
-
-#endif /* CONFIG_TSEC_ENET */