Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1682204 > unrolled thread

[PATCH] net: axienet: add support for standard phy-mode binding

Started byAlvaro Gamez Machado <alvaro.gamez@hazent.com>
First post2017-07-06 11:00 +0200
Last post2017-07-06 15:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: axienet: add support for standard phy-mode binding Alvaro Gamez Machado <alvaro.gamez@hazent.com> - 2017-07-06 11:00 +0200
    Re: [PATCH] net: axienet: add support for standard phy-mode binding Andrew Lunn <andrew@lunn.ch> - 2017-07-06 15:40 +0200

#1682204 — [PATCH] net: axienet: add support for standard phy-mode binding

FromAlvaro Gamez Machado <alvaro.gamez@hazent.com>
Date2017-07-06 11:00 +0200
Subject[PATCH] net: axienet: add support for standard phy-mode binding
Message-ID<u0aNI-1Z7-17@gated-at.bofh.it>
Keep supporting proprietary "xlnx,phy-type" attribute and add support for
MII connectivity to the PHY.

Signed-off-by: Alvaro Gamez Machado <alvaro.gamez@hazent.com>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 48 +++++++++++++++++------
 1 file changed, 36 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 33c595f4691d..f669b8e69e8b 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -531,11 +531,11 @@ static void axienet_adjust_link(struct net_device *ndev)
 	link_state = phy->speed | (phy->duplex << 1) | phy->link;
 	if (lp->last_link != link_state) {
 		if ((phy->speed == SPEED_10) || (phy->speed == SPEED_100)) {
-			if (lp->phy_type == XAE_PHY_TYPE_1000BASE_X)
+			if (lp->phy_type == PHY_INTERFACE_MODE_1000BASEX)
 				setspeed = 0;
 		} else {
 			if ((phy->speed == SPEED_1000) &&
-			    (lp->phy_type == XAE_PHY_TYPE_MII))
+			    (lp->phy_type == PHY_INTERFACE_MODE_MII))
 				setspeed = 0;
 		}
 
@@ -935,15 +935,8 @@ static int axienet_open(struct net_device *ndev)
 		return ret;
 
 	if (lp->phy_node) {
-		if (lp->phy_type == XAE_PHY_TYPE_GMII) {
-			phydev = of_phy_connect(lp->ndev, lp->phy_node,
-						axienet_adjust_link, 0,
-						PHY_INTERFACE_MODE_GMII);
-		} else if (lp->phy_type == XAE_PHY_TYPE_RGMII_2_0) {
-			phydev = of_phy_connect(lp->ndev, lp->phy_node,
-						axienet_adjust_link, 0,
-						PHY_INTERFACE_MODE_RGMII_ID);
-		}
+		phydev = of_phy_connect(lp->ndev, lp->phy_node,
+					axienet_adjust_link, 0, lp->phy_type);
 
 		if (!phydev)
 			dev_err(lp->dev, "of_phy_connect() failed\n");
@@ -1539,7 +1532,38 @@ static int axienet_probe(struct platform_device *pdev)
 	 * the device-tree and accordingly set flags.
 	 */
 	of_property_read_u32(pdev->dev.of_node, "xlnx,rxmem", &lp->rxmem);
-	of_property_read_u32(pdev->dev.of_node, "xlnx,phy-type", &lp->phy_type);
+
+	/* Start with the proprietary, and broken phy_type */
+	ret = of_property_read_u32(pdev->dev.of_node, "xlnx,phy-type", &value);
+	if (!ret) {
+		netdev_warn(ndev, "Please upgrade your device tree binary blob to use phy-mode");
+		switch (phy_type) {
+		case XAE_PHY_TYPE_MII:
+			lp->phy_type = PHY_INTERFACE_MODE_MII;
+			break;
+		case XAE_PHY_TYPE_GMII:
+			lp->phy_type = PHY_INTERFACE_MODE_GMII;
+			break;
+		case XAE_PHY_TYPE_RGMII_2_0:
+			lp->phy_type = PHY_INTERFACE_MODE_RGMII;
+			break;
+		case XAE_PHY_TYPE_SGMII:
+			lp->phy_type = PHY_INTERFACE_MODE_SGMII;
+			break;
+		case XAE_PHY_TYPE_1000BASE_X:
+			lp->phy_type = PHY_INTERFACE_MODE_1000BASEX;
+			break;
+		default:
+			ret = -EINVAL;
+			goto free_netdev;
+		}
+	} else {
+		lp->phy_type = of_get_phy_mode(pdev->dev.of_node);
+		if (lp->phy_mode < 0) {
+			ret = -EINVAL;
+			goto free_netdev;
+		}
+	}
 
 	/* Find the DMA node, map the DMA registers, and decode the DMA IRQs */
 	np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0);
-- 
2.11.0

[toc] | [next] | [standalone]


#1682439

FromAndrew Lunn <andrew@lunn.ch>
Date2017-07-06 15:40 +0200
Message-ID<u0faG-4Uc-11@gated-at.bofh.it>
In reply to#1682204
On Thu, Jul 06, 2017 at 10:50:11AM +0200, Alvaro Gamez Machado wrote:
> Keep supporting proprietary "xlnx,phy-type" attribute and add support for
> MII connectivity to the PHY.

Hi Alvaro

Thanks for picking this up.

> 
> Signed-off-by: Alvaro Gamez Machado <alvaro.gamez@hazent.com>
> ---
>  drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 48 +++++++++++++++++------
>  1 file changed, 36 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index 33c595f4691d..f669b8e69e8b 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> @@ -531,11 +531,11 @@ static void axienet_adjust_link(struct net_device *ndev)
>  	link_state = phy->speed | (phy->duplex << 1) | phy->link;
>  	if (lp->last_link != link_state) {
>  		if ((phy->speed == SPEED_10) || (phy->speed == SPEED_100)) {
> -			if (lp->phy_type == XAE_PHY_TYPE_1000BASE_X)
> +			if (lp->phy_type == PHY_INTERFACE_MODE_1000BASEX)

In my suggestion patch, i renamed it to phy_mode. That is the
convention used by other drivers. Since we are also changing what it
means, it gives the compiler a chance to error out on any instances we
didn't find and are still trying to use the old meaning.

It would be nice to document this in a device tree binding
document. Something like Documentation/devicetree/binding/net/xilinx_axienet.txt

XILINX Axi Ethernet device driver
---------------------------------

Required properties:

- compatible	: Must be one of "xlnx,axi-ethernet-1.00.a",
                  "xlnx,axi-ethernet-1.01.a", or "xlnx,axi-ethernet-2.01.a"
- reg		: Address and length of the IO space.
- interrupts    : Should be a list of two interrupt, TX and RX.

Optional properties:

- phy-mode	: See ethernet.txt
- xlnx,phy-type : Deprecated, do not use, but still accepted in preference to phy-mode.

There are other properties, but they can be added later. The important
thing is it documents this change.

Thanks
      Andrew

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web