linux/drivers/hwmon/sis5595.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * sis5595.c - Part of lm_sensors, Linux kernel modules
 *	       for hardware monitoring
 *
 * Copyright (C) 1998 - 2001 Frodo Looijaard <[email protected]>,
 *			     Kyösti Mälkki <[email protected]>, and
 *			     Mark D. Studebaker <[email protected]>
 * Ported to Linux 2.6 by Aurelien Jarno <[email protected]> with
 * the help of Jean Delvare <[email protected]>
 */

/*
 * SiS southbridge has a LM78-like chip integrated on the same IC.
 * This driver is a customized copy of lm78.c
 *
 * Supports following revisions:
 *	Version		PCI ID		PCI Revision
 *	1		1039/0008	AF or less
 *	2		1039/0008	B0 or greater
 *
 *  Note: these chips contain a 0008 device which is incompatible with the
 *	 5595. We recognize these by the presence of the listed
 *	 "blacklist" PCI ID and refuse to load.
 *
 * NOT SUPPORTED	PCI ID		BLACKLIST PCI ID
 *	 540		0008		0540
 *	 550		0008		0550
 *	5513		0008		5511
 *	5581		0008		5597
 *	5582		0008		5597
 *	5597		0008		5597
 *	5598		0008		5597/5598
 *	 630		0008		0630
 *	 645		0008		0645
 *	 730		0008		0730
 *	 735		0008		0735
 */

#define DRIVER_NAME
#define pr_fmt(fmt)

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

/*
 * If force_addr is set to anything different from 0, we forcibly enable
 * the device at the given address.
 */
static u16 force_addr;
module_param(force_addr, ushort, 0);
MODULE_PARM_DESC();

static struct platform_device *pdev;

/* Many SIS5595 constants specified below */

/* Length of ISA address segment */
#define SIS5595_EXTENT
/* PCI Config Registers */
#define SIS5595_BASE_REG
#define SIS5595_PIN_REG
#define SIS5595_ENABLE_REG

/* Where are the ISA address/data registers relative to the base address */
#define SIS5595_ADDR_REG_OFFSET
#define SIS5595_DATA_REG_OFFSET

/* The SIS5595 registers */
#define SIS5595_REG_IN_MAX(nr)
#define SIS5595_REG_IN_MIN(nr)
#define SIS5595_REG_IN(nr)

#define SIS5595_REG_FAN_MIN(nr)
#define SIS5595_REG_FAN(nr)

/*
 * On the first version of the chip, the temp registers are separate.
 * On the second version,
 * TEMP pin is shared with IN4, configured in PCI register 0x7A.
 * The registers are the same as well.
 * OVER and HYST are really MAX and MIN.
 */

#define REV2MIN
#define SIS5595_REG_TEMP
#define SIS5595_REG_TEMP_OVER
#define SIS5595_REG_TEMP_HYST

#define SIS5595_REG_CONFIG
#define SIS5595_REG_ALARM1
#define SIS5595_REG_ALARM2
#define SIS5595_REG_FANDIV

/*
 * Conversions. Limit checking is only done on the TO_REG
 * variants.
 */

/*
 * IN: mV, (0V to 4.08V)
 * REG: 16mV/bit
 */
static inline u8 IN_TO_REG(unsigned long val)
{}
#define IN_FROM_REG(val)

static inline u8 FAN_TO_REG(long rpm, int div)
{}

static inline int FAN_FROM_REG(u8 val, int div)
{}

/*
 * TEMP: mC (-54.12C to +157.53C)
 * REG: 0.83C/bit + 52.12, two's complement
 */
static inline int TEMP_FROM_REG(s8 val)
{}
static inline s8 TEMP_TO_REG(long val)
{}

/*
 * FAN DIV: 1, 2, 4, or 8
 * REG: 0, 1, 2, or 3 (respectively)
 */
#define DIV_FROM_REG(val)

/*
 * For each registered chip, we need to keep some data in memory.
 * The structure is dynamically allocated.
 */
struct sis5595_data {};

static struct pci_dev *s_bridge;	/* pointer to the (only) sis5595 */

/* ISA access must be locked explicitly. */
static int sis5595_read_value(struct sis5595_data *data, u8 reg)
{}

static void sis5595_write_value(struct sis5595_data *data, u8 reg, u8 value)
{}

static struct sis5595_data *sis5595_update_device(struct device *dev)
{}

/* 4 Voltages */
static ssize_t in_show(struct device *dev, struct device_attribute *da,
		       char *buf)
{}

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

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

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

static ssize_t in_max_store(struct device *dev, struct device_attribute *da,
			    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);

/* Temperature */
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_store(struct device *dev,
			       struct device_attribute *attr, const char *buf,
			       size_t count)
{}

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

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

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

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

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

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

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

/*
 * Note: we save and restore the fan minimum here, because its value is
 * determined in part by the fan divisor.  This follows the principle of
 * least surprise; the user doesn't expect the fan minimum to change just
 * because the divisor changed.
 */
static ssize_t fan_div_store(struct device *dev, struct device_attribute *da,
			     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 *da,
			  char *buf)
{}
static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0);
static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1);
static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2);
static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3);
static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 15);
static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6);
static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7);
static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 15);

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

static struct attribute *sis5595_attributes[] =;

static const struct attribute_group sis5595_group =;

static struct attribute *sis5595_attributes_in4[] =;

static const struct attribute_group sis5595_group_in4 =;

static struct attribute *sis5595_attributes_temp1[] =;

static const struct attribute_group sis5595_group_temp1 =;

/* Called when we have found a new SIS5595. */
static void sis5595_init_device(struct sis5595_data *data)
{}

/* This is called when the module is loaded */
static int sis5595_probe(struct platform_device *pdev)
{}

static void sis5595_remove(struct platform_device *pdev)
{}

static const struct pci_device_id sis5595_pci_ids[] =;

MODULE_DEVICE_TABLE(pci, sis5595_pci_ids);

static int blacklist[] =;

static int sis5595_device_add(unsigned short address)
{}

static struct platform_driver sis5595_driver =;

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

static struct pci_driver sis5595_pci_driver =;

static int __init sm_sis5595_init(void)
{}

static void __exit sm_sis5595_exit(void)
{}

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

module_init();
module_exit(sm_sis5595_exit);