linux/drivers/hwmon/stts751.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * STTS751 sensor driver
 *
 * Copyright (C) 2016-2017 Istituto Italiano di Tecnologia - RBCS - EDL
 * Robotics, Brain and Cognitive Sciences department
 * Electronic Design Laboratory
 *
 * Written by Andrea Merello <[email protected]>
 *
 * Based on  LM95241 driver and LM90 driver
 */

#include <linux/bitops.h>
#include <linux/err.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/property.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/util_macros.h>

#define DEVNAME

static const unsigned short normal_i2c[] =;

#define STTS751_REG_TEMP_H
#define STTS751_REG_STATUS
#define STTS751_STATUS_TRIPT
#define STTS751_STATUS_TRIPL
#define STTS751_STATUS_TRIPH
#define STTS751_REG_TEMP_L
#define STTS751_REG_CONF
#define STTS751_CONF_RES_MASK
#define STTS751_CONF_RES_SHIFT
#define STTS751_CONF_EVENT_DIS
#define STTS751_CONF_STOP
#define STTS751_REG_RATE
#define STTS751_REG_HLIM_H
#define STTS751_REG_HLIM_L
#define STTS751_REG_LLIM_H
#define STTS751_REG_LLIM_L
#define STTS751_REG_TLIM
#define STTS751_REG_HYST
#define STTS751_REG_SMBUS_TO

#define STTS751_REG_PROD_ID
#define STTS751_REG_MAN_ID
#define STTS751_REG_REV_ID

#define STTS751_0_PROD_ID
#define STTS751_1_PROD_ID
#define ST_MAN_ID

/*
 * Possible update intervals are (in mS):
 * 16000, 8000, 4000, 2000, 1000, 500, 250, 125, 62.5, 31.25
 * However we are not going to complicate things too much and we stick to the
 * approx value in mS.
 */
static const int stts751_intervals[] =;

static const struct i2c_device_id stts751_id[] =;

static const struct of_device_id __maybe_unused stts751_of_match[] =;
MODULE_DEVICE_TABLE(of, stts751_of_match);

struct stts751_priv {};

/*
 * These functions converts temperature from HW format to integer format and
 * vice-vers. They are (mostly) taken from lm90 driver. Unit is in mC.
 */
static int stts751_to_deg(s16 hw_val)
{}

static s32 stts751_to_hw(int val)
{}

static int stts751_adjust_resolution(struct stts751_priv *priv)
{}

static int stts751_update_temp(struct stts751_priv *priv)
{}

static int stts751_set_temp_reg16(struct stts751_priv *priv, int temp,
				  u8 hreg, u8 lreg)
{}

static int stts751_set_temp_reg8(struct stts751_priv *priv, int temp, u8 reg)
{}

static int stts751_read_reg16(struct stts751_priv *priv, int *temp,
			      u8 hreg, u8 lreg)
{}

static int stts751_read_reg8(struct stts751_priv *priv, int *temp, u8 reg)
{}

/*
 * Update alert flags without waiting for cache to expire. We detects alerts
 * immediately for the sake of the alert handler; we still need to deal with
 * caching to workaround the fact that alarm flags int the status register,
 * despite what the datasheet claims, gets always cleared on read.
 */
static int stts751_update_alert(struct stts751_priv *priv)
{}

static void stts751_alert(struct i2c_client *client,
			  enum i2c_alert_protocol type, unsigned int data)
{}

static int stts751_update(struct stts751_priv *priv)
{}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

static int stts751_detect(struct i2c_client *new_client,
			  struct i2c_board_info *info)
{}

static int stts751_read_chip_config(struct stts751_priv *priv)
{}

static SENSOR_DEVICE_ATTR_RO(temp1_input, input, 0);
static SENSOR_DEVICE_ATTR_RW(temp1_min, min, 0);
static SENSOR_DEVICE_ATTR_RW(temp1_max, max, 0);
static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, min_alarm, 0);
static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, max_alarm, 0);
static SENSOR_DEVICE_ATTR_RW(temp1_crit, therm, 0);
static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, hyst, 0);
static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, therm_trip, 0);
static SENSOR_DEVICE_ATTR_RW(update_interval, interval, 0);

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

static int stts751_probe(struct i2c_client *client)
{}

MODULE_DEVICE_TABLE(i2c, stts751_id);

static struct i2c_driver stts751_driver =;

module_i2c_driver();

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