linux/drivers/hwmon/vt8231.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * vt8231.c - Part of lm_sensors, Linux kernel modules
 *	      for hardware monitoring
 *
 * Copyright (c) 2005 Roger Lucas <[email protected]>
 * Copyright (c) 2002 Mark D. Studebaker <[email protected]>
 *		      Aaron M. Marsh <[email protected]>
 */

/*
 * Supports VIA VT8231 South Bridge embedded sensors
 */

#define pr_fmt(fmt)

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

static int force_addr;
module_param(force_addr, int, 0);
MODULE_PARM_DESC();

static struct platform_device *pdev;

#define VT8231_EXTENT
#define VT8231_BASE_REG
#define VT8231_ENABLE_REG

#define DRIVER_NAME

/*
 * The VT8231 registers
 *
 * The reset value for the input channel configuration is used (Reg 0x4A=0x07)
 * which sets the selected inputs marked with '*' below if multiple options are
 * possible:
 *
 *		    Voltage Mode	  Temperature Mode
 *	Sensor	      Linux Id	      Linux Id	      VIA Id
 *	--------      --------	      --------	      ------
 *	CPU Diode	N/A		temp1		0
 *	UIC1		in0		temp2 *		1
 *	UIC2		in1 *		temp3		2
 *	UIC3		in2 *		temp4		3
 *	UIC4		in3 *		temp5		4
 *	UIC5		in4 *		temp6		5
 *	3.3V		in5		N/A
 *
 * Note that the BIOS may set the configuration register to a different value
 * to match the motherboard configuration.
 */

/* fans numbered 0-1 */
#define VT8231_REG_FAN_MIN(nr)
#define VT8231_REG_FAN(nr)

/* Voltage inputs numbered 0-5 */

static const u8 regvolt[]    =;
static const u8 regvoltmax[] =;
static const u8 regvoltmin[] =;

/*
 * Temperatures are numbered 1-6 according to the Linux kernel specification.
 *
 * In the VIA datasheet, however, the temperatures are numbered from zero.
 * Since it is important that this driver can easily be compared to the VIA
 * datasheet, we will use the VIA numbering within this driver and map the
 * kernel sysfs device name to the VIA number in the sysfs callback.
 */

#define VT8231_REG_TEMP_LOW01
#define VT8231_REG_TEMP_LOW25

static const u8 regtemp[]    =;
static const u8 regtempmax[] =;
static const u8 regtempmin[] =;

#define TEMP_FROM_REG(reg)
#define TEMP_MAXMIN_FROM_REG(reg)
#define TEMP_MAXMIN_TO_REG(val)

#define VT8231_REG_CONFIG
#define VT8231_REG_ALARM1
#define VT8231_REG_ALARM2
#define VT8231_REG_FANDIV
#define VT8231_REG_UCH_CONFIG
#define VT8231_REG_TEMP1_CONFIG
#define VT8231_REG_TEMP2_CONFIG

/*
 * temps 0-5 as numbered in VIA datasheet - see later for mapping to Linux
 * numbering
 */
#define ISTEMP(i, ch_config)
/* voltages 0-5 */
#define ISVOLT(i, ch_config)

#define DIV_FROM_REG(val)

/*
 * NB  The values returned here are NOT temperatures.  The calibration curves
 *     for the thermistor curves are board-specific and must go in the
 *     sensors.conf file.  Temperature sensors are actually ten bits, but the
 *     VIA datasheet only considers the 8 MSBs obtained from the regtemp[]
 *     register.  The temperature value returned should have a magnitude of 3,
 *     so we use the VIA scaling as the "true" scaling and use the remaining 2
 *     LSBs as fractional precision.
 *
 *     All the on-chip hardware temperature comparisons for the alarms are only
 *     8-bits wide, and compare against the 8 MSBs of the temperature.  The bits
 *     in the registers VT8231_REG_TEMP_LOW01 and VT8231_REG_TEMP_LOW25 are
 *     ignored.
 */

/*
 ****** FAN RPM CONVERSIONS ********
 * This chip saturates back at 0, not at 255 like many the other chips.
 * So, 0 means 0 RPM
 */
static inline u8 FAN_TO_REG(long rpm, int div)
{}

#define FAN_FROM_REG(val, div)

struct vt8231_data {};

static struct pci_dev *s_bridge;

