From: Shengzhou Liu <Shengzhou.Liu@freescale.com>
To: <netdev@vger.kernel.org>, <davem@davemloft.net>
Cc: <linux-kernel@vger.kernel.org>,
Shengzhou Liu <Shengzhou.Liu@freescale.com>
Subject: [PATCH v2] net/phy: tune get_phy_c45_ids to support more c45 phy
Date: Tue, 14 Apr 2015 18:09:52 +0800 [thread overview]
Message-ID: <1429006192-21403-1-git-send-email-Shengzhou.Liu@freescale.com> (raw)
As some C45 10G PHYs(e.g. Cortina CS4315/CS4340 PHY) have
zero Devices In package, current driver can't get correct
devices_in_package value by non-zero Devices In package.
so let's probe more with zero Devices In package to support
more C45 PHYs.
Signed-off-by: Shengzhou Liu <Shengzhou.Liu@freescale.com>
---
v2: use MDIO_DEVS1 and MDIO_DEVS2 instead of constant '6', '5'
drivers/net/phy/phy_device.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index bdfe51f..c4f836f 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -242,12 +242,29 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
return -EIO;
c45_ids->devices_in_package |= (phy_reg & 0xffff);
- /* If mostly Fs, there is no device there,
- * let's get out of here.
+ /* If mostly Fs, let's continue to probe more
+ * as some c45 PHYs have zero Devices In package,
+ * e.g. Cortina CS4315/CS4340 PHY.
*/
if ((c45_ids->devices_in_package & 0x1fffffff) == 0x1fffffff) {
- *phy_id = 0xffffffff;
- return 0;
+ reg_addr = MII_ADDR_C45 | 0 << 16 | MDIO_DEVS2;
+ phy_reg = mdiobus_read(bus, addr, reg_addr);
+ if (phy_reg < 0)
+ return -EIO;
+ c45_ids->devices_in_package = (phy_reg & 0xffff) << 16;
+ reg_addr = MII_ADDR_C45 | 0 << 16 | MDIO_DEVS1;
+ phy_reg = mdiobus_read(bus, addr, reg_addr);
+ if (phy_reg < 0)
+ return -EIO;
+ c45_ids->devices_in_package |= (phy_reg & 0xffff);
+ /* If mostly Fs, there is no device there,
+ * let's get out of here.
+ */
+ if ((c45_ids->devices_in_package & 0x1fffffff) ==
+ 0x1fffffff) {
+ *phy_id = 0xffffffff;
+ return 0;
+ }
}
}
--
2.1.0.27.g96db324
next reply other threads:[~2015-04-14 10:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-14 10:09 Shengzhou Liu [this message]
2015-04-14 17:45 ` Florian Fainelli
2015-04-15 8:27 ` Shengzhou.Liu
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=1429006192-21403-1-git-send-email-Shengzhou.Liu@freescale.com \
--to=shengzhou.liu@freescale.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®