linux/drivers/hwmon/w83795.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  w83795.c - Linux kernel driver for hardware monitoring
 *  Copyright (C) 2008 Nuvoton Technology Corp.
 *                Wei Song
 *  Copyright (C) 2010 Jean Delvare <[email protected]>
 *
 *  Supports following chips:
 *
 *  Chip       #vin   #fanin #pwm #temp #dts wchipid  vendid  i2c  ISA
 *  w83795g     21     14     8     6     8    0x79   0x5ca3  yes   no
 *  w83795adg   18     14     2     6     8    0x79   0x5ca3  yes   no
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/jiffies.h>
#include <linux/util_macros.h>

/* Addresses to scan */
static const unsigned short normal_i2c[] =;


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


#define W83795_REG_BANKSEL
#define W83795_REG_VENDORID
#define W83795_REG_CHIPID
#define W83795_REG_DEVICEID
#define W83795_REG_DEVICEID_A

#define W83795_REG_I2C_ADDR
#define W83795_REG_CONFIG
#define W83795_REG_CONFIG_CONFIG48
#define W83795_REG_CONFIG_START

/* Multi-Function Pin Ctrl Registers */
#define W83795_REG_VOLT_CTRL1
#define W83795_REG_VOLT_CTRL2
#define W83795_REG_TEMP_CTRL1
#define W83795_REG_TEMP_CTRL2
#define W83795_REG_FANIN_CTRL1
#define W83795_REG_FANIN_CTRL2
#define W83795_REG_VMIGB_CTRL

#define TEMP_READ
#define TEMP_CRIT
#define TEMP_CRIT_HYST
#define TEMP_WARN
#define TEMP_WARN_HYST
/*
 * only crit and crit_hyst affect real-time alarm status
 * current crit crit_hyst warn warn_hyst
 */
static const u16 W83795_REG_TEMP[][5] =;

#define IN_READ
#define IN_MAX
#define IN_LOW
static const u16 W83795_REG_IN[][3] =;
#define W83795_REG_VRLSB

static const u8 W83795_REG_IN_HL_LSB[] =;

#define IN_LSB_REG(index, type)

#define IN_LSB_SHIFT
#define IN_LSB_IDX
static const u8 IN_LSB_SHIFT_IDX[][2] =;


#define W83795_REG_FAN(index)
#define W83795_REG_FAN_MIN_HL(index)
#define W83795_REG_FAN_MIN_LSB(index)
#define W83795_REG_FAN_MIN_LSB_SHIFT(index)

#define W83795_REG_VID_CTRL

#define W83795_REG_ALARM_CTRL
#define ALARM_CTRL_RTSACS
#define W83795_REG_ALARM(index)
#define W83795_REG_CLR_CHASSIS
#define W83795_REG_BEEP(index)

#define W83795_REG_OVT_CFG
#define OVT_CFG_SEL


#define W83795_REG_FCMS1
#define W83795_REG_FCMS2
#define W83795_REG_TFMR(index)
#define W83795_REG_FOMC

#define W83795_REG_TSS(index)

#define TSS_MAP_RESERVED
static const u8 tss_map[4][6] =;

#define PWM_OUTPUT
#define PWM_FREQ
#define PWM_START
#define PWM_NONSTOP
#define PWM_STOP_TIME
#define W83795_REG_PWM(index, nr)

#define W83795_REG_FTSH(index)
#define W83795_REG_FTSL(index)
#define W83795_REG_TFTS

#define TEMP_PWM_TTTI
#define TEMP_PWM_CTFS
#define TEMP_PWM_HCT
#define TEMP_PWM_HOT
#define W83795_REG_TTTI(index)
#define W83795_REG_CTFS(index)
#define W83795_REG_HT(index)

#define SF4_TEMP
#define SF4_PWM
#define W83795_REG_SF4_TEMP(temp_num, index)
#define W83795_REG_SF4_PWM(temp_num, index)

#define W83795_REG_DTSC
#define W83795_REG_DTSE
#define W83795_REG_DTS(index)
#define W83795_REG_PECI_TBASE(index)

#define DTS_CRIT
#define DTS_CRIT_HYST
#define DTS_WARN
#define DTS_WARN_HYST
#define W83795_REG_DTS_EXT(index)

#define SETUP_PWM_DEFAULT
#define SETUP_PWM_UPTIME
#define SETUP_PWM_DOWNTIME
#define W83795_REG_SETUP_PWM(index)

static inline u16 in_from_reg(u8 index, u16 val)
{}

static inline u16 in_to_reg(u8 index, u16 val)
{}

static inline unsigned long fan_from_reg(u16 val)
{}

static inline u16 fan_to_reg(long rpm)
{}

static inline unsigned long time_from_reg(u8 reg)
{}

static inline u8 time_to_reg(unsigned long val)
{}

static inline long temp_from_reg(s8 reg)
{}

static inline s8 temp_to_reg(long val, s8 min, s8 max)
{}

static const u16 pwm_freq_cksel0[16] =;

