linux/drivers/hwmon/lm92.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * lm92 - Hardware monitoring driver
 * Copyright (C) 2005-2008  Jean Delvare <[email protected]>
 *
 * Based on the lm90 driver, with some ideas taken from the lm_sensors
 * lm92 driver as well.
 *
 * The LM92 is a sensor chip made by National Semiconductor. It reports
 * its own temperature with a 0.0625 deg resolution and a 0.33 deg
 * accuracy. Complete datasheet can be obtained from National's website
 * at:
 *   http://www.national.com/pf/LM/LM92.html
 *
 * This driver also supports the MAX6635 sensor chip made by Maxim.
 * This chip is compatible with the LM92, but has a lesser accuracy
 * (1.0 deg). Complete datasheet can be obtained from Maxim's website
 * at:
 *   http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3074
 *
 * Since the LM92 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.
 *
 * Support could easily be added for the National Semiconductor LM76
 * and Maxim MAX6633 and MAX6634 chips, which are mostly compatible
 * with the LM92.
 */

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

/*
 * The LM92 and MAX6635 have 2 two-state pins for address selection,
 * resulting in 4 possible addresses.
 */
static const unsigned short normal_i2c[] =;
/* The LM92 registers */
#define LM92_REG_CONFIG
#define LM92_REG_TEMP
#define LM92_REG_TEMP_HYST
#define LM92_REG_TEMP_CRIT
#define LM92_REG_TEMP_LOW
#define LM92_REG_TEMP_HIGH
#define LM92_REG_MAN_ID

/*
 * The LM92 uses signed 13-bit values with LSB = 0.0625 degree Celsius,
 * left-justified in 16-bit registers. No rounding is done, with such
 * a resolution it's just not worth it. Note that the MAX6635 doesn't
 * make use of the 4 lower bits for limits (i.e. effective resolution
 * for limits is 1 degree Celsius).
 */
static inline int TEMP_FROM_REG(s16 reg)
{}

static inline s16 TEMP_TO_REG(long val, int resolution)
{}

/* Alarm flags are stored in the 3 LSB of the temperature register */
static inline u8 ALARMS_FROM_REG(s16 reg)
{}

/* Client data (each client gets its own) */
struct lm92_data {};

static int lm92_temp_read(struct lm92_data *data, u32 attr, int channel, long *val)
{}

static int lm92_chip_read(struct lm92_data *data, u32 attr, long *val)
{}

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

static int lm92_temp_write(struct lm92_data *data, u32 attr, long val)
{}

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

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

static const struct hwmon_channel_info * const lm92_info[] =;

static const struct hwmon_ops lm92_hwmon_ops =;

static const struct hwmon_chip_info lm92_chip_info =;

/*
 * Detection and registration
 */

static int lm92_init_client(struct regmap *regmap)
{}

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

/* regmap */

static int lm92_reg_read(void *context, unsigned int reg, unsigned int *val)
{}

static int lm92_reg_write(void *context, unsigned int reg, unsigned int val)
{}

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

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

static const struct regmap_config lm92_regmap_config =;

static const struct regmap_bus lm92_regmap_bus =;

static int lm92_probe(struct i2c_client *client)
{}

/*
 * Module and driver stuff
 */

/* .driver_data is limit register resolution */ 
static const struct i2c_device_id lm92_id[] =;
MODULE_DEVICE_TABLE(i2c, lm92_id);

static struct i2c_driver lm92_driver =;

module_i2c_driver();

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