From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org
Cc: "Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Daniel Golle" <daniel@makrotopia.org>,
linux-kernel@vger.kernel.org,
"Nikita Yushchenko" <nikita.yoush@cogentembedded.com>,
"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>,
"Robert Marko" <robimarko@gmail.com>,
"Paweł Owoc" <frut3k7@gmail.com>,
"Sean Anderson" <sean.anderson@seco.com>,
"Jon Hunter" <jonathanh@nvidia.com>
Subject: [PATCH net-next 02/15] net: phy: aquantia: merge aqr113c_fill_interface_modes() into aqr107_fill_interface_modes()
Date: Thu, 21 Aug 2025 18:20:09 +0300 [thread overview]
Message-ID: <20250821152022.1065237-3-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20250821152022.1065237-1-vladimir.oltean@nxp.com>
I'm unsure whether intentionate or not, but I think the (partially
observed) naming convention in this driver is that function prefixes
denote the earliest generation when a feature is available. In case of
aqr107_fill_interface_modes(), that means that the GLOBAL_CFG registers
are a Gen2 feature. Supporting evidence: the AQR105, a Gen1 PHY, does
not have these registers, thus the function is not named aqr105_*.
Based on this inferred naming scheme, I am proposing a refinement of
commit a7f3abcf6357 ("net: phy: aquantia: only poll GLOBAL_CFG regs on
aqr113, aqr113c and aqr115c") which introduced aqr113c_fill_interface_modes(),
suggesting this may be a Gen4 PHY feature.
The long-term goal is for aqr107_config_init() to tail-call
aqr107_fill_interface_modes(), such that the latter function is also
called by AQR107 itself, and many other PHY drivers. Currently it can't,
because aqr113c_config_init() calls aqr107_config_init() and then
aqr113c_fill_interface_modes(). So this would lead to a duplicate call
to aqr107_fill_interface_modes() for AQR113C.
Centralize the reading of GLOBAL_CFG registers in the AQR107 method, and
create a boolean, set to true by AQR113C, which tests whether waiting
for a non-zero value in the GLOBAL_CFG_100M register is necessary.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/phy/aquantia/aquantia.h | 1 +
drivers/net/phy/aquantia/aquantia_main.c | 41 ++++++++++++------------
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/drivers/net/phy/aquantia/aquantia.h b/drivers/net/phy/aquantia/aquantia.h
index 0c78bfabace5..67ec6f7484af 100644
--- a/drivers/net/phy/aquantia/aquantia.h
+++ b/drivers/net/phy/aquantia/aquantia.h
@@ -178,6 +178,7 @@ struct aqr107_priv {
u64 sgmii_stats[AQR107_SGMII_STAT_SZ];
unsigned long leds_active_low;
unsigned long leds_active_high;
+ bool wait_on_global_cfg;
};
#if IS_REACHABLE(CONFIG_HWMON)
diff --git a/drivers/net/phy/aquantia/aquantia_main.c b/drivers/net/phy/aquantia/aquantia_main.c
index 52facd318c83..b9b58c6ce686 100644
--- a/drivers/net/phy/aquantia/aquantia_main.c
+++ b/drivers/net/phy/aquantia/aquantia_main.c
@@ -991,9 +991,24 @@ static const u16 aqr_global_cfg_regs[] = {
static int aqr107_fill_interface_modes(struct phy_device *phydev)
{
unsigned long *possible = phydev->possible_interfaces;
+ struct aqr107_priv *priv = phydev->priv;
unsigned int serdes_mode, rate_adapt;
phy_interface_t interface;
- int i, val;
+ int i, val, ret;
+
+ /* It's been observed on some models that - when coming out of suspend
+ * - the FW signals that the PHY is ready but the GLOBAL_CFG registers
+ * continue on returning zeroes for some time. Let's poll the 100M
+ * register until it returns a real value as both 113c and 115c support
+ * this mode.
+ */
+ if (priv->wait_on_global_cfg) {
+ ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1,
+ VEND1_GLOBAL_CFG_100M, val,
+ val != 0, 1000, 100000, false);
+ if (ret)
+ return ret;
+ }
/* Walk the media-speed configuration registers to determine which
* host-side serdes modes may be used by the PHY depending on the
@@ -1042,25 +1057,6 @@ static int aqr107_fill_interface_modes(struct phy_device *phydev)
return 0;
}
-static int aqr113c_fill_interface_modes(struct phy_device *phydev)
-{
- int val, ret;
-
- /* It's been observed on some models that - when coming out of suspend
- * - the FW signals that the PHY is ready but the GLOBAL_CFG registers
- * continue on returning zeroes for some time. Let's poll the 100M
- * register until it returns a real value as both 113c and 115c support
- * this mode.
- */
- ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1,
- VEND1_GLOBAL_CFG_100M, val, val != 0,
- 1000, 100000, false);
- if (ret)
- return ret;
-
- return aqr107_fill_interface_modes(phydev);
-}
-
static int aqr115c_get_features(struct phy_device *phydev)
{
unsigned long *supported = phydev->supported;
@@ -1088,8 +1084,11 @@ static int aqr111_get_features(struct phy_device *phydev)
static int aqr113c_config_init(struct phy_device *phydev)
{
+ struct aqr107_priv *priv = phydev->priv;
int ret;
+ priv->wait_on_global_cfg = true;
+
ret = aqr107_config_init(phydev);
if (ret < 0)
return ret;
@@ -1103,7 +1102,7 @@ static int aqr113c_config_init(struct phy_device *phydev)
if (ret)
return ret;
- return aqr113c_fill_interface_modes(phydev);
+ return aqr107_fill_interface_modes(phydev);
}
static int aqr107_probe(struct phy_device *phydev)
--
2.34.1
next prev parent reply other threads:[~2025-08-21 15:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 15:20 [PATCH net-next 00/15] Aquantia PHY driver consolidation - part 1 Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 01/15] net: phy: aquantia: rename AQR412 to AQR412C and add real AQR412 Vladimir Oltean
2025-08-21 15:35 ` Andrew Lunn
2025-08-21 15:20 ` Vladimir Oltean [this message]
2025-08-21 16:20 ` [PATCH net-next 02/15] net: phy: aquantia: merge aqr113c_fill_interface_modes() into aqr107_fill_interface_modes() Andrew Lunn
2025-08-21 15:20 ` [PATCH net-next 03/15] net: phy: aquantia: reorder AQR113C PMD Global Transmit Disable bit clearing with supported_interfaces Vladimir Oltean
2025-08-21 16:21 ` Andrew Lunn
2025-08-21 15:20 ` [PATCH net-next 04/15] net: phy: aquantia: rename some aqr107 functions according to generation Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 05/15] net: phy: aquantia: fill supported_interfaces for all aqr_gen2_config_init() callers Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 06/15] net: phy: aquantia: save a local shadow of GLOBAL_CFG register values Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 07/15] net: phy: aquantia: remove handling for get_rate_matching(PHY_INTERFACE_MODE_NA) Vladimir Oltean
2025-08-22 3:22 ` Andrew Lunn
2025-08-21 15:20 ` [PATCH net-next 08/15] net: phy: aquantia: use cached GLOBAL_CFG registers in aqr107_read_rate() Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 09/15] net: phy: aquantia: merge and rename aqr105_read_status() and aqr107_read_status() Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 10/15] net: phy: aquantia: call aqr_gen2_fill_interface_modes() for AQCS109 Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 11/15] net: phy: aquantia: call aqr_gen3_config_init() for AQR112 and AQR412(C) Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 12/15] net: phy: aquantia: reimplement aqcs109_config_init() as aqr_gen2_config_init() Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 13/15] net: phy: aquantia: rename aqr113c_config_init() to aqr_gen4_config_init() Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 14/15] net: phy: aquantia: promote AQR813 and AQR114C " Vladimir Oltean
2025-08-21 15:20 ` [PATCH net-next 15/15] net: phy: aquantia: add support for AQR115 Vladimir Oltean
2025-08-25 17:53 ` [PATCH net-next 00/15] Aquantia PHY driver consolidation - part 1 Jakub Kicinski
2025-08-25 18:00 ` patchwork-bot+netdevbpf
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=20250821152022.1065237-3-vladimir.oltean@nxp.com \
--to=vladimir.oltean@nxp.com \
--cc=andrew@lunn.ch \
--cc=bartosz.golaszewski@linaro.org \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=frut3k7@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=nikita.yoush@cogentembedded.com \
--cc=pabeni@redhat.com \
--cc=robimarko@gmail.com \
--cc=sean.anderson@seco.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®