pci.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Intel(R) Trace Hub pci driver
  3. *
  4. * Copyright (C) 2014-2015 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. */
  15. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  16. #include <linux/types.h>
  17. #include <linux/module.h>
  18. #include <linux/device.h>
  19. #include <linux/sysfs.h>
  20. #include <linux/pci.h>
  21. #include "intel_th.h"
  22. #define DRIVER_NAME "intel_th_pci"
  23. #define BAR_MASK (BIT(TH_MMIO_CONFIG) | BIT(TH_MMIO_SW))
  24. static int intel_th_pci_probe(struct pci_dev *pdev,
  25. const struct pci_device_id *id)
  26. {
  27. struct intel_th *th;
  28. int err;
  29. err = pcim_enable_device(pdev);
  30. if (err)
  31. return err;
  32. err = pcim_iomap_regions_request_all(pdev, BAR_MASK, DRIVER_NAME);
  33. if (err)
  34. return err;
  35. th = intel_th_alloc(&pdev->dev, pdev->resource,
  36. DEVICE_COUNT_RESOURCE, pdev->irq);
  37. if (IS_ERR(th))
  38. return PTR_ERR(th);
  39. pci_set_drvdata(pdev, th);
  40. return 0;
  41. }
  42. static void intel_th_pci_remove(struct pci_dev *pdev)
  43. {
  44. struct intel_th *th = pci_get_drvdata(pdev);
  45. intel_th_free(th);
  46. }
  47. static const struct pci_device_id intel_th_pci_id_table[] = {
  48. {
  49. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x9d26),
  50. .driver_data = (kernel_ulong_t)0,
  51. },
  52. {
  53. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa126),
  54. .driver_data = (kernel_ulong_t)0,
  55. },
  56. { 0 },
  57. };
  58. MODULE_DEVICE_TABLE(pci, intel_th_pci_id_table);
  59. static struct pci_driver intel_th_pci_driver = {
  60. .name = DRIVER_NAME,
  61. .id_table = intel_th_pci_id_table,
  62. .probe = intel_th_pci_probe,
  63. .remove = intel_th_pci_remove,
  64. };
  65. module_pci_driver(intel_th_pci_driver);
  66. MODULE_LICENSE("GPL v2");
  67. MODULE_DESCRIPTION("Intel(R) Trace Hub PCI controller driver");
  68. MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@intel.com>");