linux/drivers/hwmon/adm9240.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * adm9240.c	Part of lm_sensors, Linux kernel modules for hardware
 *		monitoring
 *
 * Copyright (C) 1999	Frodo Looijaard <[email protected]>
 *			Philip Edelbrock <[email protected]>
 * Copyright (C) 2003	Michiel Rook <[email protected]>
 * Copyright (C) 2005	Grant Coady <[email protected]> with valuable
 *				guidance from Jean Delvare
 *
 * Driver supports	Analog Devices		ADM9240
 *			Dallas Semiconductor	DS1780
 *			National Semiconductor	LM81
 *
 * ADM9240 is the reference, DS1780 and LM81 are register compatibles
 *
 * Voltage	Six inputs are scaled by chip, VID also reported
 * Temperature	Chip temperature to 0.5'C, maximum and max_hysteris
 * Fans		2 fans, low speed alarm, automatic fan clock divider
 * Alarms	16-bit map of active alarms
 * Analog Out	0..1250 mV output
 *
 * Chassis Intrusion: clear CI latch with 'echo 0 > intrusion0_alarm'
 *
 * Test hardware: Intel SE440BX-2 desktop motherboard --Grant
 *
 * LM81 extended temp reading not implemented
 */

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

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

enum chips {};

/* ADM9240 registers */
#define ADM9240_REG_MAN_ID
#define ADM9240_REG_DIE_REV
#define ADM9240_REG_CONFIG

#define ADM9240_REG_IN(nr)
#define ADM9240_REG_IN_MAX(nr)
#define ADM9240_REG_IN_MIN(nr)
#define ADM9240_REG_FAN(nr)
#define ADM9240_REG_FAN_MIN(nr)
#define ADM9240_REG_INT(nr)
#define ADM9240_REG_INT_MASK(nr)
#define ADM9240_REG_TEMP
#define ADM9240_REG_TEMP_MAX(nr)
#define ADM9240_REG_ANALOG_OUT
#define ADM9240_REG_CHASSIS_CLEAR
#define ADM9240_REG_VID_FAN_DIV
#define ADM9240_REG_I2C_ADDR
#define ADM9240_REG_VID4
#define ADM9240_REG_TEMP_CONF

/* generalised scaling with integer rounding */
static inline int SCALE(long val, int mul, int div)
{}

/* adm9240 internally scales voltage measurements */
static const u16 nom_mv[] =;

static inline unsigned int IN_FROM_REG(u8 reg, int n)
{}

static inline u8 IN_TO_REG(unsigned long val, int n)
{}

/* temperature range: -40..125, 127 disables temperature alarm */
static inline s8 TEMP_TO_REG(long val)
{}

/* two fans, each with low fan speed limit */
static inline unsigned int FAN_FROM_REG(u8 reg, u8 div)
{}

/* analog out 0..1250mV */
static inline u8 AOUT_TO_REG(unsigned long val)
{}

static inline unsigned int AOUT_FROM_REG(u8 reg)
{}

/* per client data */
struct adm9240_data {};

/* write new fan div, callers must hold data->update_lock */
static int adm9240_write_fan_div(struct adm9240_data *data, int channel, u8 fan_div)
{}

/*
 * set fan speed low limit:
 *
 * - value is zero: disable fan speed low limit alarm
 *
 * - value is below fan speed measurement range: enable fan speed low
 *   limit alarm to be asserted while fan speed too slow to measure
 *
 * - otherwise: select fan clock divider to suit fan speed low limit,
 *   measurement code may adjust registers to ensure fan speed reading
 */
static int adm9240_fan_min_write(struct adm9240_data *data, int channel, long val)
{}

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

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

static ssize_t aout_output_store(struct device *dev,
				 struct device_attribute *attr,
				 const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(aout_output);

static struct attribute *adm9240_attrs[] =;

ATTRIBUTE_GROUPS();

/*** sensor chip detect and driver install ***/

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

static int adm9240_init_client(struct adm9240_data *data)
{}

static int adm9240_chip_read(struct device *dev, u32 attr, long *val)
{}

static int adm9240_intrusion_read(struct device *dev, u32 attr, long *val)
{}

static int adm9240_intrusion_write(struct device *dev, u32 attr, long val)
{}

static int adm9240_in_read(struct device *dev, u32 attr, int channel, long *val)
{}

static int adm9240_in_write(struct device *dev, u32 attr, int channel, long val)
{}

static int adm9240_fan_read(struct device *dev, u32 attr, int channel, long *val)
{}

static int adm9240_fan_write(struct device *dev, u32 attr, int channel, long val)
{}

static int adm9240_temp_read(struct device *dev, u32 attr, int channel, long *val)
{}

static int adm9240_temp_write(struct device *dev, u32 attr, int channel, long val)
{}

static int adm9240_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
			int channel, long *val)
{}

static int adm9240_write(struct device *dev, enum hwmon_sensor_types type, u32 attr,
			 int channel, long val)
{}

static umode_t adm9240_is_visible(const void *_data, enum hwmon_sensor_types type,
				  u32 attr, int channel)
{}

static const struct hwmon_ops adm9240_hwmon_ops =;

static const struct hwmon_channel_info * const adm9240_info[] =;

static const struct hwmon_chip_info adm9240_chip_info =;

static bool adm9240_volatile_reg(struct device *dev, unsigned int reg)
{}

static const struct regmap_config adm9240_regmap_config =;

static int adm9240_probe(struct i2c_client *client)
{}

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

static struct i2c_driver adm9240_driver =;

module_i2c_driver();

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