Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e42f715 authored by Heiko Schocher's avatar Heiko Schocher Committed by David S. Miller
Browse files

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: default avatarHeiko Schocher <hs@denx.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent aebd9947
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ Required properties:
Optional properties:
- dual_emac_res_vlan	: Specifies VID to be used to segregate the ports
- mac-address		: See ethernet.txt file in the same directory
- phy-handle		: See ethernet.txt file in the same directory

Note: "ti,hwmods" field is used to fetch the base address and irq
resources from TI, omap hwmod data base during device registration.
+11 −4
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include <linux/delay.h>
#include <linux/pm_runtime.h>
#include <linux/of.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>
#include <linux/of_device.h>
#include <linux/if_vlan.h>
@@ -365,6 +366,7 @@ struct cpsw_priv {
	spinlock_t			lock;
	struct platform_device		*pdev;
	struct net_device		*ndev;
	struct device_node		*phy_node;
	struct napi_struct		napi_rx;
	struct napi_struct		napi_tx;
	struct device			*dev;
@@ -1145,6 +1147,10 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
		cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
				   1 << slave_port, 0, 0, ALE_MCAST_FWD_2);

	if (priv->phy_node)
		slave->phy = of_phy_connect(priv->ndev, priv->phy_node,
				 &cpsw_adjust_link, 0, slave->data->phy_if);
	else
		slave->phy = phy_connect(priv->ndev, slave->data->phy_id,
				 &cpsw_adjust_link, slave->data->phy_if);
	if (IS_ERR(slave->phy)) {
@@ -1934,11 +1940,12 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv,
	slave->port_vlan = data->dual_emac_res_vlan;
}

static int cpsw_probe_dt(struct cpsw_platform_data *data,
static int cpsw_probe_dt(struct cpsw_priv *priv,
			 struct platform_device *pdev)
{
	struct device_node *node = pdev->dev.of_node;
	struct device_node *slave_node;
	struct cpsw_platform_data *data = &priv->data;
	int i = 0, ret;
	u32 prop;

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

		priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0);
		parp = of_get_property(slave_node, "phy_id", &lenp);
		if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) {
			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,
		}
		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);
		if (slave_data->phy_if < 0) {
			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)
	/* Select default pin state */
	pinctrl_pm_select_default_state(&pdev->dev);

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