Skip to content

Commit cf3db45

Browse files
committed
Merge branch 'phy-internal'
Florian Fainelli says: ==================== net: phy: Support "internal" PHY interface This makes the "internal" phy-mode property generally available and documented and this allows us to remove some custom parsing code we had for bcmgenet and bcm_sf2 which both used that specific value. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents d4d0249 + bedd00c commit cf3db45

File tree

4 files changed

+17
-27
lines changed

4 files changed

+17
-27
lines changed

Documentation/devicetree/bindings/net/ethernet.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The following properties are common to the Ethernet controllers:
1111
the maximum frame size (there's contradiction in ePAPR).
1212
- phy-mode: string, operation mode of the PHY interface. This is now a de-facto
1313
standard property; supported values are:
14+
* "internal"
1415
* "mii"
1516
* "gmii"
1617
* "sgmii"

drivers/net/dsa/bcm_sf2.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,8 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
498498
struct device_node *dn)
499499
{
500500
struct device_node *port;
501-
const char *phy_mode_str;
502501
int mode;
503502
unsigned int port_num;
504-
int ret;
505503

506504
priv->moca_port = -1;
507505

@@ -515,15 +513,11 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
515513
* time
516514
*/
517515
mode = of_get_phy_mode(port);
518-
if (mode < 0) {
519-
ret = of_property_read_string(port, "phy-mode",
520-
&phy_mode_str);
521-
if (ret < 0)
522-
continue;
523-
524-
if (!strcasecmp(phy_mode_str, "internal"))
525-
priv->int_phy_mask |= 1 << port_num;
526-
}
516+
if (mode < 0)
517+
continue;
518+
519+
if (mode == PHY_INTERFACE_MODE_INTERNAL)
520+
priv->int_phy_mask |= 1 << port_num;
527521

528522
if (mode == PHY_INTERFACE_MODE_MOCA)
529523
priv->moca_port = port_num;

drivers/net/ethernet/broadcom/genet/bcmmii.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,8 @@ int bcmgenet_mii_config(struct net_device *dev)
251251
priv->ext_phy = !priv->internal_phy &&
252252
(priv->phy_interface != PHY_INTERFACE_MODE_MOCA);
253253

254-
if (priv->internal_phy)
255-
priv->phy_interface = PHY_INTERFACE_MODE_NA;
256-
257254
switch (priv->phy_interface) {
258-
case PHY_INTERFACE_MODE_NA:
255+
case PHY_INTERFACE_MODE_INTERNAL:
259256
case PHY_INTERFACE_MODE_MOCA:
260257
/* Irrespective of the actually configured PHY speed (100 or
261258
* 1000) GENETv4 only has an internal GPHY so we will just end
@@ -471,7 +468,6 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
471468
{
472469
struct device_node *dn = priv->pdev->dev.of_node;
473470
struct device *kdev = &priv->pdev->dev;
474-
const char *phy_mode_str = NULL;
475471
struct phy_device *phydev = NULL;
476472
char *compat;
477473
int phy_mode;
@@ -510,23 +506,19 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
510506

511507
/* Get the link mode */
512508
phy_mode = of_get_phy_mode(dn);
509+
if (phy_mode < 0) {
510+
dev_err(kdev, "invalid PHY mode property\n");
511+
return phy_mode;
512+
}
513+
513514
priv->phy_interface = phy_mode;
514515

515516
/* We need to specifically look up whether this PHY interface is internal
516517
* or not *before* we even try to probe the PHY driver over MDIO as we
517518
* may have shut down the internal PHY for power saving purposes.
518519
*/
519-
if (phy_mode < 0) {
520-
ret = of_property_read_string(dn, "phy-mode", &phy_mode_str);
521-
if (ret < 0) {
522-
dev_err(kdev, "invalid PHY mode property\n");
523-
return ret;
524-
}
525-
526-
priv->phy_interface = PHY_INTERFACE_MODE_NA;
527-
if (!strcasecmp(phy_mode_str, "internal"))
528-
priv->internal_phy = true;
529-
}
520+
if (priv->phy_interface == PHY_INTERFACE_MODE_INTERNAL)
521+
priv->internal_phy = true;
530522

531523
/* Make sure we initialize MoCA PHYs with a link down */
532524
if (phy_mode == PHY_INTERFACE_MODE_MOCA) {

include/linux/phy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
/* Interface Mode definitions */
6565
typedef enum {
6666
PHY_INTERFACE_MODE_NA,
67+
PHY_INTERFACE_MODE_INTERNAL,
6768
PHY_INTERFACE_MODE_MII,
6869
PHY_INTERFACE_MODE_GMII,
6970
PHY_INTERFACE_MODE_SGMII,
@@ -114,6 +115,8 @@ static inline const char *phy_modes(phy_interface_t interface)
114115
switch (interface) {
115116
case PHY_INTERFACE_MODE_NA:
116117
return "";
118+
case PHY_INTERFACE_MODE_INTERNAL:
119+
return "internal";
117120
case PHY_INTERFACE_MODE_MII:
118121
return "mii";
119122
case PHY_INTERFACE_MODE_GMII:

0 commit comments

Comments
 (0)