Skip to content

Commit 9e42f71

Browse files
hsdenxdavem330
authored andcommitted
drivers: net: cpsw: add phy-handle parsing
add the ability to parse "phy-handle". This is needed for phys, which have a DT node, and need to parse DT properties. Signed-off-by: Heiko Schocher <hs@denx.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent aebd994 commit 9e42f71

File tree

2 files changed

+12
-4
lines changed
  • Documentation/devicetree/bindings/net
  • drivers/net/ethernet/ti

2 files changed

+12
-4
lines changed

Documentation/devicetree/bindings/net/cpsw.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Required properties:
3939
Optional properties:
4040
- dual_emac_res_vlan : Specifies VID to be used to segregate the ports
4141
- mac-address : See ethernet.txt file in the same directory
42+
- phy-handle : See ethernet.txt file in the same directory
4243

4344
Note: "ti,hwmods" field is used to fetch the base address and irq
4445
resources from TI, omap hwmod data base during device registration.

drivers/net/ethernet/ti/cpsw.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/delay.h>
3131
#include <linux/pm_runtime.h>
3232
#include <linux/of.h>
33+
#include <linux/of_mdio.h>
3334
#include <linux/of_net.h>
3435
#include <linux/of_device.h>
3536
#include <linux/if_vlan.h>
@@ -365,6 +366,7 @@ struct cpsw_priv {
365366
spinlock_t lock;
366367
struct platform_device *pdev;
367368
struct net_device *ndev;
369+
struct device_node *phy_node;
368370
struct napi_struct napi_rx;
369371
struct napi_struct napi_tx;
370372
struct device *dev;
@@ -1145,7 +1147,11 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
11451147
cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
11461148
1 << slave_port, 0, 0, ALE_MCAST_FWD_2);
11471149

1148-
slave->phy = phy_connect(priv->ndev, slave->data->phy_id,
1150+
if (priv->phy_node)
1151+
slave->phy = of_phy_connect(priv->ndev, priv->phy_node,
1152+
&cpsw_adjust_link, 0, slave->data->phy_if);
1153+
else
1154+
slave->phy = phy_connect(priv->ndev, slave->data->phy_id,
11491155
&cpsw_adjust_link, slave->data->phy_if);
11501156
if (IS_ERR(slave->phy)) {
11511157
dev_err(priv->dev, "phy %s not found on slave %d\n",
@@ -1934,11 +1940,12 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv,
19341940
slave->port_vlan = data->dual_emac_res_vlan;
19351941
}
19361942

1937-
static int cpsw_probe_dt(struct cpsw_platform_data *data,
1943+
static int cpsw_probe_dt(struct cpsw_priv *priv,
19381944
struct platform_device *pdev)
19391945
{
19401946
struct device_node *node = pdev->dev.of_node;
19411947
struct device_node *slave_node;
1948+
struct cpsw_platform_data *data = &priv->data;
19421949
int i = 0, ret;
19431950
u32 prop;
19441951

@@ -2029,6 +2036,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
20292036
if (strcmp(slave_node->name, "slave"))
20302037
continue;
20312038

2039+
priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0);
20322040
parp = of_get_property(slave_node, "phy_id", &lenp);
20332041
if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) {
20342042
dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i);
@@ -2044,7 +2052,6 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
20442052
}
20452053
snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
20462054
PHY_ID_FMT, mdio->name, phyid);
2047-
20482055
slave_data->phy_if = of_get_phy_mode(slave_node);
20492056
if (slave_data->phy_if < 0) {
20502057
dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
@@ -2240,7 +2247,7 @@ static int cpsw_probe(struct platform_device *pdev)
22402247
/* Select default pin state */
22412248
pinctrl_pm_select_default_state(&pdev->dev);
22422249

2243-
if (cpsw_probe_dt(&priv->data, pdev)) {
2250+
if (cpsw_probe_dt(priv, pdev)) {
22442251
dev_err(&pdev->dev, "cpsw: platform data missing\n");
22452252
ret = -ENODEV;
22462253
goto clean_runtime_disable_ret;

0 commit comments

Comments
 (0)