Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Intel(R) Trace Hub ACPI driver
0004  *
0005  * Copyright (C) 2017 Intel Corporation.
0006  */
0007 
0008 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0009 
0010 #include <linux/types.h>
0011 #include <linux/module.h>
0012 #include <linux/device.h>
0013 #include <linux/sysfs.h>
0014 #include <linux/platform_device.h>
0015 #include <linux/acpi.h>
0016 
0017 #include "intel_th.h"
0018 
0019 #define DRIVER_NAME "intel_th_acpi"
0020 
0021 static const struct intel_th_drvdata intel_th_acpi_pch = {
0022     .host_mode_only = 1,
0023 };
0024 
0025 static const struct intel_th_drvdata intel_th_acpi_uncore = {
0026     .host_mode_only = 1,
0027 };
0028 
0029 static const struct acpi_device_id intel_th_acpi_ids[] = {
0030     { "INTC1000",   (kernel_ulong_t)&intel_th_acpi_uncore },
0031     { "INTC1001",   (kernel_ulong_t)&intel_th_acpi_pch },
0032     { "",       0 },
0033 };
0034 
0035 MODULE_DEVICE_TABLE(acpi, intel_th_acpi_ids);
0036 
0037 static int intel_th_acpi_probe(struct platform_device *pdev)
0038 {
0039     struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
0040     struct resource resource[TH_MMIO_END];
0041     const struct acpi_device_id *id;
0042     struct intel_th *th;
0043     int i, r;
0044 
0045     id = acpi_match_device(intel_th_acpi_ids, &pdev->dev);
0046     if (!id)
0047         return -ENODEV;
0048 
0049     for (i = 0, r = 0; i < pdev->num_resources && r < TH_MMIO_END; i++)
0050         if (pdev->resource[i].flags &
0051             (IORESOURCE_IRQ | IORESOURCE_MEM))
0052             resource[r++] = pdev->resource[i];
0053 
0054     th = intel_th_alloc(&pdev->dev, (void *)id->driver_data, resource, r);
0055     if (IS_ERR(th))
0056         return PTR_ERR(th);
0057 
0058     adev->driver_data = th;
0059 
0060     return 0;
0061 }
0062 
0063 static int intel_th_acpi_remove(struct platform_device *pdev)
0064 {
0065     struct intel_th *th = platform_get_drvdata(pdev);
0066 
0067     intel_th_free(th);
0068 
0069     return 0;
0070 }
0071 
0072 static struct platform_driver intel_th_acpi_driver = {
0073     .probe      = intel_th_acpi_probe,
0074     .remove     = intel_th_acpi_remove,
0075     .driver     = {
0076         .name           = DRIVER_NAME,
0077         .acpi_match_table   = intel_th_acpi_ids,
0078     },
0079 };
0080 
0081 module_platform_driver(intel_th_acpi_driver);
0082 
0083 MODULE_LICENSE("GPL v2");
0084 MODULE_DESCRIPTION("Intel(R) Trace Hub ACPI controller driver");
0085 MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@intel.com>");