net: ethernet: mediatek: add extension of phy-mode for TRGMII
authorSean Wang <sean.wang@mediatek.com>
Thu, 22 Sep 2016 02:33:54 +0000 (10:33 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Sep 2016 12:21:21 +0000 (08:21 -0400)
adds PHY-mode "trgmii" as an extension for the operation
mode of the PHY interface for PHY_INTERFACE_MODE_TRGMII.
and adds a variable trgmii inside mtk_mac as the indication
to make the difference between the MAC connected to internal
switch or connected to external PHY by the given configuration
on the board and then to perform the corresponding setup on
TRGMII hardware module.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mediatek/mtk_eth_soc.c
drivers/net/ethernet/mediatek/mtk_eth_soc.h
include/linux/phy.h

index 2909372c4da02f7bba5f7212b4124f7d3b74c9ac..e873e21fd20edf2d9fa26e18588fd665a6e648a1 100644 (file)
@@ -244,6 +244,8 @@ static int mtk_phy_connect(struct mtk_mac *mac)
                return -ENODEV;
 
        switch (of_get_phy_mode(np)) {
+       case PHY_INTERFACE_MODE_TRGMII:
+               mac->trgmii = true;
        case PHY_INTERFACE_MODE_RGMII_TXID:
        case PHY_INTERFACE_MODE_RGMII_RXID:
        case PHY_INTERFACE_MODE_RGMII_ID:
index 7c5e534d21201a40e050a2489989cc365ca3fbb1..e3b9525f94c659defb5aa63763b1659835ccb9dc 100644 (file)
@@ -529,6 +529,8 @@ struct mtk_eth {
  * @hw:                        Backpointer to our main datastruture
  * @hw_stats:          Packet statistics counter
  * @phy_dev:           The attached PHY if available
+ * @trgmii             Indicate if the MAC uses TRGMII connected to internal
+                       switch
  */
 struct mtk_mac {
        int                             id;
@@ -539,6 +541,7 @@ struct mtk_mac {
        struct phy_device               *phy_dev;
        __be32                          hwlro_ip[MTK_MAX_LRO_IP_CNT];
        int                             hwlro_ip_cnt;
+       bool                            trgmii;
 };
 
 /* the struct describing the SoC. these are declared in the soc_xyz.c files */
index 2d24b283aa2d989b83caec4323c2126c4256c664..e25f1830fbcfbcfc34f76fc4f16c882109b736c6 100644 (file)
@@ -80,6 +80,7 @@ typedef enum {
        PHY_INTERFACE_MODE_XGMII,
        PHY_INTERFACE_MODE_MOCA,
        PHY_INTERFACE_MODE_QSGMII,
+       PHY_INTERFACE_MODE_TRGMII,
        PHY_INTERFACE_MODE_MAX,
 } phy_interface_t;
 
@@ -123,6 +124,8 @@ static inline const char *phy_modes(phy_interface_t interface)
                return "moca";
        case PHY_INTERFACE_MODE_QSGMII:
                return "qsgmii";
+       case PHY_INTERFACE_MODE_TRGMII:
+               return "trgmii";
        default:
                return "unknown";
        }