1*68046d50SOndrej Zary // SPDX-License-Identifier: GPL-2.0
2*68046d50SOndrej Zary
3*68046d50SOndrej Zary #include <linux/module.h>
4*68046d50SOndrej Zary #include <linux/pci.h>
5*68046d50SOndrej Zary #include "fdomain.h"
6*68046d50SOndrej Zary
fdomain_pci_probe(struct pci_dev * pdev,const struct pci_device_id * d)7*68046d50SOndrej Zary static int fdomain_pci_probe(struct pci_dev *pdev,
8*68046d50SOndrej Zary const struct pci_device_id *d)
9*68046d50SOndrej Zary {
10*68046d50SOndrej Zary int err;
11*68046d50SOndrej Zary struct Scsi_Host *sh;
12*68046d50SOndrej Zary
13*68046d50SOndrej Zary err = pci_enable_device(pdev);
14*68046d50SOndrej Zary if (err)
15*68046d50SOndrej Zary goto fail;
16*68046d50SOndrej Zary
17*68046d50SOndrej Zary err = pci_request_regions(pdev, "fdomain_pci");
18*68046d50SOndrej Zary if (err)
19*68046d50SOndrej Zary goto disable_device;
20*68046d50SOndrej Zary
21*68046d50SOndrej Zary err = -ENODEV;
22*68046d50SOndrej Zary if (pci_resource_len(pdev, 0) == 0)
23*68046d50SOndrej Zary goto release_region;
24*68046d50SOndrej Zary
25*68046d50SOndrej Zary sh = fdomain_create(pci_resource_start(pdev, 0), pdev->irq, 7,
26*68046d50SOndrej Zary &pdev->dev);
27*68046d50SOndrej Zary if (!sh)
28*68046d50SOndrej Zary goto release_region;
29*68046d50SOndrej Zary
30*68046d50SOndrej Zary pci_set_drvdata(pdev, sh);
31*68046d50SOndrej Zary return 0;
32*68046d50SOndrej Zary
33*68046d50SOndrej Zary release_region:
34*68046d50SOndrej Zary pci_release_regions(pdev);
35*68046d50SOndrej Zary disable_device:
36*68046d50SOndrej Zary pci_disable_device(pdev);
37*68046d50SOndrej Zary fail:
38*68046d50SOndrej Zary return err;
39*68046d50SOndrej Zary }
40*68046d50SOndrej Zary
fdomain_pci_remove(struct pci_dev * pdev)41*68046d50SOndrej Zary static void fdomain_pci_remove(struct pci_dev *pdev)
42*68046d50SOndrej Zary {
43*68046d50SOndrej Zary struct Scsi_Host *sh = pci_get_drvdata(pdev);
44*68046d50SOndrej Zary
45*68046d50SOndrej Zary fdomain_destroy(sh);
46*68046d50SOndrej Zary pci_release_regions(pdev);
47*68046d50SOndrej Zary pci_disable_device(pdev);
48*68046d50SOndrej Zary }
49*68046d50SOndrej Zary
50*68046d50SOndrej Zary static struct pci_device_id fdomain_pci_table[] = {
51*68046d50SOndrej Zary { PCI_DEVICE(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70) },
52*68046d50SOndrej Zary {}
53*68046d50SOndrej Zary };
54*68046d50SOndrej Zary MODULE_DEVICE_TABLE(pci, fdomain_pci_table);
55*68046d50SOndrej Zary
56*68046d50SOndrej Zary static struct pci_driver fdomain_pci_driver = {
57*68046d50SOndrej Zary .name = "fdomain_pci",
58*68046d50SOndrej Zary .id_table = fdomain_pci_table,
59*68046d50SOndrej Zary .probe = fdomain_pci_probe,
60*68046d50SOndrej Zary .remove = fdomain_pci_remove,
61*68046d50SOndrej Zary .driver.pm = FDOMAIN_PM_OPS,
62*68046d50SOndrej Zary };
63*68046d50SOndrej Zary
64*68046d50SOndrej Zary module_pci_driver(fdomain_pci_driver);
65*68046d50SOndrej Zary
66*68046d50SOndrej Zary MODULE_AUTHOR("Ondrej Zary, Rickard E. Faith");
67*68046d50SOndrej Zary MODULE_DESCRIPTION("Future Domain TMC-3260 PCI SCSI driver");
68*68046d50SOndrej Zary MODULE_LICENSE("GPL");
69