All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antoine Tenart <antoine.tenart@free-electrons.com>
To: davem@davemloft.net, kishon@ti.com, andrew@lunn.ch,
	jason@lakedaemon.net, sebastian.hesselbarth@gmail.com,
	gregory.clement@free-electrons.com
Cc: Antoine Tenart <antoine.tenart@free-electrons.com>,
	thomas.petazzoni@free-electrons.com, nadavh@marvell.com,
	linux@armlinux.org.uk, linux-kernel@vger.kernel.org,
	mw@semihalf.com, stefanc@marvell.com,
	miquel.raynal@free-electrons.com, netdev@vger.kernel.org
Subject: [PATCH net-next v3 07/13] net: mvpp2: do not set GMAC autoneg when using XLG MAC
Date: Mon, 28 Aug 2017 16:57:19 +0200	[thread overview]
Message-ID: <20170828145725.2539-8-antoine.tenart@free-electrons.com> (raw)
In-Reply-To: <20170828145725.2539-1-antoine.tenart@free-electrons.com>

When using the XLG MAC, it does not make sense to force the GMAC autoneg
parameters. This patch adds checks to only set the GMAC autoneg
parameters when needed (i.e. when not using the XLG MAC).

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 64 +++++++++++++++++++++++-------------
 1 file changed, 42 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index 09cad32734f3..2f05a0b0773c 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -5735,6 +5735,37 @@ static irqreturn_t mvpp2_isr(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static void mvpp2_gmac_set_autoneg(struct mvpp2_port *port,
+				   struct phy_device *phydev)
+{
+	u32 val;
+
+	if (port->phy_interface != PHY_INTERFACE_MODE_RGMII &&
+	    port->phy_interface != PHY_INTERFACE_MODE_RGMII_ID &&
+	    port->phy_interface != PHY_INTERFACE_MODE_RGMII_RXID &&
+	    port->phy_interface != PHY_INTERFACE_MODE_RGMII_TXID &&
+	    port->phy_interface != PHY_INTERFACE_MODE_SGMII)
+		return;
+
+	val = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG);
+	val &= ~(MVPP2_GMAC_CONFIG_MII_SPEED |
+		 MVPP2_GMAC_CONFIG_GMII_SPEED |
+		 MVPP2_GMAC_CONFIG_FULL_DUPLEX |
+		 MVPP2_GMAC_AN_SPEED_EN |
+		 MVPP2_GMAC_AN_DUPLEX_EN);
+
+	if (phydev->duplex)
+		val |= MVPP2_GMAC_CONFIG_FULL_DUPLEX;
+
+	if (phydev->speed == SPEED_1000)
+		val |= MVPP2_GMAC_CONFIG_GMII_SPEED;
+	else if (phydev->speed == SPEED_100)
+		val |= MVPP2_GMAC_CONFIG_MII_SPEED;
+
+	writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
+
+}
+
 /* Adjust link */
 static void mvpp2_link_event(struct net_device *dev)
 {
@@ -5745,24 +5776,7 @@ static void mvpp2_link_event(struct net_device *dev)
 	if (phydev->link) {
 		if ((port->speed != phydev->speed) ||
 		    (port->duplex != phydev->duplex)) {
-			u32 val;
-
-			val = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG);
-			val &= ~(MVPP2_GMAC_CONFIG_MII_SPEED |
-				 MVPP2_GMAC_CONFIG_GMII_SPEED |
-				 MVPP2_GMAC_CONFIG_FULL_DUPLEX |
-				 MVPP2_GMAC_AN_SPEED_EN |
-				 MVPP2_GMAC_AN_DUPLEX_EN);
-
-			if (phydev->duplex)
-				val |= MVPP2_GMAC_CONFIG_FULL_DUPLEX;
-
-			if (phydev->speed == SPEED_1000)
-				val |= MVPP2_GMAC_CONFIG_GMII_SPEED;
-			else if (phydev->speed == SPEED_100)
-				val |= MVPP2_GMAC_CONFIG_MII_SPEED;
-
-			writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
+			mvpp2_gmac_set_autoneg(port, phydev);
 
 			port->duplex = phydev->duplex;
 			port->speed  = phydev->speed;
@@ -5773,10 +5787,16 @@ static void mvpp2_link_event(struct net_device *dev)
 		port->link = phydev->link;
 
 		if (phydev->link) {
-			val = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG);
-			val |= (MVPP2_GMAC_FORCE_LINK_PASS |
-				MVPP2_GMAC_FORCE_LINK_DOWN);
-			writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
+			if (port->phy_interface == PHY_INTERFACE_MODE_RGMII ||
+			    port->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+			    port->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID ||
+			    port->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID ||
+			    port->phy_interface == PHY_INTERFACE_MODE_SGMII) {
+				val = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG);
+				val |= (MVPP2_GMAC_FORCE_LINK_PASS |
+					MVPP2_GMAC_FORCE_LINK_DOWN);
+				writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
+			}
 
 			mvpp2_interrupts_enable(port);
 			mvpp2_port_enable(port);
-- 
2.13.5

  parent reply	other threads:[~2017-08-28 14:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 14:57 [PATCH net-next v3 00/13] net: mvpp2: comphy configuration Antoine Tenart
2017-08-28 14:57 ` [PATCH net-next v3 01/13] phy: add sgmii and 10gkr modes to the phy_mode enum Antoine Tenart
2017-08-29 10:38   ` Kishon Vijay Abraham I
2017-08-29 11:27     ` Antoine Tenart
2017-08-29 12:21       ` Kishon Vijay Abraham I
2017-08-28 14:57 ` [PATCH net-next v3 02/13] phy: add the mvebu cp110 comphy driver Antoine Tenart
2017-08-29 11:04   ` Kishon Vijay Abraham I
2017-08-29 11:23     ` Antoine Tenart
2017-08-29 12:25       ` Kishon Vijay Abraham I
2017-08-29 13:12         ` Antoine Tenart
2017-08-30  5:31           ` Kishon Vijay Abraham I
2017-08-30  6:43             ` Antoine Tenart
2017-08-30  5:19   ` Kishon Vijay Abraham I
2017-08-30  6:36     ` Antoine Tenart
2017-08-28 14:57 ` [PATCH net-next v3 03/13] Documentation/bindings: phy: document the Marvell " Antoine Tenart
2017-08-28 14:57 ` [PATCH net-next v3 04/13] net: mvpp2: initialize the comphy Antoine Tenart
2017-08-28 14:57 ` [PATCH net-next v3 05/13] net: mvpp2: simplify the link_event function Antoine Tenart
2017-08-28 14:57 ` [PATCH net-next v3 06/13] net: mvpp2: improve the link management function Antoine Tenart
2017-08-28 14:57 ` Antoine Tenart [this message]
2017-08-28 14:57 ` [PATCH net-next v3 08/13] net: mvpp2: dynamic reconfiguration of the comphy/GoP/MAC Antoine Tenart
2017-08-28 14:57 ` [PATCH net-next v3 09/13] arm64: dts: marvell: extend the cp110 syscon register area length Antoine Tenart
2017-08-28 14:57 ` [PATCH net-next v3 10/13] arm64: dts: marvell: add comphy nodes on cp110 master and slave Antoine Tenart
2017-08-28 14:57 ` [PATCH net-next v3 11/13] arm64: dts: marvell: mcbin: add comphy references to Ethernet ports Antoine Tenart
2017-08-28 14:57 ` [PATCH net-next v3 12/13] arm64: dts: marvell: 7040-db: " Antoine Tenart
2017-08-28 14:57 ` [PATCH net-next v3 13/13] arm64: defconfig: enable Marvell CP110 comphy Antoine Tenart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170828145725.2539-8-antoine.tenart@free-electrons.com \
    --to=antoine.tenart@free-electrons.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=gregory.clement@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=miquel.raynal@free-electrons.com \
    --cc=mw@semihalf.com \
    --cc=nadavh@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=stefanc@marvell.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --subject='Re: [PATCH net-next v3 07/13] net: mvpp2: do not set GMAC autoneg when using XLG MAC' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.