linux/drivers/hwmon/lm77.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * lm77.c - Part of lm_sensors, Linux kernel modules for hardware
 *	    monitoring
 *
 * Copyright (c) 2004  Andras BALI <[email protected]>
 *
 * Heavily based on lm75.c by Frodo Looijaard <[email protected]>.  The LM77
 * is a temperature sensor and thermal window comparator with 0.5 deg
 * resolution made by National Semiconductor.  Complete datasheet can be
 * obtained at their site:
 *	http://www.national.com/pf/LM/LM77.html
 */

#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[] =;

/* The LM77 registers */
#define LM77_REG_TEMP
#define LM77_REG_CONF
#define LM77_REG_TEMP_HYST
#define LM77_REG_TEMP_CRIT
#define LM77_REG_TEMP_MIN
#define LM77_REG_TEMP_MAX

enum temp_index {};

static const u8 temp_regs[t_num_temp] =;

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

/* straight from the datasheet */
#define LM77_TEMP_MIN
#define LM77_TEMP_MAX

/*
 * In the temperature registers, the low 3 bits are not part of the
 * temperature values; they are the status bits.
 */
static inline s16 LM77_TEMP_TO_REG(int temp)
{}

static inline int LM77_TEMP_FROM_REG(s16 reg)
{}

/*
 * All registers are word-sized, except for the configuration register.
 * The LM77 uses the high-byte first convention.
 */
static u16 lm77_read_value(struct i2c_client *client, u8 reg)
{}

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

static struct lm77_data *lm77_update_device(struct device *dev)
{}

/* sysfs stuff */

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

static ssize_t temp_hyst_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)
{}

/*
 * hysteresis is stored as a relative value on the chip, so it has to be
 * converted first.
 */
static ssize_t temp_hyst_store(struct device *dev,
			       struct device_attribute *devattr,
			       const char *buf, size_t count)
{}

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

static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, t_input);
static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp, t_crit);
static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, t_min);
static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, t_max);

static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, temp_hyst, t_crit);
static SENSOR_DEVICE_ATTR_RO(temp1_min_hyst, temp_hyst, t_min);
static SENSOR_DEVICE_ATTR_RO(temp1_max_hyst, temp_hyst, t_max);

static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 2);
static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 0);
static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 1);

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

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

static void lm77_init_client(struct i2c_client *client)
{}

static int lm77_probe(struct i2c_client *client)
{}

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

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

module_i2c_driver();

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