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