Lines Matching +full:ambient +full:- +full:celsius

1 // SPDX-License-Identifier: GPL-2.0
12 #include <linux/hwmon-sysfs.h>
65 #define VOLTAGE_MIN -300
76 #define CURRENT_MIN -30000
85 #define POWER_MIN -450000000
95 /* in millidegress Celsius */
97 #define TEMP_MIN -40000
107 #define LTC2947_ALERTS_SIZE (LTC2947_REG_STATVDVCC - LTC2947_REG_STATUS)
125 * complete sequence select_page->read/write needs to be protected.
138 ret = regmap_bulk_read(st->map, reg, &__val, 2); in __ltc2947_val_read16()
153 ret = regmap_bulk_read(st->map, reg, &__val, 3); in __ltc2947_val_read24()
168 ret = regmap_bulk_read(st->map, reg, &__val, 6); in __ltc2947_val_read64()
183 mutex_lock(&st->lock); in ltc2947_val_read()
185 ret = regmap_write(st->map, LTC2947_REG_PAGE_CTRL, page); in ltc2947_val_read()
187 mutex_unlock(&st->lock); in ltc2947_val_read()
191 dev_dbg(st->dev, "Read val, reg:%02X, p:%d sz:%zu\n", reg, page, in ltc2947_val_read()
205 ret = -EINVAL; in ltc2947_val_read()
209 mutex_unlock(&st->lock); in ltc2947_val_read()
214 *val = sign_extend64(__val, (8 * size) - 1); in ltc2947_val_read()
216 dev_dbg(st->dev, "Got s:%lld, u:%016llX\n", *val, __val); in ltc2947_val_read()
227 return regmap_bulk_write(st->map, reg, &__val, 6); in __ltc2947_val_write64()
236 return regmap_bulk_write(st->map, reg, &__val, 2); in __ltc2947_val_write16()
244 mutex_lock(&st->lock); in ltc2947_val_write()
246 ret = regmap_write(st->map, LTC2947_REG_PAGE_CTRL, page); in ltc2947_val_write()
248 mutex_unlock(&st->lock); in ltc2947_val_write()
252 dev_dbg(st->dev, "Write val, r:%02X, p:%d, sz:%zu, val:%016llX\n", in ltc2947_val_write()
263 ret = -EINVAL; in ltc2947_val_write()
267 mutex_unlock(&st->lock); in ltc2947_val_write()
290 u8 offset = reg - LTC2947_REG_STATUS; in ltc2947_alarm_read()
297 mutex_lock(&st->lock); in ltc2947_alarm_read()
299 ret = regmap_write(st->map, LTC2947_REG_PAGE_CTRL, LTC2947_PAGE0); in ltc2947_alarm_read()
303 dev_dbg(st->dev, "Read alarm, reg:%02X, mask:%02X\n", reg, mask); in ltc2947_alarm_read()
307 * multi-byte transaction. in ltc2947_alarm_read()
309 ret = regmap_bulk_read(st->map, LTC2947_REG_STATUS, alarms, in ltc2947_alarm_read()
317 mutex_unlock(&st->lock); in ltc2947_alarm_read()
329 ret = ltc2947_val_read(st, attr->index, LTC2947_PAGE0, 6, &val); in ltc2947_show_value()
333 /* value in microJoule. st->lsb_energy was multiplied by 10E9 */ in ltc2947_show_value()
334 val = div_s64(val * st->lsb_energy, 1000); in ltc2947_show_value()
392 return -ENOTSUPP; in ltc2947_read_temp()
440 return -ENOTSUPP; in ltc2947_read_power()
487 return -ENOTSUPP; in ltc2947_read_curr()
507 dev_err(st->dev, "Invalid chan%d for voltage", channel); in ltc2947_read_in()
508 return -EINVAL; in ltc2947_read_in()
579 return -ENOTSUPP; in ltc2947_read_in()
603 return -ENOTSUPP; in ltc2947_read()
613 dev_err(st->dev, "Invalid chan%d for temperature", channel); in ltc2947_write_temp()
614 return -EINVAL; in ltc2947_write_temp()
620 return -EINVAL; in ltc2947_write_temp()
626 if (!st->gpio_out) in ltc2947_write_temp()
627 return -ENOTSUPP; in ltc2947_write_temp()
632 DIV_ROUND_CLOSEST(val - 550, 204)); in ltc2947_write_temp()
637 DIV_ROUND_CLOSEST(val - 550, 204)); in ltc2947_write_temp()
641 if (!st->gpio_out) in ltc2947_write_temp()
642 return -ENOTSUPP; in ltc2947_write_temp()
647 DIV_ROUND_CLOSEST(val - 550, 204)); in ltc2947_write_temp()
652 DIV_ROUND_CLOSEST(val - 550, 204)); in ltc2947_write_temp()
654 return -ENOTSUPP; in ltc2947_write_temp()
666 return -EINVAL; in ltc2947_write_power()
680 return -ENOTSUPP; in ltc2947_write_power()
692 return -EINVAL; in ltc2947_write_curr()
706 return -ENOTSUPP; in ltc2947_write_curr()
716 dev_err(st->dev, "Invalid chan%d for voltage", channel); in ltc2947_write_in()
717 return -EINVAL; in ltc2947_write_in()
723 return -EINVAL; in ltc2947_write_in()
756 return -ENOTSUPP; in ltc2947_write_in()
774 return -ENOTSUPP; in ltc2947_write()
787 *str = "VP-VM"; in ltc2947_read_labels()
790 *str = "IP-IM"; in ltc2947_read_labels()
796 *str = "Ambient"; in ltc2947_read_labels()
802 return -ENOTSUPP; in ltc2947_read_labels()
974 ret = regmap_read(st->map, LTC2947_REG_STATUS, &dummy); in ltc2947_setup()
992 extclk = devm_clk_get(st->dev, NULL); in ltc2947_setup()
1001 dev_err(st->dev, "Invalid rate:%lu for external clock", in ltc2947_setup()
1003 return -EINVAL; in ltc2947_setup()
1010 ret = devm_add_action_or_reset(st->dev, ltc2947_clk_disable, in ltc2947_setup()
1034 ret = regmap_write(st->map, LTC2947_REG_TBCTL, tbctl); in ltc2947_setup()
1043 st->lsb_energy = DIV_ROUND_CLOSEST_ULL(aux, rate_hz); in ltc2947_setup()
1045 /* 19.89E-6 * 10E9 */ in ltc2947_setup()
1046 st->lsb_energy = 19890; in ltc2947_setup()
1048 ret = of_property_read_u32_array(st->dev->of_node, in ltc2947_setup()
1049 "adi,accumulator-ctl-pol", accum, in ltc2947_setup()
1055 ret = regmap_write(st->map, LTC2947_REG_ACCUM_POL, accum_reg); in ltc2947_setup()
1059 ret = of_property_read_u32(st->dev->of_node, in ltc2947_setup()
1060 "adi,accumulation-deadband-microamp", in ltc2947_setup()
1064 ret = regmap_write(st->map, LTC2947_REG_ACCUM_DEADBAND, in ltc2947_setup()
1070 ret = of_property_read_u32(st->dev->of_node, "adi,gpio-out-pol", &pol); in ltc2947_setup()
1076 st->gpio_out = true; in ltc2947_setup()
1077 ret = regmap_write(st->map, LTC2947_REG_GPIOSTATCTL, gpio_ctl); in ltc2947_setup()
1081 ret = of_property_read_u32_array(st->dev->of_node, "adi,gpio-in-accum", in ltc2947_setup()
1091 if (st->gpio_out) { in ltc2947_setup()
1092 dev_err(st->dev, in ltc2947_setup()
1094 return -EINVAL; in ltc2947_setup()
1097 ret = regmap_write(st->map, LTC2947_REG_GPIO_ACCUM, accum_val); in ltc2947_setup()
1103 return regmap_update_bits(st->map, LTC2947_REG_CTRL, in ltc2947_setup()
1116 return -ENOMEM; in ltc2947_core_probe()
1118 st->map = map; in ltc2947_core_probe()
1119 st->dev = dev; in ltc2947_core_probe()
1121 mutex_init(&st->lock); in ltc2947_core_probe()
1141 ret = regmap_read(st->map, LTC2947_REG_CTRL, &ctrl); in ltc2947_resume()
1149 ret = regmap_read(st->map, LTC2947_REG_CTRL, &ctrl); in ltc2947_resume()
1154 dev_err(st->dev, "Device failed to wake up, ctl:%02X\n", ctrl); in ltc2947_resume()
1155 return -ETIMEDOUT; in ltc2947_resume()
1159 return regmap_update_bits(st->map, LTC2947_REG_CTRL, in ltc2947_resume()
1167 return regmap_update_bits(st->map, LTC2947_REG_CTRL, in ltc2947_suspend()