Skip to contentSkip to conversation

net: phy: smsc: disable energy detect mode

PATCH Superseded Heiko Schocher 2 participants 6 messages Oct 13, 2015 – Oct 17, 2015

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: smsc: disable energy detect mode

On some boards the energy enable detect mode leads in trouble with some switches, so make the enabling of this mode configurable through DT.

---

 .../devicetree/bindings/net/smsc-lan87xx.txt       | 19 +++++++++++++++++
 drivers/net/phy/smsc.c                             | 24 +++++++++++++++++-----
 2 files changed, 38 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/smsc-lan87xx.txt
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +19 -0
new file mode 100644
index 0000000..39aa1dc
@@ -0,0 +1,19 @@
+SMSC LAN87xx Ethernet PHY
+
+Some boards require special tuning values. Configure them
+through an Ethernet OF device node.
+
+Optional properties:
+
+- disable-energy-detect:
+  If set, do not enable energy detect mode for the SMSC phy.
+  default: enable energy detect mode
+
+Examples:
+
+	/* Attach to an Ethernet device with autodetected PHY */
+	&cpsw_emac0 {
+		phy_id = <&davinci_mdio>, <0>;
+		phy-mode = "mii";
+		disable-energy-detect;
+	};
drivers/net/phy/smsc.c +19 -5
index 70b0895..f90fbf3 100644
@@ -43,16 +43,30 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
 
 static int smsc_phy_config_init(struct phy_device *phydev)
 {
+#ifdef CONFIG_OF
+	int len;
+	struct device *dev = &phydev->dev;
+	struct device_node *of_node = dev->of_node;
+#endif
 	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+	int enable_energy = 1;
 
 	if (rc < 0)
 		return rc;
 
-	/* Enable energy detect mode for this SMSC Transceivers */
-	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
-		       rc | MII_LAN83C185_EDPWRDOWN);
-	if (rc < 0)
-		return rc;
+#ifdef CONFIG_OF
+	if (!of_node && dev->parent->of_node)
+		of_node = dev->parent->of_node;
+	if (of_find_property(of_node, "disable-energy-detect", &len))
+		enable_energy = 0;
+#endif
+	if (enable_energy) {
+		/* Enable energy detect mode for this SMSC Transceivers */
+		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
+			       rc | MII_LAN83C185_EDPWRDOWN);
+		if (rc < 0)
+			return rc;
+	}
 
 	return smsc_phy_ack_interrupt(phydev);
 }
Signature · 6 lines
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 18 lines · Heiko Schocher

On some boards the energy enable detect mode leads in trouble with some switches, so make the enabling of this mode configurable through DT.

---

 .../devicetree/bindings/net/smsc-lan87xx.txt       | 19 +++++++++++++++++
 drivers/net/phy/smsc.c                             | 24 +++++++++++++++++-----
 2 files changed, 38 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/smsc-lan87xx.txt
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +0 -0
new file mode 100644
index 0000000..39aa1dc

Documentation/devicetree/bindings/net/smsc-lan87xx.txt line 10

Quoted 10 lines
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +10 -0
@@ -0,0 +1,19 @@
+SMSC LAN87xx Ethernet PHY
+
+Some boards require special tuning values. Configure them
+through an Ethernet OF device node.
+
+Optional properties:
+
+- disable-energy-detect:
+  If set, do not enable energy detect mode for the SMSC phy.
+  default: enable energy detect mode

Although energy detection is something that is implemented by many PHYs, I am not sure a generic property is suitable here, I would prefix that with the SMSC vendor prefix here to make it clear this only applies to this PHY.

Would not you want to make it a reverse property here though, something like this:

smsc,energy-detect: boolean, when present indicates the PHY reliably supports energy detection

Quoted 14 lines
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +9 -0
+
+Examples:
+
+	/* Attach to an Ethernet device with autodetected PHY */
+	&cpsw_emac0 {
+		phy_id = <&davinci_mdio>, <0>;
+		phy-mode = "mii";
+		disable-energy-detect;
+	};
drivers/net/phy/smsc.c +0 -0
index 70b0895..f90fbf3 100644

drivers/net/phy/smsc.c static int smsc_phy_ack_interrupt(struct phy_device *phydev) · line 49

