Commit 24c30dbbcdda9aeccb23b4eecb6bb8e538742ea4
Committed by
David S. Miller
1 parent
a947a39d52
Exists in
master
and in
39 other branches
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>
Showing 2 changed files with 45 additions and 0 deletions Side-by-side Diff
drivers/of/of_mdio.c
... | ... | @@ -9,6 +9,10 @@ |
9 | 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 | 16 | #include <linux/phy.h> |
13 | 17 | #include <linux/of.h> |
14 | 18 | #include <linux/of_mdio.h> |
... | ... | @@ -137,4 +141,42 @@ |
137 | 141 | return phy_connect_direct(dev, phy, hndlr, flags, iface) ? NULL : phy; |
138 | 142 | } |
139 | 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); |
include/linux/of_mdio.h
... | ... | @@ -18,6 +18,9 @@ |
18 | 18 | struct device_node *phy_np, |
19 | 19 | void (*hndlr)(struct net_device *), |
20 | 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 | 25 | #endif /* __LINUX_OF_MDIO_H */ |