summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/freescale/gianfar.c
diff options
context:
space:
mode:
authorArseny Solokha <asolokha@kb.kras.ru>2019-09-04 20:52:22 +0700
committerDavid S. Miller <davem@davemloft.net>2019-09-05 12:28:15 +0200
commit8e578e73ef2ebc49196d5bb36220dc97b53559a1 (patch)
tree8279c7e08a17543c71b4e86bd142bb2340cf3139 /drivers/net/ethernet/freescale/gianfar.c
parent887b8194fb86811ddd7de9c6218ed1ccf6792ee6 (diff)
gianfar: use DT more consistently when selecting PHY connection type
Historically, gianfar only used phy-connection-type DT property when connected to PHY in the rgmii-id mode. It ignored the property otherwise, relying on the connection type auto-detection carried out by MAC and providing that reconstructed mode to of_phy_connect(). It also did not consider alternative phy-mode property at all. Make the driver properly query DT node for PHY connection type first and use an obtained value if it was specified there. Otherwise, if a particular DT relies on connection type auto-detection, fall back to reconstructing the value from MAC registers, as before. Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/freescale/gianfar.c')
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 17fb412e4bb4..24bf7f68375f 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -639,7 +639,6 @@ static phy_interface_t gfar_get_interface(struct net_device *dev)
static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
{
const char *model;
- const char *ctype;
const void *mac_addr;
int err = 0, i;
struct net_device *dev = NULL;
@@ -802,13 +801,15 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
FSL_GIANFAR_DEV_HAS_TIMER |
FSL_GIANFAR_DEV_HAS_RX_FILER;
- err = of_property_read_string(np, "phy-connection-type", &ctype);
-
- /* We only care about rgmii-id. The rest are autodetected */
- if (err == 0 && !strcmp(ctype, "rgmii-id"))
- priv->interface = PHY_INTERFACE_MODE_RGMII_ID;
+ /* Use PHY connection type from the DT node if one is specified there.
+ * rgmii-id really needs to be specified. Other types can be
+ * detected by hardware
+ */
+ err = of_get_phy_mode(np);
+ if (err >= 0)
+ priv->interface = err;
else
- priv->interface = PHY_INTERFACE_MODE_MII;
+ priv->interface = gfar_get_interface(dev);
if (of_find_property(np, "fsl,magic-packet", NULL))
priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
@@ -1670,7 +1671,7 @@ static int init_phy(struct net_device *dev)
{
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
struct gfar_private *priv = netdev_priv(dev);
- phy_interface_t interface;
+ phy_interface_t interface = priv->interface;
struct phy_device *phydev;
struct ethtool_eee edata;
@@ -1686,8 +1687,6 @@ static int init_phy(struct net_device *dev)
priv->oldspeed = 0;
priv->oldduplex = -1;
- interface = gfar_get_interface(dev);
-
phydev = of_phy_connect(dev, priv->phy_node, &adjust_link, 0,
interface);
if (!phydev) {