All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yanteng Si <siyanteng@loongson.cn>
To: andrew@lunn.ch, hkallweit1@gmail.com, peppe.cavallaro@st.com,
	alexandre.torgue@foss.st.com, joabreu@synopsys.com,
	fancer.lancer@gmail.com
Cc: Yanteng Si <siyanteng@loongson.cn>,
	Jose.Abreu@synopsys.com, chenhuacai@loongson.cn,
	linux@armlinux.org.uk, guyinggang@loongson.cn,
	netdev@vger.kernel.org, chris.chenfeiyang@gmail.com
Subject: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET
Date: Tue, 30 Jan 2024 16:48:20 +0800	[thread overview]
Message-ID: <e3c83d1e62cd67d5f3b50b30f46c232a307504ab.1706601050.git.siyanteng@loongson.cn> (raw)
In-Reply-To: <cover.1706601050.git.siyanteng@loongson.cn>

Current GNET on LS7A only supports ANE when speed is
set to 1000M.

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
Signed-off-by: Yinggang Gu <guyinggang@loongson.cn>
---
 .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 19 +++++++++++++++++++
 .../ethernet/stmicro/stmmac/stmmac_ethtool.c  |  6 ++++++
 include/linux/stmmac.h                        |  1 +
 3 files changed, 26 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 60d0a122d7c9..264c4c198d5a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -344,6 +344,21 @@ static struct stmmac_pci_info loongson_gmac_pci_info = {
 	.config = loongson_gmac_config,
 };
 
