netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
	Vladimir Zapolskiy <vz@mleia.com>
Subject: [PATCH net-next 7/9] net: stmmac: sti: use PHY_INTF_SEL_x directly
Date: Thu, 06 Nov 2025 11:23:42 +0000	[thread overview]
Message-ID: <E1vGy5e-0000000DhQb-2B7I@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <aQyEs4DAZRWpAz32@shell.armlinux.org.uk>

Use the PHY_INTF_SEL_x values directly rather than the driver private
ETH_PHY_SEL_x values. Move the FIELD_PREP() into sti_dwmac_set_mode().
Use dwmac->interface directly.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-sti.c   | 27 +++++++++----------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index 1e8769a81d77..c97535824be0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -81,11 +81,6 @@
  */
 #define MII_PHY_SEL_MASK	GENMASK(4, 2)
 #define MII_PHY_SEL_VAL(val)	FIELD_PREP_CONST(MII_PHY_SEL_MASK, val)
-#define ETH_PHY_SEL_RMII	MII_PHY_SEL_VAL(PHY_INTF_SEL_RMII)
-#define ETH_PHY_SEL_SGMII	MII_PHY_SEL_VAL(PHY_INTF_SEL_SGMII)
-#define ETH_PHY_SEL_RGMII	MII_PHY_SEL_VAL(PHY_INTF_SEL_RGMII)
-#define ETH_PHY_SEL_GMII	MII_PHY_SEL_VAL(PHY_INTF_SEL_GMII_MII)
-#define ETH_PHY_SEL_MII		MII_PHY_SEL_VAL(PHY_INTF_SEL_GMII_MII)
 
 struct sti_dwmac {
 	phy_interface_t interface;	/* MII interface */
@@ -104,13 +99,13 @@ struct sti_dwmac_of_data {
 	void (*fix_retime_src)(void *priv, int speed, unsigned int mode);
 };
 
-static u32 phy_intf_sels[] = {
-	[PHY_INTERFACE_MODE_MII] = ETH_PHY_SEL_MII,
-	[PHY_INTERFACE_MODE_GMII] = ETH_PHY_SEL_GMII,
-	[PHY_INTERFACE_MODE_RGMII] = ETH_PHY_SEL_RGMII,
-	[PHY_INTERFACE_MODE_RGMII_ID] = ETH_PHY_SEL_RGMII,
-	[PHY_INTERFACE_MODE_SGMII] = ETH_PHY_SEL_SGMII,
-	[PHY_INTERFACE_MODE_RMII] = ETH_PHY_SEL_RMII,
+static u8 phy_intf_sels[] = {
+	[PHY_INTERFACE_MODE_MII] = PHY_INTF_SEL_GMII_MII,
+	[PHY_INTERFACE_MODE_GMII] = PHY_INTF_SEL_GMII_MII,
+	[PHY_INTERFACE_MODE_RGMII] = PHY_INTF_SEL_RGMII,
+	[PHY_INTERFACE_MODE_RGMII_ID] = PHY_INTF_SEL_RGMII,
+	[PHY_INTERFACE_MODE_SGMII] = PHY_INTF_SEL_SGMII,
+	[PHY_INTERFACE_MODE_RMII] = PHY_INTF_SEL_RMII,
 };
 
 enum {
@@ -164,16 +159,18 @@ static void stih4xx_fix_retime_src(void *priv, int spd, unsigned int mode)
 static int sti_dwmac_set_mode(struct sti_dwmac *dwmac)
 {
 	struct regmap *regmap = dwmac->regmap;
-	int iface = dwmac->interface;
 	u32 reg = dwmac->ctrl_reg;
+	u8 phy_intf_sel;
 	u32 val;
 
 	if (dwmac->gmac_en)
 		regmap_update_bits(regmap, reg, EN_MASK, EN);
 
-	regmap_update_bits(regmap, reg, MII_PHY_SEL_MASK, phy_intf_sels[iface]);
+	phy_intf_sel = phy_intf_sels[dwmac->interface];
+	regmap_update_bits(regmap, reg, MII_PHY_SEL_MASK,
+			   FIELD_PREP(MII_PHY_SEL_MASK, phy_intf_sel));
 
-	val = (iface == PHY_INTERFACE_MODE_REVMII) ? 0 : ENMII;
+	val = (dwmac->interface == PHY_INTERFACE_MODE_REVMII) ? 0 : ENMII;
 	regmap_update_bits(regmap, reg, ENMII_MASK, val);
 
 	dwmac->fix_retime_src(dwmac, dwmac->speed, 0);
-- 
2.47.3


  parent reply	other threads:[~2025-11-06 11:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06 11:21 [PATCH net-next 0/9] net: stmmac: lpc18xx and sti: convert to set_phy_intf_sel() Russell King (Oracle)
2025-11-06 11:23 ` [PATCH net-next 1/9] net: stmmac: lpc18xx: convert to PHY_INTF_SEL_x Russell King (Oracle)
2025-11-06 11:23 ` [PATCH net-next 2/9] net: stmmac: lpc18xx: use PHY_INTF_SEL_x directly Russell King (Oracle)
2025-11-06 11:23 ` [PATCH net-next 3/9] net: stmmac: lpc18xx: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-06 11:23 ` [PATCH net-next 4/9] net: stmmac: lpc18xx: validate phy_intf_sel Russell King (Oracle)
2025-11-06 11:23 ` [PATCH net-next 5/9] net: stmmac: lpc18xx: use ->set_phy_intf_sel() Russell King (Oracle)
2025-11-06 11:23 ` [PATCH net-next 6/9] net: stmmac: sti: use PHY_INTF_SEL_x to select PHY interface Russell King (Oracle)
2025-11-06 11:23 ` Russell King (Oracle) [this message]
2025-11-06 11:23 ` [PATCH net-next 8/9] net: stmmac: sti: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-06 11:23 ` [PATCH net-next 9/9] net: stmmac: sti: use ->set_phy_intf_sel() Russell King (Oracle)
2025-11-08  3:20 ` [PATCH net-next 0/9] net: stmmac: lpc18xx and sti: convert to set_phy_intf_sel() 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=E1vGy5e-0000000DhQb-2B7I@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vz@mleia.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;
as well as URLs for NNTP newsgroup(s).