linux/drivers/hwmon/vt1211.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * vt1211.c - driver for the VIA VT1211 Super-I/O chip integrated hardware
 *            monitoring features
 * Copyright (C) 2006 Juerg Haefliger <[email protected]>
 *
 * This driver is based on the driver for kernel 2.4 by Mark D. Studebaker
 * and its port to kernel 2.6 by Lars Ekman.
 */

#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/ioport.h>
#include <linux/acpi.h>
#include <linux/io.h>

static int uch_config =;
module_param(uch_config, int, 0);
MODULE_PARM_DESC();

static int int_mode =;
module_param(int_mode, int, 0);
MODULE_PARM_DESC();

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

static struct platform_device *pdev;

#define DRVNAME

/* ---------------------------------------------------------------------
 * Registers
 *
 * The sensors are defined as follows.
 *
 * Sensor          Voltage Mode   Temp Mode   Notes (from the datasheet)
 * --------        ------------   ---------   --------------------------
 * Reading 1                      temp1       Intel thermal diode
 * Reading 3                      temp2       Internal thermal diode
 * UCH1/Reading2   in0            temp3       NTC type thermistor
 * UCH2            in1            temp4       +2.5V
 * UCH3            in2            temp5       VccP
 * UCH4            in3            temp6       +5V
 * UCH5            in4            temp7       +12V
 * 3.3V            in5                        Internal VDD (+3.3V)
 *
 * --------------------------------------------------------------------- */

/* Voltages (in) numbered 0-5 (ix) */
#define VT1211_REG_IN(ix)
#define VT1211_REG_IN_MIN(ix)
#define VT1211_REG_IN_MAX(ix)

/* Temperatures (temp) numbered 0-6 (ix) */
static u8 regtemp[]	=;
static u8 regtempmax[]	=;
static u8 regtemphyst[]	=;

/* Fans numbered 0-1 (ix) */
#define VT1211_REG_FAN(ix)
#define VT1211_REG_FAN_MIN(ix)
#define VT1211_REG_FAN_DIV

/* PWMs numbered 0-1 (ix) */
/* Auto points numbered 0-3 (ap) */
#define VT1211_REG_PWM(ix)
#define VT1211_REG_PWM_CLK
#define VT1211_REG_PWM_CTL
#define VT1211_REG_PWM_AUTO_TEMP(ap)
#define VT1211_REG_PWM_AUTO_PWM(ix, ap)

/* Miscellaneous registers */
#define VT1211_REG_CONFIG
#define VT1211_REG_ALARM1
#define VT1211_REG_ALARM2
#define VT1211_REG_VID
#define VT1211_REG_UCH_CONFIG
#define VT1211_REG_TEMP1_CONFIG
#define VT1211_REG_TEMP2_CONFIG

/* In, temp & fan alarm bits */
static const u8 bitalarmin[]	=;
static const u8 bitalarmtemp[]	=;
static const u8 bitalarmfan[]	=;

/* ---------------------------------------------------------------------
 * Data structures and manipulation thereof
 * --------------------------------------------------------------------- */

struct vt1211_data {};

/* ix = [0-5] */
#define ISVOLT(ix, uch_config)

/* ix = [0-6] */
#define ISTEMP(ix, uch_config)

/*
 * in5 (ix = 5) is special. It's the internal 3.3V so it's scaled in the
 * driver according to the VT1211 BIOS porting guide
 */
#define IN_FROM_REG(ix, reg)
#define IN_TO_REG(ix, val)

/*
 * temp1 (ix = 0) is an intel thermal diode which is scaled in user space.
 * temp2 (ix = 1) is the internal temp diode so it's scaled in the driver
 * according to some measurements that I took on an EPIA M10000.
 * temp3-7 are thermistor based so the driver returns the voltage measured at
 * the pin (range 0V - 2.2V).
 */
#define TEMP_FROM_REG(ix, reg)
#define TEMP_TO_REG(ix, val)

#define DIV_FROM_REG(reg)

