Commit 5790cf3c authored by Mathieu Olivari's avatar Mathieu Olivari Committed by David S. Miller

stmmac: add phy-handle support to the platform layer

On stmmac driver, PHY specification in device-tree was done using the
non-standard property "snps,phy-addr". Specifying a PHY on a different
MDIO bus that the one within the stmmac controller doesn't seem to be
possible when device-tree is used.

This change adds support for the phy-handle property, as specified in
Documentation/devicetree/bindings/net/ethernet.txt.
Signed-off-by: default avatarMathieu Olivari <mathieu@codeaurora.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f7b81d67
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "stmmac_ptp.h" #include "stmmac_ptp.h"
#include "stmmac.h" #include "stmmac.h"
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/of_mdio.h>
#define STMMAC_ALIGN(x) L1_CACHE_ALIGN(x) #define STMMAC_ALIGN(x) L1_CACHE_ALIGN(x)
...@@ -816,6 +817,10 @@ static int stmmac_init_phy(struct net_device *dev) ...@@ -816,6 +817,10 @@ static int stmmac_init_phy(struct net_device *dev)
priv->speed = 0; priv->speed = 0;
priv->oldduplex = -1; priv->oldduplex = -1;
if (priv->plat->phy_node) {
phydev = of_phy_connect(dev, priv->plat->phy_node,
&stmmac_adjust_link, 0, interface);
} else {
if (priv->plat->phy_bus_name) if (priv->plat->phy_bus_name)
snprintf(bus_id, MII_BUS_ID_SIZE, "%s-%x", snprintf(bus_id, MII_BUS_ID_SIZE, "%s-%x",
priv->plat->phy_bus_name, priv->plat->bus_id); priv->plat->phy_bus_name, priv->plat->bus_id);
...@@ -825,9 +830,12 @@ static int stmmac_init_phy(struct net_device *dev) ...@@ -825,9 +830,12 @@ static int stmmac_init_phy(struct net_device *dev)
snprintf(phy_id_fmt, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id, snprintf(phy_id_fmt, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id,
priv->plat->phy_addr); priv->plat->phy_addr);
pr_debug("stmmac_init_phy: trying to attach to %s\n", phy_id_fmt); pr_debug("stmmac_init_phy: trying to attach to %s\n",
phy_id_fmt);
phydev = phy_connect(dev, phy_id_fmt, &stmmac_adjust_link, interface); phydev = phy_connect(dev, phy_id_fmt, &stmmac_adjust_link,
interface);
}
if (IS_ERR(phydev)) { if (IS_ERR(phydev)) {
pr_err("%s: Could not attach to PHY\n", dev->name); pr_err("%s: Could not attach to PHY\n", dev->name);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_net.h> #include <linux/of_net.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_mdio.h>
#include "stmmac.h" #include "stmmac.h"
#include "stmmac_platform.h" #include "stmmac_platform.h"
...@@ -144,13 +145,16 @@ static int stmmac_probe_config_dt(struct platform_device *pdev, ...@@ -144,13 +145,16 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
/* Default to phy auto-detection */ /* Default to phy auto-detection */
plat->phy_addr = -1; plat->phy_addr = -1;
/* If we find a phy-handle property, use it as the PHY */
plat->phy_node = of_parse_phandle(np, "phy-handle", 0);
/* "snps,phy-addr" is not a standard property. Mark it as deprecated /* "snps,phy-addr" is not a standard property. Mark it as deprecated
* and warn of its use. Remove this when phy node support is added. * and warn of its use. Remove this when phy node support is added.
*/ */
if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0) if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0)
dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n"); dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n");
if (plat->phy_bus_name) if (plat->phy_node || plat->phy_bus_name)
plat->mdio_bus_data = NULL; plat->mdio_bus_data = NULL;
else else
plat->mdio_bus_data = plat->mdio_bus_data =
......
...@@ -99,6 +99,7 @@ struct plat_stmmacenet_data { ...@@ -99,6 +99,7 @@ struct plat_stmmacenet_data {
int phy_addr; int phy_addr;
int interface; int interface;
struct stmmac_mdio_bus_data *mdio_bus_data; struct stmmac_mdio_bus_data *mdio_bus_data;
struct device_node *phy_node;
struct stmmac_dma_cfg *dma_cfg; struct stmmac_dma_cfg *dma_cfg;
int clk_csr; int clk_csr;
int has_gmac; int has_gmac;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment