Commit ce2a04c1 authored by David S. Miller's avatar David S. Miller

Merge branch 'stmmac-fixes'

Giuseppe Cavallaro says:

====================
stmmac MDIO and normal descr fixes

This patch series is to fix the problems below and recently debugged
in this mailing list:

o to fix a problem for the HW where the normal descriptor
o to fix the mdio registration according to the different
  platform configurations

I am resending all the patches again: built on top of net.git repo.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c66e98c9 a7657f12
...@@ -199,11 +199,6 @@ static void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, ...@@ -199,11 +199,6 @@ static void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
{ {
unsigned int tdes1 = p->des1; unsigned int tdes1 = p->des1;
if (mode == STMMAC_CHAIN_MODE)
norm_set_tx_desc_len_on_chain(p, len);
else
norm_set_tx_desc_len_on_ring(p, len);
if (is_fs) if (is_fs)
tdes1 |= TDES1_FIRST_SEGMENT; tdes1 |= TDES1_FIRST_SEGMENT;
else else
...@@ -217,10 +212,15 @@ static void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, ...@@ -217,10 +212,15 @@ static void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
if (ls) if (ls)
tdes1 |= TDES1_LAST_SEGMENT; tdes1 |= TDES1_LAST_SEGMENT;
if (tx_own)
tdes1 |= TDES0_OWN;
p->des1 = tdes1; p->des1 = tdes1;
if (mode == STMMAC_CHAIN_MODE)
norm_set_tx_desc_len_on_chain(p, len);
else
norm_set_tx_desc_len_on_ring(p, len);
if (tx_own)
p->des0 |= TDES0_OWN;
} }
static void ndesc_set_tx_ic(struct dma_desc *p) static void ndesc_set_tx_ic(struct dma_desc *p)
......
...@@ -278,7 +278,6 @@ static void stmmac_eee_ctrl_timer(unsigned long arg) ...@@ -278,7 +278,6 @@ static void stmmac_eee_ctrl_timer(unsigned long arg)
*/ */
bool stmmac_eee_init(struct stmmac_priv *priv) bool stmmac_eee_init(struct stmmac_priv *priv)
{ {
char *phy_bus_name = priv->plat->phy_bus_name;
unsigned long flags; unsigned long flags;
bool ret = false; bool ret = false;
...@@ -290,7 +289,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv) ...@@ -290,7 +289,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv)
goto out; goto out;
/* Never init EEE in case of a switch is attached */ /* Never init EEE in case of a switch is attached */
if (phy_bus_name && (!strcmp(phy_bus_name, "fixed"))) if (priv->phydev->is_pseudo_fixed_link)
goto out; goto out;
/* MAC core supports the EEE feature. */ /* MAC core supports the EEE feature. */
...@@ -827,12 +826,8 @@ static int stmmac_init_phy(struct net_device *dev) ...@@ -827,12 +826,8 @@ static int stmmac_init_phy(struct net_device *dev)
phydev = of_phy_connect(dev, priv->plat->phy_node, phydev = of_phy_connect(dev, priv->plat->phy_node,
&stmmac_adjust_link, 0, interface); &stmmac_adjust_link, 0, interface);
} else { } else {
if (priv->plat->phy_bus_name) snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x",
snprintf(bus_id, MII_BUS_ID_SIZE, "%s-%x", priv->plat->bus_id);
priv->plat->phy_bus_name, priv->plat->bus_id);
else
snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x",
priv->plat->bus_id);
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);
...@@ -871,9 +866,8 @@ static int stmmac_init_phy(struct net_device *dev) ...@@ -871,9 +866,8 @@ static int stmmac_init_phy(struct net_device *dev)
} }
/* If attached to a switch, there is no reason to poll phy handler */ /* If attached to a switch, there is no reason to poll phy handler */
if (priv->plat->phy_bus_name) if (phydev->is_pseudo_fixed_link)
if (!strcmp(priv->plat->phy_bus_name, "fixed")) phydev->irq = PHY_IGNORE_INTERRUPT;
phydev->irq = PHY_IGNORE_INTERRUPT;
pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)" pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)"
" Link = %d\n", dev->name, phydev->phy_id, phydev->link); " Link = %d\n", dev->name, phydev->phy_id, phydev->link);
......
...@@ -198,20 +198,12 @@ int stmmac_mdio_register(struct net_device *ndev) ...@@ -198,20 +198,12 @@ int stmmac_mdio_register(struct net_device *ndev)
struct mii_bus *new_bus; struct mii_bus *new_bus;
struct stmmac_priv *priv = netdev_priv(ndev); struct stmmac_priv *priv = netdev_priv(ndev);
struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
int addr, found;
struct device_node *mdio_node = priv->plat->mdio_node; struct device_node *mdio_node = priv->plat->mdio_node;
int addr, found;
if (!mdio_bus_data) if (!mdio_bus_data)
return 0; return 0;
if (IS_ENABLED(CONFIG_OF)) {
if (mdio_node) {
netdev_dbg(ndev, "FOUND MDIO subnode\n");
} else {
netdev_warn(ndev, "No MDIO subnode found\n");
}
}
new_bus = mdiobus_alloc(); new_bus = mdiobus_alloc();
if (new_bus == NULL) if (new_bus == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -131,6 +131,69 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev) ...@@ -131,6 +131,69 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
return axi; return axi;
} }
/**
* stmmac_dt_phy - parse device-tree driver parameters to allocate PHY resources
* @plat: driver data platform structure
* @np: device tree node
* @dev: device pointer
* Description:
* The mdio bus will be allocated in case of a phy transceiver is on board;
* it will be NULL if the fixed-link is configured.
* If there is the "snps,dwmac-mdio" sub-node the mdio will be allocated
* in any case (for DSA, mdio must be registered even if fixed-link).
* The table below sums the supported configurations:
* -------------------------------
* snps,phy-addr | Y
* -------------------------------
* phy-handle | Y
* -------------------------------
* fixed-link | N
* -------------------------------
* snps,dwmac-mdio |
* even if | Y
* fixed-link |
* -------------------------------
*
* It returns 0 in case of success otherwise -ENODEV.
*/
static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
struct device_node *np, struct device *dev)
{
bool mdio = true;
/* If phy-handle property is passed from DT, use it as the PHY */
plat->phy_node = of_parse_phandle(np, "phy-handle", 0);
if (plat->phy_node)
dev_dbg(dev, "Found phy-handle subnode\n");
/* If phy-handle is not specified, check if we have a fixed-phy */
if (!plat->phy_node && of_phy_is_fixed_link(np)) {
if ((of_phy_register_fixed_link(np) < 0))
return -ENODEV;
dev_dbg(dev, "Found fixed-link subnode\n");
plat->phy_node = of_node_get(np);
mdio = false;
}
/* If snps,dwmac-mdio is passed from DT, always register the MDIO */
for_each_child_of_node(np, plat->mdio_node) {
if (of_device_is_compatible(plat->mdio_node, "snps,dwmac-mdio"))
break;
}
if (plat->mdio_node) {
dev_dbg(dev, "Found MDIO subnode\n");
mdio = true;
}
if (mdio)
plat->mdio_bus_data =
devm_kzalloc(dev, sizeof(struct stmmac_mdio_bus_data),
GFP_KERNEL);
return 0;
}
/** /**
* stmmac_probe_config_dt - parse device-tree driver parameters * stmmac_probe_config_dt - parse device-tree driver parameters
* @pdev: platform_device structure * @pdev: platform_device structure
...@@ -146,7 +209,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) ...@@ -146,7 +209,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct plat_stmmacenet_data *plat; struct plat_stmmacenet_data *plat;
struct stmmac_dma_cfg *dma_cfg; struct stmmac_dma_cfg *dma_cfg;
struct device_node *child_node = NULL;
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
if (!plat) if (!plat)
...@@ -166,36 +228,15 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) ...@@ -166,36 +228,15 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
/* 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);
/* If phy-handle is not specified, check if we have a fixed-phy */
if (!plat->phy_node && of_phy_is_fixed_link(np)) {
if ((of_phy_register_fixed_link(np) < 0))
return ERR_PTR(-ENODEV);
plat->phy_node = of_node_get(np);
}
for_each_child_of_node(np, child_node)
if (of_device_is_compatible(child_node, "snps,dwmac-mdio")) {
plat->mdio_node = child_node;
break;
}
/* "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_node && !of_phy_is_fixed_link(np)) || !plat->mdio_node) /* To Configure PHY by using all device-tree supported properties */
plat->mdio_bus_data = NULL; if (stmmac_dt_phy(plat, np, &pdev->dev))
else return ERR_PTR(-ENODEV);
plat->mdio_bus_data =
devm_kzalloc(&pdev->dev,
sizeof(struct stmmac_mdio_bus_data),
GFP_KERNEL);
of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size); of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size);
......
...@@ -108,7 +108,6 @@ struct stmmac_axi { ...@@ -108,7 +108,6 @@ struct stmmac_axi {
}; };
struct plat_stmmacenet_data { struct plat_stmmacenet_data {
char *phy_bus_name;
int bus_id; int bus_id;
int phy_addr; int phy_addr;
int interface; int interface;
......
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