acpi.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Intel(R) Trace Hub ACPI driver
  4. *
  5. * Copyright (C) 2017 Intel Corporation.
  6. */
  7. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  8. #include <linux/types.h>
  9. #include <linux/module.h>
  10. #include <linux/device.h>
  11. #include <linux/sysfs.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/acpi.h>
  14. #include "intel_th.h"
  15. #define DRIVER_NAME "intel_th_acpi"
  16. static const struct intel_th_drvdata intel_th_acpi_pch = {
  17. .host_mode_only = 1,
  18. };
  19. static const struct intel_th_drvdata intel_th_acpi_uncore = {
  20. .host_mode_only = 1,
  21. };
  22. static const struct acpi_device_id intel_th_acpi_ids[] = {
  23. { "INTC1000", (kernel_ulong_t)&intel_th_acpi_uncore },
  24. { "INTC1001", (kernel_ulong_t)&intel_th_acpi_pch },
  25. { "", 0 },
  26. };
  27. MODULE_DEVICE_TABLE(acpi, intel_th_acpi_ids);
  28. static int intel_th_acpi_probe(struct platform_device *pdev)
  29. {
  30. struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
  31. struct resource resource[TH_MMIO_END];
  32. const struct acpi_device_id *id;
  33. struct intel_th *th;
  34. int i, r;
  35. id = acpi_match_device(intel_th_acpi_ids, &pdev->dev);
  36. if (!id)
  37. return -ENODEV;
  38. for (i = 0, r = 0; i < pdev->num_resources && r < TH_MMIO_END; i++)
  39. if (pdev->resource[i].flags &
  40. (IORESOURCE_IRQ | IORESOURCE_MEM))
  41. resource[r++] = pdev->resource[i];
  42. th = intel_th_alloc(&pdev->dev, (void *)id->driver_data, resource, r);
  43. if (IS_ERR(th))
  44. return PTR_ERR(th);
  45. adev->driver_data = th;
  46. return 0;
  47. }
  48. static int intel_th_acpi_remove(struct platform_device *pdev)
  49. {
  50. struct intel_th *th = platform_get_drvdata(pdev);
  51. intel_th_free(th);
  52. return 0;
  53. }
  54. static struct platform_driver intel_th_acpi_driver = {
  55. .probe = intel_th_acpi_probe,
  56. .remove = intel_th_acpi_remove,
  57. .driver = {
  58. .name = DRIVER_NAME,
  59. .acpi_match_table = intel_th_acpi_ids,
  60. },
  61. };
  62. module_platform_driver(intel_th_acpi_driver);
  63. MODULE_LICENSE("GPL v2");
  64. MODULE_DESCRIPTION("Intel(R) Trace Hub ACPI controller driver");
  65. MODULE_AUTHOR("Alexander Shishkin <[email protected]>");