pci.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. { 0 },
  66. };
  67. MODULE_DEVICE_TABLE(pci, intel_th_pci_id_table);
  68. static struct pci_driver intel_th_pci_driver = {
  69. .name = DRIVER_NAME,
  70. .id_table = intel_th_pci_id_table,
  71. .probe = intel_th_pci_probe,
  72. .remove = intel_th_pci_remove,
  73. };
  74. module_pci_driver(intel_th_pci_driver);
  75. MODULE_LICENSE("GPL v2");
  76. MODULE_DESCRIPTION("Intel(R) Trace Hub PCI controller driver");
  77. MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@intel.com>");