Add support of platforms without PHY to gianfar driver
Subsystems (4)
PATCH 1/2 Add support of platforms without PHY to gianfar driver
Gianfar driver is now able to work without real phy subnode, that is necessary to cope with fixed-link situation, when SoC is connected to the Ethernet inteface or embedded switch without any PHY. In this case, fixed-speed property will describe such a situation for gianfar driver.
The property is in form <duplexity speed>
---
arch/powerpc/sysdev/fsl_soc.c | 39 +++++++++++++++++++++++---------------- drivers/net/gianfar.c | 17 ++++++++++++++--- 2 files changed, 37 insertions(+), 19 deletions(-)
arch/powerpc/sysdev/fsl_soc.c +23 -16
@@ -255,29 +255,36 @@ static int __init gfar_of_init(void)FSL_GIANFAR_DEV_HAS_EXTENDED_HASH ; ph =of_get_property (np,"phy-handle" ,NULL ); - phy =of_find_node_by_phandle (*ph); +if (ph ==NULL ) { +unsigned int *bus_id; -if (phy ==NULL ) { - ret = -ENODEV ; - goto unreg; - } + bus_id =of_get_property (np,"fixed_speed" ,NULL ); + gfar_data.bus_id = (bus_id[0 ]<<16 ) | bus_id[1 ]; + }else { + phy =of_find_node_by_phandle (*ph); - mdio =of_get_parent (phy); +if (phy ==NULL ) { + ret = -ENODEV ; + goto unreg; + } + + mdio =of_get_parent (phy); + + id =of_get_property (phy,"reg" ,NULL ); + ret =of_address_to_resource (mdio,0 , &res); +if (ret) { +of_node_put (phy); +of_node_put (mdio); + goto unreg; + } + + gfar_data.phy_id = *id; + gfar_data.bus_id = res.start; - id =of_get_property (phy,"reg" ,NULL ); - ret =of_address_to_resource (mdio,0 , &res); -if (ret) {of_node_put (phy);of_node_put (mdio); - goto unreg; } - gfar_data.phy_id = *id; - gfar_data.bus_id = res.start; - -of_node_put (phy); -of_node_put (mdio); - ret = platform_device_add_data(gfar_dev, &gfar_data, sizeof(struct
drivers/net/gianfar.c +14 -3
@@ -93,6 +93,7 @@#include <linux/crc32.h> #include <linux/mii.h> #include <linux/phy.h> +#include <linux/phy_fixed.h> #include "gianfar.h" #include "gianfar_mii.h"
@@ -445,11 +446,21 @@ static int init_phy(struct net_device *dev) priv->oldspeed =0 ; priv->oldduplex =-1 ; -snprintf (phy_id,BUS_ID_SIZE ,PHY_ID_FMT , priv->einfo->bus_id, priv->einfo->phy_id); - interface =gfar_get_interface (dev); - phydev =phy_connect (dev, phy_id, &adjust_link,0 , interface); +if (priv->einfo->phy_id) { +snprintf (phy_id,BUS_ID_SIZE ,PHY_ID_FMT , priv->einfo->bus_id, priv->einfo->phy_id); + phydev =phy_connect (dev, phy_id, &adjust_link,0 , interface); + }else { +struct fixed_info *phyinfo; +int phy_addr = (priv->einfo->bus_id >>16 ); + + phyinfo =fixed_mdio_get_phydev (phy_addr-1 ); + phydev = phyinfo->phydev; +snprintf (phydev->dev.bus_id,BUS_ID_SIZE ,PHY_ID_FMT , + (priv->einfo->bus_id &0xffff ) , phy_addr); +memset (phyinfo->regs,0xff ,sizeof (phyinfo->regs[0 ])*phyinfo->regs_num); + }if (IS_ERR (phydev)) {printk (KERN_ERR "%s: Could not attach to PHY\n" , dev->name);
PATCH 2/2 Remove dummy network phy from MPC8313E-RDB
Cleaned up inexistent network phy from the target dts, added necessary property to gianfar node there.
---
arch/powerpc/boot/dts/mpc8313erdb.dts | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
arch/powerpc/boot/dts/mpc8313erdb.dts +1 -7
@@ -98,12 +98,6 @@ reg = <24520 20>; #address-cells = <1>; #size-cells = <0>; - phy1: ethernet-phy@1 { - interrupt-parent = < &ipic >; - interrupts = <13 8>; - reg = <1>; - device_type = "ethernet-phy"; - }; phy4: ethernet-phy@4 { interrupt-parent = < &ipic >; interrupts = <14 8>;
@@ -120,7 +114,7 @@ local-mac-address = [ 00 00 00 00 00 00 ]; interrupts = <25 8 24 8 23 8>; interrupt-parent = < &ipic >; - phy-handle = < &phy1 >; + fixed_speed = <1 1000>; }; ethernet@25000 {
I'll let paulus and linuxppc merge this one (or not)...
Jeff
Quoted 1 line · Jeff Garzik
I'll let paulus and linuxppc merge this one (or not)...
That would most likely be me, than paulus. Since this is for a Freescale PPC SoC.
- k
Quoted 7 lines · On Wed, 25 Jul 2007 21:43:12 +0400 Vitaly Bordug <[email protected]>…
Gianfar driver is now able to work without real phy subnode, that is necessary to cope with fixed-link situation, when SoC is connected to the Ethernet inteface or embedded switch without any PHY. In this case, fixed-speed property will describe such a situation for gianfar driver.
Quoted 8 lines
The property is in form <duplexity speed>
Signed-off-by Vitaly Bordug <[email protected]>---
arch/powerpc/sysdev/fsl_soc.c | 39 +++++++++++++++++++++++---------------- drivers/net/gianfar.c | 17 ++++++++++++++---
please run this through checkpatch.pl until it passes.
<snip>
arch/powerpc/sysdev/fsl_soc.c static int __init gfar_of_init(void) · line 261
Quoted 1 line
arch/powerpc/sysdev/fsl_soc.c +1
-0+ bus_id =of_get_property (np,"fixed_speed" ,NULL );
hyphens are preferred for new properties. Plus, isn't fixed-link a better name? unless you instead want to put speed first and make duplexity an optional second, or possibly even a string.
Also, can we get this new property documented in b-w-of in a separate patch?
Kim
Quoted 30 lines · On Thu, 26 Jul 2007 19:04:17 -0500 Kim Phillips wrote:
Quoted 9 lines · On Wed, 25 Jul 2007 21:43:12 +0400 Vitaly Bordug <[email protected]>…
Gianfar driver is now able to work without real phy subnode, that is necessary to cope with fixed-link situation, when SoC is connected to the Ethernet inteface or embedded switch without any PHY. In this case, fixed-speed property will describe such a situation for gianfar driver.
The property is in form <duplexity speed>
Quoted 7 lines
Signed-off-by Vitaly Bordug <[email protected]>---
arch/powerpc/sysdev/fsl_soc.c | 39+++++++++++++++++++++++----------------
drivers/net/gianfar.c| 17 ++++++++++++++---please run this through checkpatch.pl until it passes.
<snip>
Quoted 2 lines
(quoted diff) +1
-0+ bus_id = of_get_property(np,"fixed_speed",NULL);
hyphens are preferred for new properties. Plus, isn't fixed-link a better name? unless you instead want to put speed first and make duplexity an optional second, or possibly even a string.
Quoted 3 lines
Also, can we get this new property documented in b-w-of in a separate patch?
yes, fixed-link is better name.
I'll redo the patch, thx
Quoted 1 line
Kim
Signature · 1 line
Sincerely, Vitaly