Lines Matching +full:am654 +full:- +full:vtm
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com/
73 * struct err_values - structure containing error/reference values
74 * @refs: reference error values for -40C, 30C, 125C & 150C
75 * @errs: Actual error values for -40C, 30C, 125C & 150C read from the efuse
90 idx1 = err_vals->refs[seg]; in create_table_segments()
92 idx2 = err_vals->refs[seg + 1]; in create_table_segments()
93 err1 = err_vals->errs[seg]; in create_table_segments()
94 err2 = err_vals->errs[seg + 1]; in create_table_segments()
95 ref1 = err_vals->refs[seg]; in create_table_segments()
96 ref2 = err_vals->refs[seg + 1]; in create_table_segments()
100 * as the y-axis param and err in adc value as x-axis param in create_table_segments()
102 num = ref2 - ref1; in create_table_segments()
103 den = err2 - err1; in create_table_segments()
106 c = ref2 - m * err2; in create_table_segments()
114 err = (i - c) / m; in create_table_segments()
134 * region -40C to +30C in prep_lookup_table()
152 while (i--) in prep_lookup_table()
153 derived_table[i] = derived_table[i + 1] - 300; in prep_lookup_table()
160 i = TABLE_SIZE - 1; in prep_lookup_table()
162 i--; in prep_lookup_table()
167 derived_table[i] = derived_table[i - 1] + inc * 100; in prep_lookup_table()
198 return (0 - tmp); in two_cmp()
204 int d01 = abs(s0 - s1); in vtm_get_best_value()
205 int d02 = abs(s0 - s2); in vtm_get_best_value()
206 int d12 = abs(s1 - s2); in vtm_get_best_value()
223 bgp = devdata->bgp; in k3_bgp_read_temp()
225 * Errata is applicable for am654 pg 1.0 silicon/J7ES. There in k3_bgp_read_temp()
226 * is a variation of the order for certain degree centigrade on AM654. in k3_bgp_read_temp()
233 s0 = readl(bgp->base + devdata->stat_offset) & in k3_bgp_read_temp()
235 s1 = readl(bgp->base + devdata->stat_offset) & in k3_bgp_read_temp()
237 s2 = readl(bgp->base + devdata->stat_offset) & in k3_bgp_read_temp()
242 return -EINVAL; in k3_bgp_read_temp()
261 int low = 0, high = TABLE_SIZE - 1, mid; in k3_j72xx_bandgap_temp_to_adc_code()
263 if (temp > 160000 || temp < -50000) in k3_j72xx_bandgap_temp_to_adc_code()
264 return -EINVAL; in k3_j72xx_bandgap_temp_to_adc_code()
267 while (low < (high - 1)) { in k3_j72xx_bandgap_temp_to_adc_code()
285 { 0x0, -1, 0x4 }, in get_efuse_values()
286 { 0x0, 0xC, -1 }, in get_efuse_values()
298 /* Extract the offset value using bit-mask */ in get_efuse_values()
299 if (ct_offsets[id][i] == -1 && i == 1) { in get_efuse_values()
304 } else if (ct_offsets[id][i] == -1 && i == 2) { in get_efuse_values()
348 for (id = 0; id < bgp->cnt; id++) { in k3_j72xx_bandgap_init_hw()
349 data = bgp->ts_data[id]; in k3_j72xx_bandgap_init_hw()
350 val = readl(bgp->cfg2_base + data->ctrl_offset); in k3_j72xx_bandgap_init_hw()
354 writel(val, bgp->cfg2_base + data->ctrl_offset); in k3_j72xx_bandgap_init_hw()
367 writel((low_temp << 16) | high_max, bgp->cfg2_base + K3_VTM_MISC_CTRL2_OFFSET); in k3_j72xx_bandgap_init_hw()
368 writel(K3_VTM_ANYMAXT_OUTRG_ALERT_EN, bgp->cfg2_base + K3_VTM_MISC_CTRL_OFFSET); in k3_j72xx_bandgap_init_hw()
379 struct device *dev = &pdev->dev; in k3_j72xx_bandgap_probe()
390 -490019999999999936, in k3_j72xx_bandgap_probe()
392 -1705800000000, in k3_j72xx_bandgap_probe()
394 -92627, in k3_j72xx_bandgap_probe()
398 -415230000000000000, in k3_j72xx_bandgap_probe()
400 -1157800000000, in k3_j72xx_bandgap_probe()
403 bgp = devm_kzalloc(&pdev->dev, sizeof(*bgp), GFP_KERNEL); in k3_j72xx_bandgap_probe()
405 return -ENOMEM; in k3_j72xx_bandgap_probe()
407 bgp->dev = dev; in k3_j72xx_bandgap_probe()
409 bgp->base = devm_ioremap_resource(dev, res); in k3_j72xx_bandgap_probe()
410 if (IS_ERR(bgp->base)) in k3_j72xx_bandgap_probe()
411 return PTR_ERR(bgp->base); in k3_j72xx_bandgap_probe()
414 bgp->cfg2_base = devm_ioremap_resource(dev, res); in k3_j72xx_bandgap_probe()
415 if (IS_ERR(bgp->cfg2_base)) in k3_j72xx_bandgap_probe()
416 return PTR_ERR(bgp->cfg2_base); in k3_j72xx_bandgap_probe()
420 workaround_needed = driver_data->has_errata_i2128; in k3_j72xx_bandgap_probe()
441 dev_dbg(bgp->dev, "Work around %sneeded\n", in k3_j72xx_bandgap_probe()
452 /* Get the sensor count in the VTM */ in k3_j72xx_bandgap_probe()
453 val = readl(bgp->base + K3_VTM_DEVINFO_PWR0_OFFSET); in k3_j72xx_bandgap_probe()
454 bgp->cnt = val & K3_VTM_DEVINFO_PWR0_TEMPSENS_CT_MASK; in k3_j72xx_bandgap_probe()
455 bgp->cnt >>= __ffs(K3_VTM_DEVINFO_PWR0_TEMPSENS_CT_MASK); in k3_j72xx_bandgap_probe()
457 data = devm_kcalloc(bgp->dev, bgp->cnt, sizeof(*data), GFP_KERNEL); in k3_j72xx_bandgap_probe()
459 ret = -ENOMEM; in k3_j72xx_bandgap_probe()
465 ret = -ENOMEM; in k3_j72xx_bandgap_probe()
469 derived_table = devm_kzalloc(bgp->dev, sizeof(*derived_table) * TABLE_SIZE, in k3_j72xx_bandgap_probe()
472 ret = -ENOMEM; in k3_j72xx_bandgap_probe()
482 for (id = 0; id < bgp->cnt; id++) { in k3_j72xx_bandgap_probe()
489 /* ref adc values for -40C, 30C & 125C respectively */ in k3_j72xx_bandgap_probe()
502 bgp->ts_data[id] = &data[id]; in k3_j72xx_bandgap_probe()
508 for (id = 0; id < bgp->cnt; id++) { in k3_j72xx_bandgap_probe()
509 ti_thermal = devm_thermal_of_zone_register(bgp->dev, id, &data[id], in k3_j72xx_bandgap_probe()
512 dev_err(bgp->dev, "thermal zone device is NULL\n"); in k3_j72xx_bandgap_probe()
533 pm_runtime_put_sync(&pdev->dev); in k3_j72xx_bandgap_probe()
534 pm_runtime_disable(&pdev->dev); in k3_j72xx_bandgap_probe()
541 pm_runtime_put_sync(&pdev->dev); in k3_j72xx_bandgap_remove()
542 pm_runtime_disable(&pdev->dev); in k3_j72xx_bandgap_remove()
584 .compatible = "ti,j721e-vtm",
588 .compatible = "ti,j7200-vtm",
599 .name = "k3-j72xx-soc-thermal",
609 MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");