Skip to content

Commit 7b647b9

Browse files
Murali Karicheridavem330
authored andcommitted
net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes
The phy used for K2G allows for internal delays to be added optionally to the clock circuitry based on board desing. To add this support, enhance the driver to use of_get_phy_mode() to read the phy-mode from the phy device and pass the same to phy through of_phy_connect(). Signed-off-by: Murali Karicheri <m-karicheri2@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dc07ec9 commit 7b647b9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/net/ethernet/ti/netcp_ethss.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/io.h>
2222
#include <linux/module.h>
2323
#include <linux/of_mdio.h>
24+
#include <linux/of_net.h>
2425
#include <linux/of_address.h>
2526
#include <linux/if_vlan.h>
2627
#include <linux/ptp_classify.h>
@@ -707,6 +708,7 @@ struct gbe_slave {
707708
u32 link_interface;
708709
u32 mac_control;
709710
u8 phy_port_t;
711+
struct device_node *node;
710712
struct device_node *phy_node;
711713
struct ts_ctl ts_ctl;
712714
struct list_head slave_list;
@@ -2322,6 +2324,21 @@ static int gbe_slave_open(struct gbe_intf *gbe_intf)
23222324
has_phy = true;
23232325
phy_mode = PHY_INTERFACE_MODE_SGMII;
23242326
slave->phy_port_t = PORT_MII;
2327+
} else if (slave->link_interface == RGMII_LINK_MAC_PHY) {
2328+
has_phy = true;
2329+
phy_mode = of_get_phy_mode(slave->node);
2330+
/* if phy-mode is not present, default to
2331+
* PHY_INTERFACE_MODE_RGMII
2332+
*/
2333+
if (phy_mode < 0)
2334+
phy_mode = PHY_INTERFACE_MODE_RGMII;
2335+
2336+
if (!phy_interface_mode_is_rgmii(phy_mode)) {
2337+
dev_err(priv->dev,
2338+
"Unsupported phy mode %d\n", phy_mode);
2339+
return -EINVAL;
2340+
}
2341+
slave->phy_port_t = PORT_MII;
23252342
} else if (slave->link_interface == XGMII_LINK_MAC_PHY) {
23262343
has_phy = true;
23272344
phy_mode = PHY_INTERFACE_MODE_NA;
@@ -2947,6 +2964,7 @@ static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave,
29472964
slave->link_interface = SGMII_LINK_MAC_PHY;
29482965
}
29492966

2967+
slave->node = node;
29502968
slave->open = false;
29512969
if ((slave->link_interface == SGMII_LINK_MAC_PHY) ||
29522970
(slave->link_interface == RGMII_LINK_MAC_PHY) ||

0 commit comments

Comments
 (0)