#define RPM_FROM_REG(reg, div)
#define RPM_TO_REG(val, div)

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

/*
 * Configuration index port registers
 * The vt1211 can live at 2 different addresses so we need to probe both
 */
#define SIO_REG_CIP1
#define SIO_REG_CIP2

/* Configuration registers */
#define SIO_VT1211_LDN
#define SIO_VT1211_DEVID
#define SIO_VT1211_DEVREV
#define SIO_VT1211_ACTIVE
#define SIO_VT1211_BADDR
#define SIO_VT1211_ID

/* VT1211 logical device numbers */
#define SIO_VT1211_LDN_HWMON

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

static inline void superio_select(int sio_cip, int ldn)
{}

static inline int superio_enter(int sio_cip)
{}

static inline void superio_exit(int sio_cip)
{}

/* ---------------------------------------------------------------------
 * Device I/O access
 * --------------------------------------------------------------------- */

static inline u8 vt1211_read8(struct vt1211_data *data, u8 reg)
{}

static inline void vt1211_write8(struct vt1211_data *data, u8 reg, u8 val)
{}

static struct vt1211_data *vt1211_update_device(struct device *dev)
{}

/* ---------------------------------------------------------------------
 * Voltage sysfs interfaces
 * ix = [0-5]
 * --------------------------------------------------------------------- */

#define SHOW_IN_INPUT
#define SHOW_SET_IN_MIN
#define SHOW_SET_IN_MAX
#define SHOW_IN_ALARM

static ssize_t show_in(struct device *dev, struct device_attribute *attr,
		       char *buf)
{}

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

/* ---------------------------------------------------------------------
 * Temperature sysfs interfaces
 * ix = [0-6]
 * --------------------------------------------------------------------- */

#define SHOW_TEMP_INPUT
#define SHOW_SET_TEMP_MAX
#define SHOW_SET_TEMP_MAX_HYST
#define SHOW_TEMP_ALARM

static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}

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

/* ---------------------------------------------------------------------
 * Fan sysfs interfaces
 * ix = [0-1]
 * --------------------------------------------------------------------- */

#define SHOW_FAN_INPUT
#define SHOW_SET_FAN_MIN
#define SHOW_SET_FAN_DIV
#define SHOW_FAN_ALARM

static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
			char *buf)
{}

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

/* ---------------------------------------------------------------------
 * PWM sysfs interfaces
 * ix = [0-1]
 * --------------------------------------------------------------------- */

#define SHOW_PWM
#define SHOW_SET_PWM_ENABLE
#define SHOW_SET_PWM_FREQ
#define SHOW_SET_PWM_AUTO_CHANNELS_TEMP

static ssize_t show_pwm(struct device *dev, struct device_attribute *attr,
			char *buf)
{}

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

/* ---------------------------------------------------------------------
 * PWM auto point definitions
 * ix = [0-1]
 * ap = [0-3]
 * --------------------------------------------------------------------- */

/*
 * pwm[ix+1]_auto_point[ap+1]_temp mapping table:
 * Note that there is only a single set of temp auto points that controls both
 * PWM controllers. We still create 2 sets of sysfs files to make it look
 * more consistent even though they map to the same registers.
 *
 * ix ap : description
 * -------------------
 * 0  0  : pwm1/2 off temperature        (pwm_auto_temp[0])
 * 0  1  : pwm1/2 low speed temperature  (pwm_auto_temp[1])
 * 0  2  : pwm1/2 high speed temperature (pwm_auto_temp[2])
 * 0  3  : pwm1/2 full speed temperature (pwm_auto_temp[3])
 * 1  0  : pwm1/2 off temperature        (pwm_auto_temp[0])
 * 1  1  : pwm1/2 low speed temperature  (pwm_auto_temp[1])
 * 1  2  : pwm1/2 high speed temperature (pwm_auto_temp[2])
 * 1  3  : pwm1/2 full speed temperature (pwm_auto_temp[3])
 */

