Re: [PATCH] Add support for configuring the PHY connection interface
Andy Fleming wrote: Most PHYs connect to an ethernet controller over a GMII or MII interface. However, a growing number are connected over different interfaces, such as RGMII or SGMII. The ethernet driver will tell the PHY what type of connection it is by setting it manually, or passing it in through phy_connect (or phy_attach). Changes include: * Updates to documentation * Updates to other PHY Lib consumers * Changes to PHY Lib to add interface support * Some minor changes to whitespace in phy.h * interface values now passed to gianfar Signed-off-by: Andrew Fleming [EMAIL PROTECTED] ACK technical content, but Applying 'Add support for configuring the PHY connection interface' error: patch failed: arch/powerpc/sysdev/fsl_soc.c:211 error: arch/powerpc/sysdev/fsl_soc.c: patch does not apply - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Add support for configuring the PHY connection interface
Hi Andy, Andy Fleming wrote: diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index b4b5b4a..b053370 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -211,6 +211,36 @@ static int __init gfar_set_flags(struct return device_flags; } +/* Return the Linux interface mode type based on the + * specification in the device-tree */ +static int __init gfar_get_interface(struct device_node *np) +{ + const char *istr; + int interface = 0; + + istr = get_property(np, interface, NULL); + + if (istr == NULL) + istr = GMII; + + if (!strcasecmp(istr, GMII)) + interface = PHY_INTERFACE_MODE_GMII; + else if (!strcasecmp(istr, MII)) + interface = PHY_INTERFACE_MODE_MII; + else if (!strcasecmp(istr, RGMII)) + interface = PHY_INTERFACE_MODE_RGMII; + else if (!strcasecmp(istr, SGMII)) + interface = PHY_INTERFACE_MODE_SGMII; + else if (!strcasecmp(istr, TBI)) + interface = PHY_INTERFACE_MODE_TBI; + else if (!strcasecmp(istr, RMII)) + interface = PHY_INTERFACE_MODE_RMII; + else if (!strcasecmp(istr, RTBI)) + interface = PHY_INTERFACE_MODE_RTBI; + + return interface; +} If you change the modes into an enum (as suggested by Kumar), you can make a nice static lookup table indexed by mode with a for loop here. Regards Ingo Oeser - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Add support for configuring the PHY connection interface
Most PHYs connect to an ethernet controller over a GMII or MII interface. However, a growing number are connected over different interfaces, such as RGMII or SGMII. The ethernet driver will tell the PHY what type of connection it is by setting it manually, or passing it in through phy_connect (or phy_attach). Changes include: * Updates to documentation * Updates to other PHY Lib consumers * Changes to PHY Lib to add interface support * Some minor changes to whitespace in phy.h * interface values now passed to gianfar Signed-off-by: Andrew Fleming [EMAIL PROTECTED] --- Documentation/networking/phy.txt | 11 --- arch/powerpc/sysdev/fsl_soc.c | 36 drivers/net/au1000_eth.c |3 ++- drivers/net/fs_enet/fs_enet-main.c |3 ++- drivers/net/gianfar.c |5 +++-- drivers/net/phy/phy_device.c | 29 - include/linux/phy.h| 32 ++-- 7 files changed, 97 insertions(+), 22 deletions(-) diff --git a/Documentation/networking/phy.txt b/Documentation/networking/phy.txt index 29ccae4..1c9873d 100644 --- a/Documentation/networking/phy.txt +++ b/Documentation/networking/phy.txt @@ -97,11 +97,12 @@ Letting the PHY Abstraction Layer do Eve Next, you need to know the device name of the PHY connected to this device. The name will look something like, phy0:0, where the first number is the - bus id, and the second is the PHY's address on that bus. + bus id, and the second is the PHY's address on that bus. Typically, + the bus is responsible for making its ID unique. Now, to connect, just call this function: - phydev = phy_connect(dev, phy_name, adjust_link, flags); + phydev = phy_connect(dev, phy_name, adjust_link, flags, interface); phydev is a pointer to the phy_device structure which represents the PHY. If phy_connect is successful, it will return the pointer. dev, here, is the @@ -115,6 +116,10 @@ Letting the PHY Abstraction Layer do Eve This is useful if the system has put hardware restrictions on the PHY/controller, of which the PHY needs to be aware. + interface is a u32 which specifies the connection type used + between the controller and the PHY. Examples are GMII, MII, + RGMII, and SGMII. For a full list, see include/linux/phy.h + Now just make sure that phydev-supported and phydev-advertising have any values pruned from them which don't make sense for your controller (a 10/100 controller may be connected to a gigabit capable PHY, so you would need to @@ -191,7 +196,7 @@ Doing it all yourself start, or disables then frees them for stop. struct phy_device * phy_attach(struct net_device *dev, const char *phy_id, -u32 flags); +u32 flags, u32 interface); Attaches a network device to a particular PHY, binding the PHY to a generic driver if none was found during bus initialization. Passes in diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index b4b5b4a..b053370 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -211,6 +211,36 @@ static int __init gfar_set_flags(struct return device_flags; } +/* Return the Linux interface mode type based on the + * specification in the device-tree */ +static int __init gfar_get_interface(struct device_node *np) +{ + const char *istr; + int interface = 0; + + istr = get_property(np, interface, NULL); + + if (istr == NULL) + istr = GMII; + + if (!strcasecmp(istr, GMII)) + interface = PHY_INTERFACE_MODE_GMII; + else if (!strcasecmp(istr, MII)) + interface = PHY_INTERFACE_MODE_MII; + else if (!strcasecmp(istr, RGMII)) + interface = PHY_INTERFACE_MODE_RGMII; + else if (!strcasecmp(istr, SGMII)) + interface = PHY_INTERFACE_MODE_SGMII; + else if (!strcasecmp(istr, TBI)) + interface = PHY_INTERFACE_MODE_TBI; + else if (!strcasecmp(istr, RMII)) + interface = PHY_INTERFACE_MODE_RMII; + else if (!strcasecmp(istr, RTBI)) + interface = PHY_INTERFACE_MODE_RTBI; + + return interface; +} + static struct device_node * __init gfar_get_phy_node(struct device_node *np) { const phandle *ph; @@ -342,6 +372,12 @@ static int __init gfar_of_init(void) if (mac_addr) memcpy(gfar_data.mac_addr, mac_addr, 6); + gfar_data.interface = gfar_get_interface(np); + if (gfar_data.interface == 0) { + printk(gfar %d failed to set interface\n, num); + continue; + } + ret = gfar_set_phy_info(np, gfar_data.phy_id, gfar_data.bus_id, gfar_data.phy_flags); if (ret) { diff --git a/drivers/net/au1000_eth.c
Re: [PATCH] Add support for configuring the PHY connection interface
On Nov 8, 2006, at 12:10 AM, Andy Fleming wrote: Most PHYs connect to an ethernet controller over a GMII or MII interface. However, a growing number are connected over different interfaces, such as RGMII or SGMII. The ethernet driver will tell the PHY what type of connection it is by setting it manually, or passing it in through phy_connect (or phy_attach). Changes include: * Updates to documentation * Updates to other PHY Lib consumers * Changes to PHY Lib to add interface support * Some minor changes to whitespace in phy.h * interface values now passed to gianfar Signed-off-by: Andrew Fleming [EMAIL PROTECTED] Any reason to not make interface an enum? - k --- Documentation/networking/phy.txt | 11 --- arch/powerpc/sysdev/fsl_soc.c | 36 + +++ drivers/net/au1000_eth.c |3 ++- drivers/net/fs_enet/fs_enet-main.c |3 ++- drivers/net/gianfar.c |5 +++-- drivers/net/phy/phy_device.c | 29 +++ +- include/linux/phy.h| 32 + +-- 7 files changed, 97 insertions(+), 22 deletions(-) diff --git a/Documentation/networking/phy.txt b/Documentation/ networking/phy.txt index 29ccae4..1c9873d 100644 --- a/Documentation/networking/phy.txt +++ b/Documentation/networking/phy.txt @@ -97,11 +97,12 @@ Letting the PHY Abstraction Layer do Eve Next, you need to know the device name of the PHY connected to this device. The name will look something like, phy0:0, where the first number is the - bus id, and the second is the PHY's address on that bus. + bus id, and the second is the PHY's address on that bus. Typically, + the bus is responsible for making its ID unique. Now, to connect, just call this function: - phydev = phy_connect(dev, phy_name, adjust_link, flags); + phydev = phy_connect(dev, phy_name, adjust_link, flags, interface); phydev is a pointer to the phy_device structure which represents the PHY. If phy_connect is successful, it will return the pointer. dev, here, is the @@ -115,6 +116,10 @@ Letting the PHY Abstraction Layer do Eve This is useful if the system has put hardware restrictions on the PHY/controller, of which the PHY needs to be aware. + interface is a u32 which specifies the connection type used + between the controller and the PHY. Examples are GMII, MII, + RGMII, and SGMII. For a full list, see include/linux/phy.h + Now just make sure that phydev-supported and phydev-advertising have any values pruned from them which don't make sense for your controller (a 10/100 controller may be connected to a gigabit capable PHY, so you would need to @@ -191,7 +196,7 @@ Doing it all yourself start, or disables then frees them for stop. struct phy_device * phy_attach(struct net_device *dev, const char *phy_id, -u32 flags); +u32 flags, u32 interface); Attaches a network device to a particular PHY, binding the PHY to a generic driver if none was found during bus initialization. Passes in diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/ fsl_soc.c index b4b5b4a..b053370 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -211,6 +211,36 @@ static int __init gfar_set_flags(struct return device_flags; } +/* Return the Linux interface mode type based on the + * specification in the device-tree */ +static int __init gfar_get_interface(struct device_node *np) +{ + const char *istr; + int interface = 0; + + istr = get_property(np, interface, NULL); + + if (istr == NULL) + istr = GMII; + + if (!strcasecmp(istr, GMII)) + interface = PHY_INTERFACE_MODE_GMII; + else if (!strcasecmp(istr, MII)) + interface = PHY_INTERFACE_MODE_MII; + else if (!strcasecmp(istr, RGMII)) + interface = PHY_INTERFACE_MODE_RGMII; + else if (!strcasecmp(istr, SGMII)) + interface = PHY_INTERFACE_MODE_SGMII; + else if (!strcasecmp(istr, TBI)) + interface = PHY_INTERFACE_MODE_TBI; + else if (!strcasecmp(istr, RMII)) + interface = PHY_INTERFACE_MODE_RMII; + else if (!strcasecmp(istr, RTBI)) + interface = PHY_INTERFACE_MODE_RTBI; + + return interface; +} + static struct device_node * __init gfar_get_phy_node(struct device_node *np) { const phandle *ph; @@ -342,6 +372,12 @@ static int __init gfar_of_init(void) if (mac_addr) memcpy(gfar_data.mac_addr, mac_addr, 6); + gfar_data.interface = gfar_get_interface(np); + if (gfar_data.interface == 0) { + printk(gfar %d failed to set interface\n, num); + continue; + } + ret = gfar_set_phy_info(np, gfar_data.phy_id,
Re: [PATCH] Add support for configuring the PHY connection interface
On Nov 8, 2006, at 00:16, Kumar Gala wrote: On Nov 8, 2006, at 12:10 AM, Andy Fleming wrote: Most PHYs connect to an ethernet controller over a GMII or MII interface. However, a growing number are connected over different interfaces, such as RGMII or SGMII. The ethernet driver will tell the PHY what type of connection it is by setting it manually, or passing it in through phy_connect (or phy_attach). Changes include: * Updates to documentation * Updates to other PHY Lib consumers * Changes to PHY Lib to add interface support * Some minor changes to whitespace in phy.h * interface values now passed to gianfar Signed-off-by: Andrew Fleming [EMAIL PROTECTED] Any reason to not make interface an enum? I became mildly attached to the notion of having a reduced bit. I'd be open to changing it. - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html