All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] net: phy: soft reset rework for 10G PHYs
@ 2014-02-17 21:34 Florian Fainelli
  2014-02-17 21:34 ` [PATCH net-next v2 1/3] net: phy: move PHY software reset to genphy_soft_reset Florian Fainelli
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Florian Fainelli @ 2014-02-17 21:34 UTC (permalink / raw)
  To: netdev; +Cc: davem, Shaohui.Xie, Florian Fainelli

Hi David,

As reported by Shaohui, 10G PHYs may have a slightly more complex reset
sequence for which a BMCR_RESET software reset might not suffice. This
patchset offers a solution for those by allowing them to implement their
own soft_reset() callback. Finally there is an update to the PHY library
Documentation to cover for the newly added callbacks of the PHY driver
structure.

Thanks!

Changes in v2:
- fixed callback testing
- fixed typo in Documentation

Florian Fainelli (3):
  net: phy: move PHY software reset to genphy_soft_reset
  net: phy: allow PHY drivers to implement their own software reset
  Documentation: networking: update phy.txt with recent changes

 Documentation/networking/phy.txt |  9 +++++++++
 drivers/net/phy/phy_device.c     | 39 ++++++++++++++++++++++++++++++++++-----
 include/linux/phy.h              |  6 ++++++
 3 files changed, 49 insertions(+), 5 deletions(-)

-- 
1.8.3.2

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

* [PATCH net-next v2 1/3] net: phy: move PHY software reset to genphy_soft_reset
  2014-02-17 21:34 [PATCH net-next v2 0/3] net: phy: soft reset rework for 10G PHYs Florian Fainelli
@ 2014-02-17 21:34 ` Florian Fainelli
  2014-02-17 21:34 ` [PATCH net-next v2 2/3] net: phy: allow PHY drivers to implement their own software reset Florian Fainelli
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2014-02-17 21:34 UTC (permalink / raw)
  To: netdev; +Cc: davem, Shaohui.Xie, Florian Fainelli

As pointed out by Shaohui, this function is generic for 10/100/1000
PHYs, but 10G PHYs might have a slightly different reset sequence which
prevents most of them from using this function.

Move the BMCR_RESET based software resent sequence to
genphy_soft_reset() in preparation for allowing PHY drivers to implement
a soft_reset() callback.

Reported-by: Shaohui Xie <Shaohui.Xie@freescale.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:
- respin

 drivers/net/phy/phy_device.c | 27 ++++++++++++++++++++++-----
 include/linux/phy.h          |  1 +
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c2d778d..7c21b82 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -540,11 +540,7 @@ int phy_init_hw(struct phy_device *phydev)
 	if (!phydev->drv || !phydev->drv->config_init)
 		return 0;
 
-	ret = phy_write(phydev, MII_BMCR, BMCR_RESET);
-	if (ret < 0)
-		return ret;
-
-	ret = phy_poll_reset(phydev);
+	ret = genphy_soft_reset(phydev);
 	if (ret < 0)
 		return ret;
 
@@ -1045,6 +1041,27 @@ static int gen10g_read_status(struct phy_device *phydev)
 	return 0;
 }
 
+/**
+ * genphy_soft_reset - software reset the PHY via BMCR_RESET bit
+ * @phydev: target phy_device struct
+ *
+ * Description: Perform a software PHY reset using the standard
+ * BMCR_RESET bit and poll for the reset bit to be cleared.
+ *
+ * Returns: 0 on success, < 0 on failure
+ */
+int genphy_soft_reset(struct phy_device *phydev)
+{
+	int ret;
+
+	ret = phy_write(phydev, MII_BMCR, BMCR_RESET);
+	if (ret < 0)
+		return ret;
+
+	return phy_poll_reset(phydev);
+}
+EXPORT_SYMBOL(genphy_soft_reset);
+
 static int genphy_config_init(struct phy_device *phydev)
 {
 	int val;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f7fe546..bffe0ec 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -666,6 +666,7 @@ int genphy_update_link(struct phy_device *phydev);
 int genphy_read_status(struct phy_device *phydev);
 int genphy_suspend(struct phy_device *phydev);
 int genphy_resume(struct phy_device *phydev);
+int genphy_soft_reset(struct phy_device *phydev);
 void phy_driver_unregister(struct phy_driver *drv);
 void phy_drivers_unregister(struct phy_driver *drv, int n);
 int phy_driver_register(struct phy_driver *new_driver);
-- 
1.8.3.2

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

* [PATCH net-next v2 2/3] net: phy: allow PHY drivers to implement their own software reset
  2014-02-17 21:34 [PATCH net-next v2 0/3] net: phy: soft reset rework for 10G PHYs Florian Fainelli
  2014-02-17 21:34 ` [PATCH net-next v2 1/3] net: phy: move PHY software reset to genphy_soft_reset Florian Fainelli
