All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] rtl_pci: add support for Realtek management device
@ 2026-03-03  3:01 javen
  2026-03-03  4:45 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: javen @ 2026-03-03  3:01 UTC (permalink / raw)
  To: arnd, gregkh; +Cc: linux-kernel, Javen Xu

From: Javen Xu <javen_xu@realsil.com.cn>

This is not the standard ethernet driver. It specially handles the
management function.

I tried to submitted to linux/net-next before, but they said these class
didn't belong there. So I came here, and I'm wondering if these unknown
classes used for management functions should be submitted here.

Thanks,
Javen Xu

Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
---
 drivers/misc/Kconfig   | 12 +++++++
 drivers/misc/Makefile  |  1 +
 drivers/misc/rtl_pci.c | 78 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 drivers/misc/rtl_pci.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 5cc79d1517af..e3c572bd1e34 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -643,6 +643,18 @@ config MCHP_LAN966X_PCI
 	    - lan966x-miim (MDIO_MSCC_MIIM)
 	    - lan966x-switch (LAN966X_SWITCH)
 
+config RTL_PCI
+	tristate "Realtek Management Interface Support"
+	depends on PCI
+	help
+	  This enables support for the Realtek nic PCIe Management device.
+
+	  Please note that this is NOT the standard Ethernet driver for network
+	  traffic. It specifically handles the management function.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called rtl_pci.o.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b32a2597d246..b937a25707c8 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -75,3 +75,4 @@ obj-$(CONFIG_MCHP_LAN966X_PCI)	+= lan966x-pci.o
 obj-y				+= keba/
 obj-y				+= amd-sbi/
 obj-$(CONFIG_MISC_RP1)		+= rp1/
+obj-$(CONFIG_RTL_PCI)		+= rtl_pci.o
diff --git a/drivers/misc/rtl_pci.c b/drivers/misc/rtl_pci.c
new file mode 100644
index 000000000000..148acb192b33
--- /dev/null
+++ b/drivers/misc/rtl_pci.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ *  This module handles PCI endpoint functions exposed by Realtek
+ *  management controllers (e.g. RTL8111x series). It manages device
+ *  probing for virtual devices.
+ *
+ *  Copyright(c) 2026 Realtek Semiconductor Corp.
+ */
+
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+
+#define PCI_DEVICE_ID_REALTEK_PTOU      0x8164
+#define PCI_DEVICE_ID_REALTEK_COM1      0x816a
+#define PCI_DEVICE_ID_REALTEK_COM2      0x816b
+#define PCI_DEVICE_ID_REALTEK_IPMI      0x816c
+#define PCI_DEVICE_ID_REALTEK_BMC       0x816e
+#define PCI_DEVICE_ID_REALTEK_PCIBR     0x9151
+
+static struct pci_device_id rtl_pci_tbl[] = {
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_PTOU), },
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_COM1), },
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_COM2), },
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_IPMI), },
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_BMC), },
+	{ PCI_VDEVICE(REALTEK, PCI_DEVICE_ID_REALTEK_PCIBR), .class_mask = 0xff00 },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(pci, rtl_pci_tbl);
+
+static int rtl_probe(struct pci_dev *pdev,
+			 const struct pci_device_id *ent)
+{
+	int rc;
+
+	/* enable device (incl. PCI PM wakeup and hotplug setup) */
+	rc = pcim_enable_device(pdev);
+	if (rc < 0)
+		return dev_err_probe(&pdev->dev, rc, "enable failure\n");
+
+	dev_info(&pdev->dev, "enable device\n");
+
+	return rc;
+}
+
+static void rtl_remove(struct pci_dev *pdev) {}
+
+static int rtl_pm_suspend(struct device *device)
+{
+	return 0;
+}
+
+static int rtl_pm_resume(struct device *device)
+{
+	return 0;
+}
+
+static const struct dev_pm_ops rtl_pm_ops = {
+	SYSTEM_SLEEP_PM_OPS(rtl_pm_suspend, rtl_pm_resume)
+};
+
+static struct pci_driver rtl_pci_driver = {
+	.name		= "rtl_pci",
+	.id_table	= rtl_pci_tbl,
+	.probe		= rtl_probe,
+	.remove		= rtl_remove,
+#ifdef CONFIG_PM
+	.driver.pm  = pm_ptr(&rtl_pm_ops),
+#endif
+};
+
+module_pci_driver(rtl_pci_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RealTek pci driver");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-03  4:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03  3:01 [PATCH v1] rtl_pci: add support for Realtek management device javen
2026-03-03  4:45 ` kernel test robot

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.