]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: rnpgbe: Add build support for rnpgbe
authorDong Yibo <dong100@mucse.com>
Sat, 1 Nov 2025 01:38:45 +0000 (09:38 +0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 5 Nov 2025 02:11:36 +0000 (18:11 -0800)
Add build options and doc for mucse.
Initialize pci device access for MUCSE devices.

Signed-off-by: Dong Yibo <dong100@mucse.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: MD Danish Anwar <danishanwar@ti.com>
Link: https://patch.msgid.link/20251101013849.120565-2-dong100@mucse.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/networking/device_drivers/ethernet/index.rst
Documentation/networking/device_drivers/ethernet/mucse/rnpgbe.rst [new file with mode: 0644]
MAINTAINERS
drivers/net/ethernet/Kconfig
drivers/net/ethernet/Makefile
drivers/net/ethernet/mucse/Kconfig [new file with mode: 0644]
drivers/net/ethernet/mucse/Makefile [new file with mode: 0644]
drivers/net/ethernet/mucse/rnpgbe/Makefile [new file with mode: 0644]
drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h [new file with mode: 0644]
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c [new file with mode: 0644]

index 7cfcd183054f843496c3acdfe66026abda92c15e..bcc02355f828bc5c5fbcb87f0f2e5e4b45256849 100644 (file)
@@ -47,6 +47,7 @@ Contents:
    mellanox/mlx5/index
    meta/fbnic
    microsoft/netvsc
+   mucse/rnpgbe
    neterion/s2io
    netronome/nfp
    pensando/ionic
diff --git a/Documentation/networking/device_drivers/ethernet/mucse/rnpgbe.rst b/Documentation/networking/device_drivers/ethernet/mucse/rnpgbe.rst
new file mode 100644 (file)
index 0000000..d35cf8a
--- /dev/null
@@ -0,0 +1,17 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+===========================================================
+Linux Base Driver for MUCSE(R) Gigabit PCI Express Adapters
+===========================================================
+
+Contents
+========
+
+- Identifying Your Adapter
+
+Identifying Your Adapter
+========================
+The driver is compatible with devices based on the following:
+
+ * MUCSE(R) Ethernet Controller N210 series
+ * MUCSE(R) Ethernet Controller N500 series
index 1ab7e87462993bb7dac5d042b630ab9eac5baa37..bdf0a3a0dd36e0188ffb5dff47912643ae151d05 100644 (file)
@@ -17610,6 +17610,14 @@ T:     git git://linuxtv.org/media.git
 F:     Documentation/devicetree/bindings/media/i2c/aptina,mt9v111.yaml
 F:     drivers/media/i2c/mt9v111.c
 
+MUCSE ETHERNET DRIVER
+M:     Yibo Dong <dong100@mucse.com>
+L:     netdev@vger.kernel.org
+S:     Maintained
+W:     https://www.mucse.com/en/
+F:     Documentation/networking/device_drivers/ethernet/mucse/
+F:     drivers/net/ethernet/mucse/
+
 MULTIFUNCTION DEVICES (MFD)
 M:     Lee Jones <lee@kernel.org>
 S:     Maintained
index aead145dd91d129b7bb410f2d4d754c744dddbf4..4a1b368ca7e61095d1444951618684d9011f0b52 100644 (file)
@@ -129,6 +129,7 @@ source "drivers/net/ethernet/microchip/Kconfig"
 source "drivers/net/ethernet/mscc/Kconfig"
 source "drivers/net/ethernet/microsoft/Kconfig"
 source "drivers/net/ethernet/moxa/Kconfig"
+source "drivers/net/ethernet/mucse/Kconfig"
 source "drivers/net/ethernet/myricom/Kconfig"
 
 config FEALNX
index 998dd628b202ced212748450753fe180f0440c74..2e18df8ca8ec512c51ed61ffe98befc8ac723458 100644 (file)
@@ -65,6 +65,7 @@ obj-$(CONFIG_NET_VENDOR_MICREL) += micrel/
 obj-$(CONFIG_NET_VENDOR_MICROCHIP) += microchip/
 obj-$(CONFIG_NET_VENDOR_MICROSEMI) += mscc/
 obj-$(CONFIG_NET_VENDOR_MOXART) += moxa/
+obj-$(CONFIG_NET_VENDOR_MUCSE) += mucse/
 obj-$(CONFIG_NET_VENDOR_MYRI) += myricom/
 obj-$(CONFIG_FEALNX) += fealnx.o
 obj-$(CONFIG_NET_VENDOR_NATSEMI) += natsemi/
diff --git a/drivers/net/ethernet/mucse/Kconfig b/drivers/net/ethernet/mucse/Kconfig
new file mode 100644 (file)
index 0000000..0b3e853
--- /dev/null
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Mucse network device configuration
+#
+
+config NET_VENDOR_MUCSE
+       bool "Mucse devices"
+       default y
+       help
+         If you have a network (Ethernet) card from Mucse(R), say Y.
+
+         Note that the answer to this question doesn't directly affect the
+         kernel: saying N will just cause the configurator to skip all
+         the questions about Mucse(R) cards. If you say Y, you will
+         be asked for your specific card in the following questions.
+
+if NET_VENDOR_MUCSE
+
+config MGBE
+       tristate "Mucse(R) 1GbE PCI Express adapters support"
+       depends on PCI
+       help
+         This driver supports Mucse(R) 1GbE PCI Express family of
+         adapters.
+
+         More specific information on configuring the driver is in
+         <file:Documentation/networking/device_drivers/ethernet/mucse/rnpgbe.rst>.
+
+         To compile this driver as a module, choose M here. The module
+         will be called rnpgbe.
+
+endif # NET_VENDOR_MUCSE
+
diff --git a/drivers/net/ethernet/mucse/Makefile b/drivers/net/ethernet/mucse/Makefile
new file mode 100644 (file)
index 0000000..675173f
--- /dev/null
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2020 - 2025 MUCSE Corporation.
+#
+# Makefile for the MUCSE(R) network device drivers
+#
+
+obj-$(CONFIG_MGBE) += rnpgbe/
diff --git a/drivers/net/ethernet/mucse/rnpgbe/Makefile b/drivers/net/ethernet/mucse/rnpgbe/Makefile
new file mode 100644 (file)
index 0000000..9df536f
--- /dev/null
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2020 - 2025 MUCSE Corporation.
+#
+# Makefile for the MUCSE(R) 1GbE PCI Express ethernet driver
+#
+
+obj-$(CONFIG_MGBE) += rnpgbe.o
+rnpgbe-objs := rnpgbe_main.o
diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h
new file mode 100644 (file)
index 0000000..d3439d2
--- /dev/null
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright(c) 2020 - 2025 Mucse Corporation. */
+
+#ifndef _RNPGBE_H
+#define _RNPGBE_H
+
+enum rnpgbe_boards {
+       board_n500,
+       board_n210
+};
+
+/* Device IDs */
+#define PCI_VENDOR_ID_MUCSE               0x8848
+#define RNPGBE_DEVICE_ID_N500_QUAD_PORT   0x8308
+#define RNPGBE_DEVICE_ID_N500_DUAL_PORT   0x8318
+#define RNPGBE_DEVICE_ID_N210             0x8208
+#define RNPGBE_DEVICE_ID_N210L            0x820a
+#endif /* _RNPGBE_H */
diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c
new file mode 100644 (file)
index 0000000..019e819
--- /dev/null
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright(c) 2020 - 2025 Mucse Corporation. */
+
+#include <linux/pci.h>
+
+#include "rnpgbe.h"
+
+static const char rnpgbe_driver_name[] = "rnpgbe";
+
+/* rnpgbe_pci_tbl - PCI Device ID Table
+ *
+ * { PCI_VDEVICE(Vendor ID, Device ID),
+ *   private_data (used for different hw chip) }
+ */
+static struct pci_device_id rnpgbe_pci_tbl[] = {
+       { PCI_VDEVICE(MUCSE, RNPGBE_DEVICE_ID_N210), board_n210 },
+       { PCI_VDEVICE(MUCSE, RNPGBE_DEVICE_ID_N210L), board_n210 },
+       { PCI_VDEVICE(MUCSE, RNPGBE_DEVICE_ID_N500_DUAL_PORT), board_n500 },
+       { PCI_VDEVICE(MUCSE, RNPGBE_DEVICE_ID_N500_QUAD_PORT), board_n500 },
+       /* required last entry */
+       {0, },
+};
+
+/**
+ * rnpgbe_probe - Device initialization routine
+ * @pdev: PCI device information struct
+ * @id: entry in rnpgbe_pci_tbl
+ *
+ * rnpgbe_probe initializes a PF adapter identified by a pci_dev
+ * structure.
+ *
+ * Return: 0 on success, negative errno on failure
+ **/
+static int rnpgbe_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+       int err;
+
+       err = pci_enable_device_mem(pdev);
+       if (err)
+               return err;
+
+       err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(56));
+       if (err) {
+               dev_err(&pdev->dev,
+                       "No usable DMA configuration, aborting %d\n", err);
+               goto err_disable_dev;
+       }
+
+       err = pci_request_mem_regions(pdev, rnpgbe_driver_name);
+       if (err) {
+               dev_err(&pdev->dev,
+                       "pci_request_selected_regions failed %d\n", err);
+               goto err_disable_dev;
+       }
+
+       pci_set_master(pdev);
+       err = pci_save_state(pdev);
+       if (err) {
+               dev_err(&pdev->dev, "pci_save_state failed %d\n", err);
+               goto err_free_regions;
+       }
+
+       return 0;
+err_free_regions:
+       pci_release_mem_regions(pdev);
+err_disable_dev:
+       pci_disable_device(pdev);
+       return err;
+}
+
+/**
+ * rnpgbe_remove - Device removal routine
+ * @pdev: PCI device information struct
+ *
+ * rnpgbe_remove is called by the PCI subsystem to alert the driver
+ * that it should release a PCI device. This could be caused by a
+ * Hot-Plug event, or because the driver is going to be removed from
+ * memory.
+ **/
+static void rnpgbe_remove(struct pci_dev *pdev)
+{
+       pci_release_mem_regions(pdev);
+       pci_disable_device(pdev);
+}
+
+/**
+ * rnpgbe_dev_shutdown - Device shutdown routine
+ * @pdev: PCI device information struct
+ **/
+static void rnpgbe_dev_shutdown(struct pci_dev *pdev)
+{
+       pci_disable_device(pdev);
+}
+
+/**
+ * rnpgbe_shutdown - Device shutdown routine
+ * @pdev: PCI device information struct
+ *
+ * rnpgbe_shutdown is called by the PCI subsystem to alert the driver
+ * that os shutdown. Device should setup wakeup state here.
+ **/
+static void rnpgbe_shutdown(struct pci_dev *pdev)
+{
+       rnpgbe_dev_shutdown(pdev);
+}
+
+static struct pci_driver rnpgbe_driver = {
+       .name     = rnpgbe_driver_name,
+       .id_table = rnpgbe_pci_tbl,
+       .probe    = rnpgbe_probe,
+       .remove   = rnpgbe_remove,
+       .shutdown = rnpgbe_shutdown,
+};
+
+module_pci_driver(rnpgbe_driver);
+
+MODULE_DEVICE_TABLE(pci, rnpgbe_pci_tbl);
+MODULE_AUTHOR("Yibo Dong, <dong100@mucse.com>");
+MODULE_DESCRIPTION("Mucse(R) 1 Gigabit PCI Express Network Driver");
+MODULE_LICENSE("GPL");