From: Felix Fietkau <nbd@openwrt.org>
To: netdev@vger.kernel.org
Subject: RFC: Custom PHY device detection functions
Date: Wed, 04 Jun 2008 22:55:23 +0200 [thread overview]
Message-ID: <4847013B.4090408@openwrt.org> (raw)
Hi,
I'm working on Linux on small consumer grade wireless routers. Many of
these have switches that connect directly to the Ethernet controller
through MII/MDIO. These typically support 6-8 ports, one of which connects
to the CPU. I am working on supporting some of these with PHY drivers,
which I will submit for review when they're ready.
Most of these devices can be detected with the regular PHY ID and mask, but
unfortunately there are some that lay out their registers a bit differently
and thus need custom detection.
I worked around this with the following patch, that allows drivers to do
their own detection, but I'm not sure if this is suitable for inclusion in
the PHY layer or if there is a different way to solve this.
Any ideas?
- Felix
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -132,6 +132,9 @@
struct phy_device *phydev = to_phy_device(dev);
struct phy_driver *phydrv = to_phy_driver(drv);
+ if (phydrv->detect)
+ return (phydrv->detect(phydev->bus, phydev->addr));
+
return ((phydrv->phy_id & phydrv->phy_id_mask) ==
(phydev->phy_id & phydrv->phy_id_mask));
}
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -325,6 +325,11 @@
u32 features;
u32 flags;
+ /* Called during discovery to test if the
+ * device can attach to the bus, even if
+ * phy id and mask do not match */
+ bool (*detect)(struct mii_bus *bus, int addr);
+
/* Called to initialize the PHY,
* including after a reset */
int (*config_init)(struct phy_device *phydev);
next reply other threads:[~2008-06-04 21:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-04 20:55 Felix Fietkau [this message]
2008-06-05 18:52 ` RFC: Custom PHY device detection functions Trent Piepho
2008-06-05 20:19 ` Felix Fietkau
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=4847013B.4090408@openwrt.org \
--to=nbd@openwrt.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;
as well as URLs for NNTP newsgroup(s).