All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: davem@davemloft.net, jakub.kicinski@netronome.com,
	linux@armlinux.org.uk, andrew@lunn.ch, f.fainelli@gmail.com,
	vivien.didelot@gmail.com
Cc: alexandru.marginean@nxp.com, claudiu.manoil@nxp.com,
	xiaoliang.yang_1@nxp.com, yangbo.lu@nxp.com,
	netdev@vger.kernel.org, alexandre.belloni@bootlin.com,
	horatiu.vultur@microchip.com, UNGLinuxDriver@microchip.com,
	Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: [PATCH v3 net-next 06/11] net: phy: vsc8514: configure explicit in-band SGMII auto-negotiation settings
Date: Fri, 27 Dec 2019 23:36:21 +0200	[thread overview]
Message-ID: <20191227213626.4404-7-olteanv@gmail.com> (raw)
In-Reply-To: <20191227213626.4404-1-olteanv@gmail.com>

From: Alex Marginean <alexandru.marginean@nxp.com>

The IN_BAND_AN_DEFAULT setting for the VSC8514 PHY is not very reliable:
its out-of-reset state is with SerDes AN disabled, but certain boot
firmware (such as U-Boot) enables it during the boot process.

So its final state as seen by Linux depends on whether the U-Boot PHY
driver has run or not.

If SGMII auto-negotiation is enabled but not acknowledged by the MAC,
the PHY does not pass traffic.

But otherwise, it is able to pass traffic both with AN disabled, and
with AN enabled. So make it explicitly configurable.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
Changes in v3:
- Patch is new.

 drivers/net/phy/mscc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c
index 50214c081164..b9a22474a715 100644
--- a/drivers/net/phy/mscc.c
+++ b/drivers/net/phy/mscc.c
@@ -176,6 +176,8 @@ enum rgmii_rx_clock_delay {
 #define SECURE_ON_PASSWD_LEN_4		  0x4000
 
 /* Extended Page 3 Registers */
+#define MSCC_PHY_SERDES_CON		  16
+#define MSCC_PHY_SERDES_ANEG		  BIT(7)
 #define MSCC_PHY_SERDES_TX_VALID_CNT	  21
 #define MSCC_PHY_SERDES_TX_CRC_ERR_CNT	  22
 #define MSCC_PHY_SERDES_RX_VALID_CNT	  28
@@ -2157,6 +2159,19 @@ static int vsc8514_config_init(struct phy_device *phydev)
 
 	mutex_unlock(&phydev->mdio.bus->mdio_lock);
 
+	ret = phy_write(phydev, MSCC_EXT_PAGE_ACCESS, MSCC_PHY_PAGE_EXTENDED_3);
+	if (ret)
+		return ret;
+
+	if (phydev->in_band_autoneg == IN_BAND_AN_ENABLED)
+		ret = phy_set_bits(phydev, MSCC_PHY_SERDES_CON,
+				   MSCC_PHY_SERDES_ANEG);
+	else if (phydev->in_band_autoneg == IN_BAND_AN_DISABLED)
+		ret = phy_clear_bits(phydev, MSCC_PHY_SERDES_CON,
+				     MSCC_PHY_SERDES_ANEG);
+	if (ret)
+		return ret;
+
 	ret = phy_write(phydev, MSCC_EXT_PAGE_ACCESS, MSCC_PHY_PAGE_STANDARD);
 
 	if (ret)
-- 
2.17.1


  parent reply	other threads:[~2019-12-27 21:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-27 21:36 [PATCH v3 net-next 00/11] Convert Felix DSA switch to PHYLINK Vladimir Oltean
2019-12-27 21:36 ` [PATCH v3 net-next 01/11] mii: Add helpers for parsing SGMII auto-negotiation Vladimir Oltean
2019-12-27 21:36 ` [PATCH v3 net-next 02/11] net: phylink: make QSGMII a valid PHY mode for in-band AN Vladimir Oltean
2019-12-27 21:36 ` [PATCH v3 net-next 03/11] net: phylink: add support for polling MAC PCS Vladimir Oltean
2019-12-27 21:36 ` [PATCH v3 net-next 04/11] net: dsa: Pass pcs_poll flag from driver to PHYLINK Vladimir Oltean
2019-12-27 21:36 ` [PATCH v3 net-next 05/11] net: phy: Add a property for controlling in-band auto-negotiation Vladimir Oltean
2019-12-28 12:17   ` Vladimir Oltean
2019-12-27 21:36 ` Vladimir Oltean [this message]
2019-12-27 21:36 ` [PATCH v3 net-next 07/11] enetc: Make MDIO accessors more generic and export to include/linux/fsl Vladimir Oltean
2019-12-27 21:36 ` [PATCH v3 net-next 08/11] enetc: Set MDIO_CFG_HOLD to the recommended value of 2 Vladimir Oltean
2019-12-27 21:36 ` [PATCH v3 net-next 09/11] net: mscc: ocelot: make phy_mode a member of the common struct ocelot_port Vladimir Oltean
2019-12-27 21:36 ` [PATCH v3 net-next 10/11] net: mscc: ocelot: export ANA, DEV and QSYS registers to include/soc/mscc Vladimir Oltean
2019-12-27 21:36 ` [PATCH v3 net-next 11/11] net: dsa: felix: Add PCS operations for PHYLINK Vladimir Oltean

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=20191227213626.4404-7-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=xiaoliang.yang_1@nxp.com \
    --cc=yangbo.lu@nxp.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.