Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Heiko Schocher and committed by
David S. Miller
9e42f715 aebd9947

+12 -4
+1
Documentation/devicetree/bindings/net/cpsw.txt
··· 39 39 Optional properties: 40 40 - dual_emac_res_vlan : Specifies VID to be used to segregate the ports 41 41 - mac-address : See ethernet.txt file in the same directory 42 + - phy-handle : See ethernet.txt file in the same directory 42 43 43 44 Note: "ti,hwmods" field is used to fetch the base address and irq 44 45 resources from TI, omap hwmod data base during device registration.
+11 -4
drivers/net/ethernet/ti/cpsw.c
··· 30 30 #include <linux/delay.h> 31 31 #include <linux/pm_runtime.h> 32 32 #include <linux/of.h> 33 + #include <linux/of_mdio.h> 33 34 #include <linux/of_net.h> 34 35 #include <linux/of_device.h> 35 36 #include <linux/if_vlan.h> ··· 366 365 spinlock_t lock; 367 366 struct platform_device *pdev; 368 367 struct net_device *ndev; 368 + struct device_node *phy_node; 369 369 struct napi_struct napi_rx; 370 370 struct napi_struct napi_tx; 371 371 struct device *dev; ··· 1147 1145 cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, 1148 1146 1 << slave_port, 0, 0, ALE_MCAST_FWD_2); 1149 1147 1150 - slave->phy = phy_connect(priv->ndev, slave->data->phy_id, 1148 + if (priv->phy_node) 1149 + slave->phy = of_phy_connect(priv->ndev, priv->phy_node, 1150 + &cpsw_adjust_link, 0, slave->data->phy_if); 1151 + else 1152 + slave->phy = phy_connect(priv->ndev, slave->data->phy_id, 1151 1153 &cpsw_adjust_link, slave->data->phy_if); 1152 1154 if (IS_ERR(slave->phy)) { 1153 1155 dev_err(priv->dev, "phy %s not found on slave %d\n", ··· 1940 1934 slave->port_vlan = data->dual_emac_res_vlan; 1941 1935 } 1942 1936 1943 - static int cpsw_probe_dt(struct cpsw_platform_data *data, 1937 + static int cpsw_probe_dt(struct cpsw_priv *priv, 1944 1938 struct platform_device *pdev) 1945 1939 { 1946 1940 struct device_node *node = pdev->dev.of_node; 1947 1941 struct device_node *slave_node; 1942 + struct cpsw_platform_data *data = &priv->data; 1948 1943 int i = 0, ret; 1949 1944 u32 prop; 1950 1945 ··· 2036 2029 if (strcmp(slave_node->name, "slave")) 2037 2030 continue; 2038 2031 2032 + priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0); 2039 2033 parp = of_get_property(slave_node, "phy_id", &lenp); 2040 2034 if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { 2041 2035 dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i); ··· 2052 2044 } 2053 2045 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), 2054 2046 PHY_ID_FMT, mdio->name, phyid); 2055 - 2056 2047 slave_data->phy_if = of_get_phy_mode(slave_node); 2057 2048 if (slave_data->phy_if < 0) { 2058 2049 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n", ··· 2247 2240 /* Select default pin state */ 2248 2241 pinctrl_pm_select_default_state(&pdev->dev); 2249 2242 2250 - if (cpsw_probe_dt(&priv->data, pdev)) { 2243 + if (cpsw_probe_dt(priv, pdev)) { 2251 2244 dev_err(&pdev->dev, "cpsw: platform data missing\n"); 2252 2245 ret = -ENODEV; 2253 2246 goto clean_runtime_disable_ret;