Lines Matching +full:pull +full:- +full:ups

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2000 Chen-Yuan Wu <gwu@esoft.com>
6 * Copyright (C) 2003-2009 Jean Delvare <jdelvare@suse.de>
19 * only in that it has "open-drain VID inputs while the ADM1025 has
20 * on-chip 100k pull-ups on the VID inputs". It doesn't make any
41 #include <linux/hwmon-sysfs.h>
42 #include <linux/hwmon-vid.h>
76 * The ADM1025 uses signed 8-bit values for temperatures.
87 #define TEMP_TO_REG(val) ((val) <= -127500 ? -128 : \
89 (((val) < 0 ? (val) - 500 : \
117 struct i2c_client *client = data->client; in adm1025_update_device()
119 mutex_lock(&data->update_lock); in adm1025_update_device()
121 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { in adm1025_update_device()
124 dev_dbg(&client->dev, "Updating data.\n"); in adm1025_update_device()
126 data->in[i] = i2c_smbus_read_byte_data(client, in adm1025_update_device()
128 data->in_min[i] = i2c_smbus_read_byte_data(client, in adm1025_update_device()
130 data->in_max[i] = i2c_smbus_read_byte_data(client, in adm1025_update_device()
134 data->temp[i] = i2c_smbus_read_byte_data(client, in adm1025_update_device()
136 data->temp_min[i] = i2c_smbus_read_byte_data(client, in adm1025_update_device()
138 data->temp_max[i] = i2c_smbus_read_byte_data(client, in adm1025_update_device()
141 data->alarms = i2c_smbus_read_byte_data(client, in adm1025_update_device()
145 data->vid = (i2c_smbus_read_byte_data(client, in adm1025_update_device()
150 data->last_updated = jiffies; in adm1025_update_device()
151 data->valid = true; in adm1025_update_device()
154 mutex_unlock(&data->update_lock); in adm1025_update_device()
166 int index = to_sensor_dev_attr(attr)->index; in in_show()
168 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[index], in in_show()
175 int index = to_sensor_dev_attr(attr)->index; in in_min_show()
177 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[index], in in_min_show()
184 int index = to_sensor_dev_attr(attr)->index; in in_max_show()
186 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[index], in in_max_show()
193 int index = to_sensor_dev_attr(attr)->index; in temp_show()
195 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[index])); in temp_show()
201 int index = to_sensor_dev_attr(attr)->index; in temp_min_show()
203 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[index])); in temp_min_show()
209 int index = to_sensor_dev_attr(attr)->index; in temp_max_show()
211 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[index])); in temp_max_show()
217 int index = to_sensor_dev_attr(attr)->index; in in_min_store()
219 struct i2c_client *client = data->client; in in_min_store()
227 mutex_lock(&data->update_lock); in in_min_store()
228 data->in_min[index] = IN_TO_REG(val, in_scale[index]); in in_min_store()
230 data->in_min[index]); in in_min_store()
231 mutex_unlock(&data->update_lock); in in_min_store()
238 int index = to_sensor_dev_attr(attr)->index; in in_max_store()
240 struct i2c_client *client = data->client; in in_max_store()
248 mutex_lock(&data->update_lock); in in_max_store()
249 data->in_max[index] = IN_TO_REG(val, in_scale[index]); in in_max_store()
251 data->in_max[index]); in in_max_store()
252 mutex_unlock(&data->update_lock); in in_max_store()
279 int index = to_sensor_dev_attr(attr)->index; in temp_min_store()
281 struct i2c_client *client = data->client; in temp_min_store()
289 mutex_lock(&data->update_lock); in temp_min_store()
290 data->temp_min[index] = TEMP_TO_REG(val); in temp_min_store()
292 data->temp_min[index]); in temp_min_store()
293 mutex_unlock(&data->update_lock); in temp_min_store()
301 int index = to_sensor_dev_attr(attr)->index; in temp_max_store()
303 struct i2c_client *client = data->client; in temp_max_store()
311 mutex_lock(&data->update_lock); in temp_max_store()
312 data->temp_max[index] = TEMP_TO_REG(val); in temp_max_store()
314 data->temp_max[index]); in temp_max_store()
315 mutex_unlock(&data->update_lock); in temp_max_store()
330 return sprintf(buf, "%u\n", data->alarms); in alarms_show()
337 int bitnr = to_sensor_dev_attr(attr)->index; in alarm_show()
339 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); in alarm_show()
355 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); in cpu0_vid_show()
363 return sprintf(buf, "%u\n", data->vrm); in vrm_show()
377 return -EINVAL; in vrm_store()
379 data->vrm = val; in vrm_store()
440 /* Return 0 if detection is successful, -ENODEV otherwise */
444 struct i2c_adapter *adapter = client->adapter; in adm1025_detect()
449 return -ENODEV; in adm1025_detect()
455 dev_dbg(&adapter->dev, "ADM1025 detection failed at 0x%02x\n", in adm1025_detect()
456 client->addr); in adm1025_detect()
457 return -ENODEV; in adm1025_detect()
463 return -ENODEV; in adm1025_detect()
468 else if (man_id == 0xA1 && client->addr != 0x2E) in adm1025_detect()
471 return -ENODEV; in adm1025_detect()
473 strscpy(info->type, name, I2C_NAME_SIZE); in adm1025_detect()
484 data->vrm = vid_which_vrm(); in adm1025_init_client()
522 struct device *dev = &client->dev; in adm1025_probe()
529 return -ENOMEM; in adm1025_probe()
532 data->client = client; in adm1025_probe()
533 mutex_init(&data->update_lock); in adm1025_probe()
539 data->groups[0] = &adm1025_group; in adm1025_probe()
543 data->groups[1] = &adm1025_group_in4; in adm1025_probe()
545 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, in adm1025_probe()
546 data, data->groups); in adm1025_probe()