linux/drivers/hwmon/nct6683.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * nct6683 - Driver for the hardware monitoring functionality of
 *	     Nuvoton NCT6683D/NCT6686D/NCT6687D eSIO
 *
 * Copyright (C) 2013  Guenter Roeck <[email protected]>
 *
 * Derived from nct6775 driver
 * Copyright (C) 2012, 2013  Guenter Roeck <[email protected]>
 *
 * Supports the following chips:
 *
 * Chip        #vin    #fan    #pwm    #temp  chip ID
 * nct6683d     21(1)   16      8       32(1) 0xc730
 * nct6686d     21(1)   16      8       32(1) 0xd440
 * nct6687d     21(1)   16      8       32(1) 0xd590
 *
 * Notes:
 *	(1) Total number of vin and temp inputs is 32.
 */

#define pr_fmt(fmt)

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

enum kinds {};

static bool force;
module_param(force, bool, 0);
MODULE_PARM_DESC();

static const char * const nct6683_device_names[] =;

static const char * const nct6683_chip_names[] =;

#define DRVNAME

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

#define NCT6683_LD_ACPI
#define NCT6683_LD_HWM
#define NCT6683_LD_VID

#define SIO_REG_LDSEL
#define SIO_REG_DEVID
#define SIO_REG_ENABLE
#define SIO_REG_ADDR

#define SIO_NCT6681_ID
#define SIO_NCT6683_ID
#define SIO_NCT6686_ID
#define SIO_NCT6687_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 EC_PAGE_REG
#define EC_INDEX_REG
#define EC_DATA_REG
#define EC_EVENT_REG

/* Common and NCT6683 specific data */

#define NCT6683_NUM_REG_MON
#define NCT6683_NUM_REG_FAN
#define NCT6683_NUM_REG_PWM

#define NCT6683_REG_MON(x)
#define NCT6683_REG_FAN_RPM(x)
#define NCT6683_REG_PWM(x)
#define NCT6683_REG_PWM_WRITE(x)

#define NCT6683_REG_MON_STS(x)
#define NCT6683_REG_IDLE(x)

#define NCT6683_REG_FAN_STS(x)
#define NCT6683_REG_FAN_ERRSTS
#define NCT6683_REG_FAN_INITSTS

#define NCT6683_HWM_CFG

#define NCT6683_REG_MON_CFG(x)
#define NCT6683_REG_FANIN_CFG(x)
#define NCT6683_REG_FANOUT_CFG(x)

#define NCT6683_REG_INTEL_TEMP_MAX(x)
#define NCT6683_REG_INTEL_TEMP_CRIT(x)

#define NCT6683_REG_TEMP_HYST(x)
#define NCT6683_REG_TEMP_MAX(x)
#define NCT6683_REG_MON_HIGH(x)
#define NCT6683_REG_MON_LOW(x)

#define NCT6683_REG_FAN_MIN(x)

#define NCT6683_REG_FAN_CFG_CTRL
#define NCT6683_FAN_CFG_REQ
#define NCT6683_FAN_CFG_DONE

#define NCT6683_REG_CUSTOMER_ID
#define NCT6683_CUSTOMER_ID_INTEL
#define NCT6683_CUSTOMER_ID_MITAC
#define NCT6683_CUSTOMER_ID_MSI
#define NCT6683_CUSTOMER_ID_MSI2
#define NCT6683_CUSTOMER_ID_MSI3
#define NCT6683_CUSTOMER_ID_ASROCK
#define NCT6683_CUSTOMER_ID_ASROCK2
#define NCT6683_CUSTOMER_ID_ASROCK3

#define NCT6683_REG_BUILD_YEAR
#define NCT6683_REG_BUILD_MONTH
#define NCT6683_REG_BUILD_DAY
#define NCT6683_REG_SERIAL
#define NCT6683_REG_VERSION_HI
#define NCT6683_REG_VERSION_LO

#define NCT6683_REG_CR_CASEOPEN
#define NCT6683_CR_CASEOPEN_MASK

