From: Florian Fainelli <f.fainelli@gmail.com>
To: <netdev@vger.kernel.org>
Cc: <davem@davemloft.net>, <Shaohui.Xie@freescale.com>,
Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next v2 2/3] net: phy: allow PHY drivers to implement their own software reset
Date: Mon, 17 Feb 2014 13:34:03 -0800 [thread overview]
Message-ID: <1392672844-1767-3-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1392672844-1767-1-git-send-email-f.fainelli@gmail.com>
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
next prev parent reply other threads:[~2014-02-17 21:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1392672844-1767-3-git-send-email-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=Shaohui.Xie@freescale.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).