linux/drivers/thermal/intel/x86_pkg_temp_thermal.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * x86_pkg_temp_thermal driver
 * Copyright (c) 2013, Intel Corporation.
 */
#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/init.h>
#include <linux/intel_tcc.h>
#include <linux/err.h>
#include <linux/param.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/cpu.h>
#include <linux/smp.h>
#include <linux/slab.h>
#include <linux/pm.h>
#include <linux/thermal.h>
#include <linux/debugfs.h>

#include <asm/cpu_device_id.h>

#include "thermal_interrupt.h"

/*
* Rate control delay: Idea is to introduce denounce effect
* This should be long enough to avoid reduce events, when
* threshold is set to a temperature, which is constantly
* violated, but at the short enough to take any action.
* The action can be remove threshold or change it to next
* interesting setting. Based on experiments, in around
* every 5 seconds under load will give us a significant
* temperature change.
*/
#define PKG_TEMP_THERMAL_NOTIFY_DELAY
static int notify_delay_ms =;
module_param(notify_delay_ms, int, 0644);
MODULE_PARM_DESC();

/* Number of trip points in thermal zone. Currently it can't
* be more than 2. MSR can allow setting and getting notifications
* for only 2 thresholds. This define enforces this, if there
* is some wrong values returned by cpuid for number of thresholds.
*/
#define MAX_NUMBER_OF_TRIPS

struct zone_device {};

static struct thermal_zone_params pkg_temp_tz_params =;

/* Keep track of how many zone pointers we allocated in init() */
static int max_id __read_mostly;
/* Array of zone pointers */
static struct zone_device **zones;
/* Serializes interrupt notification, work and hotplug */
static DEFINE_RAW_SPINLOCK(pkg_temp_lock);
/* Protects zone operation in the work function against hotplug removal */
static DEFINE_MUTEX(thermal_zone_mutex);

/* The dynamically assigned cpu hotplug state for module_exit() */
static enum cpuhp_state pkg_thermal_hp_state __read_mostly;

/* Debug counters to show using debugfs */
static struct dentry *debugfs;
static unsigned int pkg_interrupt_cnt;
static unsigned int pkg_work_cnt;

static void pkg_temp_debugfs_init(void)
{}

/*
 * Protection:
 *
 * - cpu hotplug: Read serialized by cpu hotplug lock
 *		  Write must hold pkg_temp_lock
 *
 * - Other callsites: Must hold pkg_temp_lock
 */
static struct zone_device *pkg_temp_thermal_get_dev(unsigned int cpu)
{}

static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
{}

static int
sys_set_trip_temp(struct thermal_zone_device *tzd,
		  const struct thermal_trip *trip, int temp)
{}

/* Thermal zone callback registry */
static const struct thermal_zone_device_ops tzone_ops =;

static bool pkg_thermal_rate_control(void)
{}

/* Enable threshold interrupt on local package/cpu */
static inline void enable_pkg_thres_interrupt(void)
{}

/* Disable threshold interrupt on local package/cpu */
static inline void disable_pkg_thres_interrupt(void)
{}

static void pkg_temp_thermal_threshold_work_fn(struct work_struct *work)
{}

static void pkg_thermal_schedule_work(int cpu, struct delayed_work *work)
{}

static int pkg_thermal_notify(u64 msr_val)
{}

static int pkg_temp_thermal_trips_init(int cpu, int tj_max,
				       struct thermal_trip *trips, int num_trips)
{}

static int pkg_temp_thermal_device_add(unsigned int cpu)
{}

static int pkg_thermal_cpu_offline(unsigned int cpu)
{}

static int pkg_thermal_cpu_online(unsigned int cpu)
{}

static const struct x86_cpu_id __initconst pkg_temp_thermal_ids[] =;
MODULE_DEVICE_TABLE(x86cpu, pkg_temp_thermal_ids);

static int __init pkg_temp_thermal_init(void)
{}
module_init()

static void __exit pkg_temp_thermal_exit(void)
{}
module_exit()

MODULE_IMPORT_NS();
MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();