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