diff options
| author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-07-16 17:31:31 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2009-07-22 12:27:18 -0400 |
| commit | 24c30dbbcdda9aeccb23b4eecb6bb8e538742ea4 (patch) | |
| tree | 3b19ab216397bae4712e435d68f1e40ce444527b | |
| parent | a947a39d52f5b647a2fd5eca55d39e722a2fa90f (diff) | |
of/mdio: Add support function for Ethernet fixed-link property
Fixed-link support is broken for the ucc_eth, gianfar, and fs_enet
device drivers. The "OF MDIO rework" patches removed most of the
support. Instead of re-adding fixed-link stuff to the drivers, this
patch adds a support function for parsing the fixed-link property
and obtaining a dummy phy to match.
Note: the dummy phy handling in arch/powerpc is a bit of a hack and
needs to be reworked. This function is being added now to solve the
regression in the Ethernet drivers, but it should be considered a
temporary measure until the fixed link handling can be reworked.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/of/of_mdio.c | 42 | ||||
| -rw-r--r-- | include/linux/of_mdio.h | 3 |
2 files changed, 45 insertions, 0 deletions
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index aee967d7f760..bacaa536fd51 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c | |||
| @@ -9,6 +9,10 @@ | |||
| 9 | * out of the OpenFirmware device tree and using it to populate an mii_bus. | 9 | * out of the OpenFirmware device tree and using it to populate an mii_bus. |
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | #include <linux/kernel.h> | ||
| 13 | #include <linux/device.h> | ||
| 14 | #include <linux/netdevice.h> | ||
| 15 | #include <linux/err.h> | ||
| 12 | #include <linux/phy.h> | 16 | #include <linux/phy.h> |
| 13 | #include <linux/of.h> | 17 | #include <linux/of.h> |
| 14 | #include <linux/of_mdio.h> | 18 | #include <linux/of_mdio.h> |
| @@ -137,3 +141,41 @@ struct phy_device *of_phy_connect(struct net_device *dev, | |||
| 137 | return phy_connect_direct(dev, phy, hndlr, flags, iface) ? NULL : phy; | 141 | return phy_connect_direct(dev, phy, hndlr, flags, iface) ? NULL : phy; |
| 138 | } | 142 | } |
| 139 | EXPORT_SYMBOL(of_phy_connect); | 143 | EXPORT_SYMBOL(of_phy_connect); |
| 144 | |||
| 145 | /** | ||
| 146 | * of_phy_connect_fixed_link - Parse fixed-link property and return a dummy phy | ||
| 147 | * @dev: pointer to net_device claiming the phy | ||
| 148 | * @hndlr: Link state callback for the network device | ||
| 149 | * @iface: PHY data interface type | ||
| 150 | * | ||
| 151 | * This function is a temporary stop-gap and will be removed soon. It is | ||
| 152 | * only to support the fs_enet, ucc_geth and gianfar Ethernet drivers. Do | ||
| 153 | * not call this function from new drivers. | ||
| 154 | */ | ||
| 155 | struct phy_device *of_phy_connect_fixed_link(struct net_device *dev, | ||
| 156 | void (*hndlr)(struct net_device *), | ||
| 157 | phy_interface_t iface) | ||
| 158 | { | ||
| 159 | struct device_node *net_np; | ||
| 160 | char bus_id[MII_BUS_ID_SIZE + 3]; | ||
| 161 | struct phy_device *phy; | ||
| 162 | const u32 *phy_id; | ||
| 163 | int sz; | ||
| 164 | |||
| 165 | if (!dev->dev.parent) | ||
| 166 | return NULL; | ||
| 167 | |||
| 168 | net_np = dev_archdata_get_node(&dev->dev.parent->archdata); | ||
| 169 | if (!net_np) | ||
| 170 | return NULL; | ||
| 171 | |||
| 172 | phy_id = of_get_property(net_np, "fixed-link", &sz); | ||
| 173 | if (!phy_id || sz < sizeof(*phy_id)) | ||
| 174 | return NULL; | ||
| 175 | |||
| 176 | sprintf(bus_id, PHY_ID_FMT, "0", phy_id[0]); | ||
| 177 | |||
| 178 | phy = phy_connect(dev, bus_id, hndlr, 0, iface); | ||
| 179 | return IS_ERR(phy) ? NULL : phy; | ||
| 180 | } | ||
| 181 | EXPORT_SYMBOL(of_phy_connect_fixed_link); | ||
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h index c9663c690303..53b94e025c7c 100644 --- a/include/linux/of_mdio.h +++ b/include/linux/of_mdio.h | |||
| @@ -18,5 +18,8 @@ extern struct phy_device *of_phy_connect(struct net_device *dev, | |||
| 18 | struct device_node *phy_np, | 18 | struct device_node *phy_np, |
| 19 | void (*hndlr)(struct net_device *), | 19 | void (*hndlr)(struct net_device *), |
| 20 | u32 flags, phy_interface_t iface); | 20 | u32 flags, phy_interface_t iface); |
| 21 | extern struct phy_device *of_phy_connect_fixed_link(struct net_device *dev, | ||
| 22 | void (*hndlr)(struct net_device *), | ||
| 23 | phy_interface_t iface); | ||
| 21 | 24 | ||
| 22 | #endif /* __LINUX_OF_MDIO_H */ | 25 | #endif /* __LINUX_OF_MDIO_H */ |
