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