aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Daney <david.daney@cavium.com>2012-06-27 03:33:37 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-28 00:23:25 -0400
commita30e2c1891296b5ee8de48430a07fdf8b818c661 (patch)
tree3d66f111e7e5e467774eca749f6a1833b85f85b8
parent6bd47ac2e434611e52027155438d7b4ad3c76bdb (diff)
netdev/phy/of: Add more methods for binding PHY devices to drivers.
Allow PHY drivers to supply their own device matching function (match_phy_device()), or to be matched OF compatible properties. PHYs following IEEE802.3 clause 45 have more than one device identifier constants, which breaks the default device matching code. Other 10G PHYs don't follow the standard manufacturer/device identifier register layout standards, but they do use the standard MDIO bus protocols for register access. Both of these require adjustments to the PHY driver to device matching code. If the there is an of_node associated with such a PHY, we can match it to its driver using the "compatible" properties, just as we do with certain platform devices. If the "compatible" property match fails, first check if there is a driver supplied matching function, and if not fall back to the existing identifier matching rules. Signed-off-by: David Daney <david.daney@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/phy/mdio_bus.c7
-rw-r--r--include/linux/phy.h6
2 files changed, 13 insertions, 0 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 2cee6d218d2..170eb411ab5 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -25,6 +25,7 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/of_device.h>
28#include <linux/netdevice.h> 29#include <linux/netdevice.h>
29#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
30#include <linux/skbuff.h> 31#include <linux/skbuff.h>
@@ -308,6 +309,12 @@ static int mdio_bus_match(struct device *dev, struct device_driver *drv)
308 struct phy_device *phydev = to_phy_device(dev); 309 struct phy_device *phydev = to_phy_device(dev);
309 struct phy_driver *phydrv = to_phy_driver(drv); 310 struct phy_driver *phydrv = to_phy_driver(drv);
310 311
312 if (of_driver_match_device(dev, drv))
313 return 1;
314
315 if (phydrv->match_phy_device)
316 return phydrv->match_phy_device(phydev);
317
311 return ((phydrv->phy_id & phydrv->phy_id_mask) == 318 return ((phydrv->phy_id & phydrv->phy_id_mask) ==
312 (phydev->phy_id & phydrv->phy_id_mask)); 319 (phydev->phy_id & phydrv->phy_id_mask));
313} 320}
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 597d05dd0fb..7eac80a2557 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -426,6 +426,12 @@ struct phy_driver {
426 /* Clears up any memory if needed */ 426 /* Clears up any memory if needed */
427 void (*remove)(struct phy_device *phydev); 427 void (*remove)(struct phy_device *phydev);
428 428
429 /* Returns true if this is a suitable driver for the given
430 * phydev. If NULL, matching is based on phy_id and
431 * phy_id_mask.
432 */
433 int (*match_phy_device)(struct phy_device *phydev);
434
429 /* Handles ethtool queries for hardware time stamping. */ 435 /* Handles ethtool queries for hardware time stamping. */
430 int (*ts_info)(struct phy_device *phydev, struct ethtool_ts_info *ti); 436 int (*ts_info)(struct phy_device *phydev, struct ethtool_ts_info *ti);
431 437