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>
@@ -365,6 +366,7 @@ struct cpsw_priv {
365
366
spinlock_t lock ;
366
367
struct platform_device * pdev ;
367
368
struct net_device * ndev ;
369
+ struct device_node * phy_node ;
368
370
struct napi_struct napi_rx ;
369
371
struct napi_struct napi_tx ;
370
372
struct device * dev ;
@@ -1145,7 +1147,11 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
1145
1147
cpsw_ale_add_mcast (priv -> ale , priv -> ndev -> broadcast ,
1146
1148
1 << slave_port , 0 , 0 , ALE_MCAST_FWD_2 );
1147
1149
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 ,
1149
1155
& cpsw_adjust_link , slave -> data -> phy_if );
1150
1156
if (IS_ERR (slave -> phy )) {
1151
1157
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,
1934
1940
slave -> port_vlan = data -> dual_emac_res_vlan ;
1935
1941
}
1936
1942
1937
- static int cpsw_probe_dt (struct cpsw_platform_data * data ,
1943
+ static int cpsw_probe_dt (struct cpsw_priv * priv ,
1938
1944
struct platform_device * pdev )
1939
1945
{
1940
1946
struct device_node * node = pdev -> dev .of_node ;
1941
1947
struct device_node * slave_node ;
1948
+ struct cpsw_platform_data * data = & priv -> data ;
1942
1949
int i = 0 , ret ;
1943
1950
u32 prop ;
1944
1951
@@ -2029,6 +2036,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
2029
2036
if (strcmp (slave_node -> name , "slave" ))
2030
2037
continue ;
2031
2038
2039
+ priv -> phy_node = of_parse_phandle (slave_node , "phy-handle" , 0 );
2032
2040
parp = of_get_property (slave_node , "phy_id" , & lenp );
2033
2041
if ((parp == NULL ) || (lenp != (sizeof (void * ) * 2 ))) {
2034
2042
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,
2044
2052
}
2045
2053
snprintf (slave_data -> phy_id , sizeof (slave_data -> phy_id ),
2046
2054
PHY_ID_FMT , mdio -> name , phyid );
2047
-
2048
2055
slave_data -> phy_if = of_get_phy_mode (slave_node );
2049
2056
if (slave_data -> phy_if < 0 ) {
2050
2057
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)
2240
2247
/* Select default pin state */
2241
2248
pinctrl_pm_select_default_state (& pdev -> dev );
2242
2249
2243
- if (cpsw_probe_dt (& priv -> data , pdev )) {
2250
+ if (cpsw_probe_dt (priv , pdev )) {
2244
2251
dev_err (& pdev -> dev , "cpsw: platform data missing\n" );
2245
2252
ret = - ENODEV ;
2246
2253
goto clean_runtime_disable_ret ;
0 commit comments