Lines Matching +full:alarm +full:- +full:pol
1 // SPDX-License-Identifier: GPL-2.0
3 * max31827.c - Support for Maxim Low-Power Switch
123 * Before the Temperature Threshold Alarm, Alarm Hysteresis Threshold in shutdown_write()
130 mutex_lock(&st->lock); in shutdown_write()
132 if (!st->enable) { in shutdown_write()
134 ret = regmap_write(st->regmap, reg, val); in shutdown_write()
136 ret = regmap_update_bits(st->regmap, reg, mask, val); in shutdown_write()
140 ret = regmap_read(st->regmap, MAX31827_CONFIGURATION_REG, &cfg); in shutdown_write()
147 ret = regmap_write(st->regmap, MAX31827_CONFIGURATION_REG, cfg); in shutdown_write()
152 ret = regmap_write(st->regmap, reg, val); in shutdown_write()
154 ret = regmap_update_bits(st->regmap, reg, mask, val); in shutdown_write()
159 ret = regmap_update_bits(st->regmap, MAX31827_CONFIGURATION_REG, in shutdown_write()
164 mutex_unlock(&st->lock); in shutdown_write()
214 ret = regmap_read(st->regmap, in max31827_read()
226 mutex_lock(&st->lock); in max31827_read()
228 if (!st->enable) { in max31827_read()
235 ret = regmap_update_bits(st->regmap, in max31827_read()
240 mutex_unlock(&st->lock); in max31827_read()
243 msleep(max31827_conv_times[st->resolution]); in max31827_read()
247 * For 12-bit resolution the conversion time is 140 ms, in max31827_read()
251 if (max31827_resolutions[st->resolution] == 12 && in max31827_read()
252 st->update_interval == 125) in max31827_read()
255 ret = regmap_read(st->regmap, MAX31827_T_REG, &uval); in max31827_read()
257 mutex_unlock(&st->lock); in max31827_read()
266 ret = regmap_read(st->regmap, MAX31827_TH_REG, &uval); in max31827_read()
273 ret = regmap_read(st->regmap, MAX31827_TH_HYST_REG, in max31827_read()
281 ret = regmap_read(st->regmap, in max31827_read()
290 ret = regmap_read(st->regmap, MAX31827_TL_REG, &uval); in max31827_read()
297 ret = regmap_read(st->regmap, MAX31827_TL_HYST_REG, in max31827_read()
305 ret = regmap_read(st->regmap, in max31827_read()
314 ret = -EOPNOTSUPP; in max31827_read()
322 ret = regmap_read(st->regmap, in max31827_read()
334 ret = -EOPNOTSUPP; in max31827_read()
353 return -EINVAL; in max31827_write()
355 mutex_lock(&st->lock); in max31827_write()
359 * the alarm values are changed. in max31827_write()
362 st->enable = val; in max31827_write()
364 ret = regmap_update_bits(st->regmap, in max31827_write()
370 mutex_unlock(&st->lock); in max31827_write()
387 return -EOPNOTSUPP; in max31827_write()
393 if (!st->enable) in max31827_write()
394 return -EINVAL; in max31827_write()
407 res = ARRAY_SIZE(max31827_conversions) - 1; in max31827_write()
412 ret = regmap_update_bits(st->regmap, in max31827_write()
419 st->update_interval = val; in max31827_write()
423 return regmap_update_bits(st->regmap, MAX31827_CONFIGURATION_REG, in max31827_write()
427 return -EOPNOTSUPP; in max31827_write()
430 return -EOPNOTSUPP; in max31827_write()
442 ret = regmap_read(st->regmap, MAX31827_CONFIGURATION_REG, &val); in temp1_resolution_show()
475 idx = ARRAY_SIZE(max31827_resolutions) - 1; in temp1_resolution_store()
477 st->resolution = idx; in temp1_resolution_store()
515 st->enable = true; in max31827_init_client()
520 prop = fwnode_property_read_bool(fwnode, "adi,comp-int"); in max31827_init_client()
523 prop = fwnode_property_read_bool(fwnode, "adi,timeout-enable"); in max31827_init_client()
528 if (fwnode_property_present(fwnode, "adi,alarm-pol")) { in max31827_init_client()
529 ret = fwnode_property_read_u32(fwnode, "adi,alarm-pol", &data); in max31827_init_client()
549 return -EOPNOTSUPP; in max31827_init_client()
553 if (fwnode_property_present(fwnode, "adi,fault-q")) { in max31827_init_client()
554 ret = fwnode_property_read_u32(fwnode, "adi,fault-q", &data); in max31827_init_client()
565 dev_err(dev, "Invalid data in adi,fault-q\n"); in max31827_init_client()
566 return -EINVAL; in max31827_init_client()
585 return -EOPNOTSUPP; in max31827_init_client()
589 return regmap_write(st->regmap, MAX31827_CONFIGURATION_REG, res); in max31827_init_client()
614 struct device *dev = &client->dev; in max31827_probe()
619 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) in max31827_probe()
620 return -EOPNOTSUPP; in max31827_probe()
624 return -ENOMEM; in max31827_probe()
626 mutex_init(&st->lock); in max31827_probe()
628 st->regmap = devm_regmap_init_i2c(client, &max31827_regmap); in max31827_probe()
629 if (IS_ERR(st->regmap)) in max31827_probe()
630 return dev_err_probe(dev, PTR_ERR(st->regmap), in max31827_probe()
641 hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, st, in max31827_probe()
676 MODULE_DESCRIPTION("Maxim MAX31827 low-power temperature switch driver");