Quoted 7 lines
drivers/net/phy/smsc.c +4 -0
@@ -43,16 +43,30 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
 
 static int smsc_phy_config_init(struct phy_device *phydev)
 {
+#ifdef CONFIG_OF
+	int len;
+	struct device *dev = &phydev->dev;
+	struct device_node *of_node = dev->of_node;

That does not need to be ifdefd out, at best annontate with __maybe_unused?

Quoted 5 lines
drivers/net/phy/smsc.c +2 -0
+#endif
 	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+	int enable_energy = 1;
 
 	if (rc < 0)

drivers/net/phy/smsc.c static int smsc_phy_ack_interrupt(struct phy_device *phydev) · line 59

Quoted 10 lines
drivers/net/phy/smsc.c +3 -5
 		return rc;
 
-	/* Enable energy detect mode for this SMSC Transceivers */
-	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
-		       rc | MII_LAN83C185_EDPWRDOWN);
-	if (rc < 0)
-		return rc;
+#ifdef CONFIG_OF
+	if (!of_node && dev->parent->of_node)
+		of_node = dev->parent->of_node;

That looks strange, why would the property be placed at the parent level when this is a PHY device tree node property?

Quoted 14 lines
drivers/net/phy/smsc.c +10 -0
+	if (of_find_property(of_node, "disable-energy-detect", &len))
+		enable_energy = 0;
+#endif
+	if (enable_energy) {
+		/* Enable energy detect mode for this SMSC Transceivers */
+		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
+			       rc | MII_LAN83C185_EDPWRDOWN);
+		if (rc < 0)
+			return rc;
+	}
 
 	return smsc_phy_ack_interrupt(phydev);
 }
Signature · 1 line
Florian
#2 lore raw

Hello Florian,

Am 13.10.2015 um 21:26 schrieb Florian Fainelli:

Quoted 26 lines · Heiko Schocher
Quoted 25 lines

On some boards the energy enable detect mode leads in trouble with some switches, so make the enabling of this mode configurable through DT.

---

  .../devicetree/bindings/net/smsc-lan87xx.txt       | 19 +++++++++++++++++
  drivers/net/phy/smsc.c                             | 24 +++++++++++++++++-----
  2 files changed, 38 insertions(+), 5 deletions(-)

create mode 100644 Documentation/devicetree/bindings/net/smsc-lan87xx.txt

Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +7 -0
new file mode 100644
index 0000000..39aa1dc
@@ -0,0 +1,19 @@
+SMSC LAN87xx Ethernet PHY
+
+Some boards require special tuning values. Configure them
+through an Ethernet OF device node.
+
+Optional properties:
+
Quoted 8 lines

Documentation/devicetree/bindings/net/smsc-lan87xx.txt line 10

Quoted 3 lines
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +3 -0
+- disable-energy-detect:
+  If set, do not enable energy detect mode for the SMSC phy.
+  default: enable energy detect mode

Although energy detection is something that is implemented by many PHYs, I am not sure a generic property is suitable here, I would prefix that with the SMSC vendor prefix here to make it clear this only applies to this PHY.

Hmm... but all PHYs should be able to enable, disable it in some way, or?

Quoted 5 lines

Would not you want to make it a reverse property here though, something like this:

smsc,energy-detect: boolean, when present indicates the PHY reliably supports energy detection

Yes, that was also my first thought, but currently, on this PHYs energy detect mode is on ... and if I introduce such a property, it will disable it for all existing boards, because property is missing ... so, maybe I break boards ...

Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +9 -0
+
+Examples:
+
+	/* Attach to an Ethernet device with autodetected PHY */
+	&cpsw_emac0 {
+		phy_id = <&davinci_mdio>, <0>;
+		phy-mode = "mii";
+		disable-energy-detect;
+	};
drivers/net/phy/smsc.c +0 -0
index 70b0895..f90fbf3 100644
@@ -43,16 +43,30 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
 
Quoted 8 lines

drivers/net/phy/smsc.c static int smsc_phy_ack_interrupt(struct phy_device *phydev) · line 49

Quoted 6 lines
drivers/net/phy/smsc.c +4 -0
  static int smsc_phy_config_init(struct phy_device *phydev)
  {
+#ifdef CONFIG_OF
+	int len;
+	struct device *dev = &phydev->dev;
+	struct device_node *of_node = dev->of_node;

That does not need to be ifdefd out, at best annontate with __maybe_unused?

Yes, I try it.

Quoted 7 lines
Quoted 7 lines
drivers/net/phy/smsc.c +2 -0
+#endif
  	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+	int enable_energy = 1;
 
  	if (rc < 0)
  		return rc;
 
Quoted 11 lines

drivers/net/phy/smsc.c static int smsc_phy_ack_interrupt(struct phy_device *phydev) · line 59

Quoted 8 lines
drivers/net/phy/smsc.c +3 -5
-	/* Enable energy detect mode for this SMSC Transceivers */
-	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
-		       rc | MII_LAN83C185_EDPWRDOWN);
-	if (rc < 0)
-		return rc;
+#ifdef CONFIG_OF
+	if (!of_node && dev->parent->of_node)
+		of_node = dev->parent->of_node;

That looks strange, why would the property be placed at the parent level when this is a PHY device tree node property?

