linux/drivers/hwmon/w83627ehf.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  w83627ehf - Driver for the hardware monitoring functionality of
 *		the Winbond W83627EHF Super-I/O chip
 *  Copyright (C) 2005-2012  Jean Delvare <[email protected]>
 *  Copyright (C) 2006  Yuan Mu (Winbond),
 *			Rudolf Marek <[email protected]>
 *			David Hubbard <[email protected]>
 *			Daniel J Blueman <[email protected]>
 *  Copyright (C) 2010  Sheng-Yuan Huang (Nuvoton) (PS00)
 *
 *  Shamelessly ripped from the w83627hf driver
 *  Copyright (C) 2003  Mark Studebaker
 *
 *  Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help
 *  in testing and debugging this driver.
 *
 *  This driver also supports the W83627EHG, which is the lead-free
 *  version of the W83627EHF.
 *
 *  Supports the following chips:
 *
 *  Chip        #vin    #fan    #pwm    #temp  chip IDs       man ID
 *  w83627ehf   10      5       4       3      0x8850 0x88    0x5ca3
 *					       0x8860 0xa1
 *  w83627dhg    9      5       4       3      0xa020 0xc1    0x5ca3
 *  w83627dhg-p  9      5       4       3      0xb070 0xc1    0x5ca3
 *  w83627uhg    8      2       2       3      0xa230 0xc1    0x5ca3
 *  w83667hg     9      5       3       3      0xa510 0xc1    0x5ca3
 *  w83667hg-b   9      5       3       4      0xb350 0xc1    0x5ca3
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/platform_device.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/acpi.h>
#include <linux/io.h>
#include "lm75.h"

enum kinds {};

/* used to set data->name = w83627ehf_device_names[data->sio_kind] */
static const char * const w83627ehf_device_names[] =;

static unsigned short force_id;
module_param(force_id, ushort, 0);
MODULE_PARM_DESC();

#define DRVNAME

/*
 * Super-I/O constants and functions
 */

#define W83627EHF_LD_HWM
#define W83667HG_LD_VID

#define SIO_REG_LDSEL
#define SIO_REG_DEVID
#define SIO_REG_EN_VRM10
#define SIO_REG_ENABLE
#define SIO_REG_ADDR
#define SIO_REG_VID_CTRL
#define SIO_REG_VID_DATA

#define SIO_W83627EHF_ID
#define SIO_W83627EHG_ID
#define SIO_W83627DHG_ID
#define SIO_W83627DHG_P_ID
#define SIO_W83627UHG_ID
#define SIO_W83667HG_ID
#define SIO_W83667HG_B_ID
#define SIO_ID_MASK

static inline void
superio_outb(int ioreg, int reg, int val)
{}

static inline int
superio_inb(int ioreg, int reg)
{}

static inline void
superio_select(int ioreg, int ld)
{}

static inline int
superio_enter(int ioreg)
{}

static inline void
superio_exit(int ioreg)
{}

/*
 * ISA constants
 */

#define IOREGION_ALIGNMENT
#define IOREGION_OFFSET
#define IOREGION_LENGTH
#define ADDR_REG_OFFSET
#define DATA_REG_OFFSET

#define W83627EHF_REG_BANK
#define W83627EHF_REG_CONFIG

/*
 * Not currently used:
 * REG_MAN_ID has the value 0x5ca3 for all supported chips.
 * REG_CHIP_ID == 0x88/0xa1/0xc1 depending on chip model.
 * REG_MAN_ID is at port 0x4f
 * REG_CHIP_ID is at port 0x58
 */

static const u16 W83627EHF_REG_FAN[] =;
static const u16 W83627EHF_REG_FAN_MIN[] =;

/* The W83627EHF registers for nr=7,8,9 are in bank 5 */
#define W83627EHF_REG_IN_MAX(nr)
#define W83627EHF_REG_IN_MIN(nr)
#define W83627EHF_REG_IN(nr)

static const u16 W83627EHF_REG_TEMP[] =;
static const u16 W83627EHF_REG_TEMP_HYST[] =;
static const u16 W83627EHF_REG_TEMP_OVER[] =;
static const u16 W83627EHF_REG_TEMP_CONFIG[] =;

