Lines Matching +full:thermal +full:- +full:diode

1 // SPDX-License-Identifier: GPL-2.0-only
3 * emc1403.c - SMSC Thermal Driver
17 #include <linux/hwmon-sysfs.h>
42 retval = regmap_read(data->regmap, 0x03, &val); in power_state_show()
56 return -EINVAL; in power_state_store()
58 retval = regmap_update_bits(data->regmap, 0x03, BIT(6), in power_state_store()
77 /* Check if thermal chip is SMSC and EMC1403 or EMC1423 */ in emc1403_detect()
81 return -ENODEV; in emc1403_detect()
86 strscpy(info->type, "emc1402", I2C_NAME_SIZE); in emc1403_detect()
89 strscpy(info->type, "emc1403", I2C_NAME_SIZE); in emc1403_detect()
92 strscpy(info->type, "emc1422", I2C_NAME_SIZE); in emc1403_detect()
95 strscpy(info->type, "emc1423", I2C_NAME_SIZE); in emc1403_detect()
98 strscpy(info->type, "emc1404", I2C_NAME_SIZE); in emc1403_detect()
101 strscpy(info->type, "emc1424", I2C_NAME_SIZE); in emc1403_detect()
104 strscpy(info->type, "emc1428", I2C_NAME_SIZE); in emc1403_detect()
107 strscpy(info->type, "emc1438", I2C_NAME_SIZE); in emc1403_detect()
110 strscpy(info->type, "emc1442", I2C_NAME_SIZE); in emc1403_detect()
113 return -ENODEV; in emc1403_detect()
118 return -ENODEV; in emc1403_detect()
126 case 0x00: /* internal diode high byte */ in emc1403_regmap_is_volatile()
127 case 0x01: /* external diode 1 high byte */ in emc1403_regmap_is_volatile()
129 case 0x10: /* external diode 1 low byte */ in emc1403_regmap_is_volatile()
130 case 0x1b: /* external diode fault */ in emc1403_regmap_is_volatile()
131 case 0x23: /* external diode 2 high byte */ in emc1403_regmap_is_volatile()
132 case 0x24: /* external diode 2 low byte */ in emc1403_regmap_is_volatile()
133 case 0x29: /* internal diode low byte */ in emc1403_regmap_is_volatile()
134 case 0x2a: /* externl diode 3 high byte */ in emc1403_regmap_is_volatile()
135 case 0x2b: /* external diode 3 low byte */ in emc1403_regmap_is_volatile()
139 case 0x41: /* external diode 4 high byte */ in emc1403_regmap_is_volatile()
140 case 0x42: /* external diode 4 low byte */ in emc1403_regmap_is_volatile()
141 case 0x43: /* external diode 5 high byte */ in emc1403_regmap_is_volatile()
142 case 0x44: /* external diode 5 low byte */ in emc1403_regmap_is_volatile()
143 case 0x45: /* external diode 6 high byte */ in emc1403_regmap_is_volatile()
144 case 0x46: /* external diode 6 low byte */ in emc1403_regmap_is_volatile()
145 case 0x47: /* external diode 7 high byte */ in emc1403_regmap_is_volatile()
146 case 0x48: /* external diode 7 low byte */ in emc1403_regmap_is_volatile()
222 [temp_min] = -1,
223 [temp_max] = -1,
224 [temp_crit] = -1,
230 [temp_crit] = -1,
236 [temp_crit] = -1,
242 [temp_crit] = -1,
248 [temp_crit] = -1,
254 [temp_crit] = -1,
260 [temp_crit] = -1,
266 [temp_crit] = -1,
279 ret = regmap_read(data->regmap, emc1403_temp_regs[channel][map], &regvalh); in __emc1403_get_temp()
285 ret = regmap_read(data->regmap, reg, &regvall); in __emc1403_get_temp()
290 if (data->chip == emc1428) in __emc1403_get_temp()
303 mutex_lock(&data->mutex); in emc1403_get_temp()
305 mutex_unlock(&data->mutex); in emc1403_get_temp()
316 mutex_lock(&data->mutex); in emc1403_get_hyst()
320 ret = regmap_read(data->regmap, 0x21, &hyst); in emc1403_get_hyst()
326 *val = limit - hyst * 1000; in emc1403_get_hyst()
328 mutex_unlock(&data->mutex); in emc1403_get_hyst()
354 if (data->chip == emc1402) { in emc1403_temp_read()
355 ret = regmap_read(data->regmap, 0x02, &regval); in emc1403_temp_read()
358 *val = !!(regval & BIT(5 - 2 * channel)); in emc1403_temp_read()
360 ret = regmap_read(data->regmap, 0x36, &regval); in emc1403_temp_read()
367 if (data->chip == emc1402) { in emc1403_temp_read()
368 ret = regmap_read(data->regmap, 0x02, &regval); in emc1403_temp_read()
371 *val = !!(regval & BIT(6 - 2 * channel)); in emc1403_temp_read()
373 ret = regmap_read(data->regmap, 0x35, &regval); in emc1403_temp_read()
380 if (data->chip == emc1402) { in emc1403_temp_read()
381 ret = regmap_read(data->regmap, 0x02, &regval); in emc1403_temp_read()
386 ret = regmap_read(data->regmap, 0x37, &regval); in emc1403_temp_read()
393 ret = regmap_read(data->regmap, 0x1b, &regval); in emc1403_temp_read()
399 return -EOPNOTSUPP; in emc1403_temp_read()
409 ret = regmap_read(data->regmap, 0x04, &convrate); in emc1403_get_convrate()
425 return -EOPNOTSUPP; in emc1403_chip_read()
440 return -EOPNOTSUPP; in emc1403_read()
449 if (data->chip == emc1428) in emc1403_set_hyst()
450 val = clamp_val(val, -128000, 127000); in emc1403_set_hyst()
454 mutex_lock(&data->mutex); in emc1403_set_hyst()
459 hyst = limit - val; in emc1403_set_hyst()
460 if (data->chip == emc1428) in emc1403_set_hyst()
464 ret = regmap_write(data->regmap, 0x21, hyst); in emc1403_set_hyst()
466 mutex_unlock(&data->mutex); in emc1403_set_hyst()
481 mutex_lock(&data->mutex); in emc1403_set_temp()
483 if (data->chip == emc1428) in emc1403_set_temp()
484 val = clamp_val(val, -128000, 127875); in emc1403_set_temp()
488 ret = regmap_write(data->regmap, regh, (regval >> 3) & 0xff); in emc1403_set_temp()
491 ret = regmap_write(data->regmap, regl, (regval & 0x07) << 5); in emc1403_set_temp()
493 if (data->chip == emc1428) in emc1403_set_temp()
494 val = clamp_val(val, -128000, 127000); in emc1403_set_temp()
498 ret = regmap_write(data->regmap, regh, regval); in emc1403_set_temp()
501 mutex_unlock(&data->mutex); in emc1403_set_temp()
515 return -EOPNOTSUPP; in emc1403_temp_write()
530 return regmap_write(data->regmap, 0x04, convrate); in emc1403_set_convrate()
539 return -EOPNOTSUPP; in emc1403_chip_write()
554 return -EOPNOTSUPP; in emc1403_write()
562 if (data->chip == emc1402 && channel > 1) in emc1403_temp_is_visible()
564 if (data->chip == emc1403 && channel > 2) in emc1403_temp_is_visible()
566 if (data->chip != emc1428 && channel > 3) in emc1403_temp_is_visible()
688 data = devm_kzalloc(&client->dev, sizeof(struct thermal_data), in emc1403_probe()
691 return -ENOMEM; in emc1403_probe()
693 data->chip = id->driver_data; in emc1403_probe()
694 data->regmap = devm_regmap_init_i2c(client, &emc1403_regmap_config); in emc1403_probe()
695 if (IS_ERR(data->regmap)) in emc1403_probe()
696 return PTR_ERR(data->regmap); in emc1403_probe()
698 mutex_init(&data->mutex); in emc1403_probe()
700 hwmon_dev = devm_hwmon_device_register_with_info(&client->dev, in emc1403_probe()
701 client->name, data, in emc1403_probe()
725 MODULE_DESCRIPTION("emc1403 Thermal Driver");