@@ -163,16 +163,6 @@ void bcmgenet_mii_setup(struct net_device *dev)
163
163
phy_print_status (phydev );
164
164
}
165
165
166
- void bcmgenet_mii_reset (struct net_device * dev )
167
- {
168
- struct bcmgenet_priv * priv = netdev_priv (dev );
169
-
170
- if (priv -> phydev ) {
171
- phy_init_hw (priv -> phydev );
172
- phy_start_aneg (priv -> phydev );
173
- }
174
- }
175
-
176
166
void bcmgenet_phy_power_set (struct net_device * dev , bool enable )
177
167
{
178
168
struct bcmgenet_priv * priv = netdev_priv (dev );
@@ -215,7 +205,6 @@ static void bcmgenet_internal_phy_setup(struct net_device *dev)
215
205
reg = bcmgenet_ext_readl (priv , EXT_EXT_PWR_MGMT );
216
206
reg |= EXT_PWR_DN_EN_LD ;
217
207
bcmgenet_ext_writel (priv , reg , EXT_EXT_PWR_MGMT );
218
- bcmgenet_mii_reset (dev );
219
208
}
220
209
221
210
static void bcmgenet_moca_phy_setup (struct bcmgenet_priv * priv )
@@ -228,7 +217,7 @@ static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)
228
217
bcmgenet_sys_writel (priv , reg , SYS_PORT_CTRL );
229
218
}
230
219
231
- int bcmgenet_mii_config (struct net_device * dev , bool init )
220
+ int bcmgenet_mii_config (struct net_device * dev )
232
221
{
233
222
struct bcmgenet_priv * priv = netdev_priv (dev );
234
223
struct phy_device * phydev = priv -> phydev ;
@@ -238,10 +227,10 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
238
227
u32 port_ctrl ;
239
228
u32 reg ;
240
229
241
- priv -> ext_phy = !phy_is_internal ( priv -> phydev ) &&
230
+ priv -> ext_phy = !priv -> internal_phy &&
242
231
(priv -> phy_interface != PHY_INTERFACE_MODE_MOCA );
243
232
244
- if (phy_is_internal ( priv -> phydev ) )
233
+ if (priv -> internal_phy )
245
234
priv -> phy_interface = PHY_INTERFACE_MODE_NA ;
246
235
247
236
switch (priv -> phy_interface ) {
@@ -259,7 +248,7 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
259
248
260
249
bcmgenet_sys_writel (priv , port_ctrl , SYS_PORT_CTRL );
261
250
262
- if (phy_is_internal ( priv -> phydev ) ) {
251
+ if (priv -> internal_phy ) {
263
252
phy_name = "internal PHY" ;
264
253
bcmgenet_internal_phy_setup (dev );
265
254
} else if (priv -> phy_interface == PHY_INTERFACE_MODE_MOCA ) {
@@ -321,13 +310,12 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
321
310
bcmgenet_ext_writel (priv , reg , EXT_RGMII_OOB_CTRL );
322
311
}
323
312
324
- if (init )
325
- dev_info (kdev , "configuring instance for %s\n" , phy_name );
313
+ dev_info_once (kdev , "configuring instance for %s\n" , phy_name );
326
314
327
315
return 0 ;
328
316
}
329
317
330
- static int bcmgenet_mii_probe (struct net_device * dev )
318
+ int bcmgenet_mii_probe (struct net_device * dev )
331
319
{
332
320
struct bcmgenet_priv * priv = netdev_priv (dev );
333
321
struct device_node * dn = priv -> pdev -> dev .of_node ;
@@ -345,22 +333,6 @@ static int bcmgenet_mii_probe(struct net_device *dev)
345
333
priv -> old_pause = -1 ;
346
334
347
335
if (dn ) {
348
- if (priv -> phydev ) {
349
- pr_info ("PHY already attached\n" );
350
- return 0 ;
351
- }
352
-
353
- /* In the case of a fixed PHY, the DT node associated
354
- * to the PHY is the Ethernet MAC DT node.
355
- */
356
- if (!priv -> phy_dn && of_phy_is_fixed_link (dn )) {
357
- ret = of_phy_register_fixed_link (dn );
358
- if (ret )
359
- return ret ;
360
-
361
- priv -> phy_dn = of_node_get (dn );
362
- }
363
-
364
336
phydev = of_phy_connect (dev , priv -> phy_dn , bcmgenet_mii_setup ,
365
337
phy_flags , priv -> phy_interface );
366
338
if (!phydev ) {
@@ -386,7 +358,7 @@ static int bcmgenet_mii_probe(struct net_device *dev)
386
358
* PHY speed which is needed for bcmgenet_mii_config() to configure
387
359
* things appropriately.
388
360
*/
389
- ret = bcmgenet_mii_config (dev , true );
361
+ ret = bcmgenet_mii_config (dev );
390
362
if (ret ) {
391
363
phy_disconnect (priv -> phydev );
392
364
return ret ;
@@ -397,14 +369,11 @@ static int bcmgenet_mii_probe(struct net_device *dev)
397
369
/* The internal PHY has its link interrupts routed to the
398
370
* Ethernet MAC ISRs
399
371
*/
400
- if (phy_is_internal ( priv -> phydev ) )
372
+ if (priv -> internal_phy )
401
373
priv -> mii_bus -> irq [phydev -> addr ] = PHY_IGNORE_INTERRUPT ;
402
374
else
403
375
priv -> mii_bus -> irq [phydev -> addr ] = PHY_POLL ;
404
376
405
- pr_info ("attached PHY at address %d [%s]\n" ,
406
- phydev -> addr , phydev -> drv -> name );
407
-
408
377
return 0 ;
409
378
}
410
379
@@ -490,7 +459,9 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
490
459
{
491
460
struct device_node * dn = priv -> pdev -> dev .of_node ;
492
461
struct device * kdev = & priv -> pdev -> dev ;
462
+ const char * phy_mode_str = NULL ;
493
463
char * compat ;
464
+ int phy_mode ;
494
465
int ret ;
495
466
496
467
compat = kasprintf (GFP_KERNEL , "brcm,genet-mdio-v%d" , priv -> version );
@@ -513,8 +484,36 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
513
484
/* Fetch the PHY phandle */
514
485
priv -> phy_dn = of_parse_phandle (dn , "phy-handle" , 0 );
515
486
487
+ /* In the case of a fixed PHY, the DT node associated
488
+ * to the PHY is the Ethernet MAC DT node.
489
+ */
490
+ if (!priv -> phy_dn && of_phy_is_fixed_link (dn )) {
491
+ ret = of_phy_register_fixed_link (dn );
492
+ if (ret )
493
+ return ret ;
494
+
495
+ priv -> phy_dn = of_node_get (dn );
496
+ }
497
+
516
498
/* Get the link mode */
517
- priv -> phy_interface = of_get_phy_mode (dn );
499
+ phy_mode = of_get_phy_mode (dn );
500
+ priv -> phy_interface = phy_mode ;
501
+
502
+ /* We need to specifically look up whether this PHY interface is internal
503
+ * or not *before* we even try to probe the PHY driver over MDIO as we
504
+ * may have shut down the internal PHY for power saving purposes.
505
+ */
506
+ if (phy_mode < 0 ) {
507
+ ret = of_property_read_string (dn , "phy-mode" , & phy_mode_str );
508
+ if (ret < 0 ) {
509
+ dev_err (kdev , "invalid PHY mode property\n" );
510
+ return ret ;
511
+ }
512
+
513
+ priv -> phy_interface = PHY_INTERFACE_MODE_NA ;
514
+ if (!strcasecmp (phy_mode_str , "internal" ))
515
+ priv -> internal_phy = true;
516
+ }
518
517
519
518
return 0 ;
520
519
}
@@ -614,10 +613,6 @@ int bcmgenet_mii_init(struct net_device *dev)
614
613
return ret ;
615
614
616
615
ret = bcmgenet_mii_bus_init (priv );
617
- if (ret )
618
- goto out_free ;
619
-
620
- ret = bcmgenet_mii_probe (dev );
621
616
if (ret )
622
617
goto out ;
623
618
@@ -626,7 +621,6 @@ int bcmgenet_mii_init(struct net_device *dev)
626
621
out :
627
622
of_node_put (priv -> phy_dn );
628
623
mdiobus_unregister (priv -> mii_bus );
629
- out_free :
630
624
kfree (priv -> mii_bus -> irq );
631
625
mdiobus_free (priv -> mii_bus );
632
626
return ret ;
0 commit comments