xref: /linux/drivers/misc/pvpanic/pvpanic-pci.c (revision 4232da23d75d173195c6766729e51947b64f83cd)
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 
8*7037f714SAndy Shevchenko #include <linux/errno.h>
9db3a4f0aSMihai Carabas #include <linux/module.h>
10db3a4f0aSMihai Carabas #include <linux/pci.h>
11db3a4f0aSMihai Carabas #include <linux/types.h>
12db3a4f0aSMihai Carabas 
13db3a4f0aSMihai Carabas #include "pvpanic.h"
14db3a4f0aSMihai Carabas 
15db3a4f0aSMihai Carabas #define PCI_DEVICE_ID_REDHAT_PVPANIC     0x0011
16db3a4f0aSMihai Carabas 
17db3a4f0aSMihai Carabas MODULE_AUTHOR("Mihai Carabas <mihai.carabas@oracle.com>");
18db3a4f0aSMihai Carabas MODULE_DESCRIPTION("pvpanic device driver");
19db3a4f0aSMihai Carabas MODULE_LICENSE("GPL");
20db3a4f0aSMihai Carabas 
pvpanic_pci_probe(struct pci_dev * pdev,const struct pci_device_id * ent)2184b0f12aSAndy Shevchenko static int pvpanic_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
22db3a4f0aSMihai Carabas {
23db3a4f0aSMihai Carabas 	void __iomem *base;
24db3a4f0aSMihai Carabas 	int ret;
25db3a4f0aSMihai Carabas 
26372dae89SChristophe JAILLET 	ret = pcim_enable_device(pdev);
27db3a4f0aSMihai Carabas 	if (ret < 0)
28db3a4f0aSMihai Carabas 		return ret;
29db3a4f0aSMihai Carabas 
30372dae89SChristophe JAILLET 	base = pcim_iomap(pdev, 0, 0);
31642fa28bSQiheng Lin 	if (!base)
32642fa28bSQiheng Lin 		return -ENOMEM;
33db3a4f0aSMihai Carabas 
34c1426d39SThomas Weißschuh 	return devm_pvpanic_probe(&pdev->dev, base);
35db3a4f0aSMihai Carabas }
36db3a4f0aSMihai Carabas 
3733a43041SAndy Shevchenko static const struct pci_device_id pvpanic_pci_id_tbl[]  = {
3833a43041SAndy Shevchenko 	{ PCI_DEVICE(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_PVPANIC)},
3933a43041SAndy Shevchenko 	{}
4033a43041SAndy Shevchenko };
4133a43041SAndy Shevchenko MODULE_DEVICE_TABLE(pci, pvpanic_pci_id_tbl);
4233a43041SAndy Shevchenko 
43db3a4f0aSMihai Carabas static struct pci_driver pvpanic_pci_driver = {
44db3a4f0aSMihai Carabas 	.name =         "pvpanic-pci",
45db3a4f0aSMihai Carabas 	.id_table =     pvpanic_pci_id_tbl,
46db3a4f0aSMihai Carabas 	.probe =        pvpanic_pci_probe,
47c1426d39SThomas Weißschuh 	.dev_groups =   pvpanic_dev_groups,
48db3a4f0aSMihai Carabas };
49db3a4f0aSMihai Carabas module_pci_driver(pvpanic_pci_driver);
50