Hmm.. I recheck this.

Quoted 11 lines
Quoted 11 lines
drivers/net/phy/smsc.c +10 -0
+	if (of_find_property(of_node, "disable-energy-detect", &len))
+		enable_energy = 0;
+#endif
+	if (enable_energy) {
+		/* Enable energy detect mode for this SMSC Transceivers */
+		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
+			       rc | MII_LAN83C185_EDPWRDOWN);
+		if (rc < 0)
+			return rc;
+	}
 
Quoted 3 lines

drivers/net/phy/smsc.c static int smsc_phy_ack_interrupt(struct phy_device *phydev) · line 72

Quoted 3 lines
drivers/net/phy/smsc.c +0 -0
  	return smsc_phy_ack_interrupt(phydev);
  }

Thanks for your review.

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#3 lore raw

Hello Florian,

Am 14.10.2015 um 06:17 schrieb Heiko Schocher:

Quoted 39 lines

Hello Florian,

Am 13.10.2015 um 21:26 schrieb Florian Fainelli:

Quoted 27 lines · Heiko Schocher
Quoted 26 lines

On some boards the energy enable detect mode leads in trouble with some switches, so make the enabling of this mode configurable through DT.

---

  .../devicetree/bindings/net/smsc-lan87xx.txt       | 19 +++++++++++++++++
  drivers/net/phy/smsc.c                             | 24 +++++++++++++++++-----
  2 files changed, 38 insertions(+), 5 deletions(-)

create mode 100644 Documentation/devicetree/bindings/net/smsc-lan87xx.txt

Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +7 -0
new file mode 100644
index 0000000..39aa1dc
@@ -0,0 +1,19 @@
+SMSC LAN87xx Ethernet PHY
+
+Some boards require special tuning values. Configure them
+through an Ethernet OF device node.
+
+Optional properties:
+
Quoted 8 lines

Documentation/devicetree/bindings/net/smsc-lan87xx.txt line 10

Quoted 3 lines
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +3 -0
+- disable-energy-detect:
+  If set, do not enable energy detect mode for the SMSC phy.
+  default: enable energy detect mode

Although energy detection is something that is implemented by many PHYs, I am not sure a generic property is suitable here, I would prefix that with the SMSC vendor prefix here to make it clear this only applies to this PHY.

Quoted 1 line

Hmm... but all PHYs should be able to enable, disable it in some way, or?

ping?

Quoted 10 lines
Quoted 5 lines

Would not you want to make it a reverse property here though, something like this:

smsc,energy-detect: boolean, when present indicates the PHY reliably supports energy detection

Yes, that was also my first thought, but currently, on this PHYs energy detect mode is on ... and if I introduce such a property, it will disable it for all existing boards, because property is missing ... so, maybe I break boards ...

I have a v2 prepared, but what to do here?

Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +9 -0
+
+Examples:
+
+    /* Attach to an Ethernet device with autodetected PHY */
+    &cpsw_emac0 {
+        phy_id = <&davinci_mdio>, <0>;
+        phy-mode = "mii";
+        disable-energy-detect;
+    };
drivers/net/phy/smsc.c +0 -0
index 70b0895..f90fbf3 100644
@@ -43,16 +43,30 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
 
Quoted 8 lines

drivers/net/phy/smsc.c static int smsc_phy_ack_interrupt(struct phy_device *phydev) · line 49

Quoted 6 lines
drivers/net/phy/smsc.c +4 -0
  static int smsc_phy_config_init(struct phy_device *phydev)
  {
+#ifdef CONFIG_OF
+    int len;
+    struct device *dev = &phydev->dev;
+    struct device_node *of_node = dev->of_node;

That does not need to be ifdefd out, at best annontate with __maybe_unused?

Quoted 1 line

Yes, I try it.

removed.

Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/phy/smsc.c +2 -0
+#endif
      int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+    int enable_energy = 1;
 
      if (rc < 0)
          return rc;
 
Quoted 11 lines

drivers/net/phy/smsc.c static int smsc_phy_ack_interrupt(struct phy_device *phydev) · line 59

Quoted 8 lines
drivers/net/phy/smsc.c +3 -5
-    /* Enable energy detect mode for this SMSC Transceivers */
-    rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
-               rc | MII_LAN83C185_EDPWRDOWN);
-    if (rc < 0)
-        return rc;
+#ifdef CONFIG_OF
+    if (!of_node && dev->parent->of_node)
+        of_node = dev->parent->of_node;

That looks strange, why would the property be placed at the parent level when this is a PHY device tree node property?

Quoted 1 line

Hmm.. I recheck this.

Hmm.. the drivers/net/ethernet/ti/cpsw.c has no phy-handle support ... I added this, so my v2 is now a patchset of 2 patches.

