All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: micrel.c: Support ksz9031 energy-detect power-down mode
@ 2016-10-03 13:04 Mike Looijmans
  2016-10-03 14:35   ` Andrew Lunn
  2016-10-04  5:52 ` [PATCH v2] phy: micrel.c: Enable " Mike Looijmans
  0 siblings, 2 replies; 8+ messages in thread
From: Mike Looijmans @ 2016-10-03 13:04 UTC (permalink / raw)
  To: netdev; +Cc: devicetree, linux-kernel, f.fainelli, Mike Looijmans

Set bit 0 in register 1C.23 to enable the EDPD feature of the
KSZ9031 PHY. This reduces power consumption when the link is
down. To use this, set "enable-edpd" in the devicetree.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
---
 .../devicetree/bindings/net/micrel-ksz90x1.txt        |  6 ++++++
 drivers/net/phy/micrel.c                              | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt b/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt
index f9c32ad..fbec6f8 100644
--- a/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt
+++ b/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt
@@ -56,6 +56,11 @@ KSZ9031:
       - txd2-skew-ps : Skew control of TX data 2 pad
       - txd3-skew-ps : Skew control of TX data 3 pad
 
+    Boolean:
+
+      - enable-edpd : Not related to timing. Specify this property to enable
+                      energy-detect power-down mode in the PHY.
+
 Examples:
 
 	mdio {
@@ -64,6 +69,7 @@ Examples:
 			rxdv-skew-ps = <0>;
 			txc-skew-ps = <3000>;
 			txen-skew-ps = <0>;
+			enable-edpd;
 			reg = <0>;
 		};
 	};
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 4516c8a..0a365b4 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -409,6 +409,10 @@ static int ksz9021_config_init(struct phy_device *phydev)
 #define MII_KSZ9031RN_TX_DATA_PAD_SKEW	6
 #define MII_KSZ9031RN_CLK_PAD_SKEW	8
 
+/* MMD Address 0x1C */
+#define MII_KSZ9031RN_EDPD		0x23
+#define MII_KSZ9031RN_EDPD_ENABLE	BIT(0)
+
 static int ksz9031_extended_write(struct phy_device *phydev,
 				  u8 mode, u32 dev_addr, u32 regnum, u16 val)
 {
@@ -480,6 +484,18 @@ static int ksz9031_center_flp_timing(struct phy_device *phydev)
 	return genphy_restart_aneg(phydev);
 }
 
+/* Enable energy-detect power-down mode */
+static int ksz9031_enable_edpd(struct phy_device *phydev)
+{
+	int reg;
+
+	reg = ksz9031_extended_read(phydev, OP_DATA, 0x1C, MII_KSZ9031RN_EDPD);
+	if (reg < 0)
+		return reg;
+	return ksz9031_extended_write(phydev, OP_DATA, 0x1C, MII_KSZ9031RN_EDPD,
+				      reg | MII_KSZ9031RN_EDPD_ENABLE);
+}
+
 static int ksz9031_config_init(struct phy_device *phydev)
 {
 	const struct device *dev = &phydev->mdio.dev;
@@ -522,6 +538,9 @@ static int ksz9031_config_init(struct phy_device *phydev)
 		ksz9031_of_load_skew_values(phydev, of_node,
 				MII_KSZ9031RN_TX_DATA_PAD_SKEW, 4,
 				tx_data_skews, 4);
+
+		if (of_property_read_bool(of_node, "enable-edpd"))
+			ksz9031_enable_edpd(phydev);
 	}
 
 	return ksz9031_center_flp_timing(phydev);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] phy: micrel.c: Support ksz9031 energy-detect power-down mode
@ 2016-10-03 14:35   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2016-10-03 14:35 UTC (permalink / raw)
  To: Mike Looijmans; +Cc: netdev, devicetree, linux-kernel, f.fainelli

> +    Boolean:
> +
> +      - enable-edpd : Not related to timing. Specify this property to enable
> +                      energy-detect power-down mode in the PHY.

