aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev/fsl_soc.c
diff options
context:
space:
mode:
authorVitaly Bordug <vitb@kernel.crashing.org>2007-12-06 17:51:31 -0500
committerKumar Gala <galak@kernel.crashing.org>2008-01-23 20:34:04 -0500
commita21e282a124f4679c040087ab73aa5b147d4275f (patch)
treee4577d144198456c812d45fa4921b7c4ec3e3fb8 /arch/powerpc/sysdev/fsl_soc.c
parente30007656463228ba23748df81a786f74dabf8b4 (diff)
[POWERPC] fsl_soc: add support to gianfar for fixed-link property
fixed-link says: register new "Fixed/emulated PHY", i.e. PHY that not connected to the real MDIO bus. Signed-off-by: Vitaly Bordug <vitb@kernel.crashing.org> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/sysdev/fsl_soc.c')
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c79
1 files changed, 62 insertions, 17 deletions
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index f5c240242cfd..474cb8e22f64 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -24,6 +24,7 @@
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/of_platform.h> 25#include <linux/of_platform.h>
26#include <linux/phy.h> 26#include <linux/phy.h>
27#include <linux/phy_fixed.h>
27#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
28#include <linux/fsl_devices.h> 29#include <linux/fsl_devices.h>
29#include <linux/fs_enet_pd.h> 30#include <linux/fs_enet_pd.h>
@@ -130,6 +131,37 @@ u32 get_baudrate(void)
130EXPORT_SYMBOL(get_baudrate); 131EXPORT_SYMBOL(get_baudrate);
131#endif /* CONFIG_CPM2 */ 132#endif /* CONFIG_CPM2 */
132 133
134#ifdef CONFIG_FIXED_PHY
135static int __init of_add_fixed_phys(void)
136{
137 int ret;
138 struct device_node *np;
139 u32 *fixed_link;
140 struct fixed_phy_status status = {};
141
142 for_each_node_by_name(np, "ethernet") {
143 fixed_link = (u32 *)of_get_property(np, "fixed-link", NULL);
144 if (!fixed_link)
145 continue;
146
147 status.link = 1;
148 status.duplex = fixed_link[1];
149 status.speed = fixed_link[2];
150 status.pause = fixed_link[3];
151 status.asym_pause = fixed_link[4];
152
153 ret = fixed_phy_add(PHY_POLL, fixed_link[0], &status);
154 if (ret) {
155 of_node_put(np);
156 return ret;
157 }
158 }
159
160 return 0;
161}
162arch_initcall(of_add_fixed_phys);
163#endif /* CONFIG_FIXED_PHY */
164
133static int __init gfar_mdio_of_init(void) 165static int __init gfar_mdio_of_init(void)
134{ 166{
135 struct device_node *np = NULL; 167 struct device_node *np = NULL;
@@ -198,7 +230,6 @@ static const char *gfar_tx_intr = "tx";
198static const char *gfar_rx_intr = "rx"; 230static const char *gfar_rx_intr = "rx";
199static const char *gfar_err_intr = "error"; 231static const char *gfar_err_intr = "error";
200 232
201
202static int __init gfar_of_init(void) 233static int __init gfar_of_init(void)
203{ 234{
204 struct device_node *np; 235 struct device_node *np;
@@ -282,29 +313,43 @@ static int __init gfar_of_init(void)
282 gfar_data.interface = PHY_INTERFACE_MODE_MII; 313 gfar_data.interface = PHY_INTERFACE_MODE_MII;
283 314
284 ph = of_get_property(np, "phy-handle", NULL); 315 ph = of_get_property(np, "phy-handle", NULL);
285 phy = of_find_node_by_phandle(*ph); 316 if (ph == NULL) {
317 u32 *fixed_link;
286 318
287 if (phy == NULL) { 319 fixed_link = (u32 *)of_get_property(np, "fixed-link",
288 ret = -ENODEV; 320 NULL);
289 goto unreg; 321 if (!fixed_link) {
290 } 322 ret = -ENODEV;
323 goto unreg;
324 }
291 325
292 mdio = of_get_parent(phy); 326 gfar_data.bus_id = 0;
327 gfar_data.phy_id = fixed_link[0];
328 } else {
329 phy = of_find_node_by_phandle(*ph);
330
331 if (phy == NULL) {
332 ret = -ENODEV;
333 goto unreg;
334 }
335
336 mdio = of_get_parent(phy);
337
338 id = of_get_property(phy, "reg", NULL);
339 ret = of_address_to_resource(mdio, 0, &res);
340 if (ret) {
341 of_node_put(phy);
342 of_node_put(mdio);
343 goto unreg;
344 }
345
346 gfar_data.phy_id = *id;
347 gfar_data.bus_id = res.start;
293 348
294 id = of_get_property(phy, "reg", NULL);
295 ret = of_address_to_resource(mdio, 0, &res);
296 if (ret) {
297 of_node_put(phy); 349 of_node_put(phy);
298 of_node_put(mdio); 350 of_node_put(mdio);
299 goto unreg;
300 } 351 }
301 352
302 gfar_data.phy_id = *id;
303 gfar_data.bus_id = res.start;
304
305 of_node_put(phy);
306 of_node_put(mdio);
307
308 ret = 353 ret =
309 platform_device_add_data(gfar_dev, &gfar_data, 354 platform_device_add_data(gfar_dev, &gfar_data,
310 sizeof(struct 355 sizeof(struct