Lines Matching +full:temp +full:- +full:alarm
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * lm83.c - Part of lm_sensors, Linux kernel modules for hardware
5 * Copyright (C) 2003-2009 Jean Delvare <jdelvare@suse.de>
10 * resolution and a 3-4 deg accuracy. Complete datasheet can be obtained
16 * Also supports the LM82 temp sensor, which is basically a stripped down
26 #include <linux/hwmon-sysfs.h>
34 * Address is selected using 2 three-level pins, resulting in 9 possible
71 * The LM83 uses signed 8-bit values with LSB = 1 degree Celsius.
75 #define TEMP_TO_REG(val) ((val) <= -128000 ? -128 : \
77 (val) < 0 ? ((val) - 500) / 1000 : \
112 s8 temp[9]; /* 0..3: input 1-4, member
113 4..7: high limit 1-4,
121 struct i2c_client *client = data->client; in lm83_update_device()
123 mutex_lock(&data->update_lock); in lm83_update_device()
125 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { in lm83_update_device()
128 dev_dbg(&client->dev, "Updating lm83 data.\n"); in lm83_update_device()
130 data->temp[nr] = in lm83_update_device()
134 data->alarms = in lm83_update_device()
139 data->last_updated = jiffies; in lm83_update_device()
140 data->valid = 1; in lm83_update_device()
143 mutex_unlock(&data->update_lock); in lm83_update_device()
157 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); in temp_show()
166 struct i2c_client *client = data->client; in temp_store()
168 int nr = attr->index; in temp_store()
175 mutex_lock(&data->update_lock); in temp_store()
176 data->temp[nr] = TEMP_TO_REG(val); in temp_store()
177 i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], in temp_store()
178 data->temp[nr]); in temp_store()
179 mutex_unlock(&data->update_lock); in temp_store()
187 return sprintf(buf, "%d\n", data->alarms); in alarms_show()
195 int bitnr = attr->index; in alarm_show()
197 return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1); in alarm_show()
200 static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
201 static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1);
202 static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2);
203 static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3);
204 static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 4);
205 static SENSOR_DEVICE_ATTR_RW(temp2_max, temp, 5);
206 static SENSOR_DEVICE_ATTR_RW(temp3_max, temp, 6);
207 static SENSOR_DEVICE_ATTR_RW(temp4_max, temp, 7);
208 static SENSOR_DEVICE_ATTR_RO(temp1_crit, temp, 8);
209 static SENSOR_DEVICE_ATTR_RO(temp2_crit, temp, 8);
210 static SENSOR_DEVICE_ATTR_RW(temp3_crit, temp, 8);
211 static SENSOR_DEVICE_ATTR_RO(temp4_crit, temp, 8);
213 /* Individual alarm files */
214 static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 0);
215 static SENSOR_DEVICE_ATTR_RO(temp3_crit_alarm, alarm, 1);
216 static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 2);
217 static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, alarm, 4);
218 static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6);
219 static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 8);
220 static SENSOR_DEVICE_ATTR_RO(temp4_crit_alarm, alarm, 9);
221 static SENSOR_DEVICE_ATTR_RO(temp4_fault, alarm, 10);
222 static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, alarm, 12);
223 static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 13);
224 static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 15);
225 /* Raw alarm file for compatibility */
274 /* Return 0 if detection is successful, -ENODEV otherwise */
278 struct i2c_adapter *adapter = new_client->adapter; in lm83_detect()
283 return -ENODEV; in lm83_detect()
289 dev_dbg(&adapter->dev, "LM83 detection failed at 0x%02x\n", in lm83_detect()
290 new_client->addr); in lm83_detect()
291 return -ENODEV; in lm83_detect()
297 return -ENODEV; in lm83_detect()
309 dev_info(&adapter->dev, in lm83_detect()
312 return -ENODEV; in lm83_detect()
315 strlcpy(info->type, name, I2C_NAME_SIZE); in lm83_detect()
327 data = devm_kzalloc(&new_client->dev, sizeof(struct lm83_data), in lm83_probe()
330 return -ENOMEM; in lm83_probe()
332 data->client = new_client; in lm83_probe()
333 mutex_init(&data->update_lock); in lm83_probe()
338 * at the same register as the LM83 temp3 entry - so we in lm83_probe()
341 data->groups[0] = &lm83_group; in lm83_probe()
342 if (i2c_match_id(lm83_id, new_client)->driver_data == lm83) in lm83_probe()
343 data->groups[1] = &lm83_group_opt; in lm83_probe()
345 hwmon_dev = devm_hwmon_device_register_with_groups(&new_client->dev, in lm83_probe()
346 new_client->name, in lm83_probe()
347 data, data->groups); in lm83_probe()