1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  *  Pvpanic PCI Device Support
4  *
5  *  Copyright (C) 2021 Oracle.
6  */
7 
8 #include <linux/kernel.h>
9 #include <linux/module.h>
10 #include <linux/pci.h>
11 #include <linux/types.h>
12 #include <linux/slab.h>
13 
14 #include <uapi/misc/pvpanic.h>
15 
16 #include "pvpanic.h"
17 
18 #define PCI_VENDOR_ID_REDHAT             0x1b36
19 #define PCI_DEVICE_ID_REDHAT_PVPANIC     0x0011
20 
21 MODULE_AUTHOR("Mihai Carabas <mihai.carabas@oracle.com>");
22 MODULE_DESCRIPTION("pvpanic device driver");
23 MODULE_LICENSE("GPL");
24 
pvpanic_pci_probe(struct pci_dev * pdev,const struct pci_device_id * ent)25 static int pvpanic_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
26 {
27 	void __iomem *base;
28 	int ret;
29 
30 	ret = pcim_enable_device(pdev);
31 	if (ret < 0)
32 		return ret;
33 
34 	base = pcim_iomap(pdev, 0, 0);
35 	if (!base)
36 		return -ENOMEM;
37 
38 	return devm_pvpanic_probe(&pdev->dev, base);
39 }
40 
41 static const struct pci_device_id pvpanic_pci_id_tbl[]  = {
42 	{ PCI_DEVICE(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_PVPANIC)},
43 	{}
44 };
45 MODULE_DEVICE_TABLE(pci, pvpanic_pci_id_tbl);
46 
47 static struct pci_driver pvpanic_pci_driver = {
48 	.name =         "pvpanic-pci",
49 	.id_table =     pvpanic_pci_id_tbl,
50 	.probe =        pvpanic_pci_probe,
51 	.dev_groups =   pvpanic_dev_groups,
52 };
53 module_pci_driver(pvpanic_pci_driver);
54