static unsigned int pwm_freq_from_reg(u8 reg, u16 clkin)
{}

static u8 pwm_freq_to_reg(unsigned long val, u16 clkin)
{}

enum chip_types {};

struct w83795_data {};

/*
 * Hardware access
 * We assume that nobdody can change the bank outside the driver.
 */

/* Must be called with data->update_lock held, except during initialization */
static int w83795_set_bank(struct i2c_client *client, u8 bank)
{}

/* Must be called with data->update_lock held, except during initialization */
static u8 w83795_read(struct i2c_client *client, u16 reg)
{}

/* Must be called with data->update_lock held, except during initialization */
static int w83795_write(struct i2c_client *client, u16 reg, u8 value)
{}

static void w83795_update_limits(struct i2c_client *client)
{}

static struct w83795_data *w83795_update_pwm_config(struct device *dev)
{}

static struct w83795_data *w83795_update_device(struct device *dev)
{}

/*
 * Sysfs attributes
 */

#define ALARM_STATUS
#define BEEP_ENABLE
static ssize_t
show_alarm_beep(struct device *dev, struct device_attribute *attr, char *buf)
{}

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

/* Write 0 to clear chassis alarm */
static ssize_t
store_chassis_clear(struct device *dev,
		    struct device_attribute *attr, const char *buf,
		    size_t count)
{}

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

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

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)
{}

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

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

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

/*
 * Check whether a given temperature source can ever be useful.
 * Returns the number of selectable temperature channels which are
 * enabled.
 */
static int w83795_tss_useful(const struct w83795_data *data, int tsrc)
{}

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

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

#define TEMP_PWM_ENABLE
#define TEMP_PWM_FAN_MAP
static ssize_t
show_temp_pwm_enable(struct device *dev, struct device_attribute *attr,
		     char *buf)
{}

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

#define FANIN_TARGET
#define FANIN_TOL
static ssize_t
show_fanin(struct device *dev, struct device_attribute *attr, char *buf)
{}

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


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

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

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

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

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

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


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

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


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

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

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

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


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

/* Only for temp1-4 (temp5-6 can only be thermistor) */
static ssize_t
store_temp_mode(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t count)
{}


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

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


#ifdef CONFIG_SENSORS_W83795_FANCTRL
static ssize_t
show_sf_setup(struct device *dev, struct device_attribute *attr, char *buf)
{}

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


#define NOT_USED

/*
 * Don't change the attribute order, _max, _min and _beep are accessed by index
 * somewhere else in the code
 */
#define SENSOR_ATTR_IN(index)

/*
 * Don't change the attribute order, _beep is accessed by index
 * somewhere else in the code
 */
#define SENSOR_ATTR_FAN(index)

#define SENSOR_ATTR_PWM(index)

/*
 * Don't change the attribute order, _beep is accessed by index
 * somewhere else in the code
 */
#define SENSOR_ATTR_DTS(index)

/*
 * Don't change the attribute order, _beep is accessed by index
 * somewhere else in the code
 */
#define SENSOR_ATTR_TEMP(index)


static struct sensor_device_attribute_2 w83795_in[][5] =;

static const struct sensor_device_attribute_2 w83795_fan[][4] =;

static const struct sensor_device_attribute_2 w83795_temp[][28] =;

static const struct sensor_device_attribute_2 w83795_dts[][8] =;

static const struct sensor_device_attribute_2 w83795_pwm[][8] =;

static const struct sensor_device_attribute_2 w83795_tss[6] =;

static const struct sensor_device_attribute_2 sda_single_files[] =;

static const struct sensor_device_attribute_2 sda_beep_files[] =;

/*
 * Driver interface
 */

static void w83795_init_client(struct i2c_client *client)
{}

static int w83795_get_device_id(struct i2c_client *client)
{}

/* Return 0 if detection is successful, -ENODEV otherwise */
static int w83795_detect(struct i2c_client *client,
			 struct i2c_board_info *info)
{}

#ifdef CONFIG_SENSORS_W83795_FANCTRL
#define NUM_PWM_ATTRIBUTES
#define NUM_TEMP_ATTRIBUTES
#else
#define NUM_PWM_ATTRIBUTES
#define NUM_TEMP_ATTRIBUTES
#endif

static int w83795_handle_files(struct device *dev, int (*fn)(struct device *,
			       const struct device_attribute *))
{}

/* We need a wrapper that fits in w83795_handle_files */
static int device_remove_file_wrapper(struct device *dev,
				      const struct device_attribute *attr)
{}

static void w83795_check_dynamic_in_limits(struct i2c_client *client)
{}

/* Check pins that can be used for either temperature or voltage monitoring */
static void w83795_apply_temp_config(struct w83795_data *data, u8 config,
				     int temp_chan, int in_chan)
{}

static int w83795_probe(struct i2c_client *client)
{}

static void w83795_remove(struct i2c_client *client)
{}


static const struct i2c_device_id w83795_id[] =;
MODULE_DEVICE_TABLE(i2c, w83795_id);

static struct i2c_driver w83795_driver =;

module_i2c_driver();

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