From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Li Yang <leoli@freescale.com>,
Andy Fleming <afleming@freescale.com>,
linuxppc-dev@ozlabs.org
Subject: [PATCH 1/4] of/mdio: Add fixed link support
Date: Sat, 27 Jun 2009 02:29:45 +0400 [thread overview]
Message-ID: <20090626222945.GA32487@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <20090626222900.GA14594@oksana.dev.rtsoft.ru>
Currently the fixed link support is broken for all OF ethernet drivers,
an "OF MDIO rework" removed most of the support. Instead of re-adding
fixed-link stuff to the drivers, add the support to a framework, so we
won't duplicate any code.
With this patch, if a node pointer is NULL, then of_phy_connect() will
try to find ethernet device's node, then will look for fixed-link
property, and if specified, it connects PHY as usual, via bus_id (fixed
link PHYs do not have any device tree nodes associated with them).
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
drivers/of/of_mdio.c | 45 +++++++++++++++++++++++++++++++++++++++++----
1 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index aee967d..cfd876a 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -9,6 +9,10 @@
* out of the OpenFirmware device tree and using it to populate an mii_bus.
*/
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/netdevice.h>
+#include <linux/err.h>
#include <linux/phy.h>
#include <linux/of.h>
#include <linux/of_mdio.h>
@@ -129,11 +133,44 @@ struct phy_device *of_phy_connect(struct net_device *dev,
void (*hndlr)(struct net_device *), u32 flags,
phy_interface_t iface)
{
- struct phy_device *phy = of_phy_find_device(phy_np);
+ struct phy_device *phy = NULL;
+
+ if (phy_np) {
+ int ret;
+
+ phy = of_phy_find_device(phy_np);
+ if (!phy)
+ return NULL;
+
+ ret = phy_connect_direct(dev, phy, hndlr, flags, iface);
+ if (ret)
+ return NULL;
+ } else if (dev->dev.parent) {
+ struct device_node *net_np;
+ const u32 *phy_id;
+ char *bus_id;
+ int sz;
+
+ net_np = dev_archdata_get_node(&dev->dev.parent->archdata);
+ if (!net_np)
+ return NULL;
+
+ phy_id = of_get_property(net_np, "fixed-link", &sz);
+ if (!phy_id || sz < sizeof(*phy_id))
+ return NULL;
+
+ bus_id = kasprintf(GFP_KERNEL, PHY_ID_FMT, "0", phy_id[0]);
+ if (!bus_id) {
+ dev_err(&dev->dev, "could not allocate memory\n");
+ return NULL;
+ }
- if (!phy)
- return NULL;
+ phy = phy_connect(dev, bus_id, hndlr, 0, iface);
+ kfree(bus_id);
+ if (IS_ERR(phy))
+ return NULL;
+ }
- return phy_connect_direct(dev, phy, hndlr, flags, iface) ? NULL : phy;
+ return phy;
}
EXPORT_SYMBOL(of_phy_connect);
--
1.6.3.1
next prev parent reply other threads:[~2009-06-26 22:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-26 22:29 [PATCH 0/4 for 2.6.31] NET: Revive fixed link support Anton Vorontsov
2009-06-26 22:29 ` Anton Vorontsov
2009-06-26 22:29 ` Anton Vorontsov [this message]
2009-06-26 23:33 ` [PATCH 1/4] of/mdio: Add " Grant Likely
2009-06-26 23:33 ` Grant Likely
2009-06-27 0:11 ` Anton Vorontsov
2009-06-27 0:11 ` Anton Vorontsov
2009-06-26 22:29 ` [PATCH 2/4] gianfar: Revive " Anton Vorontsov
2009-06-26 22:29 ` Anton Vorontsov
2009-06-26 22:29 ` [PATCH 3/4] ucc_geth: " Anton Vorontsov
2009-06-26 22:29 ` Anton Vorontsov
2009-06-26 22:29 ` [PATCH 4/4] fs_enet: " Anton Vorontsov
2009-06-26 22:29 ` Anton Vorontsov
2009-06-26 23:35 ` [PATCH 0/4 for 2.6.31] NET: " Grant Likely
2009-06-26 23:35 ` Grant Likely
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=20090626222945.GA32487@oksana.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=afleming@freescale.com \
--cc=davem@davemloft.net \
--cc=leoli@freescale.com \
--cc=linuxppc-dev@ozlabs.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 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.