mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
net: stmmac: Add generic suspend/resume helper for PCI-based controllers
Most glue driver for PCI-based DWMAC controllers utilize similar platform suspend/resume routines. Add a generic implementation to reduce duplicated code. Signed-off-by: Yao Zi <ziyao@disroot.org> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Yanteng Si <siyanteng@cqsoftware.com.cn> Link: https://patch.msgid.link/20251124160417.51514-2-ziyao@disroot.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -349,6 +349,11 @@ config DWMAC_VISCONTI
|
||||
|
||||
endif
|
||||
|
||||
config STMMAC_LIBPCI
|
||||
tristate
|
||||
help
|
||||
This option enables the PCI bus helpers for the stmmac driver.
|
||||
|
||||
config DWMAC_INTEL
|
||||
tristate "Intel GMAC support"
|
||||
default X86
|
||||
|
||||
@@ -44,6 +44,7 @@ obj-$(CONFIG_DWMAC_VISCONTI) += dwmac-visconti.o
|
||||
stmmac-platform-objs:= stmmac_platform.o
|
||||
dwmac-altr-socfpga-objs := dwmac-socfpga.o
|
||||
|
||||
obj-$(CONFIG_STMMAC_LIBPCI) += stmmac_libpci.o
|
||||
obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
|
||||
obj-$(CONFIG_DWMAC_INTEL) += dwmac-intel.o
|
||||
obj-$(CONFIG_DWMAC_LOONGSON) += dwmac-loongson.o
|
||||
|
||||
48
drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c
Normal file
48
drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.c
Normal file
@@ -0,0 +1,48 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* PCI bus helpers for STMMAC driver
|
||||
* Copyright (C) 2025 Yao Zi <ziyao@disroot.org>
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/pci.h>
|
||||
|
||||
#include "stmmac_libpci.h"
|
||||
|
||||
int stmmac_pci_plat_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;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(stmmac_pci_plat_suspend);
|
||||
|
||||
int stmmac_pci_plat_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;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(stmmac_pci_plat_resume);
|
||||
|
||||
MODULE_DESCRIPTION("STMMAC PCI helper library");
|
||||
MODULE_AUTHOR("Yao Zi <ziyao@disroot.org>");
|
||||
MODULE_LICENSE("GPL");
|
||||
12
drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h
Normal file
12
drivers/net/ethernet/stmicro/stmmac/stmmac_libpci.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (C) 2025 Yao Zi <ziyao@disroot.org>
|
||||
*/
|
||||
|
||||
#ifndef __STMMAC_LIBPCI_H__
|
||||
#define __STMMAC_LIBPCI_H__
|
||||
|
||||
int stmmac_pci_plat_suspend(struct device *dev, void *bsp_priv);
|
||||
int stmmac_pci_plat_resume(struct device *dev, void *bsp_priv);
|
||||
|
||||
#endif /* __STMMAC_LIBPCI_H__ */
|
||||
Reference in New Issue
Block a user