/* Fan clock dividers are spread over the following five registers */
#define W83627EHF_REG_FANDIV1
#define W83627EHF_REG_FANDIV2
#define W83627EHF_REG_VBAT
#define W83627EHF_REG_DIODE
#define W83627EHF_REG_SMI_OVT

#define W83627EHF_REG_ALARM1
#define W83627EHF_REG_ALARM2
#define W83627EHF_REG_ALARM3

#define W83627EHF_REG_CASEOPEN_DET
#define W83627EHF_REG_CASEOPEN_CLR

/* SmartFan registers */
#define W83627EHF_REG_FAN_STEPUP_TIME
#define W83627EHF_REG_FAN_STEPDOWN_TIME

/* DC or PWM output fan configuration */
static const u8 W83627EHF_REG_PWM_ENABLE[] =;

static const u8 W83627EHF_PWM_MODE_SHIFT[] =;
static const u8 W83627EHF_PWM_ENABLE_SHIFT[] =;

/* FAN Duty Cycle, be used to control */
static const u16 W83627EHF_REG_PWM[] =;
static const u16 W83627EHF_REG_TARGET[] =;
static const u8 W83627EHF_REG_TOLERANCE[] =;

/* Advanced Fan control, some values are common for all fans */
static const u16 W83627EHF_REG_FAN_START_OUTPUT[] =;
static const u16 W83627EHF_REG_FAN_STOP_OUTPUT[] =;
static const u16 W83627EHF_REG_FAN_STOP_TIME[] =;

static const u16 W83627EHF_REG_FAN_MAX_OUTPUT_COMMON[]
						=;
static const u16 W83627EHF_REG_FAN_STEP_OUTPUT_COMMON[]
						=;

static const u16 W83627EHF_REG_FAN_MAX_OUTPUT_W83667_B[] =;
static const u16 W83627EHF_REG_FAN_STEP_OUTPUT_W83667_B[]
						=;

static const u16 W83627EHF_REG_TEMP_OFFSET[] =;

static const char *const w83667hg_b_temp_label[] =;

#define NUM_REG_TEMP

static int is_word_sized(u16 reg)
{}

/*
 * Conversions
 */

/* 1 is PWM mode, output in ms */
static inline unsigned int step_time_from_reg(u8 reg, u8 mode)
{}

static inline u8 step_time_to_reg(unsigned int msec, u8 mode)
{}

static unsigned int fan_from_reg8(u16 reg, unsigned int divreg)
{}

static inline unsigned int
div_from_reg(u8 reg)
{}

/*
 * Some of the voltage inputs have internal scaling, the tables below
 * contain 8 (the ADC LSB in mV) * scaling factor * 100
 */
static const u16 scale_in_common[10] =;
static const u16 scale_in_w83627uhg[9] =;

static inline long in_from_reg(u8 reg, u8 nr, const u16 *scale_in)
{}

static inline u8 in_to_reg(u32 val, u8 nr, const u16 *scale_in)
{}

/*
 * Data structures and manipulation thereof
 */

struct w83627ehf_data {};

struct w83627ehf_sio_data {};

/*
 * On older chips, only registers 0x50-0x5f are banked.
 * On more recent chips, all registers are banked.
 * Assume that is the case and set the bank number for each access.
 * Cache the bank number so it only needs to be set if it changes.
 */
static inline void w83627ehf_set_bank(struct w83627ehf_data *data, u16 reg)
{}

static u16 w83627ehf_read_value(struct w83627ehf_data *data, u16 reg)
{}

static int w83627ehf_write_value(struct w83627ehf_data *data, u16 reg,
				 u16 value)
{}

/* We left-align 8-bit temperature values to make the code simpler */
static u16 w83627ehf_read_temp(struct w83627ehf_data *data, u16 reg)
{}

static int w83627ehf_write_temp(struct w83627ehf_data *data, u16 reg,
				       u16 value)
{}

/* This function assumes that the caller holds data->update_lock */
static void w83627ehf_write_fan_div(struct w83627ehf_data *data, int nr)
{}

static void w83627ehf_update_fan_div(struct w83627ehf_data *data)
{}

static void w83627ehf_update_pwm(struct w83627ehf_data *data)
{}

static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
{}

#define store_in_reg(REG, reg)

store_in_reg()
store_in_reg()

