u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: u-boot@lists.denx.de, Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	Priyanka Jain <priyanka.jain@nxp.com>
Subject: [PATCH 4/9] net: introduce a helper to determine whether to use in-band autoneg
Date: Tue, 28 Sep 2021 02:48:20 +0300	[thread overview]
Message-ID: <20210927234825.823582-5-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20210927234825.823582-1-vladimir.oltean@nxp.com>

Certain serial SERDES protocols like 1000base-x, 2500base-x, SGMII,
USXGMII can operate either in a mode where the PHY (be it on-board or
inside an SFP module) passes the link parameters (speed, duplex, pause)
to the MAC through in-band through control words standardized by IEEE
802.3 clause 37, or in a mode where the MAC must configure (force) its
link parameters based on information obtained out-of-band (MDIO reads,
guesswork etc).

In Linux, the OF node property named "managed" is parsed by the phylink
framework, and the convention is that if a driver uses phylink, then the
presence of this property means that in-band autoneg should be enabled,
otherwise it shouldn't.

To be compatible with the OF node bindings of drivers that use phylink
in Linux, introduce parsing support for this property in U-Boot too.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/core/of_extra.c | 12 ++++++++++++
 include/dm/of_extra.h   | 14 ++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/core/of_extra.c b/drivers/core/of_extra.c
index 632a1c2210e8..59ce9174ad07 100644
--- a/drivers/core/of_extra.c
+++ b/drivers/core/of_extra.c
@@ -155,3 +155,15 @@ bool ofnode_phy_is_fixed_link(ofnode eth_node, ofnode *phy_node)
 
 	return true;
 }
+
+bool ofnode_eth_uses_inband_aneg(ofnode eth_node)
+{
+	bool inband_aneg = false;
+	const char *managed;
+
+	managed = ofnode_read_string(eth_node, "managed");
+	if (managed && !strcmp(managed, "in-band-status"))
+		inband_aneg = true;
+
+	return inband_aneg;
+}
diff --git a/include/dm/of_extra.h b/include/dm/of_extra.h
index f0d205491c16..c2498aa5859c 100644
--- a/include/dm/of_extra.h
+++ b/include/dm/of_extra.h
@@ -114,4 +114,18 @@ int ofnode_decode_memory_region(ofnode config_node, const char *mem_type,
  */
 bool ofnode_phy_is_fixed_link(ofnode eth_node, ofnode *phy_node);
 
+/**
+ * ofnode_eth_uses_inband_aneg() - Detect whether MAC should use in-band autoneg
+ *
+ * This function detects whether the Ethernet controller should use IEEE 802.3
+ * clause 37 in-band autonegotiation for serial protocols such as 1000base-x,
+ * SGMII, USXGMII, etc. The property is relevant when the Ethernet controller
+ * is connected to an on-board PHY or an SFP cage, and is not relevant when it
+ * has a fixed link (in that case, in-band autoneg should not be used).
+ *
+ * @param eth_node	ofnode belonging to the Ethernet controller
+ * @return true if in-band autoneg should be used, false otherwise
+ */
+bool ofnode_eth_uses_inband_aneg(ofnode eth_node);
+
 #endif
-- 
2.25.1


  parent reply	other threads:[~2021-09-27 23:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 23:48 [PATCH 0/9] Support the SJA1105 DSA switch on the NXP LS1021A-TSN board Vladimir Oltean
2021-09-27 23:48 ` [PATCH 1/9] net: tsec: add support for promiscuous mode Vladimir Oltean
2021-09-28 13:34   ` Ramon Fried
2021-09-29  2:32   ` Bin Meng
2021-09-27 23:48 ` [PATCH 2/9] include: import if_vlan.h from Linux Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-29  2:32   ` Bin Meng
2021-09-27 23:48 ` [PATCH 3/9] net: dsa: allow drivers to get the port OF node Vladimir Oltean
2021-09-28 13:34   ` Ramon Fried
2021-09-27 23:48 ` Vladimir Oltean [this message]
2021-09-28 13:34   ` [PATCH 4/9] net: introduce a helper to determine whether to use in-band autoneg Ramon Fried
2021-09-29  2:32   ` Bin Meng
2021-09-27 23:48 ` [PATCH 5/9] net: dsa: felix: configure the in-band autoneg property based on OF node info Vladimir Oltean
2021-09-28 13:34   ` Ramon Fried
2021-09-29 12:21     ` Vladimir Oltean
2021-09-27 23:48 ` [PATCH 6/9] net: add driver for NXP SJA1105 DSA L2 switch Vladimir Oltean
2021-09-28 13:35   ` Ramon Fried
2021-09-27 23:48 ` [PATCH 7/9] arm: dts: ls1021a-tsn: add sja1105 and eth2 bindings Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-27 23:48 ` [PATCH 8/9] configs: ls1021a-tsn: enable sja1105 switch driver Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-29  2:33   ` Bin Meng
2021-09-27 23:48 ` [PATCH 9/9] configs: ls1021a-tsn: enable the generation of random Ethernet MAC addresses Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-29  2:33   ` Bin Meng

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=20210927234825.823582-5-vladimir.oltean@nxp.com \
    --to=vladimir.oltean@nxp.com \
    --cc=joe.hershberger@ni.com \
    --cc=priyanka.jain@nxp.com \
    --cc=rfried.dev@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).