pci.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. return 0;
  40. }
  41. static void intel_th_pci_remove(struct pci_dev *pdev)
  42. {
  43. struct intel_th *th = pci_get_drvdata(pdev);
  44. intel_th_free(th);
  45. }
  46. static const struct pci_device_id intel_th_pci_id_table[] = {
  47. {
  48. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x9d26),
  49. .driver_data = (kernel_ulong_t)0,
  50. },
  51. {
  52. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa126),
  53. .driver_data = (kernel_ulong_t)0,
  54. },
  55. {
  56. /* Apollo Lake */
  57. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a8e),
  58. .driver_data = (kernel_ulong_t)0,
  59. },
  60. {
  61. /* Broxton */
  62. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0a80),
  63. .driver_data = (kernel_ulong_t)0,
  64. },
  65. {
  66. /* Broxton B-step */
  67. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1a8e),
  68. .driver_data = (kernel_ulong_t)0,
  69. },
  70. {
  71. /* Kaby Lake PCH-H */
  72. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa2a6),
  73. .driver_data = (kernel_ulong_t)0,
  74. },
  75. {
  76. /* Cannon Lake H */
  77. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa326),
  78. .driver_data = (kernel_ulong_t)0,
  79. },
  80. {
  81. /* Cannon Lake LP */
  82. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x9da6),
  83. .driver_data = (kernel_ulong_t)0,
  84. },
  85. {
  86. /* Gemini Lake */
  87. PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x318e),
  88. .driver_data = (kernel_ulong_t)0,
  89. },
  90. { 0 },
  91. };
  92. MODULE_DEVICE_TABLE(pci, intel_th_pci_id_table);
  93. static struct pci_driver intel_th_pci_driver = {
  94. .name = DRIVER_NAME,
  95. .id_table = intel_th_pci_id_table,
  96. .probe = intel_th_pci_probe,
  97. .remove = intel_th_pci_remove,
  98. };
  99. module_pci_driver(intel_th_pci_driver);
  100. MODULE_LICENSE("GPL v2");
  101. MODULE_DESCRIPTION("Intel(R) Trace Hub PCI controller driver");
  102. MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@intel.com>");