+static void loongson_gnet_fix_speed(void *priv, unsigned int speed, unsigned int mode)
+{
+	struct loongson_data *ld = (struct loongson_data *)priv;
+	struct net_device *ndev = dev_get_drvdata(ld->dev);
+	struct stmmac_priv *ptr = netdev_priv(ndev);
+
+	/* The controller and PHY don't work well together.
+	 * We need to use the PS bit to check if the controller's status
+	 * is correct and reset PHY if necessary.
+	 */
+	if (speed == SPEED_1000)
+		if (readl(ptr->ioaddr + MAC_CTRL_REG) & (1 << 15) /* PS */)
+			phy_restart_aneg(ndev->phydev);
+}
+
 static struct mac_device_info *loongson_setup(void *apriv)
 {
 	struct stmmac_priv *priv = apriv;
@@ -401,6 +416,7 @@ static int loongson_gnet_data(struct pci_dev *pdev,
 	plat->phy_interface = PHY_INTERFACE_MODE_INTERNAL;
 
 	plat->bsp_priv = &pdev->dev;
+	plat->fix_mac_speed = loongson_gnet_fix_speed;
 
 	plat->dma_cfg->pbl = 32;
 	plat->dma_cfg->pblx8 = true;
@@ -416,6 +432,9 @@ static int loongson_gnet_config(struct pci_dev *pdev,
 				struct stmmac_resources *res,
 				struct device_node *np)
 {
+	if (pdev->revision == 0x00 || pdev->revision == 0x01)
+		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
+
 	return 0;
 }
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index 42d27b97dd1d..31068fbc23c9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -422,6 +422,12 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev,
 		return 0;
 	}
 
+	if (FIELD_GET(STMMAC_FLAG_DISABLE_FORCE_1000, priv->plat->flags)) {
+		if (cmd->base.speed == SPEED_1000 &&
+		    cmd->base.autoneg != AUTONEG_ENABLE)
+			return -EOPNOTSUPP;
+	}
+
 	return phylink_ethtool_ksettings_set(priv->phylink, cmd);
 }
 
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index dee5ad6e48c5..2810361e4048 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -221,6 +221,7 @@ struct dwmac4_addrs {
 #define STMMAC_FLAG_RX_CLK_RUNS_IN_LPI		BIT(10)
 #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
 #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
+#define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
 
 struct plat_stmmacenet_data {
 	int bus_id;
-- 
2.31.4


  parent reply	other threads:[~2024-01-30  8:48 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30  8:43 [PATCH net-next v8 00/11] stmmac: Add Loongson platform support Yanteng Si
2024-01-30  8:43 ` [PATCH net-next v8 01/11] net: stmmac: Add multi-channel support Yanteng Si
2024-02-02 12:30   ` Simon Horman
2024-02-04  8:43     ` Yanteng Si
2024-02-04 23:28   ` Serge Semin
2024-02-06  9:02     ` Yanteng Si
2024-02-06  9:48       ` Serge Semin
2024-02-19 11:02     ` Yanteng Si
2024-02-21 13:48       ` Serge Semin
     [not found]         ` <ee2ffb6a-fe34-47a1-9734-b0e6697a5f09@loongson.cn>
2024-03-13  9:10           ` Yanteng Si
2024-03-19 14:18             ` Serge Semin
2024-03-20  9:47               ` Yanteng Si
2024-03-20  9:55               ` Russell King (Oracle)
2024-03-20 10:51                 ` Yanteng Si
2024-02-05  1:11   ` Serge Semin
2024-01-30  8:43 ` [PATCH net-next v8 02/11] net: stmmac: dwmac-loongson: Refactor code for loongson_dwmac_probe() Yanteng Si
2024-02-02 12:33   ` Simon Horman
2024-02-04  8:47     ` Yanteng Si
2024-02-05 14:43   ` Serge Semin
2024-04-05 11:13     ` Yanteng Si
2024-01-30  8:43 ` [PATCH net-next v8 03/11] net: stmmac: dwmac-loongson: Add full PCI support Yanteng Si
2024-02-05 16:49   ` Serge Semin
2024-02-21 10:08     ` Yanteng Si
2024-01-30  8:43 ` [PATCH net-next v8 04/11] net: stmmac: dwmac-loongson: Move irq config to loongson_gmac_config Yanteng Si
2024-02-05 17:01   ` Serge Semin
2024-03-13  8:14     ` Yanteng Si
2024-03-19 13:43       ` Serge Semin
2024-03-20 10:12         ` Yanteng Si
2024-01-30  8:48 ` [PATCH net-next v8 05/11] net: stmmac: dwmac-loongson: Add Loongson-specific register definitions Yanteng Si
2024-02-05 18:17   ` Serge Semin
2024-02-22 13:39     ` Yanteng Si
2024-02-22 13:59       ` Serge Semin
2024-02-23  8:16         ` Yanteng Si
2024-02-23 18:50           ` Serge Semin
2024-03-07 13:15             ` Yanteng Si
2024-03-07 13:44               ` Serge Semin
2024-03-08  4:05                 ` Yanteng Si
2024-01-30  8:48 ` [PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support Yanteng Si
2024-02-05 20:58   ` Serge Semin
     [not found]     ` <d0e56c9b-9549-4061-8e44-2504b6b96897@loongson.cn>
2024-03-14 13:12       ` Yanteng Si
2024-03-19 15:03         ` Serge Semin
2024-03-20 10:23           ` Yanteng Si
2024-03-20 12:18             ` Serge Semin
2024-03-21  9:13           ` Yanteng Si
2024-03-21 14:55             ` Andrew Lunn
2024-03-28 11:41               ` Yanteng Si
2024-03-22 19:09             ` Serge Semin
2024-01-30  8:48 ` [PATCH net-next v8 07/11] net: stmmac: dwmac-loongson: Add multi-channel supports for loongson Yanteng Si
2024-02-05 21:28   ` Serge Semin
     [not found]     ` <e1c7b5fa-f3f8-4aa3-af4d-ca72b54d9c8c@loongson.cn>
2024-03-14 13:13       ` Yanteng Si
2024-03-19 15:53         ` Serge Semin
2024-03-22 10:36           ` Yanteng Si
2024-03-22 18:47             ` Serge Semin
2024-04-03  8:09               ` Yanteng Si
2024-04-03 12:03                 ` Serge Semin
2024-04-05 10:17                   ` Yanteng Si
2024-04-03  8:23           ` Yanteng Si
2024-01-30  8:48 ` Yanteng Si [this message]
2024-02-05 21:55   ` [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET Serge Semin
     [not found]     ` <4873ea5a-1b23-4512-b039-0a9198b53adf@loongson.cn>
2024-03-14 13:18       ` Yanteng Si
2024-03-19 17:02         ` Serge Semin
2024-03-20 10:42           ` Yanteng Si
2024-03-21  9:29           ` Yanteng Si
2024-03-21 15:02             ` Andrew Lunn
2024-03-21 15:19               ` Russell King (Oracle)
2024-03-21 15:38                 ` Andrew Lunn
2024-03-26 12:32                   ` Yanteng Si
2024-03-26 12:02               ` Yanteng Si
2024-03-26 12:21                 ` Andrew Lunn
2024-03-27  2:41                   ` Yanteng Si
2024-03-27 12:47                     ` Andrew Lunn
2024-03-28 10:08                       ` Yanteng Si
2024-01-30  8:49 ` [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex Yanteng Si
2024-02-05 21:58   ` Serge Semin
2024-02-05 22:06     ` Serge Semin
2024-03-13  9:24       ` Yanteng Si
2024-03-13 10:21         ` Russell King (Oracle)
2024-03-14 13:08           ` Yanteng Si
2024-03-20 10:10             ` Serge Semin
2024-03-20 10:37               ` Russell King (Oracle)
2024-03-20 12:50                 ` Russell King (Oracle)
2024-03-20 14:22                   ` Russell King (Oracle)
2024-03-22 18:07                 ` Serge Semin
2024-03-22 19:56                   ` Russell King (Oracle)
2024-04-03 12:37                     ` Serge Semin
2024-04-05 10:48                       ` Yanteng Si
2024-01-30  8:49 ` [PATCH net-next v8 10/11] net: stmmac: dwmac-loongson: Disable flow control for GMAC Yanteng Si
2024-02-05 22:13   ` Serge Semin
2024-03-13  9:25     ` Yanteng Si
2024-01-30  8:49 ` [PATCH net-next v8 11/11] net: stmmac: dwmac-loongson: Disable coe for some Loongson GNET Yanteng Si
2024-02-05 22:18   ` Serge Semin
2024-03-13  9:52     ` Yanteng Si
2024-03-13 10:19       ` Yanteng Si
2024-03-20 11:24         ` Serge Semin
2024-01-30  9:57 ` [PATCH net-next v8 00/11] stmmac: Add Loongson platform support Serge Semin
2024-01-31  2:10 ` Jakub Kicinski
2024-01-31  9:20   ` Yanteng Si

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=e3c83d1e62cd67d5f3b50b30f46c232a307504ab.1706601050.git.siyanteng@loongson.cn \
    --to=siyanteng@loongson.cn \
    --cc=Jose.Abreu@synopsys.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew@lunn.ch \
    --cc=chenhuacai@loongson.cn \
    --cc=chris.chenfeiyang@gmail.com \
    --cc=fancer.lancer@gmail.com \
    --cc=guyinggang@loongson.cn \
    --cc=hkallweit1@gmail.com \
    --cc=joabreu@synopsys.com \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.