static inline int vt8231_read_value(struct vt8231_data *data, u8 reg)
{}

static inline void vt8231_write_value(struct vt8231_data *data, u8 reg,
					u8 value)
{}

static struct vt8231_data *vt8231_update_device(struct device *dev)
{}

/* following are the sysfs callback functions */
static ssize_t in_show(struct device *dev, struct device_attribute *attr,
		       char *buf)
{}

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

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

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

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

/* Special case for input 5 as this has 3.3V scaling built into the chip */
static ssize_t in5_input_show(struct device *dev,
			      struct device_attribute *attr, char *buf)
{}

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

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

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

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

static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0);
static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0);
static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0);
static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1);
static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1);
static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1);
static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2);
static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2);
static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2);
static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3);
static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3);
static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3);
static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4);
static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4);
static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4);

static DEVICE_ATTR_RO(in5_input);
static DEVICE_ATTR_RW(in5_min);
static DEVICE_ATTR_RW(in5_max);

/* Temperatures */
static ssize_t temp1_input_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{}

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

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

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

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

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

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

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

/*
 * Note that these map the Linux temperature sensor numbering (1-6) to the VIA
 * temperature sensor numbering (0-5)
 */

static DEVICE_ATTR_RO(temp1_input);
static DEVICE_ATTR_RW(temp1_max);
static DEVICE_ATTR_RW(temp1_max_hyst);

static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1);
static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1);
static SENSOR_DEVICE_ATTR_RW(temp2_max_hyst, temp_min, 1);
static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2);
static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2);
static SENSOR_DEVICE_ATTR_RW(temp3_max_hyst, temp_min, 2);
static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3);
static SENSOR_DEVICE_ATTR_RW(temp4_max, temp_max, 3);
static SENSOR_DEVICE_ATTR_RW(temp4_max_hyst, temp_min, 3);
static SENSOR_DEVICE_ATTR_RO(temp5_input, temp, 4);
static SENSOR_DEVICE_ATTR_RW(temp5_max, temp_max, 4);
static SENSOR_DEVICE_ATTR_RW(temp5_max_hyst, temp_min, 4);
static SENSOR_DEVICE_ATTR_RO(temp6_input, temp, 5);
static SENSOR_DEVICE_ATTR_RW(temp6_max, temp_max, 5);
static SENSOR_DEVICE_ATTR_RW(temp6_max_hyst, temp_min, 5);

/* Fans */
static ssize_t fan_show(struct device *dev, struct device_attribute *attr,
			char *buf)
{}

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

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

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

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

static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0);
static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0);
static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0);
static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1);
static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1);
static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);

/* Alarms */
static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}
static DEVICE_ATTR_RO(alarms);

static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{}
static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4);
static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 11);
static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 0);
static SENSOR_DEVICE_ATTR_RO(temp4_alarm, alarm, 1);
static SENSOR_DEVICE_ATTR_RO(temp5_alarm, alarm, 3);
static SENSOR_DEVICE_ATTR_RO(temp6_alarm, alarm, 8);
static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 11);
static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 0);
static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 1);
static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3);
static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8);
static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 2);
static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6);
static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7);

static ssize_t name_show(struct device *dev, struct device_attribute
			 *devattr, char *buf)
{}
static DEVICE_ATTR_RO(name);

static struct attribute *vt8231_attributes_temps[6][5] =;

static const struct attribute_group vt8231_group_temps[6] =;

static struct attribute *vt8231_attributes_volts[6][5] =;

static const struct attribute_group vt8231_group_volts[6] =;

static struct attribute *vt8231_attributes[] =;

static const struct attribute_group vt8231_group =;

static void vt8231_init_device(struct vt8231_data *data)
{}

static int vt8231_probe(struct platform_device *pdev)
{}

static void vt8231_remove(struct platform_device *pdev)
{}


static struct platform_driver vt8231_driver =;

static const struct pci_device_id vt8231_pci_ids[] =;

MODULE_DEVICE_TABLE(pci, vt8231_pci_ids);

static int vt8231_device_add(unsigned short address)
{}

static int vt8231_pci_probe(struct pci_dev *dev,
				const struct pci_device_id *id)
{}

static struct pci_driver vt8231_pci_driver =;

static int __init sm_vt8231_init(void)
{}

static void __exit sm_vt8231_exit(void)
{}

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

module_init();
module_exit(sm_vt8231_exit);