pci.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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_master(pdev);
  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. {
  57. /* Apollo Lake */
  58. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a8e),
  59. .driver_data = (kernel_ulong_t)0,
  60. },
  61. {
  62. /* Broxton */
  63. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0a80),
  64. .driver_data = (kernel_ulong_t)0,
  65. },
  66. {
  67. /* Broxton B-step */
  68. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1a8e),
  69. .driver_data = (kernel_ulong_t)0,
  70. },
  71. {
  72. /* Kaby Lake PCH-H */
  73. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa2a6),
  74. .driver_data = (kernel_ulong_t)0,
  75. },
  76. {
  77. /* Denverton */
  78. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x19e1),
  79. .driver_data = (kernel_ulong_t)0,
  80. },
  81. {
  82. /* Gemini Lake */
  83. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x318e),
  84. .driver_data = (kernel_ulong_t)0,
  85. },
  86. {
  87. /* Cannon Lake H */
  88. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa326),
  89. .driver_data = (kernel_ulong_t)0,
  90. },
  91. {
  92. /* Cannon Lake LP */
  93. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x9da6),
  94. .driver_data = (kernel_ulong_t)0,
  95. },
  96. { 0 },
  97. };
  98. MODULE_DEVICE_TABLE(pci, intel_th_pci_id_table);
  99. static struct pci_driver intel_th_pci_driver = {
  100. .name = DRIVER_NAME,
  101. .id_table = intel_th_pci_id_table,
  102. .probe = intel_th_pci_probe,
  103. .remove = intel_th_pci_remove,
  104. };
  105. module_pci_driver(intel_th_pci_driver);
  106. MODULE_LICENSE("GPL v2");
  107. MODULE_DESCRIPTION("Intel(R) Trace Hub PCI controller driver");
  108. MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@intel.com>");