@ 2014-02-17 21:34 ` Florian Fainelli
  2014-02-17 21:34 ` [PATCH net-next v2 3/3] Documentation: networking: update phy.txt with recent changes Florian Fainelli
  2014-02-17 21:41 ` [PATCH net-next v2 0/3] net: phy: soft reset rework for 10G PHYs David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2014-02-17 21:34 UTC (permalink / raw)
  To: netdev; +Cc: davem, Shaohui.Xie, Florian Fainelli

As pointed out by Shaohui, most 10G PHYs out there have a non-standard
compliant software reset sequence, eventually something much more
complex than just toggling the BMCR_RESET bit. Allow PHY driver to
implement their own soft_reset() callback to deal with that. If no
callback is provided, call into genphy_soft_reset() which makes sure the
existing behavior is kept intact.

Reported-by: Shaohui Xie <Shaohui.Xie@freescale.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:
- fix callback testing before actually invoking it

 drivers/net/phy/phy_device.c | 16 ++++++++++++++--
 include/linux/phy.h          |  5 +++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 7c21b82..a70b604 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -535,12 +535,16 @@ static int phy_poll_reset(struct phy_device *phydev)
 
 int phy_init_hw(struct phy_device *phydev)
 {
-	int ret;
+	int ret = 0;
 
 	if (!phydev->drv || !phydev->drv->config_init)
 		return 0;
 
-	ret = genphy_soft_reset(phydev);
+	if (phydev->drv->soft_reset)
+		ret = phydev->drv->soft_reset(phydev);
+	else
+		ret = genphy_soft_reset(phydev);
+
 	if (ret < 0)
 		return ret;
 
@@ -1108,6 +1112,12 @@ static int genphy_config_init(struct phy_device *phydev)
 	return 0;
 }
 
+static int gen10g_soft_reset(struct phy_device *phydev)
+{
+	/* Do nothing for now */
+	return 0;
+}
+
 static int gen10g_config_init(struct phy_device *phydev)
 {
 	/* Temporarily just say we support everything */
@@ -1282,6 +1292,7 @@ static struct phy_driver genphy_driver[] = {
 	.phy_id		= 0xffffffff,
 	.phy_id_mask	= 0xffffffff,
 	.name		= "Generic PHY",
+	.soft_reset	= genphy_soft_reset,
 	.config_init	= genphy_config_init,
 	.features	= 0,
 	.config_aneg	= genphy_config_aneg,
@@ -1294,6 +1305,7 @@ static struct phy_driver genphy_driver[] = {
 	.phy_id         = 0xffffffff,
 	.phy_id_mask    = 0xffffffff,
 	.name           = "Generic 10G PHY",
+	.soft_reset	= gen10g_soft_reset,
 	.config_init    = gen10g_config_init,
 	.features       = 0,
 	.config_aneg    = gen10g_config_aneg,
diff --git a/include/linux/phy.h b/include/linux/phy.h
index bffe0ec..24126c4 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -440,6 +440,11 @@ struct phy_driver {
 	u32 flags;
 
 	/*
+	 * Called to issue a PHY software reset
+	 */
+	int (*soft_reset)(struct phy_device *phydev);
+
+	/*
 	 * Called to initialize the PHY,
 	 * including after a reset
 	 */
-- 
1.8.3.2

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

* [PATCH net-next v2 3/3] Documentation: networking: update phy.txt with recent changes
  2014-02-17 21:34 [PATCH net-next v2 0/3] net: phy: soft reset rework for 10G PHYs Florian Fainelli
  2014-02-17 21:34 ` [PATCH net-next v2 1/3] net: phy: move PHY software reset to genphy_soft_reset Florian Fainelli
  2014-02-17 21:34 ` [PATCH net-next v2 2/3] net: phy: allow PHY drivers to implement their own software reset Florian Fainelli
@ 2014-02-17 21:34 ` Florian Fainelli
  2014-02-17 23:32   ` Sergei Shtylyov
  2014-02-17 21:41 ` [PATCH net-next v2 0/3] net: phy: soft reset rework for 10G PHYs David Miller
  3 siblings, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2014-02-17 21:34 UTC (permalink / raw)
  To: netdev; +Cc: davem, Shaohui.Xie, Florian Fainelli

The PHY library was missing a bunch of newly added PHY driver callbacks
along with a smallish description of what they do, fix that.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:
- fix typo on the soft_reset description

 Documentation/networking/phy.txt | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/networking/phy.txt b/Documentation/networking/phy.txt
