Lines Matching +full:4 +full:- +full:temp

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * emc6w201.c - Hardware monitoring driver for the SMSC EMC6W201
13 #include <linux/hwmon-sysfs.h>
42 * Per-device data
53 s8 temp[3][6]; member
59 * Locking: must be called with data->update_lock held
68 dev_err(&client->dev, "%d-bit %s failed at 0x%02x\n", in emc6w201_read16()
77 * Write 16-bit value to LSB and MSB registers
78 * Locking: must be called with data->update_lock held
88 dev_err(&client->dev, "%d-bit %s failed at 0x%02x\n", in emc6w201_write16()
94 /* Read 8-bit value from register */
101 dev_err(&client->dev, "%d-bit %s failed at 0x%02x\n", in emc6w201_read8()
109 /* Write 8-bit value to register */
116 dev_err(&client->dev, "%d-bit %s failed at 0x%02x\n", in emc6w201_write8()
125 struct i2c_client *client = data->client; in emc6w201_update_device()
128 mutex_lock(&data->update_lock); in emc6w201_update_device()
130 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { in emc6w201_update_device()
132 data->in[input][nr] = in emc6w201_update_device()
135 data->in[min][nr] = in emc6w201_update_device()
138 data->in[max][nr] = in emc6w201_update_device()
144 data->temp[input][nr] = in emc6w201_update_device()
147 data->temp[min][nr] = in emc6w201_update_device()
150 data->temp[max][nr] = in emc6w201_update_device()
156 data->fan[input][nr] = in emc6w201_update_device()
159 data->fan[min][nr] = in emc6w201_update_device()
164 data->last_updated = jiffies; in emc6w201_update_device()
165 data->valid = true; in emc6w201_update_device()
168 mutex_unlock(&data->update_lock); in emc6w201_update_device()
183 int sf = to_sensor_dev_attr_2(devattr)->index; in in_show()
184 int nr = to_sensor_dev_attr_2(devattr)->nr; in in_show()
187 (unsigned)data->in[sf][nr] * nominal_mv[nr] / 0xC0); in in_show()
194 struct i2c_client *client = data->client; in in_store()
195 int sf = to_sensor_dev_attr_2(devattr)->index; in in_store()
196 int nr = to_sensor_dev_attr_2(devattr)->nr; in in_store()
210 mutex_lock(&data->update_lock); in in_store()
211 data->in[sf][nr] = val; in in_store()
212 err = emc6w201_write8(client, reg, data->in[sf][nr]); in in_store()
213 mutex_unlock(&data->update_lock); in in_store()
222 int sf = to_sensor_dev_attr_2(devattr)->index; in temp_show()
223 int nr = to_sensor_dev_attr_2(devattr)->nr; in temp_show()
225 return sprintf(buf, "%d\n", (int)data->temp[sf][nr] * 1000); in temp_show()
233 struct i2c_client *client = data->client; in temp_store()
234 int sf = to_sensor_dev_attr_2(devattr)->index; in temp_store()
235 int nr = to_sensor_dev_attr_2(devattr)->nr; in temp_store()
244 val = clamp_val(val, -127000, 127000); in temp_store()
249 mutex_lock(&data->update_lock); in temp_store()
250 data->temp[sf][nr] = val; in temp_store()
251 err = emc6w201_write8(client, reg, data->temp[sf][nr]); in temp_store()
252 mutex_unlock(&data->update_lock); in temp_store()
261 int sf = to_sensor_dev_attr_2(devattr)->index; in fan_show()
262 int nr = to_sensor_dev_attr_2(devattr)->nr; in fan_show()
265 if (data->fan[sf][nr] == 0 || data->fan[sf][nr] == 0xFFFF) in fan_show()
268 rpm = 5400000U / data->fan[sf][nr]; in fan_show()
277 struct i2c_client *client = data->client; in fan_store()
278 int sf = to_sensor_dev_attr_2(devattr)->index; in fan_store()
279 int nr = to_sensor_dev_attr_2(devattr)->nr; in fan_store()
294 mutex_lock(&data->update_lock); in fan_store()
295 data->fan[sf][nr] = val; in fan_store()
297 data->fan[sf][nr]); in fan_store()
298 mutex_unlock(&data->update_lock); in fan_store()
315 static SENSOR_DEVICE_ATTR_2_RO(in4_input, in, 4, input);
316 static SENSOR_DEVICE_ATTR_2_RW(in4_min, in, 4, min);
317 static SENSOR_DEVICE_ATTR_2_RW(in4_max, in, 4, max);
322 static SENSOR_DEVICE_ATTR_2_RO(temp1_input, temp, 0, input);
323 static SENSOR_DEVICE_ATTR_2_RW(temp1_min, temp, 0, min);
324 static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp, 0, max);
325 static SENSOR_DEVICE_ATTR_2_RO(temp2_input, temp, 1, input);
326 static SENSOR_DEVICE_ATTR_2_RW(temp2_min, temp, 1, min);
327 static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp, 1, max);
328 static SENSOR_DEVICE_ATTR_2_RO(temp3_input, temp, 2, input);
329 static SENSOR_DEVICE_ATTR_2_RW(temp3_min, temp, 2, min);
330 static SENSOR_DEVICE_ATTR_2_RW(temp3_max, temp, 2, max);
331 static SENSOR_DEVICE_ATTR_2_RO(temp4_input, temp, 3, input);
332 static SENSOR_DEVICE_ATTR_2_RW(temp4_min, temp, 3, min);
333 static SENSOR_DEVICE_ATTR_2_RW(temp4_max, temp, 3, max);
334 static SENSOR_DEVICE_ATTR_2_RO(temp5_input, temp, 4, input);
335 static SENSOR_DEVICE_ATTR_2_RW(temp5_min, temp, 4, min);
336 static SENSOR_DEVICE_ATTR_2_RW(temp5_max, temp, 4, max);
337 static SENSOR_DEVICE_ATTR_2_RO(temp6_input, temp, 5, input);
338 static SENSOR_DEVICE_ATTR_2_RW(temp6_min, temp, 5, min);
339 static SENSOR_DEVICE_ATTR_2_RW(temp6_max, temp, 5, max);
349 static SENSOR_DEVICE_ATTR_2_RO(fan5_input, fan, 4, input);
350 static SENSOR_DEVICE_ATTR_2_RW(fan5_min, fan, 4, min);
410 /* Return 0 if detection is successful, -ENODEV otherwise */
414 struct i2c_adapter *adapter = client->adapter; in emc6w201_detect()
418 return -ENODEV; in emc6w201_detect()
423 return -ENODEV; in emc6w201_detect()
426 return -ENODEV; in emc6w201_detect()
428 dev_dbg(&client->dev, "Unknown EMC6W201 stepping %d\n", in emc6w201_detect()
430 return -ENODEV; in emc6w201_detect()
436 return -ENODEV; in emc6w201_detect()
438 dev_err(&client->dev, "Monitoring not enabled\n"); in emc6w201_detect()
439 return -ENODEV; in emc6w201_detect()
442 strscpy(info->type, "emc6w201", I2C_NAME_SIZE); in emc6w201_detect()
449 struct device *dev = &client->dev; in emc6w201_probe()
455 return -ENOMEM; in emc6w201_probe()
457 data->client = client; in emc6w201_probe()
458 mutex_init(&data->update_lock); in emc6w201_probe()
460 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, in emc6w201_probe()