#define NCT6683_REG_CR_BEEP
#define NCT6683_CR_BEEP_MASK

static const char *const nct6683_mon_label[] =;

#define NUM_MON_LABELS
#define MON_VOLTAGE_START

/* ------------------------------------------------------- */

struct nct6683_data {};

struct nct6683_sio_data {};

struct sensor_device_template {};

struct sensor_device_attr_u {};

#define __TEMPLATE_ATTR(_template, _mode, _show, _store)

#define SENSOR_DEVICE_TEMPLATE(_template, _mode, _show, _store, _index)

#define SENSOR_DEVICE_TEMPLATE_2(_template, _mode, _show, _store,	\
				 _nr, _index)

#define SENSOR_TEMPLATE(_name, _template, _mode, _show, _store, _index)

#define SENSOR_TEMPLATE_2(_name, _template, _mode, _show, _store,	\
			  _nr, _index)

struct sensor_template_group {};

static struct attribute_group *
nct6683_create_attr_group(struct device *dev,
			  const struct sensor_template_group *tg,
			  int repeat)
{}

/* LSB is 16 mV, except for the following sources, where it is 32 mV */
#define MON_SRC_VCC
#define MON_SRC_VSB
#define MON_SRC_AVSB
#define MON_SRC_VBAT

static inline long in_from_reg(u16 reg, u8 src)
{}

static u16 nct6683_read(struct nct6683_data *data, u16 reg)
{}

static u16 nct6683_read16(struct nct6683_data *data, u16 reg)
{}

static void nct6683_write(struct nct6683_data *data, u16 reg, u16 value)
{}

static int get_in_reg(struct nct6683_data *data, int nr, int index)
{}

static int get_temp_reg(struct nct6683_data *data, int nr, int index)
{}

static void nct6683_update_pwm(struct device *dev)
{}

static struct nct6683_data *nct6683_update_device(struct device *dev)
{}

/*
 * Sysfs callback functions
 */
static ssize_t
show_in_label(struct device *dev, struct device_attribute *attr, char *buf)
{}

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

static umode_t nct6683_in_is_visible(struct kobject *kobj,
				     struct attribute *attr, int index)
{}

SENSOR_TEMPLATE(in_label, "in%d_label", S_IRUGO, show_in_label, NULL, 0);
SENSOR_TEMPLATE_2(in_input, "in%d_input", S_IRUGO, show_in_reg, NULL, 0, 0);
SENSOR_TEMPLATE_2(in_min, "in%d_min", S_IRUGO, show_in_reg, NULL, 0, 1);
SENSOR_TEMPLATE_2(in_max, "in%d_max", S_IRUGO, show_in_reg, NULL, 0, 2);

static struct sensor_device_template *nct6683_attributes_in_template[] =;

static const struct sensor_template_group nct6683_in_template_group =;

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

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

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

static umode_t nct6683_fan_is_visible(struct kobject *kobj,
				      struct attribute *attr, int index)
{}

SENSOR_TEMPLATE(fan_input, "fan%d_input", S_IRUGO, show_fan, NULL, 0);
SENSOR_TEMPLATE(fan_pulses, "fan%d_pulses", S_IRUGO, show_fan_pulses, NULL, 0);
SENSOR_TEMPLATE(fan_min, "fan%d_min", S_IRUGO, show_fan_min, NULL, 0);

/*
 * nct6683_fan_is_visible uses the index into the following array
 * to determine if attributes should be created or not.
 * Any change in order or content must be matched.
 */
static struct sensor_device_template *nct6683_attributes_fan_template[] =;

static const struct sensor_template_group nct6683_fan_template_group =;

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

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

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

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

/*
 * Temperature sensor type is determined by temperature source
 * and can not be modified.
 * 0x02..0x07: Thermal diode
 * 0x08..0x18: Thermistor
 * 0x20..0x2b: Intel PECI
 * 0x42..0x49: AMD TSI
 * Others are unspecified (not visible)
 */