The Broadcom PHYs unconditionally enable this feature.

The SMSC driver has an option: smsc,disable-energy-detect because it
seems to have a rare hardware bug when it is enabled.

And you would like to make it off by default.

Could we avoid having three drivers doing three different things?
Could you have it unconditionally on, and see if anybody reports it
being broken?

      Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] phy: micrel.c: Support ksz9031 energy-detect power-down mode
@ 2016-10-03 14:35   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2016-10-03 14:35 UTC (permalink / raw)
  To: Mike Looijmans
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	f.fainelli-Re5JQEeQqe8AvxtiuMwx3w

> +    Boolean:
> +
> +      - enable-edpd : Not related to timing. Specify this property to enable
> +                      energy-detect power-down mode in the PHY.

The Broadcom PHYs unconditionally enable this feature.

The SMSC driver has an option: smsc,disable-energy-detect because it
seems to have a rare hardware bug when it is enabled.

And you would like to make it off by default.

Could we avoid having three drivers doing three different things?
Could you have it unconditionally on, and see if anybody reports it
being broken?

      Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] phy: micrel.c: Support ksz9031 energy-detect power-down mode
  2016-10-03 14:35   ` Andrew Lunn
  (?)
@ 2016-10-03 16:30   ` Mike Looijmans
  -1 siblings, 0 replies; 8+ messages in thread
From: Mike Looijmans @ 2016-10-03 16:30 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, devicetree, linux-kernel, f.fainelli

On 03-10-16 16:35, Andrew Lunn wrote:
>> +    Boolean:
>> +
>> +      - enable-edpd : Not related to timing. Specify this property to enable
>> +                      energy-detect power-down mode in the PHY.
>
> The Broadcom PHYs unconditionally enable this feature.
>
> The SMSC driver has an option: smsc,disable-energy-detect because it
> seems to have a rare hardware bug when it is enabled.
>
> And you would like to make it off by default.
>
> Could we avoid having three drivers doing three different things?
> Could you have it unconditionally on, and see if anybody reports it
> being broken?

Good suggestion I think. It's a feature found on many PHYs, apparently 
without any ill effects, so just enabling unconditionally simplifies 
things. And it's good for the environment...

I'll post a v2 patch (which won't need devicetree changes then).

-- 
Mike Looijmans

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] phy: micrel.c: Enable ksz9031 energy-detect power-down mode
  2016-10-03 13:04 [PATCH] phy: micrel.c: Support ksz9031 energy-detect power-down mode Mike Looijmans
  2016-10-03 14:35   ` Andrew Lunn
@ 2016-10-04  5:52 ` Mike Looijmans
  2016-10-04  6:55   ` Andrew Lunn
                     ` (2 more replies)
  1 sibling, 3 replies; 8+ messages in thread
From: Mike Looijmans @ 2016-10-04  5:52 UTC (permalink / raw)
  To: netdev; +Cc: f.fainelli, linux-kernel, Mike Looijmans

Set bit 0 in register 1C.23 to enable the EDPD feature of the
KSZ9031 PHY. This reduces power consumption when the link is
down.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
---
v2: Unconditionally enable EDPD mode

 drivers/net/phy/micrel.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 885ac9c..081df68 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -439,6 +439,10 @@ static int ksz9021_config_init(struct phy_device *phydev)
 #define MII_KSZ9031RN_TX_DATA_PAD_SKEW	6
 #define MII_KSZ9031RN_CLK_PAD_SKEW	8
 
+/* MMD Address 0x1C */
+#define MII_KSZ9031RN_EDPD		0x23
+#define MII_KSZ9031RN_EDPD_ENABLE	BIT(0)
+
 static int ksz9031_extended_write(struct phy_device *phydev,
 				  u8 mode, u32 dev_addr, u32 regnum, u16 val)
 {
@@ -510,6 +514,18 @@ static int ksz9031_center_flp_timing(struct phy_device *phydev)
 	return genphy_restart_aneg(phydev);
 }
 
