cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

int3401_thermal.c (1992B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/*
      3 * INT3401 processor thermal device
      4 * Copyright (c) 2020, Intel Corporation.
      5 */
      6#include <linux/acpi.h>
      7#include <linux/kernel.h>
      8#include <linux/module.h>
      9#include <linux/platform_device.h>
     10#include <linux/thermal.h>
     11
     12#include "int340x_thermal_zone.h"
     13#include "processor_thermal_device.h"
     14
     15static const struct acpi_device_id int3401_device_ids[] = {
     16	{"INT3401", 0},
     17	{"", 0},
     18};
     19MODULE_DEVICE_TABLE(acpi, int3401_device_ids);
     20
     21static int int3401_add(struct platform_device *pdev)
     22{
     23	struct proc_thermal_device *proc_priv;
     24	int ret;
     25
     26	proc_priv = devm_kzalloc(&pdev->dev, sizeof(*proc_priv), GFP_KERNEL);
     27	if (!proc_priv)
     28		return -ENOMEM;
     29
     30	ret = proc_thermal_add(&pdev->dev, proc_priv);
     31	if (ret)
     32		return ret;
     33
     34	platform_set_drvdata(pdev, proc_priv);
     35
     36	return ret;
     37}
     38
     39static int int3401_remove(struct platform_device *pdev)
     40{
     41	proc_thermal_remove(platform_get_drvdata(pdev));
     42
     43	return 0;
     44}
     45
     46#ifdef CONFIG_PM_SLEEP
     47static int int3401_thermal_suspend(struct device *dev)
     48{
     49	return proc_thermal_suspend(dev);
     50}
     51static int int3401_thermal_resume(struct device *dev)
     52{
     53	return proc_thermal_resume(dev);
     54}
     55#else
     56#define int3401_thermal_suspend NULL
     57#define int3401_thermal_resume NULL
     58#endif
     59
     60static SIMPLE_DEV_PM_OPS(int3401_proc_thermal_pm, int3401_thermal_suspend,
     61			 int3401_thermal_resume);
     62
     63static struct platform_driver int3401_driver = {
     64	.probe = int3401_add,
     65	.remove = int3401_remove,
     66	.driver = {
     67		.name = "int3401 thermal",
     68		.acpi_match_table = int3401_device_ids,
     69		.pm = &int3401_proc_thermal_pm,
     70	},
     71};
     72
     73static int __init proc_thermal_init(void)
     74{
     75	return platform_driver_register(&int3401_driver);
     76}
     77
     78static void __exit proc_thermal_exit(void)
     79{
     80	platform_driver_unregister(&int3401_driver);
     81}
     82
     83module_init(proc_thermal_init);
     84module_exit(proc_thermal_exit);
     85
     86MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
     87MODULE_DESCRIPTION("Processor Thermal Reporting Device Driver");
     88MODULE_LICENSE("GPL v2");