Convert glue driver for Loongson DWMAC controller to use the generic
platform suspend/resume routines for PCI controllers, instead of
implementing its own one.
Signed-off-by: Yao Zi <ziyao@disroot.org>
---
drivers/net/ethernet/stmicro/stmmac/Kconfig | 4 +++
.../ethernet/stmicro/stmmac/dwmac-loongson.c | 36 ++-----------------
2 files changed, 7 insertions(+), 33 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 1350f16f7138..7ec7c7630c41 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -367,6 +367,8 @@ config DWMAC_INTEL
This selects the Intel platform specific bus support for the
stmmac driver. This driver is used for Intel Quark/EHL/TGL.
+if STMMAC_LIBPCI
+
config DWMAC_LOONGSON
tristate "Loongson PCI DWMAC support"
default MACH_LOONGSON64
@@ -376,6 +378,8 @@ config DWMAC_LOONGSON
This selects the LOONGSON PCI bus support for the stmmac driver,
Support for ethernet controller on Loongson-2K1000 SoC and LS7A1000 bridge.
+endif
+
config STMMAC_PCI
tristate "STMMAC PCI bus support"
depends on STMMAC_ETH && PCI
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 2a3ac0136cdb..584dc4ff8320 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -8,6 +8,7 @@
#include <linux/device.h>
#include <linux/of_irq.h>
#include "stmmac.h"
+#include "stmmac_libpci.h"
#include "dwmac_dma.h"
#include "dwmac1000.h"
@@ -525,37 +526,6 @@ static int loongson_dwmac_fix_reset(struct stmmac_priv *priv, void __iomem *ioad
10000, 2000000);
}
-static int loongson_dwmac_suspend(struct device *dev, void *bsp_priv)
-{
- struct pci_dev *pdev = to_pci_dev(dev);
- int ret;
-
- ret = pci_save_state(pdev);
- if (ret)
- return ret;
-
- pci_disable_device(pdev);
- pci_wake_from_d3(pdev, true);
- return 0;
-}
-
-static int loongson_dwmac_resume(struct device *dev, void *bsp_priv)
-{
- struct pci_dev *pdev = to_pci_dev(dev);
- int ret;
-
- pci_restore_state(pdev);
- pci_set_power_state(pdev, PCI_D0);
-
- ret = pci_enable_device(pdev);
- if (ret)
- return ret;
-
- pci_set_master(pdev);
-
- return 0;
-}
-
static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct plat_stmmacenet_data *plat;
@@ -600,8 +570,8 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
plat->bsp_priv = ld;
plat->setup = loongson_dwmac_setup;
plat->fix_soc_reset = loongson_dwmac_fix_reset;
- plat->suspend = loongson_dwmac_suspend;
- plat->resume = loongson_dwmac_resume;
+ plat->suspend = stmmac_pci_plat_suspend;
+ plat->resume = stmmac_pci_plat_resume;
ld->dev = &pdev->dev;
ld->loongson_id = readl(res.addr + GMAC_VERSION) & 0xff;
--
2.51.2
On Tue, Nov 04, 2025 at 03:16:46PM +0000, Yao Zi wrote:
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -367,6 +367,8 @@ config DWMAC_INTEL
> This selects the Intel platform specific bus support for the
> stmmac driver. This driver is used for Intel Quark/EHL/TGL.
>
> +if STMMAC_LIBPCI
> +
> config DWMAC_LOONGSON
> tristate "Loongson PCI DWMAC support"
> default MACH_LOONGSON64
As the next line is:
depends on (MACH_LOONGSON64 || COMPILE_TEST) && STMMAC_ETH && PCI
where STMMAC_LIBPCI depends on PCI, and the whole lot is surrounded by
if STMMAC_ETH ... endif, shouldn't this become:
depends on MACH_LOONGSON64 || COMPILE_TEST
?
Otherwise, looks good, thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
On Tue, Nov 04, 2025 at 05:22:53PM +0000, Russell King (Oracle) wrote: > On Tue, Nov 04, 2025 at 03:16:46PM +0000, Yao Zi wrote: > > --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig > > +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig > > @@ -367,6 +367,8 @@ config DWMAC_INTEL > > This selects the Intel platform specific bus support for the > > stmmac driver. This driver is used for Intel Quark/EHL/TGL. > > > > +if STMMAC_LIBPCI > > + > > config DWMAC_LOONGSON > > tristate "Loongson PCI DWMAC support" > > default MACH_LOONGSON64 > > As the next line is: > > depends on (MACH_LOONGSON64 || COMPILE_TEST) && STMMAC_ETH && PCI > > where STMMAC_LIBPCI depends on PCI, and the whole lot is surrounded by > if STMMAC_ETH ... endif, shouldn't this become: > > depends on MACH_LOONGSON64 || COMPILE_TEST > > ? > > Otherwise, looks good, thanks. I was originally planning to send a separate patch to remove the redundant depends on STMMAC_ETH, since STMMAC_SELFTESTS, STMMAC_PLATFORM, DWMAC_INTEL have similar issues. But yes PCI could be removed from the depends as well with this series applied, so I'm not sure whether it's better to do the simplication for DWMAC_LOONGSON and STMMAC_PCI while adding STMMAC_LIBPCI dependency to them, or separate a patch with a clear topic "removing redundant depends". I prefer a separate patch to do all the Kconfig clean-up, but am willing to simplify the depends lines in this series, too if you consider it's better. By the way, if I need to send v4 of the series with your proposed simplification, should I apply your Reviewed-by tag for PATCH 2 and 3? Thanks, Yao Zi > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
© 2016 - 2026 Red Hat, Inc.