static int get_temp_type(u8 src)
{}

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

static umode_t nct6683_temp_is_visible(struct kobject *kobj,
				       struct attribute *attr, int index)
{}

SENSOR_TEMPLATE(temp_input, "temp%d_input", S_IRUGO, show_temp16, NULL, 0);
SENSOR_TEMPLATE(temp_label, "temp%d_label", S_IRUGO, show_temp_label, NULL, 0);
SENSOR_TEMPLATE_2(temp_min, "temp%d_min", S_IRUGO, show_temp8, NULL, 0, 0);
SENSOR_TEMPLATE_2(temp_max, "temp%d_max", S_IRUGO, show_temp8, NULL, 0, 1);
SENSOR_TEMPLATE(temp_max_hyst, "temp%d_max_hyst", S_IRUGO, show_temp_hyst, NULL,
		0);
SENSOR_TEMPLATE_2(temp_crit, "temp%d_crit", S_IRUGO, show_temp8, NULL, 0, 3);
SENSOR_TEMPLATE(temp_type, "temp%d_type", S_IRUGO, show_temp_type, NULL, 0);

/*
 * nct6683_temp_is_visible uses the index into the following array
 * to determine if attributes should be created or not.
 * Any change in order or content must be matched.
 */
static struct sensor_device_template *nct6683_attributes_temp_template[] =;

static const struct sensor_template_group nct6683_temp_template_group =;

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

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

SENSOR_TEMPLATE(pwm, "pwm%d", S_IRUGO, show_pwm, store_pwm, 0);

static umode_t nct6683_pwm_is_visible(struct kobject *kobj,
				      struct attribute *attr, int index)
{}

static struct sensor_device_template *nct6683_attributes_pwm_template[] =;

static const struct sensor_template_group nct6683_pwm_template_group =;

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

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

/* Case open detection */

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

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

static DEVICE_ATTR_RW(intrusion0_alarm);
static DEVICE_ATTR_RW(beep_enable);

static struct attribute *nct6683_attributes_other[] =;

static const struct attribute_group nct6683_group_other =;

/* Get the monitoring functions started */
static inline void nct6683_init_device(struct nct6683_data *data)
{}

/*
 * There are a total of 24 fan inputs. Each can be configured as input
 * or as output. A maximum of 16 inputs and 8 outputs is configurable.
 */
static void
nct6683_setup_fans(struct nct6683_data *data)
{}

/*
 * Translation from monitoring register to temperature and voltage attributes
 * ==========================================================================
 *
 * There are a total of 32 monitoring registers. Each can be assigned to either
 * a temperature or voltage monitoring source.
 * NCT6683_REG_MON_CFG(x) defines assignment for each monitoring source.
 *
 * Temperature and voltage attribute mapping is determined by walking through
 * the NCT6683_REG_MON_CFG registers. If the assigned source is
 * a temperature, temp_index[n] is set to the monitor register index, and
 * temp_src[n] is set to the temperature source. If the assigned source is
 * a voltage, the respective values are stored in in_index[] and in_src[],
 * respectively.
 */

static void nct6683_setup_sensors(struct nct6683_data *data)
{}

static int nct6683_probe(struct platform_device *pdev)
{}

#ifdef CONFIG_PM
static int nct6683_suspend(struct device *dev)
{}

static int nct6683_resume(struct device *dev)
{}

static const struct dev_pm_ops nct6683_dev_pm_ops =;

#define NCT6683_DEV_PM_OPS
#else
#define NCT6683_DEV_PM_OPS
#endif /* CONFIG_PM */

static struct platform_driver nct6683_driver =;

static int __init nct6683_find(int sioaddr, struct nct6683_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 nct6683 driver. But since we use platform_device_alloc(), we
 * must keep track of the device
 */
static struct platform_device *pdev[2];

static int __init sensors_nct6683_init(void)
{}

static void __exit sensors_nct6683_exit(void)
{}

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

module_init();
module_exit(sensors_nct6683_exit);