index ebf2707..e602c6f 100644
--- a/Documentation/networking/phy.txt
+++ b/Documentation/networking/phy.txt
@@ -253,16 +253,25 @@ Writing a PHY driver
 
  Each driver consists of a number of function pointers:
 
+   soft_reset: perform a PHY software reset
    config_init: configures PHY into a sane state after a reset.
      For instance, a Davicom PHY requires descrambling disabled.
    probe: Allocate phy->priv, optionally refuse to bind.
    PHY may not have been reset or had fixups run yet.
    suspend/resume: power management
    config_aneg: Changes the speed/duplex/negotiation settings
+   aneg_done: Determines the auto-negotiation result
    read_status: Reads the current speed/duplex/negotiation settings
    ack_interrupt: Clear a pending interrupt
+   did_interrupt: Checks if the PHY generated an interrupt
    config_intr: Enable or disable interrupts
    remove: Does any driver take-down
+   ts_info: Queries about the HW timestamping status
+   hwtstamp: Set the PHY HW timestamping configuration
+   rxtstamp: Requests a receive timestamp at the PHY level for a 'skb'
+   txtsamp: Requests a transmit timestamp at the PHY level for a 'skb'
+   set_wol: Enable Wake-on-LAN at the PHY level
+   get_wol: Get the Wake-on-LAN status at the PHY level
 
  Of these, only config_aneg and read_status are required to be
  assigned by the driver code.  The rest are optional.  Also, it is
-- 
1.8.3.2

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

* Re: [PATCH net-next v2 0/3] net: phy: soft reset rework for 10G PHYs
  2014-02-17 21:34 [PATCH net-next v2 0/3] net: phy: soft reset rework for 10G PHYs Florian Fainelli
                   ` (2 preceding siblings ...)
  2014-02-17 21:34 ` [PATCH net-next v2 3/3] Documentation: networking: update phy.txt with recent changes Florian Fainelli
@ 2014-02-17 21:41 ` David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2014-02-17 21:41 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, Shaohui.Xie

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon, 17 Feb 2014 13:34:01 -0800

> Hi David,
> 
> As reported by Shaohui, 10G PHYs may have a slightly more complex reset
> sequence for which a BMCR_RESET software reset might not suffice. This
> patchset offers a solution for those by allowing them to implement their
> own soft_reset() callback. Finally there is an update to the PHY library
> Documentation to cover for the newly added callbacks of the PHY driver
> structure.
> 
> Thanks!
> 
> Changes in v2:
> - fixed callback testing
> - fixed typo in Documentation

Much better, series applied, thanks.

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

* Re: [PATCH net-next v2 3/3] Documentation: networking: update phy.txt with recent changes
  2014-02-17 21:34 ` [PATCH net-next v2 3/3] Documentation: networking: update phy.txt with recent changes Florian Fainelli
@ 2014-02-17 23:32   ` Sergei Shtylyov
  0 siblings, 0 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2014-02-17 23:32 UTC (permalink / raw)
  To: Florian Fainelli, netdev; +Cc: davem, Shaohui.Xie

Hello.

On 02/18/2014 12:34 AM, Florian Fainelli wrote:

> The PHY library was missing a bunch of newly added PHY driver callbacks
> along with a smallish description of what they do, fix that.

> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
[...]

    Again too quick merge, not all types have been fixed. :-/

> diff --git a/Documentation/networking/phy.txt b/Documentation/networking/phy.txt
> index ebf2707..e602c6f 100644
> --- a/Documentation/networking/phy.txt
> +++ b/Documentation/networking/phy.txt
> @@ -253,16 +253,25 @@ Writing a PHY driver
>
>    Each driver consists of a number of function pointers:
[...]
> +   ts_info: Queries about the HW timestamping status
> +   hwtstamp: Set the PHY HW timestamping configuration
> +   rxtstamp: Requests a receive timestamp at the PHY level for a 'skb'
> +   txtsamp: Requests a transmit timestamp at the PHY level for a 'skb'

    s/txtsamp/txtstamp/.

WBR, Sergei

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

end of thread, other threads:[~2014-02-17 22:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-17 21:34 [PATCH net-next v2 0/3] net: phy: soft reset rework for 10G PHYs Florian Fainelli
2014-02-17 21:34 ` [PATCH net-next v2 1/3] net: phy: move PHY software reset to genphy_soft_reset Florian Fainelli
2014-02-17 21:34 ` [PATCH net-next v2 2/3] net: phy: allow PHY drivers to implement their own software reset Florian Fainelli
2014-02-17 21:34 ` [PATCH net-next v2 3/3] Documentation: networking: update phy.txt with recent changes Florian Fainelli
2014-02-17 23:32   ` Sergei Shtylyov
2014-02-17 21:41 ` [PATCH net-next v2 0/3] net: phy: soft reset rework for 10G PHYs 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.