// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2011 Alexander Stein <alexander.stein@systec-electronic.com> * * The LM95245 is a sensor chip made by TI / National Semiconductor. * It reports up to two temperatures (its own plus an external one). * * This driver is based on lm95241.c
*/
staticint lm95245_write_chip(struct device *dev, u32 attr, int channel, long val)
{ struct lm95245_data *data = dev_get_drvdata(dev); int ret;
switch (attr) { case hwmon_chip_update_interval:
mutex_lock(&data->update_lock);
ret = lm95245_set_conversion_rate(data, val);
mutex_unlock(&data->update_lock); return ret; default: return -EOPNOTSUPP;
}
}
staticint lm95245_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{ switch (type) { case hwmon_chip: return lm95245_read_chip(dev, attr, channel, val); case hwmon_temp: return lm95245_read_temp(dev, attr, channel, val); default: return -EOPNOTSUPP;
}
}
staticint lm95245_write(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long val)
{ switch (type) { case hwmon_chip: return lm95245_write_chip(dev, attr, channel, val); case hwmon_temp: return lm95245_write_temp(dev, attr, channel, val); default: return -EOPNOTSUPP;
}
}
static umode_t lm95245_temp_is_visible(constvoid *data, u32 attr, int channel)
{ switch (attr) { case hwmon_temp_input: case hwmon_temp_max_alarm: case hwmon_temp_max_hyst: case hwmon_temp_crit_alarm: case hwmon_temp_fault: return 0444; case hwmon_temp_type: case hwmon_temp_max: case hwmon_temp_crit: case hwmon_temp_offset: return 0644; case hwmon_temp_crit_hyst: return (channel == 0) ? 0644 : 0444; default: return 0;
}
}
static umode_t lm95245_is_visible(constvoid *data, enum hwmon_sensor_types type,
u32 attr, int channel)
{ switch (type) { case hwmon_chip: switch (attr) { case hwmon_chip_update_interval: return 0644; default: return 0;
} case hwmon_temp: return lm95245_temp_is_visible(data, attr, channel); default: return 0;
}
}
/* Return 0 if detection is successful, -ENODEV otherwise */ staticint lm95245_detect(struct i2c_client *new_client, struct i2c_board_info *info)
{ struct i2c_adapter *adapter = new_client->adapter; int address = new_client->addr; constchar *name; int rev, id;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV;
id = i2c_smbus_read_byte_data(new_client, LM95245_REG_R_MAN_ID); if (id != MANUFACTURER_ID) return -ENODEV;
rev = i2c_smbus_read_byte_data(new_client, LM95245_REG_R_CHIP_ID); switch (rev) { case LM95235_REVISION: if (address != 0x18 && address != 0x29 && address != 0x4c) return -ENODEV;
name = "lm95235"; break; case LM95245_REVISION:
name = "lm95245"; break; default: return -ENODEV;
}
staticbool lm95245_is_writeable_reg(struct device *dev, unsignedint reg)
{ switch (reg) { case LM95245_REG_RW_CONFIG1: case LM95245_REG_RW_CONVERS_RATE: case LM95245_REG_W_ONE_SHOT: case LM95245_REG_RW_CONFIG2: case LM95245_REG_RW_REMOTE_OFFH: case LM95245_REG_RW_REMOTE_OFFL: case LM95245_REG_RW_REMOTE_OS_LIMIT: case LM95245_REG_RW_LOCAL_OS_TCRIT_LIMIT: case LM95245_REG_RW_REMOTE_TCRIT_LIMIT: case LM95245_REG_RW_COMMON_HYSTERESIS: returntrue; default: returnfalse;
}
}
staticbool lm95245_is_volatile_reg(struct device *dev, unsignedint reg)
{ switch (reg) { case LM95245_REG_R_STATUS1: case LM95245_REG_R_STATUS2: case LM95245_REG_R_LOCAL_TEMPH_S: case LM95245_REG_R_LOCAL_TEMPL_S: case LM95245_REG_R_REMOTE_TEMPH_S: case LM95245_REG_R_REMOTE_TEMPL_S: case LM95245_REG_R_REMOTE_TEMPH_U: case LM95245_REG_R_REMOTE_TEMPL_U: returntrue; default: returnfalse;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.