+/* Enable energy-detect power-down mode */
+static int ksz9031_enable_edpd(struct phy_device *phydev)
+{
+	int reg;
+
+	reg = ksz9031_extended_read(phydev, OP_DATA, 0x1C, MII_KSZ9031RN_EDPD);
+	if (reg < 0)
+		return reg;
+	return ksz9031_extended_write(phydev, OP_DATA, 0x1C, MII_KSZ9031RN_EDPD,
+				      reg | MII_KSZ9031RN_EDPD_ENABLE);
+}
+
 static int ksz9031_config_init(struct phy_device *phydev)
 {
 	const struct device *dev = &phydev->mdio.dev;
@@ -525,6 +541,11 @@ static int ksz9031_config_init(struct phy_device *phydev)
 	};
 	static const char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"};
 	const struct device *dev_walker;
+	int result;
+
+	result = ksz9031_enable_edpd(phydev);
+	if (result < 0)
+		return result;
 
 	/* The Micrel driver has a deprecated option to place phy OF
 	 * properties in the MAC node. Walk up the tree of devices to
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] phy: micrel.c: Enable ksz9031 energy-detect power-down mode
  2016-10-04  5:52 ` [PATCH v2] phy: micrel.c: Enable " Mike Looijmans
@ 2016-10-04  6:55   ` Andrew Lunn
  2016-10-04 11:09   ` Florian Fainelli
  2016-10-06  1:19   ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2016-10-04  6:55 UTC (permalink / raw)
  To: Mike Looijmans; +Cc: netdev, f.fainelli, linux-kernel

On Tue, Oct 04, 2016 at 07:52:04AM +0200, Mike Looijmans wrote:
> Set bit 0 in register 1C.23 to enable the EDPD feature of the
> KSZ9031 PHY. This reduces power consumption when the link is
> down.
> 
> Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] phy: micrel.c: Enable ksz9031 energy-detect power-down mode
  2016-10-04  5:52 ` [PATCH v2] phy: micrel.c: Enable " Mike Looijmans
  2016-10-04  6:55   ` Andrew Lunn
@ 2016-10-04 11:09   ` Florian Fainelli
  2016-10-06  1:19   ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2016-10-04 11:09 UTC (permalink / raw)
  To: Mike Looijmans, netdev; +Cc: linux-kernel



On 10/03/2016 10:52 PM, Mike Looijmans wrote:
> Set bit 0 in register 1C.23 to enable the EDPD feature of the
> KSZ9031 PHY. This reduces power consumption when the link is
> down.
> 
> Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com
-- 
Florian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] phy: micrel.c: Enable ksz9031 energy-detect power-down mode
  2016-10-04  5:52 ` [PATCH v2] phy: micrel.c: Enable " Mike Looijmans
  2016-10-04  6:55   ` Andrew Lunn
  2016-10-04 11:09   ` Florian Fainelli
@ 2016-10-06  1:19   ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2016-10-06  1:19 UTC (permalink / raw)
  To: mike.looijmans; +Cc: netdev, f.fainelli, linux-kernel

From: Mike Looijmans <mike.looijmans@topic.nl>
Date: Tue,  4 Oct 2016 07:52:04 +0200

> Set bit 0 in register 1C.23 to enable the EDPD feature of the
> KSZ9031 PHY. This reduces power consumption when the link is
> down.
> 
> Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
> ---
> v2: Unconditionally enable EDPD mode

Applied.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-10-06  1:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-03 13:04 [PATCH] phy: micrel.c: Support ksz9031 energy-detect power-down mode Mike Looijmans
2016-10-03 14:35 ` Andrew Lunn
2016-10-03 14:35   ` Andrew Lunn
2016-10-03 16:30   ` Mike Looijmans
2016-10-04  5:52 ` [PATCH v2] phy: micrel.c: Enable " Mike Looijmans
2016-10-04  6:55   ` Andrew Lunn
2016-10-04 11:09   ` Florian Fainelli
2016-10-06  1:19   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.