Lines Matching +full:combined +full:- +full:sensors
1 // SPDX-License-Identifier: GPL-2.0
11 #include <linux/nvmem-consumer.h>
26 * struct tsens_irq_data - IRQ status and temperature violations
81 if (priv->num_sensors > MAX_SENSORS) in tsens_read_calibration()
82 return -EINVAL; in tsens_read_calibration()
88 ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &mode); in tsens_read_calibration()
89 if (ret == -ENOENT) in tsens_read_calibration()
90 dev_warn(priv->dev, "Please migrate to separate nvmem cells for calibration data\n"); in tsens_read_calibration()
94 dev_dbg(priv->dev, "calibration mode is %d\n", mode); in tsens_read_calibration()
100 ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &base1); in tsens_read_calibration()
108 ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &base2); in tsens_read_calibration()
112 for (i = 0; i < priv->num_sensors; i++) { in tsens_read_calibration()
113 ret = snprintf(name, sizeof(name), "s%d_p1%s", priv->sensor[i].hw_id, in tsens_read_calibration()
118 ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &p1[i]); in tsens_read_calibration()
122 ret = snprintf(name, sizeof(name), "s%d_p2%s", priv->sensor[i].hw_id, in tsens_read_calibration()
127 ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &p2[i]); in tsens_read_calibration()
134 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration()
139 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration()
144 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration()
148 dev_dbg(priv->dev, "calibrationless mode\n"); in tsens_read_calibration()
149 for (i = 0; i < priv->num_sensors; i++) { in tsens_read_calibration()
158 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration()
159 p2[i] += priv->sensor[i].p2_calib_offset; in tsens_read_calibration()
162 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration()
163 p1[i] += priv->sensor[i].p1_calib_offset; in tsens_read_calibration()
192 u32 *data = cell->blob ? data1 : data0; in tsens_read_cell()
194 if (cell->shift + len <= 32) { in tsens_read_cell()
195 val = data[cell->idx] >> cell->shift; in tsens_read_cell()
197 u8 part = 32 - cell->shift; in tsens_read_cell()
199 val = data[cell->idx] >> cell->shift; in tsens_read_cell()
200 val |= data[cell->idx + 1] << part; in tsens_read_cell()
203 return val & ((1 << len) - 1); in tsens_read_cell()
215 mode = tsens_read_cell(&format->mode, 2, cdata0, cdata1); in tsens_read_calibration_legacy()
216 invalid = tsens_read_cell(&format->invalid, 1, cdata0, cdata1); in tsens_read_calibration_legacy()
219 dev_dbg(priv->dev, "calibration mode is %d\n", mode); in tsens_read_calibration_legacy()
221 base1 = tsens_read_cell(&format->base[0], format->base_len, cdata0, cdata1); in tsens_read_calibration_legacy()
222 base2 = tsens_read_cell(&format->base[1], format->base_len, cdata0, cdata1); in tsens_read_calibration_legacy()
224 for (i = 0; i < priv->num_sensors; i++) { in tsens_read_calibration_legacy()
225 p1[i] = tsens_read_cell(&format->sp[i][0], format->sp_len, cdata0, cdata1); in tsens_read_calibration_legacy()
226 p2[i] = tsens_read_cell(&format->sp[i][1], format->sp_len, cdata0, cdata1); in tsens_read_calibration_legacy()
231 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration_legacy()
232 p1[i] = p1[i] + (base1 << format->base_shift); in tsens_read_calibration_legacy()
235 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration_legacy()
236 p2[i] = (p2[i] + base2) << format->base_shift; in tsens_read_calibration_legacy()
239 for (i = 0; i < priv->num_sensors; i++) in tsens_read_calibration_legacy()
240 p1[i] = (p1[i] + base1) << format->base_shift; in tsens_read_calibration_legacy()
243 dev_dbg(priv->dev, "calibrationless mode\n"); in tsens_read_calibration_legacy()
244 for (i = 0; i < priv->num_sensors; i++) { in tsens_read_calibration_legacy()
256 * and offset values are derived from tz->tzp->slope and tz->tzp->offset
265 for (i = 0; i < priv->num_sensors; i++) { in compute_intercept_slope()
266 dev_dbg(priv->dev, in compute_intercept_slope()
267 "%s: sensor%d - data_point1:%#x data_point2:%#x\n", in compute_intercept_slope()
270 if (!priv->sensor[i].slope) in compute_intercept_slope()
271 priv->sensor[i].slope = SLOPE_DEFAULT; in compute_intercept_slope()
274 * slope (m) = adc_code2 - adc_code1 (y2 - y1)/ in compute_intercept_slope()
275 * temp_120_degc - temp_30_degc (x2 - x1) in compute_intercept_slope()
277 num = p2[i] - p1[i]; in compute_intercept_slope()
279 den = CAL_DEGC_PT2 - CAL_DEGC_PT1; in compute_intercept_slope()
280 priv->sensor[i].slope = num / den; in compute_intercept_slope()
283 priv->sensor[i].offset = (p1[i] * SLOPE_FACTOR) - in compute_intercept_slope()
285 priv->sensor[i].slope); in compute_intercept_slope()
286 dev_dbg(priv->dev, "%s: offset:%d\n", __func__, in compute_intercept_slope()
287 priv->sensor[i].offset); in compute_intercept_slope()
293 u64 code = div_u64(((u64)degc * s->slope + s->offset), SLOPE_FACTOR); in degc_to_code()
303 num = (adc_code * SLOPE_FACTOR) - s->offset; in code_to_degc()
304 den = s->slope; in code_to_degc()
309 degc = num - (den / 2); in code_to_degc()
319 * tsens_hw_to_mC - Return sign-extended temperature in mCelsius.
331 struct tsens_priv *priv = s->priv; in tsens_hw_to_mC()
336 resolution = priv->fields[LAST_TEMP_0].msb - in tsens_hw_to_mC()
337 priv->fields[LAST_TEMP_0].lsb; in tsens_hw_to_mC()
339 ret = regmap_field_read(priv->rf[field], &temp); in tsens_hw_to_mC()
344 if (priv->feat->adc) in tsens_hw_to_mC()
347 /* deciCelsius -> milliCelsius along with sign extension */ in tsens_hw_to_mC()
352 * tsens_mC_to_hw - Convert temperature to hardware register value
363 struct tsens_priv *priv = s->priv; in tsens_mC_to_hw()
366 if (priv->feat->adc) in tsens_mC_to_hw()
375 return priv->feat->ver_major; in tsens_version()
394 regmap_field_write(priv->rf[index], enable ? 0 : 1); in tsens_set_interrupt_v1()
404 * - clear the mask bit in tsens_set_interrupt_v2()
406 * - Mask further interrupts for this sensor in tsens_set_interrupt_v2()
407 * - Write 1 followed by 0 to clear the interrupt in tsens_set_interrupt_v2()
425 regmap_field_write(priv->rf[index_mask], 0); in tsens_set_interrupt_v2()
427 regmap_field_write(priv->rf[index_mask], 1); in tsens_set_interrupt_v2()
428 regmap_field_write(priv->rf[index_clear], 1); in tsens_set_interrupt_v2()
429 regmap_field_write(priv->rf[index_clear], 0); in tsens_set_interrupt_v2()
434 * tsens_set_interrupt - Set state of an interrupt
440 * Call IP-specific function to set state of an interrupt
447 dev_dbg(priv->dev, "[%u] %s: %s -> %s\n", hw_id, __func__, in tsens_set_interrupt()
457 * tsens_threshold_violated - Check if a sensor temperature violated a preset threshold
470 ret = regmap_field_read(priv->rf[UPPER_STATUS_0 + hw_id], &d->up_viol); in tsens_threshold_violated()
473 ret = regmap_field_read(priv->rf[LOWER_STATUS_0 + hw_id], &d->low_viol); in tsens_threshold_violated()
477 if (priv->feat->crit_int) { in tsens_threshold_violated()
478 ret = regmap_field_read(priv->rf[CRITICAL_STATUS_0 + hw_id], in tsens_threshold_violated()
479 &d->crit_viol); in tsens_threshold_violated()
484 if (d->up_viol || d->low_viol || d->crit_viol) in tsens_threshold_violated()
496 ret = regmap_field_read(priv->rf[UP_INT_CLEAR_0 + hw_id], &d->up_irq_clear); in tsens_read_irq_state()
499 ret = regmap_field_read(priv->rf[LOW_INT_CLEAR_0 + hw_id], &d->low_irq_clear); in tsens_read_irq_state()
503 ret = regmap_field_read(priv->rf[UP_INT_MASK_0 + hw_id], &d->up_irq_mask); in tsens_read_irq_state()
506 ret = regmap_field_read(priv->rf[LOW_INT_MASK_0 + hw_id], &d->low_irq_mask); in tsens_read_irq_state()
509 ret = regmap_field_read(priv->rf[CRIT_INT_CLEAR_0 + hw_id], in tsens_read_irq_state()
510 &d->crit_irq_clear); in tsens_read_irq_state()
513 ret = regmap_field_read(priv->rf[CRIT_INT_MASK_0 + hw_id], in tsens_read_irq_state()
514 &d->crit_irq_mask); in tsens_read_irq_state()
518 d->crit_thresh = tsens_hw_to_mC(s, CRIT_THRESH_0 + hw_id); in tsens_read_irq_state()
521 d->up_irq_mask = 0; in tsens_read_irq_state()
522 d->low_irq_mask = 0; in tsens_read_irq_state()
523 d->crit_irq_clear = 0; in tsens_read_irq_state()
524 d->crit_irq_mask = 0; in tsens_read_irq_state()
525 d->crit_thresh = 0; in tsens_read_irq_state()
528 d->up_thresh = tsens_hw_to_mC(s, UP_THRESH_0 + hw_id); in tsens_read_irq_state()
529 d->low_thresh = tsens_hw_to_mC(s, LOW_THRESH_0 + hw_id); in tsens_read_irq_state()
531 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()
533 (d->up_viol || d->low_viol || d->crit_viol) ? "(V)" : "", in tsens_read_irq_state()
534 d->low_viol, d->up_viol, d->crit_viol, in tsens_read_irq_state()
535 d->low_irq_clear, d->up_irq_clear, d->crit_irq_clear, in tsens_read_irq_state()
536 d->low_irq_mask, d->up_irq_mask, d->crit_irq_mask); in tsens_read_irq_state()
537 dev_dbg(priv->dev, "[%u] %s%s: thresh: (%d:%d:%d)\n", hw_id, __func__, in tsens_read_irq_state()
538 (d->up_viol || d->low_viol || d->crit_viol) ? "(V)" : "", in tsens_read_irq_state()
539 d->low_thresh, d->up_thresh, d->crit_thresh); in tsens_read_irq_state()
554 * tsens_critical_irq_thread() - Threaded handler for critical interrupts
559 * Check all sensors to find ones that violated their critical threshold limits.
560 * Clear and then re-enable the interrupt.
562 * The level-triggered interrupt might deassert if the temperature returned to
575 if (priv->feat->has_watchdog) { in tsens_critical_irq_thread()
576 ret = regmap_field_read(priv->rf[WDOG_BARK_STATUS], in tsens_critical_irq_thread()
583 regmap_field_write(priv->rf[WDOG_BARK_CLEAR], 1); in tsens_critical_irq_thread()
584 regmap_field_write(priv->rf[WDOG_BARK_CLEAR], 0); in tsens_critical_irq_thread()
585 ret = regmap_field_read(priv->rf[WDOG_BARK_COUNT], in tsens_critical_irq_thread()
590 dev_dbg(priv->dev, "%s: watchdog count: %d\n", in tsens_critical_irq_thread()
597 for (i = 0; i < priv->num_sensors; i++) { in tsens_critical_irq_thread()
598 const struct tsens_sensor *s = &priv->sensor[i]; in tsens_critical_irq_thread()
599 u32 hw_id = s->hw_id; in tsens_critical_irq_thread()
601 if (!s->tzd) in tsens_critical_irq_thread()
607 dev_err(priv->dev, "[%u] %s: error reading sensor\n", in tsens_critical_irq_thread()
624 * tsens_irq_thread - Threaded interrupt handler for uplow interrupts
628 * Check all sensors to find ones that violated their threshold limits. If the
630 * update the thresholds, else re-enable the interrupts.
632 * The level-triggered interrupt might deassert if the temperature returned to
644 for (i = 0; i < priv->num_sensors; i++) { in tsens_irq_thread()
645 const struct tsens_sensor *s = &priv->sensor[i]; in tsens_irq_thread()
646 u32 hw_id = s->hw_id; in tsens_irq_thread()
648 if (!s->tzd) in tsens_irq_thread()
653 thermal_zone_device_update(s->tzd, THERMAL_EVENT_UNSPECIFIED); in tsens_irq_thread()
669 * tsens_combined_irq_thread() - Threaded interrupt handler for combined interrupts
673 * Handle the combined interrupt as if it were 2 separate interrupts, so call the
692 struct tsens_priv *priv = s->priv; in tsens_set_trips()
693 struct device *dev = priv->dev; in tsens_set_trips()
697 u32 hw_id = s->hw_id; in tsens_set_trips()
709 cl_high = clamp_val(high, priv->feat->trip_min_temp, priv->feat->trip_max_temp); in tsens_set_trips()
710 cl_low = clamp_val(low, priv->feat->trip_min_temp, priv->feat->trip_max_temp); in tsens_set_trips()
715 spin_lock_irqsave(&priv->ul_lock, flags); in tsens_set_trips()
720 regmap_field_write(priv->rf[LOW_THRESH_0 + hw_id], low_val); in tsens_set_trips()
721 regmap_field_write(priv->rf[UP_THRESH_0 + hw_id], high_val); in tsens_set_trips()
725 spin_unlock_irqrestore(&priv->ul_lock, flags); in tsens_set_trips()
727 dev_dbg(dev, "[%u] %s: (%d:%d)->(%d:%d)\n", in tsens_set_trips()
738 ret = regmap_field_write(priv->rf[INT_EN], val); in tsens_enable_irq()
740 dev_err(priv->dev, "%s: failed to enable interrupts\n", in tsens_enable_irq()
748 regmap_field_write(priv->rf[INT_EN], 0); in tsens_disable_irq()
753 struct tsens_priv *priv = s->priv; in get_temp_tsens_valid()
754 int hw_id = s->hw_id; in get_temp_tsens_valid()
770 ret = regmap_field_read_poll_timeout(priv->rf[valid_idx], valid, in get_temp_tsens_valid()
784 struct tsens_priv *priv = s->priv; in get_temp_common()
785 int hw_id = s->hw_id; in get_temp_common()
792 ret = regmap_field_read(priv->rf[TRDY], &trdy); in get_temp_common()
799 ret = regmap_field_read(priv->rf[LAST_TEMP_0 + hw_id], &last_temp); in get_temp_common()
808 return -ETIMEDOUT; in get_temp_common()
814 struct platform_device *pdev = s->private; in dbg_sensors_show()
819 priv->feat->max_sensors, priv->num_sensors); in dbg_sensors_show()
821 seq_puts(s, " id slope offset\n--------------------------\n"); in dbg_sensors_show()
822 for (i = 0; i < priv->num_sensors; i++) { in dbg_sensors_show()
823 seq_printf(s, "%8d %8d %8d\n", priv->sensor[i].hw_id, in dbg_sensors_show()
824 priv->sensor[i].slope, priv->sensor[i].offset); in dbg_sensors_show()
832 struct platform_device *pdev = s->private; in dbg_version_show()
838 ret = regmap_field_read(priv->rf[VER_MAJOR], &maj_ver); in dbg_version_show()
841 ret = regmap_field_read(priv->rf[VER_MINOR], &min_ver); in dbg_version_show()
844 ret = regmap_field_read(priv->rf[VER_STEP], &step_ver); in dbg_version_show()
849 seq_printf(s, "0.%d.0\n", priv->feat->ver_major); in dbg_version_show()
862 priv->debug_root = debugfs_lookup("tsens", NULL); in tsens_debug_init()
863 if (!priv->debug_root) in tsens_debug_init()
864 priv->debug_root = debugfs_create_dir("tsens", NULL); in tsens_debug_init()
867 priv->debug = debugfs_create_dir(dev_name(&pdev->dev), priv->debug_root); in tsens_debug_init()
868 debugfs_create_file("version", 0444, priv->debug, pdev, &dbg_version_fops); in tsens_debug_init()
869 debugfs_create_file("sensors", 0444, priv->debug, pdev, &dbg_sensors_fops); in tsens_debug_init()
892 struct device *dev = priv->dev; in init_common()
897 struct platform_device *op = of_find_device_by_node(priv->dev->of_node); in init_common()
900 return -EINVAL; in init_common()
902 if (op->num_resources > 1) { in init_common()
904 priv->tm_offset = 0; in init_common()
912 priv->srot_map = devm_regmap_init_mmio(dev, srot_base, in init_common()
914 if (IS_ERR(priv->srot_map)) { in init_common()
915 ret = PTR_ERR(priv->srot_map); in init_common()
920 priv->tm_offset = 0x1000; in init_common()
931 priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config); in init_common()
933 struct device *parent = priv->dev->parent; in init_common()
936 priv->tm_map = syscon_node_to_regmap(parent->of_node); in init_common()
939 if (IS_ERR_OR_NULL(priv->tm_map)) { in init_common()
940 if (!priv->tm_map) in init_common()
941 ret = -ENODEV; in init_common()
943 ret = PTR_ERR(priv->tm_map); in init_common()
948 if (!priv->srot_map) in init_common()
949 priv->srot_map = priv->tm_map; in init_common()
953 priv->rf[i] = devm_regmap_field_alloc(dev, priv->srot_map, in init_common()
954 priv->fields[i]); in init_common()
955 if (IS_ERR(priv->rf[i])) { in init_common()
956 ret = PTR_ERR(priv->rf[i]); in init_common()
960 ret = regmap_field_read(priv->rf[VER_MINOR], &ver_minor); in init_common()
965 priv->rf[TSENS_EN] = devm_regmap_field_alloc(dev, priv->srot_map, in init_common()
966 priv->fields[TSENS_EN]); in init_common()
967 if (IS_ERR(priv->rf[TSENS_EN])) { in init_common()
968 ret = PTR_ERR(priv->rf[TSENS_EN]); in init_common()
973 regmap_field_write(priv->rf[TSENS_EN], 1); in init_common()
975 ret = regmap_field_read(priv->rf[TSENS_EN], &enabled); in init_common()
980 ret = -ENODEV; in init_common()
984 priv->rf[SENSOR_EN] = devm_regmap_field_alloc(dev, priv->srot_map, in init_common()
985 priv->fields[SENSOR_EN]); in init_common()
986 if (IS_ERR(priv->rf[SENSOR_EN])) { in init_common()
987 ret = PTR_ERR(priv->rf[SENSOR_EN]); in init_common()
990 priv->rf[INT_EN] = devm_regmap_field_alloc(dev, priv->tm_map, in init_common()
991 priv->fields[INT_EN]); in init_common()
992 if (IS_ERR(priv->rf[INT_EN])) { in init_common()
993 ret = PTR_ERR(priv->rf[INT_EN]); in init_common()
997 priv->rf[TSENS_SW_RST] = in init_common()
998 devm_regmap_field_alloc(dev, priv->srot_map, priv->fields[TSENS_SW_RST]); in init_common()
999 if (IS_ERR(priv->rf[TSENS_SW_RST])) { in init_common()
1000 ret = PTR_ERR(priv->rf[TSENS_SW_RST]); in init_common()
1004 priv->rf[TRDY] = devm_regmap_field_alloc(dev, priv->tm_map, priv->fields[TRDY]); in init_common()
1005 if (IS_ERR(priv->rf[TRDY])) { in init_common()
1006 ret = PTR_ERR(priv->rf[TRDY]); in init_common()
1012 for (i = 0; i < priv->feat->max_sensors; i++) { in init_common()
1015 priv->rf[idx] = devm_regmap_field_alloc(dev, in init_common()
1016 priv->tm_map, in init_common()
1017 priv->fields[idx]); in init_common()
1018 if (IS_ERR(priv->rf[idx])) { in init_common()
1019 ret = PTR_ERR(priv->rf[idx]); in init_common()
1025 if (priv->feat->crit_int || tsens_version(priv) < VER_0_1) { in init_common()
1028 for (i = 0; i < priv->feat->max_sensors; i++) { in init_common()
1031 priv->rf[idx] = in init_common()
1033 priv->tm_map, in init_common()
1034 priv->fields[idx]); in init_common()
1035 if (IS_ERR(priv->rf[idx])) { in init_common()
1036 ret = PTR_ERR(priv->rf[idx]); in init_common()
1045 priv->feat->has_watchdog = 1; in init_common()
1047 priv->rf[i] = devm_regmap_field_alloc(dev, priv->tm_map, in init_common()
1048 priv->fields[i]); in init_common()
1049 if (IS_ERR(priv->rf[i])) { in init_common()
1050 ret = PTR_ERR(priv->rf[i]); in init_common()
1058 regmap_field_write(priv->rf[WDOG_BARK_MASK], 0); in init_common()
1059 regmap_field_write(priv->rf[CC_MON_MASK], 1); in init_common()
1062 spin_lock_init(&priv->ul_lock); in init_common()
1069 put_device(&op->dev); in init_common()
1076 struct tsens_priv *priv = s->priv; in tsens_get_temp()
1078 return priv->ops->get_temp(s, temp); in tsens_get_temp()
1085 if (priv->ops && priv->ops->suspend) in tsens_suspend()
1086 return priv->ops->suspend(priv); in tsens_suspend()
1095 if (priv->ops && priv->ops->resume) in tsens_resume()
1096 return priv->ops->resume(priv); in tsens_resume()
1105 .compatible = "qcom,ipq8064-tsens",
1108 .compatible = "qcom,ipq8074-tsens",
1111 .compatible = "qcom,mdm9607-tsens",
1114 .compatible = "qcom,msm8226-tsens",
1117 .compatible = "qcom,msm8909-tsens",
1120 .compatible = "qcom,msm8916-tsens",
1123 .compatible = "qcom,msm8939-tsens",
1126 .compatible = "qcom,msm8956-tsens",
1129 .compatible = "qcom,msm8960-tsens",
1132 .compatible = "qcom,msm8974-tsens",
1135 .compatible = "qcom,msm8976-tsens",
1138 .compatible = "qcom,msm8996-tsens",
1141 .compatible = "qcom,tsens-v1",
1144 .compatible = "qcom,tsens-v2",
1162 pdev = of_find_device_by_node(priv->dev->of_node); in tsens_register_irq()
1164 return -ENODEV; in tsens_register_irq()
1170 if (irq == -ENXIO) in tsens_register_irq()
1175 ret = devm_request_threaded_irq(&pdev->dev, irq, in tsens_register_irq()
1178 dev_name(&pdev->dev), in tsens_register_irq()
1181 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, in tsens_register_irq()
1183 dev_name(&pdev->dev), in tsens_register_irq()
1187 dev_err(&pdev->dev, "%s: failed to get irq\n", in tsens_register_irq()
1193 put_device(&pdev->dev); in tsens_register_irq()
1202 * Re-enable the watchdog, unmask the bark. in tsens_reinit()
1205 if (priv->feat->has_watchdog) { in tsens_reinit()
1206 regmap_field_write(priv->rf[WDOG_BARK_MASK], 0); in tsens_reinit()
1207 regmap_field_write(priv->rf[CC_MON_MASK], 1); in tsens_reinit()
1210 /* Re-enable interrupts */ in tsens_reinit()
1232 for (i = 0; i < priv->num_sensors; i++) { in tsens_register()
1233 priv->sensor[i].priv = priv; in tsens_register()
1234 tzd = devm_thermal_of_zone_register(priv->dev, priv->sensor[i].hw_id, in tsens_register()
1235 &priv->sensor[i], in tsens_register()
1239 priv->sensor[i].tzd = tzd; in tsens_register()
1240 if (priv->ops->enable) in tsens_register()
1241 priv->ops->enable(priv, i); in tsens_register()
1243 devm_thermal_add_hwmon_sysfs(priv->dev, tzd); in tsens_register()
1248 * - CRIT_THRESH_0 for MAX THRESH hardcoded to 120°C in tsens_register()
1249 * - CRIT_THRESH_1 for MIN THRESH hardcoded to 0°C in tsens_register()
1252 regmap_field_write(priv->rf[CRIT_THRESH_0], in tsens_register()
1253 tsens_mC_to_hw(priv->sensor, 120000)); in tsens_register()
1255 regmap_field_write(priv->rf[CRIT_THRESH_1], in tsens_register()
1256 tsens_mC_to_hw(priv->sensor, 0)); in tsens_register()
1259 if (priv->feat->combo_int) { in tsens_register()
1260 ret = tsens_register_irq(priv, "combined", in tsens_register()
1267 if (priv->feat->crit_int) in tsens_register()
1285 if (pdev->dev.of_node) in tsens_probe()
1286 dev = &pdev->dev; in tsens_probe()
1288 dev = pdev->dev.parent; in tsens_probe()
1290 np = dev->of_node; in tsens_probe()
1294 data = id->data; in tsens_probe()
1298 num_sensors = data->num_sensors; in tsens_probe()
1301 of_property_read_u32(np, "#qcom,sensors", &num_sensors); in tsens_probe()
1304 dev_err(dev, "%s: invalid number of sensors\n", __func__); in tsens_probe()
1305 return -EINVAL; in tsens_probe()
1312 return -ENOMEM; in tsens_probe()
1314 priv->dev = dev; in tsens_probe()
1315 priv->num_sensors = num_sensors; in tsens_probe()
1316 priv->ops = data->ops; in tsens_probe()
1317 for (i = 0; i < priv->num_sensors; i++) { in tsens_probe()
1318 if (data->hw_ids) in tsens_probe()
1319 priv->sensor[i].hw_id = data->hw_ids[i]; in tsens_probe()
1321 priv->sensor[i].hw_id = i; in tsens_probe()
1323 priv->feat = data->feat; in tsens_probe()
1324 priv->fields = data->fields; in tsens_probe()
1328 if (!priv->ops || !priv->ops->init || !priv->ops->get_temp) in tsens_probe()
1329 return -EINVAL; in tsens_probe()
1331 ret = priv->ops->init(priv); in tsens_probe()
1337 if (priv->ops->calibrate) { in tsens_probe()
1338 ret = priv->ops->calibrate(priv); in tsens_probe()
1355 debugfs_remove_recursive(priv->debug_root); in tsens_remove()
1357 if (priv->ops->disable) in tsens_remove()
1358 priv->ops->disable(priv); in tsens_remove()
1365 .name = "qcom-tsens",
1374 MODULE_ALIAS("platform:qcom-tsens");