Message ID | 20181008234949.15416-6-grygorii.strashko@ti.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | net: ethernet: ti: cpsw: replace cpsw-phy-sel with phy driver | expand |
> /* Configure GMII_SEL register */ > - cpsw_phy_sel(cpsw->dev, slave->phy->interface, slave->slave_num); > + if (!IS_ERR(slave->data->ifphy)) > + phy_set_netif_mode(slave->data->ifphy, slave->data->phy_if); Is slave->data->phy_if also passed to phy_connect()? So you are going to end up with both the MAC and the PHY inserting RGMII delays, and it not working. You need to somehow decide if the MAC is going to do the delay, or the PHY. But not both. Andrew
Hi Andrew, On 10/08/2018 07:50 PM, Andrew Lunn wrote: >> /* Configure GMII_SEL register */ >> - cpsw_phy_sel(cpsw->dev, slave->phy->interface, slave->slave_num); >> + if (!IS_ERR(slave->data->ifphy)) >> + phy_set_netif_mode(slave->data->ifphy, slave->data->phy_if); > > Is slave->data->phy_if also passed to phy_connect()? So you are going > to end up with both the MAC and the PHY inserting RGMII delays, and it > not working. No. This logic not changed comparing to how it was. * "rgmii" (RX and TX delays are added by the MAC when required) rgmii_id = 0 --> CPSW: 0 : Internal Delay, PHY - no delay * "rgmii-id" (RGMII with internal RX and TX delays provided by the PHY, the MAC should not add the RX or TX delays in this case) * "rgmii-rxid" (RGMII with internal RX delay provided by the PHY, the MAC should not add an RX delay in this case) * "rgmii-txid" (RGMII with internal TX delay provided by the PHY, the MAC should not add an TX delay in this case) rgmii_id = 1 --> CPSW: 1 : No Internal Delay, PHY/board - delay > > You need to somehow decide if the MAC is going to do the delay, or the > PHY. But not both. Again, this series does not change logic - only interfaces and DT. Thank you for review.
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 832bce0..4607de2 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -26,6 +26,7 @@ #include <linux/netdevice.h> #include <linux/net_tstamp.h> #include <linux/phy.h> +#include <linux/phy/phy.h> #include <linux/workqueue.h> #include <linux/delay.h> #include <linux/pm_runtime.h> @@ -387,6 +388,7 @@ struct cpsw_slave_data { int phy_if; u8 mac_addr[ETH_ALEN]; u16 dual_emac_res_vlan; /* Reserved VLAN for DualEMAC */ + struct phy *ifphy; }; struct cpsw_platform_data { @@ -1502,7 +1504,11 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) phy_start(slave->phy); /* Configure GMII_SEL register */ - cpsw_phy_sel(cpsw->dev, slave->phy->interface, slave->slave_num); + if (!IS_ERR(slave->data->ifphy)) + phy_set_netif_mode(slave->data->ifphy, slave->data->phy_if); + else + cpsw_phy_sel(cpsw->dev, slave->phy->interface, + slave->slave_num); } static inline void cpsw_add_default_vlan(struct cpsw_priv *priv) @@ -3135,6 +3141,16 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, if (strcmp(slave_node->name, "slave")) continue; + slave_data->ifphy = devm_of_phy_get(&pdev->dev, slave_node, + NULL); + if (!IS_ENABLED(CONFIG_TI_CPSW_PHY_SEL) && + IS_ERR(slave_data->ifphy)) { + ret = PTR_ERR(slave_data->ifphy); + dev_err(&pdev->dev, + "%d: Error retrieving port phy: %d\n", i, ret); + return ret; + } + slave_data->phy_node = of_parse_phandle(slave_node, "phy-handle", 0); parp = of_get_property(slave_node, "phy_id", &lenp);
Add support for port interface mode selection phy (phy-gmii-sel): - try to request interface mode selection phy from Port DT node and fail silently if not defined and old CONFIG_TI_CPSW_PHY_SEL driver enabled. - use new phy if requested successfully. Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Tony Lindgren <tony@atomide.com> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> --- drivers/net/ethernet/ti/cpsw.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)