[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1603971787-16784-5-git-send-email-mihai.carabas@oracle.com>
Date: Thu, 29 Oct 2020 13:43:07 +0200
From: Mihai Carabas <mihai.carabas@...cle.com>
To: linux-kernel@...r.kernel.org
Cc: Peng Hao <peng.hao2@....com.cn>,
Mihai Carabas <mihai.carabas@...cle.com>
Subject: [PATCH 4/4] misc/pvpanic: add new pvpanic pci driver
From: Peng Hao <peng.hao2@....com.cn>
Add new pvpanic pci driver to pvpanic driver framework.
Signed-off-by: Peng Hao <peng.hao2@....com.cn>
Signed-off-by: Mihai Carabas <mihai.carabas@...cle.com>
---
drivers/misc/pvpanic/Kconfig | 10 ++++++-
drivers/misc/pvpanic/Makefile | 1 +
drivers/misc/pvpanic/pvpanic-pci.c | 56 ++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 1 deletion(-)
create mode 100644 drivers/misc/pvpanic/pvpanic-pci.c
diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig
index 0c0c0b2..866cb37 100644
--- a/drivers/misc/pvpanic/Kconfig
+++ b/drivers/misc/pvpanic/Kconfig
@@ -1,6 +1,6 @@
config PVPANIC
tristate "pvpanic device support"
- depends on HAS_IOMEM && (ACPI || OF)
+ depends on HAS_IOMEM && (ACPI || OF || PCI)
help
This driver provides support for the pvpanic device. pvpanic is
a paravirtualized device provided by QEMU; it lets a virtual machine
@@ -23,4 +23,12 @@ config PVPANIC_OF
This driver is one specific driver for pvpanic driver framework.
It provides a mmio device as pvpanic device.
+config PVPANIC_PCI
+ tristate "pvpanic pci driver"
+ depends on PCI
+ default PVPANIC
+ help
+ This driver is one specific driver for pvpanic driver framework.
+ It provides a pci device as pvpanic device.
+
endif
diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile
index ffd11b1..45d0a60 100644
--- a/drivers/misc/pvpanic/Makefile
+++ b/drivers/misc/pvpanic/Makefile
@@ -5,3 +5,4 @@
obj-$(CONFIG_PVPANIC) += pvpanic.o
obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o
obj-$(CONFIG_PVPANIC_OF) += pvpanic-of.o
+obj-$(CONFIG_PVPANIC_PCI) += pvpanic-pci.o
diff --git a/drivers/misc/pvpanic/pvpanic-pci.c b/drivers/misc/pvpanic/pvpanic-pci.c
new file mode 100644
index 00000000..1261710
--- /dev/null
+++ b/drivers/misc/pvpanic/pvpanic-pci.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * pvpanic acpi driver.
+ *
+ * Copyright (C) 2019 ZTE Ltd.
+ * Author: Peng Hao <peng.hao2@....com.cn>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/types.h>
+#include "pvpanic.h"
+
+#define PCI_VENDOR_ID_REDHAT 0x1b36
+#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101
+
+static const struct pci_device_id pvpanic_pci_id_tbl[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_PVPANIC),},
+ {}
+};
+
+static int pvpanic_pci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int ret;
+ struct resource res;
+
+ ret = pcim_enable_device(pdev);
+ if (ret < 0)
+ return ret;
+
+ memset(&res, 0, sizeof(res));
+ res.start = pci_resource_start(pdev, 0);
+ res.end = pci_resource_end(pdev, 0);
+ res.flags = IORESOURCE_MEM;
+ ret = pvpanic_add_device(&pdev->dev, &res);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static void pvpanic_pci_remove(struct pci_dev *pdev)
+{
+ pvpanic_remove_device();
+}
+
+static struct pci_driver pvpanic_pci_driver = {
+ .name = "pvpanic-pci",
+ .id_table = pvpanic_pci_id_tbl,
+ .probe = pvpanic_pci_probe,
+ .remove = pvpanic_pci_remove,
+};
+
+module_pci_driver(pvpanic_pci_driver);
--
1.8.3.1
Powered by blists - more mailing lists