linux/drivers/hwmon/ds1621.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * ds1621.c - Part of lm_sensors, Linux kernel modules for hardware
 *	      monitoring
 * Christian W. Zuckschwerdt  <[email protected]>  2000-11-23
 * based on lm75.c by Frodo Looijaard <[email protected]>
 * Ported to Linux 2.6 by Aurelien Jarno <[email protected]> with
 * the help of Jean Delvare <[email protected]>
 *
 * The DS1621 device is a digital temperature/thermometer with 9-bit
 * resolution, a thermal alarm output (Tout), and user-defined minimum
 * and maximum temperature thresholds (TH and TL).
 *
 * The DS1625, DS1631, DS1721, and DS1731 are pin compatible with the DS1621
 * and similar in operation, with slight variations as noted in the device
 * datasheets (please refer to www.maximintegrated.com for specific
 * device information).
 *
 * Since the DS1621 was the first chipset supported by this driver,
 * most comments will refer to this chipset, but are actually general
 * and concern all supported chipsets, unless mentioned otherwise.
 */

#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>
#include <linux/sysfs.h>
#include <linux/kernel.h>

/* Supported devices */
enum chips {};

/* Insmod parameters */
static int polarity =;
module_param(polarity, int, 0);
MODULE_PARM_DESC();

/*
 * The Configuration/Status register
 *
 * - DS1621:
 *   7    6    5    4    3    2    1    0
 * |Done|THF |TLF |NVB | X  | X  |POL |1SHOT|
 *
 * - DS1625:
 *   7    6    5    4    3    2    1    0
 * |Done|THF |TLF |NVB | 1  | 0  |POL |1SHOT|
 *
 * - DS1631, DS1731:
 *   7    6    5    4    3    2    1    0
 * |Done|THF |TLF |NVB | R1 | R0 |POL |1SHOT|
 *
 * - DS1721:
 *   7    6    5    4    3    2    1    0
 * |Done| X  | X  | U  | R1 | R0 |POL |1SHOT|
 *
 * Where:
 * - 'X' is Reserved
 * - 'U' is Undefined
 */
#define DS1621_REG_CONFIG_NVB
#define DS1621_REG_CONFIG_RESOL
#define DS1621_REG_CONFIG_POLARITY
#define DS1621_REG_CONFIG_1SHOT
#define DS1621_REG_CONFIG_DONE

#define DS1621_REG_CONFIG_RESOL_SHIFT

/* ds1721 conversion rates: {C/LSB, time(ms), resolution bit setting} */
static const unsigned short ds1721_convrates[] =;

#define DS1621_CONVERSION_MAX
#define DS1625_CONVERSION_MAX

#define DS1621_TEMP_MAX
#define DS1621_TEMP_MIN

/* The DS1621 temperature registers */
static const u8 DS1621_REG_TEMP[3] =;
#define DS1621_REG_CONF
#define DS1621_COM_START
#define DS1721_COM_START
#define DS1621_COM_STOP

/* The DS1621 configuration register */
#define DS1621_ALARM_TEMP_HIGH
#define DS1621_ALARM_TEMP_LOW

/* Conversions */
#define ALARMS_FROM_REG(val)

/* Each client has this additional data */
struct ds1621_data {};

static inline int DS1621_TEMP_FROM_REG(u16 reg)
{}

/*
 * TEMP: 0.001C/bit (-55C to +125C)
 * REG:
 *  - 1621, 1625: 0.5C/bit, 7 zero-bits
 *  - 1631, 1721, 1731: 0.0625C/bit, 4 zero-bits
 */
static inline u16 DS1621_TEMP_TO_REG(long temp, u8 zbits)
{}

static void ds1621_init_client(struct ds1621_data *data,
			       struct i2c_client *client)
{}

static struct ds1621_data *ds1621_update_client(struct device *dev)
{}

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

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

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

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

static ssize_t update_interval_show(struct device *dev,
				    struct device_attribute *da, char *buf)
{}

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

static DEVICE_ATTR_RO(alarms);
static DEVICE_ATTR_RW(update_interval);

static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, 1);
static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 2);
static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, DS1621_ALARM_TEMP_LOW);
static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, DS1621_ALARM_TEMP_HIGH);

static struct attribute *ds1621_attributes[] =;

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

static const struct attribute_group ds1621_group =;
__ATTRIBUTE_GROUPS();

static int ds1621_probe(struct i2c_client *client)
{}

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

/* This is the driver that will be inserted */
static struct i2c_driver ds1621_driver =;

module_i2c_driver();

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