linux/drivers/platform/x86/acerhdf.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * acerhdf - A driver which monitors the temperature
 *           of the aspire one netbook, turns on/off the fan
 *           as soon as the upper/lower threshold is reached.
 *
 * (C) 2009 - Peter Kaestle     peter (a) piie.net
 *                              https://piie.net
 *     2009 Borislav Petkov	bp (a) alien8.de
 *
 * Inspired by and many thanks to:
 *  o acerfand   - Rachel Greenham
 *  o acer_ec.pl - Michael Kurz     michi.kurz (at) googlemail.com
 *               - Petr Tomasek     tomasek (#) etf,cuni,cz
 *               - Carlos Corbacho  cathectic (at) gmail.com
 *  o lkml       - Matthew Garrett
 *               - Borislav Petkov
 *               - Andreas Mohr
 */

#define pr_fmt(fmt)

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/dmi.h>
#include <linux/acpi.h>
#include <linux/thermal.h>
#include <linux/platform_device.h>

/*
 * The driver is started with "kernel mode off" by default. That means, the BIOS
 * is still in control of the fan. In this mode the driver allows to read the
 * temperature of the cpu and a userspace tool may take over control of the fan.
 * If the driver is switched to "kernel mode" (e.g. via module parameter) the
 * driver is in full control of the fan. If you want the module to be started in
 * kernel mode by default, define the following:
 */
#undef START_IN_KERNEL_MODE

#define DRV_VER

/*
 * According to the Atom N270 datasheet,
 * (http://download.intel.com/design/processor/datashts/320032.pdf) the
 * CPU's optimal operating limits denoted in junction temperature as
 * measured by the on-die thermal monitor are within 0 <= Tj <= 90. So,
 * assume 89°C is critical temperature.
 */
#define ACERHDF_DEFAULT_TEMP_FANON
#define ACERHDF_DEFAULT_TEMP_FANOFF
#define ACERHDF_TEMP_CRIT
#define ACERHDF_FAN_OFF
#define ACERHDF_FAN_AUTO

/*
 * No matter what value the user puts into the fanon variable, turn on the fan
 * at 80 degree Celsius to prevent hardware damage
 */
#define ACERHDF_MAX_FANON

/*
 * Maximum interval between two temperature checks is 15 seconds, as the die
 * can get hot really fast under heavy load (plus we shouldn't forget about
 * possible impact of _external_ aggressive sources such as heaters, sun etc.)
 */
#define ACERHDF_MAX_INTERVAL

#ifdef START_IN_KERNEL_MODE
static int kernelmode = 1;
#else
static int kernelmode;
#endif

static unsigned int interval =;
static unsigned int fanon =;
static unsigned int fanoff =;
static unsigned int verbose;
static unsigned int list_supported;
static unsigned int fanstate =;
static char force_bios[16];
static char force_product[16];
static struct thermal_zone_device *thz_dev;
static struct thermal_cooling_device *cl_dev;
static struct platform_device *acerhdf_dev;

module_param(kernelmode, uint, 0);
MODULE_PARM_DESC();
module_param(fanon, uint, 0600);
MODULE_PARM_DESC();
module_param(fanoff, uint, 0600);
MODULE_PARM_DESC();
module_param(verbose, uint, 0600);
MODULE_PARM_DESC();
module_param(list_supported, uint, 0600);
MODULE_PARM_DESC();
module_param_string();
MODULE_PARM_DESC();
module_param_string();
MODULE_PARM_DESC();

/*
 * cmd_off: to switch the fan completely off and check if the fan is off
 *	cmd_auto: to set the BIOS in control of the fan. The BIOS regulates then
 *		the fan speed depending on the temperature
 */
struct fancmd {};

struct manualcmd {};

/* default register and command to disable fan in manual mode */
static const struct manualcmd mcmd =;

/* BIOS settings - only used during probe */
struct bios_settings {};

/* This could be a daughter struct in the above, but not worth the redirect */
struct ctrl_settings {};

static struct thermal_trip trips[] =;

static struct ctrl_settings ctrl_cfg __read_mostly;

/* Register addresses and values for different BIOS versions */
static const struct bios_settings bios_tbl[] __initconst =;

/*
 * this struct is used to instruct thermal layer to use bang_bang instead of
 * default governor for acerhdf
 */
static struct thermal_zone_params acerhdf_zone_params =;

static int acerhdf_get_temp(int *temp)
{}

static int acerhdf_get_fanstate(int *state)
{}

static void acerhdf_change_fanstate(int state)
{}

static void acerhdf_check_param(struct thermal_zone_device *thermal)
{}

/*
 * This is the thermal zone callback which does the delayed polling of the fan
 * state. We do check /sysfs-originating settings here in acerhdf_check_param()
 * as late as the polling interval is since we can't do that in the respective
 * accessors of the module parameters.
 */
static int acerhdf_get_ec_temp(struct thermal_zone_device *thermal, int *t)
{}

static bool acerhdf_should_bind(struct thermal_zone_device *thermal,
				const struct thermal_trip *trip,
				struct thermal_cooling_device *cdev,
				struct cooling_spec *c)
{}

static inline void acerhdf_revert_to_bios_mode(void)
{}
static inline void acerhdf_enable_kernelmode(void)
{}

/*
 * set operation mode;
 * enabled: the thermal layer of the kernel takes care about
 *          the temperature and the fan.
 * disabled: the BIOS takes control of the fan.
 */
static int acerhdf_change_mode(struct thermal_zone_device *thermal,
			       enum thermal_device_mode mode)
{}

static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal,
				 int *temperature)
{}

/* bind callback functions to thermalzone */
static struct thermal_zone_device_ops acerhdf_dev_ops =;

/*
 * cooling device callback functions
 * get maximal fan cooling state
 */
static int acerhdf_get_max_state(struct thermal_cooling_device *cdev,
				 unsigned long *state)
{}

static int acerhdf_get_cur_state(struct thermal_cooling_device *cdev,
				 unsigned long *state)
{}

/* change current fan state - is overwritten when running in kernel mode */
static int acerhdf_set_cur_state(struct thermal_cooling_device *cdev,
				 unsigned long state)
{}

/* bind fan callbacks to fan device */
static const struct thermal_cooling_device_ops acerhdf_cooling_ops =;

/* suspend / resume functionality */
static int acerhdf_suspend(struct device *dev)
{}

static int acerhdf_probe(struct platform_device *device)
{}

static const struct dev_pm_ops acerhdf_pm_ops =;

static struct platform_driver acerhdf_driver =;

/* check hardware */
static int __init acerhdf_check_hardware(void)
{}

static int __init acerhdf_register_platform(void)
{}

static void acerhdf_unregister_platform(void)
{}

static int __init acerhdf_register_thermal(void)
{}

static void acerhdf_unregister_thermal(void)
{}

static int __init acerhdf_init(void)
{}

static void __exit acerhdf_exit(void)
{}

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();

module_init();
module_exit(acerhdf_exit);

static int interval_set_uint(const char *val, const struct kernel_param *kp)
{}

static const struct kernel_param_ops interval_ops =;

module_param_cb();
MODULE_PARM_DESC();