net: netcp: ethss: add support for handling rgmii link interface
authorMurali Karicheri <m-karicheri2@ti.com>
Tue, 17 Apr 2018 21:30:34 +0000 (17:30 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Apr 2018 01:00:56 +0000 (21:00 -0400)
2u cpsw hardware on K2G uses rgmii link to interface with Phy. So add
support for this interface in the code so that driver can be re-used
for 2u hardware.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/netcp.h
drivers/net/ethernet/ti/netcp_ethss.c

index 8900a6f..416f732 100644 (file)
@@ -33,6 +33,8 @@
 #define SGMII_LINK_MAC_MAC_FORCED      2
 #define SGMII_LINK_MAC_FIBER           3
 #define SGMII_LINK_MAC_PHY_NO_MDIO     4
+#define RGMII_LINK_MAC_PHY             5
+#define RGMII_LINK_MAC_PHY_NO_MDIO     7
 #define XGMII_LINK_MAC_PHY             10
 #define XGMII_LINK_MAC_MAC_FORCED      11
 
index e1e67ff..68b10b5 100644 (file)
@@ -2096,8 +2096,9 @@ static void netcp_ethss_link_state_action(struct gbe_priv *gbe_dev,
                                     ALE_PORT_STATE_FORWARD);
 
                if (ndev && slave->open &&
-                   slave->link_interface != SGMII_LINK_MAC_PHY &&
-                   slave->link_interface != XGMII_LINK_MAC_PHY)
+                   ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+                   (slave->link_interface != RGMII_LINK_MAC_PHY) &&
+                   (slave->link_interface != XGMII_LINK_MAC_PHY)))
                        netif_carrier_on(ndev);
        } else {
                writel(mac_control, GBE_REG_ADDR(slave, emac_regs,
@@ -2106,8 +2107,9 @@ static void netcp_ethss_link_state_action(struct gbe_priv *gbe_dev,
                                     ALE_PORT_STATE,
                                     ALE_PORT_STATE_DISABLE);
                if (ndev &&
-                   slave->link_interface != SGMII_LINK_MAC_PHY &&
-                   slave->link_interface != XGMII_LINK_MAC_PHY)
+                   ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+                   (slave->link_interface != RGMII_LINK_MAC_PHY) &&
+                   (slave->link_interface != XGMII_LINK_MAC_PHY)))
                        netif_carrier_off(ndev);
        }
 
@@ -2921,6 +2923,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
 
        slave->open = false;
        if ((slave->link_interface == SGMII_LINK_MAC_PHY) ||
+           (slave->link_interface == RGMII_LINK_MAC_PHY) ||
            (slave->link_interface == XGMII_LINK_MAC_PHY))
                slave->phy_node = of_parse_phandle(node, "phy-handle", 0);
        slave->port_num = gbe_get_slave_port(gbe_dev, slave->slave_num);
@@ -3082,6 +3085,9 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
        if (slave->link_interface == SGMII_LINK_MAC_PHY) {
                phy_mode = PHY_INTERFACE_MODE_SGMII;
                slave->phy_port_t = PORT_MII;
+       } else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
+               phy_mode = PHY_INTERFACE_MODE_RGMII;
+               slave->phy_port_t = PORT_MII;
        } else {
                phy_mode = PHY_INTERFACE_MODE_NA;
                slave->phy_port_t = PORT_FIBRE;
@@ -3089,6 +3095,7 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
 
        for_each_sec_slave(slave, gbe_dev) {
                if ((slave->link_interface != SGMII_LINK_MAC_PHY) &&
+                   (slave->link_interface != RGMII_LINK_MAC_PHY) &&
                    (slave->link_interface != XGMII_LINK_MAC_PHY))
                        continue;
                slave->phy =