#include <linux/module.h>
#include <linux/hwmon-sysfs.h>
#include <linux/of_device.h>
#include <linux/regmap.h>
#define W83773_CHANNELS 3
#define W83773_CONVERSION_RATE_REG_READ 0x04
#define W83773_CONVERSION_RATE_REG_WRITE 0x0A
#define W83773_MANUFACTURER_ID_REG 0xFE
#define W83773_LOCAL_TEMP 0x00
static const u8 W83773_STATUS[2] = { 0x02, 0x17 };
static const u8 W83773_TEMP_LSB[2] = { 0x10, 0x25 };
static const u8 W83773_TEMP_MSB[2] = { 0x01, 0x24 };
static const u8 W83773_OFFSET_LSB[2] = { 0x12, 0x16 };
static const u8 W83773_OFFSET_MSB[2] = { 0x11, 0x15 };
static const struct i2c_device_id w83773_id[] = {
MODULE_DEVICE_TABLE(i2c, w83773_id);
static const struct of_device_id w83773_of_match[] = {
.compatible = "nuvoton,w83773g"
MODULE_DEVICE_TABLE(of, w83773_of_match);
static inline long temp_of_local(s8 reg)
static inline long temp_of_remote(s8 hb, u8 lb)
return (hb << 3 | lb >> 5) * 125;
static int get_local_temp(struct regmap *regmap, long *val)
ret = regmap_read(regmap, W83773_LOCAL_TEMP, ®val);
*val = temp_of_local(regval);
static int get_remote_temp(struct regmap *regmap, int index, long *val)
unsigned int regval_high;
ret = regmap_read(regmap, W83773_TEMP_MSB[index], ®val_high);
ret = regmap_read(regmap, W83773_TEMP_LSB[index], ®val_low);
*val = temp_of_remote(regval_high, regval_low);