public inbox for linux-rockchip@lists.infradead.org
 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>,
	Heiko Stuebner <heiko@sntech.de>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@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>
Subject: [PATCH RFC net-next 02/15] net: stmmac: rk: convert rk3328 to use bsp_priv->id
Date: Mon, 01 Dec 2025 14:50:52 +0000	[thread overview]
Message-ID: <E1vQ5Eq-0000000GNva-3OiR@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <aS2rFBlz1jdwXaS8@shell.armlinux.org.uk>

rk3328 contains two GMAC instances - gmac2io and gmac2phy. The gmac2io
instance can be connected to an external PHY, whereas gmac2phy is
connected via RMII to an on-SoC integrated PHY. This configuration can
not be changed.

The driver tests for the gmac2phy instance by checking
bsp_priv->integrated_phy (determined from the PHY's phy-is-integrated
property) and sometimes that the interface mode is RMII. This works
because the rk3328.dtsi has:

        gmac2phy: ethernet@ff550000 {
                compatible = "rockchip,rk3328-gmac";
                phy-mode = "rmii";

                mdio {
                        phy: ethernet-phy@0 {
                                phy-is-integrated;
                        };
                };
        };

The driver contains a mechanism to look up the MMIO address in a table
to determine bsp_priv->id, which is used for every other Rockchip
device. Switch rk3328 to use this mechanism to determine bsp_priv->id
and use that to select which GRF register is used for configuration.

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 3679081047e0..f9bc9b145ff4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -566,8 +566,7 @@ static void rk3328_set_to_rmii(struct rk_priv_data *bsp_priv)
 {
 	unsigned int reg;
 
-	reg = bsp_priv->integrated_phy ? RK3328_GRF_MAC_CON2 :
-		  RK3328_GRF_MAC_CON1;
+	reg = bsp_priv->id ? RK3328_GRF_MAC_CON2 : RK3328_GRF_MAC_CON1;
 
 	regmap_write(bsp_priv->grf, reg,
 		     RK3328_GMAC_PHY_INTF_SEL(PHY_INTF_SEL_RMII) |
@@ -587,10 +586,7 @@ static int rk3328_set_speed(struct rk_priv_data *bsp_priv,
 {
 	unsigned int reg;
 
-	if (interface == PHY_INTERFACE_MODE_RMII && bsp_priv->integrated_phy)
-		reg = RK3328_GRF_MAC_CON2;
-	else
-		reg = RK3328_GRF_MAC_CON1;
+	reg = bsp_priv->id ? RK3328_GRF_MAC_CON2 : RK3328_GRF_MAC_CON1;
 
 	return rk_set_reg_speed(bsp_priv, &rk3328_reg_speed_data, reg,
 				interface, speed);
@@ -610,6 +606,13 @@ static const struct rk_gmac_ops rk3328_ops = {
 	.set_speed = rk3328_set_speed,
 	.integrated_phy_powerup = rk3328_integrated_phy_powerup,
 	.integrated_phy_powerdown = rk_gmac_integrated_ephy_powerdown,
+
+	.regs_valid = true,
+	.regs = {
+		0xff540000, /* gmac2io */
+		0xff550000, /* gmac2phy */
+		0, /* sentinel */
+	},
 };
 
 #define RK3366_GRF_SOC_CON6	0x0418
-- 
2.47.3


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

  parent reply	other threads:[~2025-12-01 14:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01 14:49 [PATCH RFC net-next 00/15] net: stmmac: rk: cleanups galore Russell King (Oracle)
2025-12-01 14:50 ` [PATCH RFC net-next 01/15] net: stmmac: rk: add GMAC_CLK_xx constants, simplify RGMII definitions Russell King (Oracle)
2025-12-02 20:31   ` Andrew Lunn
2025-12-01 14:50 ` Russell King (Oracle) [this message]
2025-12-01 14:50 ` [PATCH RFC net-next 03/15] net: stmmac: rk: add SoC specific ->init() method Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 04/15] net: stmmac: rk: convert to mask-based interface mode configuration Russell King (Oracle)
2025-12-02 20:41   ` Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 05/15] net: stmmac: rk: move speed GRF register offset to private data Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 06/15] net: stmmac: rk: convert rk3588 to rk_set_reg_speed() Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 07/15] net: stmmac: rk: use rk_encode_wm16() for RGMII clocks Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 08/15] net: stmmac: rk: use rk_encode_wm16() for RMII speed Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 09/15] net: stmmac: rk: use rk_encode_wm16() for RMII clock Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 10/15] net: stmmac: rk: move speed register into bsp_priv Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 11/15] net: stmmac: rk: convert px30 Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 12/15] net: stmmac: rk: introduce flags indicating support for RGMII/RMII Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 13/15] net: stmmac: rk: replace empty set_to_rmii() with supports_rmii Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 14/15] net: stmmac: rk: rk3328: gmac2phy only supports RMII Russell King (Oracle)
2025-12-01 14:51 ` [PATCH RFC net-next 15/15] net: stmmac: rk: rk3528: gmac0 " Russell King (Oracle)
2025-12-01 15:55 ` [PATCH RFC net-next 00/15] net: stmmac: rk: cleanups galore Andrew Lunn
2025-12-01 16:38   ` Russell King (Oracle)
2025-12-04  0:50     ` Jacob Keller
2025-12-01 16:44 ` Russell King (Oracle)
2025-12-04  0:51   ` Jacob Keller

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=E1vQ5Eq-0000000GNva-3OiR@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=heiko@sntech.de \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-rockchip@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 \
    /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