Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / hwtracing / intel_th / acpi.c
blob87f9024e4bbb7c945fb62b81540fd9b5b2cca209
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Intel(R) Trace Hub ACPI driver
5 * Copyright (C) 2017 Intel Corporation.
6 */
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/types.h>
11 #include <linux/module.h>
12 #include <linux/device.h>
13 #include <linux/sysfs.h>
14 #include <linux/platform_device.h>
15 #include <linux/acpi.h>
17 #include "intel_th.h"
19 #define DRIVER_NAME "intel_th_acpi"
21 static const struct intel_th_drvdata intel_th_acpi_pch = {
22 .host_mode_only = 1,
25 static const struct intel_th_drvdata intel_th_acpi_uncore = {
26 .host_mode_only = 1,
29 static const struct acpi_device_id intel_th_acpi_ids[] = {
30 { "INTC1000", (kernel_ulong_t)&intel_th_acpi_uncore },
31 { "INTC1001", (kernel_ulong_t)&intel_th_acpi_pch },
32 { "", 0 },
35 MODULE_DEVICE_TABLE(acpi, intel_th_acpi_ids);
37 static int intel_th_acpi_probe(struct platform_device *pdev)
39 struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
40 struct resource resource[TH_MMIO_END];
41 const struct acpi_device_id *id;
42 struct intel_th *th;
43 int i, r;
45 id = acpi_match_device(intel_th_acpi_ids, &pdev->dev);
46 if (!id)
47 return -ENODEV;
49 for (i = 0, r = 0; i < pdev->num_resources && r < TH_MMIO_END; i++)
50 if (pdev->resource[i].flags &
51 (IORESOURCE_IRQ | IORESOURCE_MEM))
52 resource[r++] = pdev->resource[i];
54 th = intel_th_alloc(&pdev->dev, (void *)id->driver_data, resource, r);
55 if (IS_ERR(th))
56 return PTR_ERR(th);
58 adev->driver_data = th;
60 return 0;
63 static int intel_th_acpi_remove(struct platform_device *pdev)
65 struct intel_th *th = platform_get_drvdata(pdev);
67 intel_th_free(th);
69 return 0;
72 static struct platform_driver intel_th_acpi_driver = {
73 .probe = intel_th_acpi_probe,
74 .remove = intel_th_acpi_remove,
75 .driver = {
76 .name = DRIVER_NAME,
77 .acpi_match_table = intel_th_acpi_ids,
81 module_platform_driver(intel_th_acpi_driver);
83 MODULE_LICENSE("GPL v2");
84 MODULE_DESCRIPTION("Intel(R) Trace Hub ACPI controller driver");
85 MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@intel.com>");