linux/drivers/hwmon/asb100.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * asb100.c - Part of lm_sensors, Linux kernel modules for hardware
 *	      monitoring
 *
 * Copyright (C) 2004 Mark M. Hoffman <[email protected]>
 *
 * (derived from w83781d.c)
 *
 * Copyright (C) 1998 - 2003  Frodo Looijaard <[email protected]>,
 *			      Philip Edelbrock <[email protected]>, and
 *			      Mark Studebaker <[email protected]>
 */

/*
 * This driver supports the hardware sensor chips: Asus ASB100 and
 * ASB100-A "BACH".
 *
 * ASB100-A supports pwm1, while plain ASB100 does not.  There is no known
 * way for the driver to tell which one is there.
 *
 * Chip		#vin	#fanin	#pwm	#temp	wchipid	vendid	i2c	ISA
 * asb100	7	3	1	4	0x31	0x0694	yes	no
 */

#define pr_fmt(fmt)

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

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

static unsigned short force_subclients[4];
module_param_array();
MODULE_PARM_DESC();

/* Voltage IN registers 0-6 */
#define ASB100_REG_IN(nr)
#define ASB100_REG_IN_MAX(nr)
#define ASB100_REG_IN_MIN(nr)

/* FAN IN registers 1-3 */
#define ASB100_REG_FAN(nr)
#define ASB100_REG_FAN_MIN(nr)

/* TEMPERATURE registers 1-4 */
static const u16 asb100_reg_temp[]	=;
static const u16 asb100_reg_temp_max[]	=;
static const u16 asb100_reg_temp_hyst[]	=;

#define ASB100_REG_TEMP(nr)
#define ASB100_REG_TEMP_MAX(nr)
#define ASB100_REG_TEMP_HYST(nr)

#define ASB100_REG_TEMP2_CONFIG
#define ASB100_REG_TEMP3_CONFIG


#define ASB100_REG_CONFIG
#define ASB100_REG_ALARM1
#define ASB100_REG_ALARM2
#define ASB100_REG_SMIM1
#define ASB100_REG_SMIM2
#define ASB100_REG_VID_FANDIV
#define ASB100_REG_I2C_ADDR
#define ASB100_REG_CHIPID
#define ASB100_REG_I2C_SUBADDR
#define ASB100_REG_PIN
#define ASB100_REG_IRQ
#define ASB100_REG_BANK
#define ASB100_REG_CHIPMAN

#define ASB100_REG_WCHIPID

/* bit 7 -> enable, bits 0-3 -> duty cycle */
#define ASB100_REG_PWM1

/*
 * CONVERSIONS
 * Rounding and limit checking is only done on the TO_REG variants.
 */

/* These constants are a guess, consistent w/ w83781d */
#define ASB100_IN_MIN
#define ASB100_IN_MAX

/*
 * IN: 1/1000 V (0V to 4.08V)
 * REG: 16mV/bit
 */
static u8 IN_TO_REG(unsigned val)
{}

static unsigned IN_FROM_REG(u8 reg)
{}

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

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

/* These constants are a guess, consistent w/ w83781d */
#define ASB100_TEMP_MIN
#define ASB100_TEMP_MAX

/*
 * TEMP: 0.001C/bit (-128C to +127C)
 * REG: 1C/bit, two's complement
 */
static u8 TEMP_TO_REG(long temp)
{}

static int TEMP_FROM_REG(u8 reg)
{}

/*
 * PWM: 0 - 255 per sensors documentation
 * REG: (6.25% duty cycle per bit)
 */
static u8 ASB100_PWM_TO_REG(int pwm)
{}

static int ASB100_PWM_FROM_REG(u8 reg)
{}

#define DIV_FROM_REG(val)

/*
 * FAN DIV: 1, 2, 4, or 8 (defaults to 2)
 * REG: 0, 1, 2, or 3 (respectively) (defaults to 1)
 */
static u8 DIV_TO_REG(long val)
{}

/*
 * For each registered client, we need to keep some data in memory. That
 * data is pointed to by client->data. The structure itself is
 * dynamically allocated, at the same time the client itself is allocated.
 */
struct asb100_data {};

static int asb100_read_value(struct i2c_client *client, u16 reg);
static void asb100_write_value(struct i2c_client *client, u16 reg, u16 val);

static int asb100_probe(struct i2c_client *client);
static int asb100_detect(struct i2c_client *client,
			 struct i2c_board_info *info);
static void asb100_remove(struct i2c_client *client);
static struct asb100_data *asb100_update_device(struct device *dev);
static void asb100_init_client(struct i2c_client *client);

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

static struct i2c_driver asb100_driver =;

/* 7 Voltages */
#define show_in_reg(reg)

show_in_reg()
show_in_reg()
show_in_reg()

#define set_in_reg(REG, reg)

set_in_reg()
set_in_reg()

#define sysfs_in(offset)

sysfs_in();
sysfs_in();
sysfs_in();
sysfs_in();
sysfs_in();
sysfs_in();
sysfs_in();

/* 3 Fans */
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_div(struct device *dev, struct device_attribute *attr,
		char *buf)
{}

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

#define sysfs_fan(offset)

sysfs_fan();
sysfs_fan();
sysfs_fan();

/* 4 Temp. Sensors */
static int sprintf_temp_from_reg(u16 reg, char *buf, int nr)
{}

#define show_temp_reg(reg)

show_temp_reg(temp);
show_temp_reg(temp_max);
show_temp_reg(temp_hyst);

#define set_temp_reg(REG, reg)

set_temp_reg(MAX, temp_max);
set_temp_reg(HYST, temp_hyst);

#define sysfs_temp(num)

sysfs_temp();
sysfs_temp();
sysfs_temp();
sysfs_temp();

/* VID */
static ssize_t cpu0_vid_show(struct device *dev,
			     struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RO(cpu0_vid);

/* VRM */
static ssize_t vrm_show(struct device *dev, struct device_attribute *attr,
		char *buf)
{}

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

/* Alarms */
static DEVICE_ATTR_RW(vrm);

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

static DEVICE_ATTR_RO(alarms);

static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
		char *buf)
{}
static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8);
static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6);
static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 11);
static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4);
static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5);
static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13);

/* 1 PWM */
static ssize_t pwm1_show(struct device *dev, struct device_attribute *attr,
		char *buf)
{}

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

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

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

static DEVICE_ATTR_RW(pwm1);
static DEVICE_ATTR_RW(pwm1_enable);

static struct attribute *asb100_attributes[] =;

static const struct attribute_group asb100_group =;

static int asb100_detect_subclients(struct i2c_client *client)
{}

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

static int asb100_probe(struct i2c_client *client)
{}

static void asb100_remove(struct i2c_client *client)
{}

/*
 * The SMBus locks itself, usually, but nothing may access the chip between
 * bank switches.
 */
static int asb100_read_value(struct i2c_client *client, u16 reg)
{}

static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
{}

static void asb100_init_client(struct i2c_client *client)
{}

static struct asb100_data *asb100_update_device(struct device *dev)
{}

module_i2c_driver();

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