Commit 62d2b157 authored by David S. Miller's avatar David S. Miller

Merge branch 'cpsw-fixed-phy-dt-bugs'

David Rivshin says:

====================
drivers: net: cpsw: Fix bugs in fixed-link PHY DT parsing

Commit 1f71e8c9 ("drivers: net: cpsw:
Add support for fixed-link PHY") added initial fixed-link PHY support
for CPSW, but missed a few considerations.

This series is based on the tip of the net tree. The first two patches
fix user-visible errors in different hardware configurations. The third
patch is for an internal reference counting issue. They are logically
independent changes, but in the same function, so must be applied in
order to apply cleanly.

The first patch was originally submitted by Pascal Speck on December 4,
but was not picked up by patchwork. I suspect that is because the patch
was mangled by the mailer. I fixed the mangling and am including it in
this series, as I believe it is the correct change.

I have tested on the following hardware configurations:
 - (EVMSK) dual emac with two real MDIO-connected phys using RGMII-TXID
 - single emac with fixed-link using RGMII
Testing of other CPSW emac configurations that folks may have would
be appreciated.

Changes from v1 [1]:
 - Split into 3 smaller patches.
 - Maintain 1f71e8c9's preference for fixed-link over phy_id if
   they are both (incorrectly) specified in the slave node.
 - Update binding documentation to no longer say that phy_mode is also
   mutually exclusive with fixed-link.
 - Dropped unnecessary include of phy_fixed.h.

[1] https://patchwork.ozlabs.org/patch/554989/
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 73796d8b dfc0a6d3
...@@ -40,18 +40,18 @@ Optional properties: ...@@ -40,18 +40,18 @@ Optional properties:
Slave Properties: Slave Properties:
Required properties: Required properties:
- phy_id : Specifies slave phy id
- phy-mode : See ethernet.txt file in the same directory - phy-mode : See ethernet.txt file in the same directory
Optional properties: Optional properties:
- dual_emac_res_vlan : Specifies VID to be used to segregate the ports - dual_emac_res_vlan : Specifies VID to be used to segregate the ports
- mac-address : See ethernet.txt file in the same directory - mac-address : See ethernet.txt file in the same directory
- phy_id : Specifies slave phy id
- phy-handle : See ethernet.txt file in the same directory - phy-handle : See ethernet.txt file in the same directory
Slave sub-nodes: Slave sub-nodes:
- fixed-link : See fixed-link.txt file in the same directory - fixed-link : See fixed-link.txt file in the same directory
Either the properties phy_id and phy-mode, Either the property phy_id, or the sub-node
or the sub-node fixed-link can be specified fixed-link can be specified
Note: "ti,hwmods" field is used to fetch the base address and irq Note: "ti,hwmods" field is used to fetch the base address and irq
resources from TI, omap hwmod data base during device registration. resources from TI, omap hwmod data base during device registration.
......
...@@ -2026,45 +2026,54 @@ static int cpsw_probe_dt(struct cpsw_priv *priv, ...@@ -2026,45 +2026,54 @@ static int cpsw_probe_dt(struct cpsw_priv *priv,
for_each_child_of_node(node, slave_node) { for_each_child_of_node(node, slave_node) {
struct cpsw_slave_data *slave_data = data->slave_data + i; struct cpsw_slave_data *slave_data = data->slave_data + i;
const void *mac_addr = NULL; const void *mac_addr = NULL;
u32 phyid;
int lenp; int lenp;
const __be32 *parp; const __be32 *parp;
struct device_node *mdio_node;
struct platform_device *mdio;
/* This is no slave child node, continue */ /* This is no slave child node, continue */
if (strcmp(slave_node->name, "slave")) if (strcmp(slave_node->name, "slave"))
continue; continue;
priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0); priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0);
parp = of_get_property(slave_node, "phy_id", &lenp);
if (of_phy_is_fixed_link(slave_node)) { if (of_phy_is_fixed_link(slave_node)) {
struct phy_device *pd; struct device_node *phy_node;
struct phy_device *phy_dev;
/* In the case of a fixed PHY, the DT node associated
* to the PHY is the Ethernet MAC DT node.
*/
ret = of_phy_register_fixed_link(slave_node); ret = of_phy_register_fixed_link(slave_node);
if (ret) if (ret)
return ret; return ret;
pd = of_phy_find_device(slave_node); phy_node = of_node_get(slave_node);
if (!pd) phy_dev = of_phy_find_device(phy_node);
if (!phy_dev)
return -ENODEV; return -ENODEV;
snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
PHY_ID_FMT, pd->bus->id, pd->phy_id); PHY_ID_FMT, phy_dev->bus->id, phy_dev->addr);
goto no_phy_slave; } else if (parp) {
} u32 phyid;
parp = of_get_property(slave_node, "phy_id", &lenp); struct device_node *mdio_node;
if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { struct platform_device *mdio;
dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i);
if (lenp != (sizeof(__be32) * 2)) {
dev_err(&pdev->dev, "Invalid slave[%d] phy_id property\n", i);
goto no_phy_slave;
}
mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
phyid = be32_to_cpup(parp+1);
mdio = of_find_device_by_node(mdio_node);
of_node_put(mdio_node);
if (!mdio) {
dev_err(&pdev->dev, "Missing mdio platform device\n");
return -EINVAL;
}
snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
PHY_ID_FMT, mdio->name, phyid);
} else {
dev_err(&pdev->dev, "No slave[%d] phy_id or fixed-link property\n", i);
goto no_phy_slave; goto no_phy_slave;
} }
mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
phyid = be32_to_cpup(parp+1);
mdio = of_find_device_by_node(mdio_node);
of_node_put(mdio_node);
if (!mdio) {
dev_err(&pdev->dev, "Missing mdio platform device\n");
return -EINVAL;
}
snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
PHY_ID_FMT, mdio->name, phyid);
slave_data->phy_if = of_get_phy_mode(slave_node); slave_data->phy_if = of_get_phy_mode(slave_node);
if (slave_data->phy_if < 0) { if (slave_data->phy_if < 0) {
dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n", dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
......
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