static ssize_t show_pwm_auto_point_temp(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{}

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

/*
 * pwm[ix+1]_auto_point[ap+1]_pwm mapping table:
 * Note that the PWM auto points 0 & 3 are hard-wired in the VT1211 and can't
 * be changed.
 *
 * ix ap : description
 * -------------------
 * 0  0  : pwm1 off                   (pwm_auto_pwm[0][0], hard-wired to 0)
 * 0  1  : pwm1 low speed duty cycle  (pwm_auto_pwm[0][1])
 * 0  2  : pwm1 high speed duty cycle (pwm_auto_pwm[0][2])
 * 0  3  : pwm1 full speed            (pwm_auto_pwm[0][3], hard-wired to 255)
 * 1  0  : pwm2 off                   (pwm_auto_pwm[1][0], hard-wired to 0)
 * 1  1  : pwm2 low speed duty cycle  (pwm_auto_pwm[1][1])
 * 1  2  : pwm2 high speed duty cycle (pwm_auto_pwm[1][2])
 * 1  3  : pwm2 full speed            (pwm_auto_pwm[1][3], hard-wired to 255)
 */

static ssize_t show_pwm_auto_point_pwm(struct device *dev,
				       struct device_attribute *attr,
				       char *buf)
{}

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

/* ---------------------------------------------------------------------
 * Miscellaneous sysfs interfaces (VRM, VID, name, and (legacy) alarms)
 * --------------------------------------------------------------------- */

static ssize_t show_vrm(struct device *dev, struct device_attribute *attr,
			char *buf)
{}

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

static ssize_t show_vid(struct device *dev, struct device_attribute *attr,
			char *buf)
{}

static ssize_t show_name(struct device *dev,
			 struct device_attribute *attr, char *buf)
{}

static ssize_t show_alarms(struct device *dev,
			   struct device_attribute *attr, char *buf)
{}

/* ---------------------------------------------------------------------
 * Device attribute structs
 * --------------------------------------------------------------------- */

#define SENSOR_ATTR_IN(ix)

static struct sensor_device_attribute_2 vt1211_sysfs_in[][4] =;

#define IN_UNIT_ATTRS(X)

static struct attribute *vt1211_in_attr[][5] =;

static const struct attribute_group vt1211_in_attr_group[] =;

#define SENSOR_ATTR_TEMP(ix)

static struct sensor_device_attribute_2 vt1211_sysfs_temp[][4] =;

#define TEMP_UNIT_ATTRS(X)

static struct attribute *vt1211_temp_attr[][5] =;

static const struct attribute_group vt1211_temp_attr_group[] =;

#define SENSOR_ATTR_FAN(ix)

#define SENSOR_ATTR_PWM(ix)

#define SENSOR_ATTR_PWM_FREQ(ix)

#define SENSOR_ATTR_PWM_FREQ_RO(ix)

#define SENSOR_ATTR_PWM_AUTO_POINT_TEMP(ix, ap)

#define SENSOR_ATTR_PWM_AUTO_POINT_TEMP_RO(ix, ap)

#define SENSOR_ATTR_PWM_AUTO_POINT_PWM(ix, ap)

#define SENSOR_ATTR_PWM_AUTO_POINT_PWM_RO(ix, ap)

static struct sensor_device_attribute_2 vt1211_sysfs_fan_pwm[] =;

static struct device_attribute vt1211_sysfs_misc[] =;

/* ---------------------------------------------------------------------
 * Device registration and initialization
 * --------------------------------------------------------------------- */

static void vt1211_init_device(struct vt1211_data *data)
{}

static void vt1211_remove_sysfs(struct platform_device *pdev)
{}

static int vt1211_probe(struct platform_device *pdev)
{}

static void vt1211_remove(struct platform_device *pdev)
{}

static struct platform_driver vt1211_driver =;

static int __init vt1211_device_add(unsigned short address)
{}

static int __init vt1211_find(int sio_cip, unsigned short *address)
{}

static int __init vt1211_init(void)
{}

static void __exit vt1211_exit(void)
{}

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

module_init();
module_exit(vt1211_exit);