0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <linux/acpi.h>
0015 #include <linux/module.h>
0016 #include <linux/platform_device.h>
0017
0018 #include <asm/cpu_device_id.h>
0019 #include <asm/intel-family.h>
0020
0021 static void intel_pmc_core_release(struct device *dev)
0022 {
0023 kfree(dev);
0024 }
0025
0026 static struct platform_device *pmc_core_device;
0027
0028
0029
0030
0031
0032
0033
0034
0035 static const struct x86_cpu_id intel_pmc_core_platform_ids[] = {
0036 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_L, &pmc_core_device),
0037 X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE, &pmc_core_device),
0038 X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE_L, &pmc_core_device),
0039 X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE, &pmc_core_device),
0040 X86_MATCH_INTEL_FAM6_MODEL(CANNONLAKE_L, &pmc_core_device),
0041 X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_L, &pmc_core_device),
0042 X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE, &pmc_core_device),
0043 X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE_L, &pmc_core_device),
0044 {}
0045 };
0046 MODULE_DEVICE_TABLE(x86cpu, intel_pmc_core_platform_ids);
0047
0048 static int __init pmc_core_platform_init(void)
0049 {
0050 int retval;
0051
0052
0053 if (acpi_dev_present("INT33A1", NULL, -1))
0054 return -ENODEV;
0055
0056 if (!x86_match_cpu(intel_pmc_core_platform_ids))
0057 return -ENODEV;
0058
0059 pmc_core_device = kzalloc(sizeof(*pmc_core_device), GFP_KERNEL);
0060 if (!pmc_core_device)
0061 return -ENOMEM;
0062
0063 pmc_core_device->name = "intel_pmc_core";
0064 pmc_core_device->dev.release = intel_pmc_core_release;
0065
0066 retval = platform_device_register(pmc_core_device);
0067 if (retval)
0068 platform_device_put(pmc_core_device);
0069
0070 return retval;
0071 }
0072
0073 static void __exit pmc_core_platform_exit(void)
0074 {
0075 platform_device_unregister(pmc_core_device);
0076 }
0077
0078 module_init(pmc_core_platform_init);
0079 module_exit(pmc_core_platform_exit);
0080 MODULE_LICENSE("GPL v2");