Lines Matching +full:tsens +full:- +full:v1

1 // SPDX-License-Identifier: GPL-2.0
11 #include <linux/nvmem-consumer.h>
22 #include "tsens.h"
25 * struct tsens_irq_data - IRQ status and temperature violations
80 if (priv->num_sensors > MAX_SENSORS) in tsens_read_calibration()
81 return -EINVAL; in tsens_read_calibration()
87 ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &mode); in tsens_read_calibration()
88 if (ret == -ENOENT) in tsens_read_calibration()
89 dev_warn(priv->dev, "Please migrate to separate nvmem cells for calibration data\n"); in tsens_read_calibration()
93 dev_dbg(priv->dev, "calibration mode is %d\n", mode); in tsens_read_calibration()
99 ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &base1); in tsens_read_calibration()
107 ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &base2); in tsens_read_calibration()
111 for (i = 0; i < priv->num_sensors; i++) { in tsens_read_calibration()
112 ret = snprintf(name, sizeof(name), "s%d_p1%s", priv->sensor[i].hw_id, in tsens_read_calibration()
117 ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &p1[i]); in tsens_read_calibration()
121 ret = snprintf(name, sizeof(name), "s%d_p2%s", priv->sensor[i].hw_id, in tsens_read_calibration()
126 ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &p2[i]); in tsens_read_calibration()
133 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration()
138 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration()
143 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration()
147 dev_dbg(priv->dev, "calibrationless mode\n"); in tsens_read_calibration()
148 for (i = 0; i < priv->num_sensors; i++) { in tsens_read_calibration()
157 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration()
158 p2[i] += priv->sensor[i].p2_calib_offset; in tsens_read_calibration()
161 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration()
162 p1[i] += priv->sensor[i].p1_calib_offset; in tsens_read_calibration()
191 u32 *data = cell->blob ? data1 : data0; in tsens_read_cell()
193 if (cell->shift + len <= 32) { in tsens_read_cell()
194 val = data[cell->idx] >> cell->shift; in tsens_read_cell()
196 u8 part = 32 - cell->shift; in tsens_read_cell()
198 val = data[cell->idx] >> cell->shift; in tsens_read_cell()
199 val |= data[cell->idx + 1] << part; in tsens_read_cell()
202 return val & ((1 << len) - 1); in tsens_read_cell()
214 mode = tsens_read_cell(&format->mode, 2, cdata0, cdata1); in tsens_read_calibration_legacy()
215 invalid = tsens_read_cell(&format->invalid, 1, cdata0, cdata1); in tsens_read_calibration_legacy()
218 dev_dbg(priv->dev, "calibration mode is %d\n", mode); in tsens_read_calibration_legacy()
220 base1 = tsens_read_cell(&format->base[0], format->base_len, cdata0, cdata1); in tsens_read_calibration_legacy()
221 base2 = tsens_read_cell(&format->base[1], format->base_len, cdata0, cdata1); in tsens_read_calibration_legacy()
223 for (i = 0; i < priv->num_sensors; i++) { in tsens_read_calibration_legacy()
224 p1[i] = tsens_read_cell(&format->sp[i][0], format->sp_len, cdata0, cdata1); in tsens_read_calibration_legacy()
225 p2[i] = tsens_read_cell(&format->sp[i][1], format->sp_len, cdata0, cdata1); in tsens_read_calibration_legacy()
230 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration_legacy()
231 p1[i] = p1[i] + (base1 << format->base_shift); in tsens_read_calibration_legacy()
234 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration_legacy()
235 p2[i] = (p2[i] + base2) << format->base_shift; in tsens_read_calibration_legacy()
238 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration_legacy()
239 p1[i] = (p1[i] + base1) << format->base_shift; in tsens_read_calibration_legacy()
242 dev_dbg(priv->dev, "calibrationless mode\n"); in tsens_read_calibration_legacy()
243 for (i = 0; i < priv->num_sensors; i++) { in tsens_read_calibration_legacy()
255 * and offset values are derived from tz->tzp->slope and tz->tzp->offset
264 for (i = 0; i < priv->num_sensors; i++) { in compute_intercept_slope()
265 dev_dbg(priv->dev, in compute_intercept_slope()
266 "%s: sensor%d - data_point1:%#x data_point2:%#x\n", in compute_intercept_slope()
269 if (!priv->sensor[i].slope) in compute_intercept_slope()
270 priv->sensor[i].slope = SLOPE_DEFAULT; in compute_intercept_slope()
273 * slope (m) = adc_code2 - adc_code1 (y2 - y1)/ in compute_intercept_slope()
274 * temp_120_degc - temp_30_degc (x2 - x1) in compute_intercept_slope()
276 num = p2[i] - p1[i]; in compute_intercept_slope()
278 den = CAL_DEGC_PT2 - CAL_DEGC_PT1; in compute_intercept_slope()
279 priv->sensor[i].slope = num / den; in compute_intercept_slope()
282 priv->sensor[i].offset = (p1[i] * SLOPE_FACTOR) - in compute_intercept_slope()
284 priv->sensor[i].slope); in compute_intercept_slope()
285 dev_dbg(priv->dev, "%s: offset:%d\n", __func__, in compute_intercept_slope()
286 priv->sensor[i].offset); in compute_intercept_slope()
292 u64 code = div_u64(((u64)degc * s->slope + s->offset), SLOPE_FACTOR); in degc_to_code()
302 num = (adc_code * SLOPE_FACTOR) - s->offset; in code_to_degc()
303 den = s->slope; in code_to_degc()
308 degc = num - (den / 2); in code_to_degc()
318 * tsens_hw_to_mC - Return sign-extended temperature in mCelsius.
330 struct tsens_priv *priv = s->priv; in tsens_hw_to_mC()
335 resolution = priv->fields[LAST_TEMP_0].msb - in tsens_hw_to_mC()
336 priv->fields[LAST_TEMP_0].lsb; in tsens_hw_to_mC()
338 ret = regmap_field_read(priv->rf[field], &temp); in tsens_hw_to_mC()
343 if (priv->feat->adc) in tsens_hw_to_mC()
346 /* deciCelsius -> milliCelsius along with sign extension */ in tsens_hw_to_mC()
351 * tsens_mC_to_hw - Convert temperature to hardware register value
362 struct tsens_priv *priv = s->priv; in tsens_mC_to_hw()
365 if (priv->feat->adc) in tsens_mC_to_hw()
374 return priv->feat->ver_major; in tsens_version()
393 regmap_field_write(priv->rf[index], enable ? 0 : 1); in tsens_set_interrupt_v1()
403 * - clear the mask bit in tsens_set_interrupt_v2()
405 * - Mask further interrupts for this sensor in tsens_set_interrupt_v2()
406 * - Write 1 followed by 0 to clear the interrupt in tsens_set_interrupt_v2()
424 regmap_field_write(priv->rf[index_mask], 0); in tsens_set_interrupt_v2()
426 regmap_field_write(priv->rf[index_mask], 1); in tsens_set_interrupt_v2()
427 regmap_field_write(priv->rf[index_clear], 1); in tsens_set_interrupt_v2()
428 regmap_field_write(priv->rf[index_clear], 0); in tsens_set_interrupt_v2()
433 * tsens_set_interrupt - Set state of an interrupt
434 * @priv: Pointer to tsens controller private data
439 * Call IP-specific function to set state of an interrupt
446 dev_dbg(priv->dev, "[%u] %s: %s -> %s\n", hw_id, __func__, in tsens_set_interrupt()
456 * tsens_threshold_violated - Check if a sensor temperature violated a preset threshold
457 * @priv: Pointer to tsens controller private data
469 ret = regmap_field_read(priv->rf[UPPER_STATUS_0 + hw_id], &d->up_viol); in tsens_threshold_violated()
472 ret = regmap_field_read(priv->rf[LOWER_STATUS_0 + hw_id], &d->low_viol); in tsens_threshold_violated()
476 if (priv->feat->crit_int) { in tsens_threshold_violated()
477 ret = regmap_field_read(priv->rf[CRITICAL_STATUS_0 + hw_id], in tsens_threshold_violated()
478 &d->crit_viol); in tsens_threshold_violated()
483 if (d->up_viol || d->low_viol || d->crit_viol) in tsens_threshold_violated()
495 ret = regmap_field_read(priv->rf[UP_INT_CLEAR_0 + hw_id], &d->up_irq_clear); in tsens_read_irq_state()
498 ret = regmap_field_read(priv->rf[LOW_INT_CLEAR_0 + hw_id], &d->low_irq_clear); in tsens_read_irq_state()
502 ret = regmap_field_read(priv->rf[UP_INT_MASK_0 + hw_id], &d->up_irq_mask); in tsens_read_irq_state()
505 ret = regmap_field_read(priv->rf[LOW_INT_MASK_0 + hw_id], &d->low_irq_mask); in tsens_read_irq_state()
508 ret = regmap_field_read(priv->rf[CRIT_INT_CLEAR_0 + hw_id], in tsens_read_irq_state()
509 &d->crit_irq_clear); in tsens_read_irq_state()
512 ret = regmap_field_read(priv->rf[CRIT_INT_MASK_0 + hw_id], in tsens_read_irq_state()
513 &d->crit_irq_mask); in tsens_read_irq_state()
517 d->crit_thresh = tsens_hw_to_mC(s, CRIT_THRESH_0 + hw_id); in tsens_read_irq_state()
519 /* No mask register on older TSENS */ in tsens_read_irq_state()
520 d->up_irq_mask = 0; in tsens_read_irq_state()
521 d->low_irq_mask = 0; in tsens_read_irq_state()
522 d->crit_irq_clear = 0; in tsens_read_irq_state()
523 d->crit_irq_mask = 0; in tsens_read_irq_state()
524 d->crit_thresh = 0; in tsens_read_irq_state()
527 d->up_thresh = tsens_hw_to_mC(s, UP_THRESH_0 + hw_id); in tsens_read_irq_state()
528 d->low_thresh = tsens_hw_to_mC(s, LOW_THRESH_0 + hw_id); in tsens_read_irq_state()
530 dev_dbg(priv->dev, "[%u] %s%s: status(%u|%u|%u) | clr(%u|%u|%u) | mask(%u|%u|%u)\n", in tsens_read_irq_state()
532 (d->up_viol || d->low_viol || d->crit_viol) ? "(V)" : "", in tsens_read_irq_state()
533 d->low_viol, d->up_viol, d->crit_viol, in tsens_read_irq_state()
534 d->low_irq_clear, d->up_irq_clear, d->crit_irq_clear, in tsens_read_irq_state()
535 d->low_irq_mask, d->up_irq_mask, d->crit_irq_mask); in tsens_read_irq_state()
536 dev_dbg(priv->dev, "[%u] %s%s: thresh: (%d:%d:%d)\n", hw_id, __func__, in tsens_read_irq_state()
537 (d->up_viol || d->low_viol || d->crit_viol) ? "(V)" : "", in tsens_read_irq_state()
538 d->low_thresh, d->up_thresh, d->crit_thresh); in tsens_read_irq_state()
548 /* v1, v0.1 don't have a irq mask register */ in masked_irq()
553 * tsens_critical_irq_thread() - Threaded handler for critical interrupts
555 * @data: tsens controller private data
559 * Clear and then re-enable the interrupt.
561 * The level-triggered interrupt might deassert if the temperature returned to
574 if (priv->feat->has_watchdog) { in tsens_critical_irq_thread()
575 ret = regmap_field_read(priv->rf[WDOG_BARK_STATUS], in tsens_critical_irq_thread()
582 regmap_field_write(priv->rf[WDOG_BARK_CLEAR], 1); in tsens_critical_irq_thread()
583 regmap_field_write(priv->rf[WDOG_BARK_CLEAR], 0); in tsens_critical_irq_thread()
584 ret = regmap_field_read(priv->rf[WDOG_BARK_COUNT], in tsens_critical_irq_thread()
589 dev_dbg(priv->dev, "%s: watchdog count: %d\n", in tsens_critical_irq_thread()
596 for (i = 0; i < priv->num_sensors; i++) { in tsens_critical_irq_thread()
597 const struct tsens_sensor *s = &priv->sensor[i]; in tsens_critical_irq_thread()
598 u32 hw_id = s->hw_id; in tsens_critical_irq_thread()
600 if (!s->tzd) in tsens_critical_irq_thread()
606 dev_err(priv->dev, "[%u] %s: error reading sensor\n", in tsens_critical_irq_thread()
623 * tsens_irq_thread - Threaded interrupt handler for uplow interrupts
625 * @data: tsens controller private data
629 * update the thresholds, else re-enable the interrupts.
631 * The level-triggered interrupt might deassert if the temperature returned to
643 for (i = 0; i < priv->num_sensors; i++) { in tsens_irq_thread()
644 const struct tsens_sensor *s = &priv->sensor[i]; in tsens_irq_thread()
645 u32 hw_id = s->hw_id; in tsens_irq_thread()
647 if (!s->tzd) in tsens_irq_thread()
652 thermal_zone_device_update(s->tzd, THERMAL_EVENT_UNSPECIFIED); in tsens_irq_thread()
668 * tsens_combined_irq_thread() - Threaded interrupt handler for combined interrupts
670 * @data: tsens controller private data
691 struct tsens_priv *priv = s->priv; in tsens_set_trips()
692 struct device *dev = priv->dev; in tsens_set_trips()
696 u32 hw_id = s->hw_id; in tsens_set_trips()
708 cl_high = clamp_val(high, priv->feat->trip_min_temp, priv->feat->trip_max_temp); in tsens_set_trips()
709 cl_low = clamp_val(low, priv->feat->trip_min_temp, priv->feat->trip_max_temp); in tsens_set_trips()
714 spin_lock_irqsave(&priv->ul_lock, flags); in tsens_set_trips()
719 regmap_field_write(priv->rf[LOW_THRESH_0 + hw_id], low_val); in tsens_set_trips()
720 regmap_field_write(priv->rf[UP_THRESH_0 + hw_id], high_val); in tsens_set_trips()
724 spin_unlock_irqrestore(&priv->ul_lock, flags); in tsens_set_trips()
726 dev_dbg(dev, "[%u] %s: (%d:%d)->(%d:%d)\n", in tsens_set_trips()
737 ret = regmap_field_write(priv->rf[INT_EN], val); in tsens_enable_irq()
739 dev_err(priv->dev, "%s: failed to enable interrupts\n", in tsens_enable_irq()
747 regmap_field_write(priv->rf[INT_EN], 0); in tsens_disable_irq()
752 struct tsens_priv *priv = s->priv; in get_temp_tsens_valid()
753 int hw_id = s->hw_id; in get_temp_tsens_valid()
769 ret = regmap_field_read_poll_timeout(priv->rf[valid_idx], valid, in get_temp_tsens_valid()
783 struct tsens_priv *priv = s->priv; in get_temp_common()
784 int hw_id = s->hw_id; in get_temp_common()
791 ret = regmap_field_read(priv->rf[TRDY], &trdy); in get_temp_common()
798 ret = regmap_field_read(priv->rf[LAST_TEMP_0 + hw_id], &last_temp); in get_temp_common()
807 return -ETIMEDOUT; in get_temp_common()
813 struct platform_device *pdev = s->private; in dbg_sensors_show()
818 priv->feat->max_sensors, priv->num_sensors); in dbg_sensors_show()
820 seq_puts(s, " id slope offset\n--------------------------\n"); in dbg_sensors_show()
821 for (i = 0; i < priv->num_sensors; i++) { in dbg_sensors_show()
822 seq_printf(s, "%8d %8d %8d\n", priv->sensor[i].hw_id, in dbg_sensors_show()
823 priv->sensor[i].slope, priv->sensor[i].offset); in dbg_sensors_show()
831 struct platform_device *pdev = s->private; in dbg_version_show()
837 ret = regmap_field_read(priv->rf[VER_MAJOR], &maj_ver); in dbg_version_show()
840 ret = regmap_field_read(priv->rf[VER_MINOR], &min_ver); in dbg_version_show()
843 ret = regmap_field_read(priv->rf[VER_STEP], &step_ver); in dbg_version_show()
848 seq_printf(s, "0.%d.0\n", priv->feat->ver_major); in dbg_version_show()
861 priv->debug_root = debugfs_lookup("tsens", NULL); in tsens_debug_init()
862 if (!priv->debug_root) in tsens_debug_init()
863 priv->debug_root = debugfs_create_dir("tsens", NULL); in tsens_debug_init()
865 /* A directory for each instance of the TSENS IP */ in tsens_debug_init()
866 priv->debug = debugfs_create_dir(dev_name(&pdev->dev), priv->debug_root); in tsens_debug_init()
867 debugfs_create_file("version", 0444, priv->debug, pdev, &dbg_version_fops); in tsens_debug_init()
868 debugfs_create_file("sensors", 0444, priv->debug, pdev, &dbg_sensors_fops); in tsens_debug_init()
891 struct device *dev = priv->dev; in init_common()
896 struct platform_device *op = of_find_device_by_node(priv->dev->of_node); in init_common()
899 return -EINVAL; in init_common()
901 if (op->num_resources > 1) { in init_common()
903 priv->tm_offset = 0; in init_common()
911 priv->srot_map = devm_regmap_init_mmio(dev, srot_base, in init_common()
913 if (IS_ERR(priv->srot_map)) { in init_common()
914 ret = PTR_ERR(priv->srot_map); in init_common()
919 priv->tm_offset = 0x1000; in init_common()
930 priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config); in init_common()
932 struct device *parent = priv->dev->parent; in init_common()
935 priv->tm_map = syscon_node_to_regmap(parent->of_node); in init_common()
938 if (IS_ERR_OR_NULL(priv->tm_map)) { in init_common()
939 if (!priv->tm_map) in init_common()
940 ret = -ENODEV; in init_common()
942 ret = PTR_ERR(priv->tm_map); in init_common()
947 if (!priv->srot_map) in init_common()
948 priv->srot_map = priv->tm_map; in init_common()
952 priv->rf[i] = devm_regmap_field_alloc(dev, priv->srot_map, in init_common()
953 priv->fields[i]); in init_common()
954 if (IS_ERR(priv->rf[i])) { in init_common()
955 ret = PTR_ERR(priv->rf[i]); in init_common()
959 ret = regmap_field_read(priv->rf[VER_MINOR], &ver_minor); in init_common()
964 priv->rf[TSENS_EN] = devm_regmap_field_alloc(dev, priv->srot_map, in init_common()
965 priv->fields[TSENS_EN]); in init_common()
966 if (IS_ERR(priv->rf[TSENS_EN])) { in init_common()
967 ret = PTR_ERR(priv->rf[TSENS_EN]); in init_common()
970 /* in VER_0 TSENS need to be explicitly enabled */ in init_common()
972 regmap_field_write(priv->rf[TSENS_EN], 1); in init_common()
974 ret = regmap_field_read(priv->rf[TSENS_EN], &enabled); in init_common()
979 ret = -ENODEV; in init_common()
983 priv->rf[SENSOR_EN] = devm_regmap_field_alloc(dev, priv->srot_map, in init_common()
984 priv->fields[SENSOR_EN]); in init_common()
985 if (IS_ERR(priv->rf[SENSOR_EN])) { in init_common()
986 ret = PTR_ERR(priv->rf[SENSOR_EN]); in init_common()
989 priv->rf[INT_EN] = devm_regmap_field_alloc(dev, priv->tm_map, in init_common()
990 priv->fields[INT_EN]); in init_common()
991 if (IS_ERR(priv->rf[INT_EN])) { in init_common()
992 ret = PTR_ERR(priv->rf[INT_EN]); in init_common()
996 priv->rf[TSENS_SW_RST] = in init_common()
997 devm_regmap_field_alloc(dev, priv->srot_map, priv->fields[TSENS_SW_RST]); in init_common()
998 if (IS_ERR(priv->rf[TSENS_SW_RST])) { in init_common()
999 ret = PTR_ERR(priv->rf[TSENS_SW_RST]); in init_common()
1003 priv->rf[TRDY] = devm_regmap_field_alloc(dev, priv->tm_map, priv->fields[TRDY]); in init_common()
1004 if (IS_ERR(priv->rf[TRDY])) { in init_common()
1005 ret = PTR_ERR(priv->rf[TRDY]); in init_common()
1011 for (i = 0; i < priv->feat->max_sensors; i++) { in init_common()
1014 priv->rf[idx] = devm_regmap_field_alloc(dev, in init_common()
1015 priv->tm_map, in init_common()
1016 priv->fields[idx]); in init_common()
1017 if (IS_ERR(priv->rf[idx])) { in init_common()
1018 ret = PTR_ERR(priv->rf[idx]); in init_common()
1024 if (priv->feat->crit_int || tsens_version(priv) < VER_0_1) { in init_common()
1027 for (i = 0; i < priv->feat->max_sensors; i++) { in init_common()
1030 priv->rf[idx] = in init_common()
1032 priv->tm_map, in init_common()
1033 priv->fields[idx]); in init_common()
1034 if (IS_ERR(priv->rf[idx])) { in init_common()
1035 ret = PTR_ERR(priv->rf[idx]); in init_common()
1044 priv->feat->has_watchdog = 1; in init_common()
1046 priv->rf[i] = devm_regmap_field_alloc(dev, priv->tm_map, in init_common()
1047 priv->fields[i]); in init_common()
1048 if (IS_ERR(priv->rf[i])) { in init_common()
1049 ret = PTR_ERR(priv->rf[i]); in init_common()
1057 regmap_field_write(priv->rf[WDOG_BARK_MASK], 0); in init_common()
1058 regmap_field_write(priv->rf[CC_MON_MASK], 1); in init_common()
1061 spin_lock_init(&priv->ul_lock); in init_common()
1068 put_device(&op->dev); in init_common()
1075 struct tsens_priv *priv = s->priv; in tsens_get_temp()
1077 return priv->ops->get_temp(s, temp); in tsens_get_temp()
1084 if (priv->ops && priv->ops->suspend) in tsens_suspend()
1085 return priv->ops->suspend(priv); in tsens_suspend()
1094 if (priv->ops && priv->ops->resume) in tsens_resume()
1095 return priv->ops->resume(priv); in tsens_resume()
1104 .compatible = "qcom,ipq8064-tsens",
1107 .compatible = "qcom,ipq8074-tsens",
1110 .compatible = "qcom,mdm9607-tsens",
1113 .compatible = "qcom,msm8226-tsens",
1116 .compatible = "qcom,msm8909-tsens",
1119 .compatible = "qcom,msm8916-tsens",
1122 .compatible = "qcom,msm8937-tsens",
1125 .compatible = "qcom,msm8939-tsens",
1128 .compatible = "qcom,msm8956-tsens",
1131 .compatible = "qcom,msm8960-tsens",
1134 .compatible = "qcom,msm8974-tsens",
1137 .compatible = "qcom,msm8976-tsens",
1140 .compatible = "qcom,msm8996-tsens",
1143 .compatible = "qcom,tsens-v1",
1146 .compatible = "qcom,tsens-v2",
1164 pdev = of_find_device_by_node(priv->dev->of_node); in tsens_register_irq()
1166 return -ENODEV; in tsens_register_irq()
1172 if (irq == -ENXIO) in tsens_register_irq()
1177 ret = devm_request_threaded_irq(&pdev->dev, irq, in tsens_register_irq()
1180 dev_name(&pdev->dev), in tsens_register_irq()
1183 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, in tsens_register_irq()
1185 dev_name(&pdev->dev), in tsens_register_irq()
1189 dev_err(&pdev->dev, "%s: failed to get irq\n", in tsens_register_irq()
1195 put_device(&pdev->dev); in tsens_register_irq()
1204 for (i = 0; i < priv->num_sensors; i++) { in tsens_register()
1205 priv->sensor[i].priv = priv; in tsens_register()
1206 tzd = devm_thermal_of_zone_register(priv->dev, priv->sensor[i].hw_id, in tsens_register()
1207 &priv->sensor[i], in tsens_register()
1211 priv->sensor[i].tzd = tzd; in tsens_register()
1212 if (priv->ops->enable) in tsens_register()
1213 priv->ops->enable(priv, i); in tsens_register()
1215 devm_thermal_add_hwmon_sysfs(priv->dev, tzd); in tsens_register()
1220 * - CRIT_THRESH_0 for MAX THRESH hardcoded to 120°C in tsens_register()
1221 * - CRIT_THRESH_1 for MIN THRESH hardcoded to 0°C in tsens_register()
1224 regmap_field_write(priv->rf[CRIT_THRESH_0], in tsens_register()
1225 tsens_mC_to_hw(priv->sensor, 120000)); in tsens_register()
1227 regmap_field_write(priv->rf[CRIT_THRESH_1], in tsens_register()
1228 tsens_mC_to_hw(priv->sensor, 0)); in tsens_register()
1231 if (priv->feat->combo_int) { in tsens_register()
1239 if (priv->feat->crit_int) in tsens_register()
1257 if (pdev->dev.of_node) in tsens_probe()
1258 dev = &pdev->dev; in tsens_probe()
1260 dev = pdev->dev.parent; in tsens_probe()
1262 np = dev->of_node; in tsens_probe()
1266 data = id->data; in tsens_probe()
1270 num_sensors = data->num_sensors; in tsens_probe()
1277 return -EINVAL; in tsens_probe()
1284 return -ENOMEM; in tsens_probe()
1286 priv->dev = dev; in tsens_probe()
1287 priv->num_sensors = num_sensors; in tsens_probe()
1288 priv->ops = data->ops; in tsens_probe()
1289 for (i = 0; i < priv->num_sensors; i++) { in tsens_probe()
1290 if (data->hw_ids) in tsens_probe()
1291 priv->sensor[i].hw_id = data->hw_ids[i]; in tsens_probe()
1293 priv->sensor[i].hw_id = i; in tsens_probe()
1295 priv->feat = data->feat; in tsens_probe()
1296 priv->fields = data->fields; in tsens_probe()
1300 if (!priv->ops || !priv->ops->init || !priv->ops->get_temp) in tsens_probe()
1301 return -EINVAL; in tsens_probe()
1303 ret = priv->ops->init(priv); in tsens_probe()
1309 if (priv->ops->calibrate) { in tsens_probe()
1310 ret = priv->ops->calibrate(priv); in tsens_probe()
1312 if (ret != -EPROBE_DEFER) in tsens_probe()
1329 debugfs_remove_recursive(priv->debug_root); in tsens_remove()
1331 if (priv->ops->disable) in tsens_remove()
1332 priv->ops->disable(priv); in tsens_remove()
1341 .name = "qcom-tsens",
1350 MODULE_ALIAS("platform:qcom-tsens");