static int
store_fan_min(struct device *dev, struct w83627ehf_data *data, int channel,
	      long val)
{}

#define store_temp_reg(addr, reg)
store_temp_reg(reg_temp_over, temp_max);
store_temp_reg(reg_temp_hyst, temp_max_hyst);

static int
store_temp_offset(struct device *dev, struct w83627ehf_data *data, int channel,
		  long val)
{}

static int
store_pwm_mode(struct device *dev, struct w83627ehf_data *data, int channel,
	       long val)
{}

static int
store_pwm(struct device *dev, struct w83627ehf_data *data, int channel,
	  long val)
{}

static int
store_pwm_enable(struct device *dev, struct w83627ehf_data *data, int channel,
		 long val)
{}

#define show_tol_temp(reg)

show_tol_temp()
show_tol_temp()

static ssize_t
store_target_temp(struct device *dev, struct device_attribute *attr,
			const char *buf, size_t count)
{}

static ssize_t
store_tolerance(struct device *dev, struct device_attribute *attr,
			const char *buf, size_t count)
{}

static SENSOR_DEVICE_ATTR(pwm1_target, 0644, show_target_temp,
	    store_target_temp, 0);
static SENSOR_DEVICE_ATTR(pwm2_target, 0644, show_target_temp,
	    store_target_temp, 1);
static SENSOR_DEVICE_ATTR(pwm3_target, 0644, show_target_temp,
	    store_target_temp, 2);
static SENSOR_DEVICE_ATTR(pwm4_target, 0644, show_target_temp,
	    store_target_temp, 3);

static SENSOR_DEVICE_ATTR(pwm1_tolerance, 0644, show_tolerance,
	    store_tolerance, 0);
static SENSOR_DEVICE_ATTR(pwm2_tolerance, 0644, show_tolerance,
	    store_tolerance, 1);
static SENSOR_DEVICE_ATTR(pwm3_tolerance, 0644, show_tolerance,
	    store_tolerance, 2);
static SENSOR_DEVICE_ATTR(pwm4_tolerance, 0644, show_tolerance,
	    store_tolerance, 3);

/* Smart Fan registers */

#define fan_functions(reg, REG)

fan_functions()
fan_functions()
fan_functions()
fan_functions()

#define fan_time_functions(reg, REG) \

fan_time_functions()

static SENSOR_DEVICE_ATTR(pwm4_stop_time, 0644, show_fan_stop_time,
	    store_fan_stop_time, 3);
static SENSOR_DEVICE_ATTR(pwm4_start_output, 0644, show_fan_start_output,
	    store_fan_start_output, 3);
static SENSOR_DEVICE_ATTR(pwm4_stop_output, 0644, show_fan_stop_output,
	    store_fan_stop_output, 3);
static SENSOR_DEVICE_ATTR(pwm4_max_output, 0644, show_fan_max_output,
	    store_fan_max_output, 3);
static SENSOR_DEVICE_ATTR(pwm4_step_output, 0644, show_fan_step_output,
	    store_fan_step_output, 3);

static SENSOR_DEVICE_ATTR(pwm3_stop_time, 0644, show_fan_stop_time,
	    store_fan_stop_time, 2);
static SENSOR_DEVICE_ATTR(pwm3_start_output, 0644, show_fan_start_output,
	    store_fan_start_output, 2);
static SENSOR_DEVICE_ATTR(pwm3_stop_output, 0644, show_fan_stop_output,
		    store_fan_stop_output, 2);

static SENSOR_DEVICE_ATTR(pwm1_stop_time, 0644, show_fan_stop_time,
	    store_fan_stop_time, 0);
static SENSOR_DEVICE_ATTR(pwm2_stop_time, 0644, show_fan_stop_time,
	    store_fan_stop_time, 1);
static SENSOR_DEVICE_ATTR(pwm1_start_output, 0644, show_fan_start_output,
	    store_fan_start_output, 0);
static SENSOR_DEVICE_ATTR(pwm2_start_output, 0644, show_fan_start_output,
	    store_fan_start_output, 1);
static SENSOR_DEVICE_ATTR(pwm1_stop_output, 0644, show_fan_stop_output,
	    store_fan_stop_output, 0);