bye,
Heiko

Signature · 6 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
In reply to Heiko Schocher

2015-10-13 21:17 GMT-07:00 Heiko Schocher <[email protected]>:

Quoted 47 lines

Hello Florian,

Am 13.10.2015 um 21:26 schrieb Florian Fainelli:

Quoted 33 lines · Heiko Schocher
Quoted 31 lines

On some boards the energy enable detect mode leads in trouble with some switches, so make the enabling of this mode configurable through DT.

---

  .../devicetree/bindings/net/smsc-lan87xx.txt       | 19
+++++++++++++++++
  drivers/net/phy/smsc.c                             | 24
+++++++++++++++++-----
  2 files changed, 38 insertions(+), 5 deletions(-)

create mode 100644
Documentation/devicetree/bindings/net/smsc-lan87xx.txt

Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +8 -0
new file mode 100644
index 0000000..39aa1dc
@@ -0,0 +1,19 @@
+SMSC LAN87xx Ethernet PHY
+
+Some boards require special tuning values. Configure them
+through an Ethernet OF device node.
+
+Optional properties:
+
+- disable-energy-detect:
Quoted 8 lines

Documentation/devicetree/bindings/net/smsc-lan87xx.txt line 10

Quoted 2 lines
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +2 -0
+  If set, do not enable energy detect mode for the SMSC phy.
+  default: enable energy detect mode

Although energy detection is something that is implemented by many PHYs, I am not sure a generic property is suitable here, I would prefix that with the SMSC vendor prefix here to make it clear this only applies to this PHY.

Quoted 1 line

Hmm... but all PHYs should be able to enable, disable it in some way, or?

It may not always be controlled directly at the PHY level, sometimes this is something that needs cooperation with the Ethernet MAC as well in case of integrated designs.

Quoted 4 lines
Quoted 4 lines

Would not you want to make it a reverse property here though, something like this:

Quoted 8 lines
Quoted 2 lines

smsc,energy-detect: boolean, when present indicates the PHY reliably supports energy detection

Yes, that was also my first thought, but currently, on this PHYs energy detect mode is on ... and if I introduce such a property, it will disable it for all existing boards, because property is missing ... so, maybe I break boards ...

Fair enough, how about smsc,disabled-energy-detect or something like that then?

Signature · 5 lines
Florian
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

Hello Florian,

Am 16.10.2015 um 18:27 schrieb Florian Fainelli:

Quoted 48 lines

2015-10-13 21:17 GMT-07:00 Heiko Schocher <[email protected]>:

Quoted 47 lines

Hello Florian,

Am 13.10.2015 um 21:26 schrieb Florian Fainelli:

Quoted 41 lines · Heiko Schocher
Quoted 23 lines

On some boards the energy enable detect mode leads in trouble with some switches, so make the enabling of this mode configurable through DT.

---

   .../devicetree/bindings/net/smsc-lan87xx.txt       | 19
+++++++++++++++++
   drivers/net/phy/smsc.c                             | 24
+++++++++++++++++-----
   2 files changed, 38 insertions(+), 5 deletions(-)

create mode 100644
Documentation/devicetree/bindings/net/smsc-lan87xx.txt

Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +0 -0
new file mode 100644
index 0000000..39aa1dc

Documentation/devicetree/bindings/net/smsc-lan87xx.txt line 10

Quoted 10 lines
Documentation/devicetree/bindings/net/smsc-lan87xx.txt new file +10 -0
@@ -0,0 +1,19 @@
+SMSC LAN87xx Ethernet PHY
+
+Some boards require special tuning values. Configure them
+through an Ethernet OF device node.
+
+Optional properties:
+
+- disable-energy-detect:
+  If set, do not enable energy detect mode for the SMSC phy.
+  default: enable energy detect mode

Although energy detection is something that is implemented by many PHYs, I am not sure a generic property is suitable here, I would prefix that with the SMSC vendor prefix here to make it clear this only applies to this PHY.

Quoted 5 lines
Quoted 1 line

Hmm... but all PHYs should be able to enable, disable it in some way, or?

It may not always be controlled directly at the PHY level, sometimes this is something that needs cooperation with the Ethernet MAC as well in case of integrated designs.

Ah, ok!

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

Would not you want to make it a reverse property here though, something like this:

smsc,energy-detect: boolean, when present indicates the PHY reliably supports energy detection

Quoted 6 lines
Quoted 4 lines

Yes, that was also my first thought, but currently, on this PHYs energy detect mode is on ... and if I introduce such a property, it will disable it for all existing boards, because property is missing ... so, maybe I break boards ...

Fair enough, how about smsc,disabled-energy-detect or something like that then?

Yes, changed it to "smsc,disable-energy-detect"

bye,
Heiko

Signature · 6 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html