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>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
"David S. Miller" <davem@davemloft.net>,
Emil Renner Berthing <kernel@esmil.dk>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Jerome Brunet <jbrunet@baylibre.com>,
Keguang Zhang <keguang.zhang@gmail.com>,
Kevin Hilman <khilman@baylibre.com>,
linux-amlogic@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-mips@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Minda Chen <minda.chen@starfivetech.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
netdev@vger.kernel.org,
Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>,
Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net-next 13/16] net: stmmac: stm32: use PHY_INTF_SEL_x directly
Date: Fri, 07 Nov 2025 14:29:05 +0000 [thread overview]
Message-ID: <E1vHNSb-0000000DkT4-1s8G@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <aQ4ByErmsnAPSHIL@shell.armlinux.org.uk>
Rather than defining separate constants for each, use the
PHY_INTF_SEL_x definitions in the switch()es configuring the
control register, and use one FIELD_PREP() to convert phy_intf_sel
to the register value.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 32 ++++++++-----------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
index 1545772419d5..18d26f096f5f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
@@ -48,30 +48,17 @@
*/
#define SYSCFG_PMCR_ETH_SEL_MII BIT(20)
#define SYSCFG_PMCR_PHY_INTF_SEL_MASK GENMASK(23, 21)
-#define SYSCFG_PMCR_ETH_SEL_RGMII \
- FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, PHY_INTF_SEL_RGMII)
-#define SYSCFG_PMCR_ETH_SEL_RMII \
- FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, PHY_INTF_SEL_RMII)
-#define SYSCFG_PMCR_ETH_SEL_GMII \
- FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, PHY_INTF_SEL_GMII_MII)
#define SYSCFG_MCU_ETH_SEL_MII 0
#define SYSCFG_MCU_ETH_SEL_RMII 1
/* STM32MP2 register definitions */
#define SYSCFG_MP2_ETH_MASK GENMASK(31, 0)
+#define SYSCFG_ETHCR_ETH_SEL_MASK GENMASK(6, 4)
#define SYSCFG_ETHCR_ETH_PTP_CLK_SEL BIT(2)
#define SYSCFG_ETHCR_ETH_CLK_SEL BIT(1)
#define SYSCFG_ETHCR_ETH_REF_CLK_SEL BIT(0)
-#define SYSCFG_ETHCR_ETH_SEL_MASK GENMASK(6, 4)
-#define SYSCFG_ETHCR_ETH_SEL_MII FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, \
- PHY_INTF_SEL_GMII_MII)
-#define SYSCFG_ETHCR_ETH_SEL_RGMII FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, \
- PHY_INTF_SEL_RGMII)
-#define SYSCFG_ETHCR_ETH_SEL_RMII FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, \
- PHY_INTF_SEL_RMII)
-
/* STM32MPx register definitions
*
* Below table summarizes the clock requirement and clock sources for
@@ -244,10 +231,12 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
{
struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
u32 reg = dwmac->mode_reg;
+ u8 phy_intf_sel;
int val = 0;
switch (plat_dat->phy_interface) {
case PHY_INTERFACE_MODE_MII:
+ phy_intf_sel = PHY_INTF_SEL_GMII_MII;
/*
* STM32MP15xx supports both MII and GMII, STM32MP13xx MII only.
* SYSCFG_PMCSETR ETH_SELMII is present only on STM32MP15xx and
@@ -258,12 +247,12 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
val |= SYSCFG_PMCR_ETH_SEL_MII;
break;
case PHY_INTERFACE_MODE_GMII:
- val = SYSCFG_PMCR_ETH_SEL_GMII;
+ phy_intf_sel = PHY_INTF_SEL_GMII_MII;
if (dwmac->enable_eth_ck)
val |= SYSCFG_PMCR_ETH_CLK_SEL;
break;
case PHY_INTERFACE_MODE_RMII:
- val = SYSCFG_PMCR_ETH_SEL_RMII;
+ phy_intf_sel = PHY_INTF_SEL_RMII;
if (dwmac->enable_eth_ck)
val |= SYSCFG_PMCR_ETH_REF_CLK_SEL;
break;
@@ -271,7 +260,7 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_TXID:
- val = SYSCFG_PMCR_ETH_SEL_RGMII;
+ phy_intf_sel = PHY_INTF_SEL_RGMII;
if (dwmac->enable_eth_ck)
val |= SYSCFG_PMCR_ETH_CLK_SEL;
break;
@@ -284,6 +273,8 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->phy_interface));
+ val |= FIELD_PREP(SYSCFG_PMCR_PHY_INTF_SEL_MASK, phy_intf_sel);
+
/* Shift value at correct ethernet MAC offset in SYSCFG_PMCSETR */
val <<= ffs(dwmac->mode_mask) - ffs(SYSCFG_MP1_ETH_MASK);
@@ -299,6 +290,7 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
{
struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
+ u8 phy_intf_sel = PHY_INTF_SEL_GMII_MII;
u32 reg = dwmac->mode_reg;
int val = 0;
@@ -307,7 +299,7 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
/* ETH_REF_CLK_SEL bit in SYSCFG register is not applicable in MII mode */
break;
case PHY_INTERFACE_MODE_RMII:
- val = SYSCFG_ETHCR_ETH_SEL_RMII;
+ phy_intf_sel = PHY_INTF_SEL_RMII;
if (dwmac->enable_eth_ck) {
/* Internal clock ETH_CLK of 50MHz from RCC is used */
val |= SYSCFG_ETHCR_ETH_REF_CLK_SEL;
@@ -317,7 +309,7 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_TXID:
- val = SYSCFG_ETHCR_ETH_SEL_RGMII;
+ phy_intf_sel = PHY_INTF_SEL_RGMII;
fallthrough;
case PHY_INTERFACE_MODE_GMII:
if (dwmac->enable_eth_ck) {
@@ -334,6 +326,8 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->phy_interface));
+ val |= FIELD_PREP(SYSCFG_ETHCR_ETH_SEL_MASK, phy_intf_sel);
+
/* Select PTP (IEEE1588) clock selection from RCC (ck_ker_ethxptp) */
val |= SYSCFG_ETHCR_ETH_PTP_CLK_SEL;
--
2.47.3
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2025-11-07 14:59 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 14:27 [PATCH net-next 00/16] net: stmmac: convert glue drivers to use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 01/16] net: stmmac: loongson1: use PHY_INTF_SEL_x Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 02/16] net: stmmac: loongson1: use PHY_INTF_SEL_x directly Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 03/16] net: stmmac: loongson1: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 04/16] net: stmmac: mediatek: use PHY_INTF_SEL_xxx Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 05/16] net: stmmac: mediatek: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 06/16] net: stmmac: mediatek: simplify set_interface() methods Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 07/16] net: stmmac: meson8b: use PHY_INTF_SEL_xxx Russell King (Oracle)
2025-11-08 12:30 ` Martin Blumenstingl
2025-11-07 14:28 ` [PATCH net-next 08/16] net: stmmac: meson8b: use phy_intf_sel directly Russell King (Oracle)
2025-11-08 12:30 ` Martin Blumenstingl
2025-11-07 14:28 ` [PATCH net-next 09/16] net: stmmac: meson8b: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-08 12:31 ` Martin Blumenstingl
2025-11-07 14:28 ` [PATCH net-next 10/16] net: stmmac: starfive: use PHY_INTF_SEL_xxx to select PHY interface Russell King (Oracle)
2025-11-07 14:28 ` [PATCH net-next 11/16] net: stmmac: starfive: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 16:00 ` Emil Renner Berthing
2025-11-07 16:08 ` Russell King (Oracle)
2025-11-07 14:29 ` [PATCH net-next 12/16] net: stmmac: stm32: use PHY_INTF_SEL_x to select PHY interface Russell King (Oracle)
2025-11-07 14:29 ` Russell King (Oracle) [this message]
2025-11-07 14:29 ` [PATCH net-next 14/16] net: stmmac: stm32: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 14:29 ` [PATCH net-next 15/16] net: stmmac: visconti: use PHY_INTF_SEL_x to select PHY interface Russell King (Oracle)
2025-11-07 14:29 ` [PATCH net-next 16/16] net: stmmac: visconti: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-07 18:23 ` Maxime Chevallier
2025-11-08 7:58 ` Russell King (Oracle)
2025-11-09 16:38 ` Maxime Chevallier
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=E1vHNSb-0000000DkT4-1s8G@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=angelogioacchino.delregno@collabora.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=jbrunet@baylibre.com \
--cc=keguang.zhang@gmail.com \
--cc=kernel@esmil.dk \
--cc=khilman@baylibre.com \
--cc=kuba@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=matthias.bgg@gmail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=minda.chen@starfivetech.com \
--cc=neil.armstrong@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=nobuhiro.iwamatsu.x90@mail.toshiba \
--cc=pabeni@redhat.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).