linux/drivers/hwmon/lm80.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * lm80.c - From lm_sensors, Linux kernel modules for hardware
 *	    monitoring
 * Copyright (C) 1998, 1999  Frodo Looijaard <[email protected]>
 *			     and Philip Edelbrock <[email protected]>
 *
 * Ported to Linux 2.6 by Tiago Sousa <[email protected]>
 */

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

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

/* Many LM80 constants specified below */

/* The LM80 registers */
#define LM80_REG_IN_MAX(nr)
#define LM80_REG_IN_MIN(nr)
#define LM80_REG_IN(nr)

#define LM80_REG_FAN1
#define LM80_REG_FAN2
#define LM80_REG_FAN_MIN(nr)

#define LM80_REG_TEMP
#define LM80_REG_TEMP_HOT_MAX
#define LM80_REG_TEMP_HOT_HYST
#define LM80_REG_TEMP_OS_MAX
#define LM80_REG_TEMP_OS_HYST

#define LM80_REG_CONFIG
#define LM80_REG_ALARM1
#define LM80_REG_ALARM2
#define LM80_REG_MASK1
#define LM80_REG_MASK2
#define LM80_REG_FANDIV
#define LM80_REG_RES

#define LM96080_REG_CONV_RATE
#define LM96080_REG_MAN_ID
#define LM96080_REG_DEV_ID


/*
 * Conversions. Rounding and limit checking is only done on the TO_REG
 * variants. Note that you should be a bit careful with which arguments
 * these macros are called: arguments may be evaluated more than once.
 * Fixing this is just not worth it.
 */

#define IN_TO_REG(val)
#define IN_FROM_REG(val)

static inline unsigned char FAN_TO_REG(unsigned rpm, unsigned div)
{}

#define FAN_FROM_REG(val, div)

#define TEMP_FROM_REG(reg)
#define TEMP_TO_REG(temp)

#define DIV_FROM_REG(val)

enum temp_index {};

static const u8 temp_regs[t_num_temp] =;

enum in_index {};

enum fan_index {};

/*
 * Client data (each client gets its own)
 */

struct lm80_data {};

static int lm80_read_value(struct i2c_client *client, u8 reg)
{}

static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value)
{}

/* Called when we have found a new LM80 and after read errors */
static void lm80_init_client(struct i2c_client *client)
{}

static struct lm80_data *lm80_update_device(struct device *dev)
{}

/*
 * Sysfs stuff
 */

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

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

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

/*
 * 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 *attr, const char *buf,
			     size_t count)
{}

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

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

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

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

static SENSOR_DEVICE_ATTR_2_RW(in0_min, in, i_min, 0);
static SENSOR_DEVICE_ATTR_2_RW(in1_min, in, i_min, 1);
static SENSOR_DEVICE_ATTR_2_RW(in2_min, in, i_min, 2);
static SENSOR_DEVICE_ATTR_2_RW(in3_min, in, i_min, 3);
static SENSOR_DEVICE_ATTR_2_RW(in4_min, in, i_min, 4);
static SENSOR_DEVICE_ATTR_2_RW(in5_min, in, i_min, 5);
static SENSOR_DEVICE_ATTR_2_RW(in6_min, in, i_min, 6);
static SENSOR_DEVICE_ATTR_2_RW(in0_max, in, i_max, 0);
static SENSOR_DEVICE_ATTR_2_RW(in1_max, in, i_max, 1);
static SENSOR_DEVICE_ATTR_2_RW(in2_max, in, i_max, 2);
static SENSOR_DEVICE_ATTR_2_RW(in3_max, in, i_max, 3);
static SENSOR_DEVICE_ATTR_2_RW(in4_max, in, i_max, 4);
static SENSOR_DEVICE_ATTR_2_RW(in5_max, in, i_max, 5);
static SENSOR_DEVICE_ATTR_2_RW(in6_max, in, i_max, 6);
static SENSOR_DEVICE_ATTR_2_RO(in0_input, in, i_input, 0);
static SENSOR_DEVICE_ATTR_2_RO(in1_input, in, i_input, 1);
static SENSOR_DEVICE_ATTR_2_RO(in2_input, in, i_input, 2);
static SENSOR_DEVICE_ATTR_2_RO(in3_input, in, i_input, 3);
static SENSOR_DEVICE_ATTR_2_RO(in4_input, in, i_input, 4);
static SENSOR_DEVICE_ATTR_2_RO(in5_input, in, i_input, 5);
static SENSOR_DEVICE_ATTR_2_RO(in6_input, in, i_input, 6);
static SENSOR_DEVICE_ATTR_2_RW(fan1_min, fan, f_min, 0);
static SENSOR_DEVICE_ATTR_2_RW(fan2_min, fan, f_min, 1);
static SENSOR_DEVICE_ATTR_2_RO(fan1_input, fan, f_input, 0);
static SENSOR_DEVICE_ATTR_2_RO(fan2_input, fan, f_input, 1);
static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0);
static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);
static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, t_input);
static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, t_hot_max);
static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, temp, t_hot_hyst);
static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp, t_os_max);
static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, temp, t_os_hyst);
static DEVICE_ATTR_RO(alarms);
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, 4);
static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 5);
static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 6);
static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 10);
static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 11);
static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 8);
static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 13);

/*
 * Real code
 */

static struct attribute *lm80_attrs[] =;
ATTRIBUTE_GROUPS();

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

static int lm80_probe(struct i2c_client *client)
{}

/*
 * Driver data (common to all clients)
 */

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

static struct i2c_driver lm80_driver =;

module_i2c_driver();

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