static SENSOR_DEVICE_ATTR(pwm2_stop_output, 0644, show_fan_stop_output,
	    store_fan_stop_output, 1);


/*
 * pwm1 and pwm3 don't support max and step settings on all chips.
 * Need to check support while generating/removing attribute files.
 */
static SENSOR_DEVICE_ATTR(pwm1_max_output, 0644, show_fan_max_output,
	    store_fan_max_output, 0);
static SENSOR_DEVICE_ATTR(pwm1_step_output, 0644, show_fan_step_output,
	    store_fan_step_output, 0);
static SENSOR_DEVICE_ATTR(pwm2_max_output, 0644, show_fan_max_output,
	    store_fan_max_output, 1);
static SENSOR_DEVICE_ATTR(pwm2_step_output, 0644, show_fan_step_output,
	    store_fan_step_output, 1);
static SENSOR_DEVICE_ATTR(pwm3_max_output, 0644, show_fan_max_output,
	    store_fan_max_output, 2);
static SENSOR_DEVICE_ATTR(pwm3_step_output, 0644, show_fan_step_output,
	    store_fan_step_output, 2);

static ssize_t
cpu0_vid_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(cpu0_vid);


/* Case open detection */
static int
clear_caseopen(struct device *dev, struct w83627ehf_data *data, int channel,
	       long val)
{}

static umode_t w83627ehf_attrs_visible(struct kobject *kobj,
				       struct attribute *a, int n)
{}

/* These groups handle non-standard attributes used in this device */
static struct attribute *w83627ehf_attrs[] =;

static const struct attribute_group w83627ehf_group =;

static const struct attribute_group *w83627ehf_groups[] =;

/*
 * Driver and device management
 */

/* Get the monitoring functions started */
static inline void w83627ehf_init_device(struct w83627ehf_data *data,
						   enum kinds kind)
{}

static void
w83627ehf_set_temp_reg_ehf(struct w83627ehf_data *data, int n_temp)
{}

static void
w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data,
			   struct w83627ehf_data *data)
{}

static umode_t
w83627ehf_is_visible(const void *drvdata, enum hwmon_sensor_types type,
		     u32 attr, int channel)
{}

static int
w83627ehf_do_read_temp(struct w83627ehf_data *data, u32 attr,
		       int channel, long *val)
{}

static int
w83627ehf_do_read_in(struct w83627ehf_data *data, u32 attr,
		     int channel, long *val)
{}

static int
w83627ehf_do_read_fan(struct w83627ehf_data *data, u32 attr,
		      int channel, long *val)
{}

static int
w83627ehf_do_read_pwm(struct w83627ehf_data *data, u32 attr,
		      int channel, long *val)
{}

static int
w83627ehf_do_read_intrusion(struct w83627ehf_data *data, u32 attr,
			    int channel, long *val)
{}

static int
w83627ehf_read(struct device *dev, enum hwmon_sensor_types type,
			u32 attr, int channel, long *val)
{}

static int
w83627ehf_read_string(struct device *dev, enum hwmon_sensor_types type,
		      u32 attr, int channel, const char **str)
{}

static int
w83627ehf_write(struct device *dev, enum hwmon_sensor_types type,
			u32 attr, int channel, long val)
{}

static const struct hwmon_ops w83627ehf_ops =;

static const struct hwmon_channel_info * const w83627ehf_info[] =;

static const struct hwmon_chip_info w83627ehf_chip_info =;

static int __init w83627ehf_probe(struct platform_device *pdev)
{}

static int w83627ehf_suspend(struct device *dev)
{}

static int w83627ehf_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(w83627ehf_dev_pm_ops, w83627ehf_suspend, w83627ehf_resume);

static struct platform_driver w83627ehf_driver =;

/* w83627ehf_find() looks for a '627 in the Super-I/O config space */
static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
				 struct w83627ehf_sio_data *sio_data)
{}

/*
 * when Super-I/O functions move to a separate file, the Super-I/O
 * bus will manage the lifetime of the device and this module will only keep
 * track of the w83627ehf driver.
 */
static struct platform_device *pdev;

static int __init sensors_w83627ehf_init(void)
{}

static void __exit sensors_w83627ehf_exit(void)
{}

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

module_init();
module_exit(sensors_w83627ehf_exit);