Lines Matching +full:temp +full:- +full:sensor
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
25 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 * |-----------| SHFT_FT | BASE_FT | BASE_CP |
39 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 * |---------------------------------------------------| SHIFT_CP |
46 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * div64_s64_precise() - wrapper for div64_s64()
84 shared->base_cp = (val & tfuse->fuse_base_cp_mask) >> in tegra_calc_shared_calib()
85 tfuse->fuse_base_cp_shift; in tegra_calc_shared_calib()
86 shared->base_ft = (val & tfuse->fuse_base_ft_mask) >> in tegra_calc_shared_calib()
87 tfuse->fuse_base_ft_shift; in tegra_calc_shared_calib()
89 shifted_ft = (val & tfuse->fuse_shift_ft_mask) >> in tegra_calc_shared_calib()
90 tfuse->fuse_shift_ft_shift; in tegra_calc_shared_calib()
93 if (tfuse->fuse_spare_realignment) { in tegra_calc_shared_calib()
94 err = tegra_fuse_readl(tfuse->fuse_spare_realignment, &val); in tegra_calc_shared_calib()
101 shared->actual_temp_cp = 2 * NOMINAL_CALIB_CP + shifted_cp; in tegra_calc_shared_calib()
102 shared->actual_temp_ft = 2 * NOMINAL_CALIB_FT + shifted_ft; in tegra_calc_shared_calib()
107 int tegra_calc_tsensor_calib(const struct tegra_tsensor *sensor, in tegra_calc_tsensor_calib() argument
117 s64 temp; in tegra_calc_tsensor_calib() local
120 sensor_group = sensor->group; in tegra_calc_tsensor_calib()
122 err = tegra_fuse_readl(sensor->calib_fuse_offset, &val); in tegra_calc_tsensor_calib()
126 actual_tsensor_cp = (shared->base_cp * 64) + sign_extend32(val, 12); in tegra_calc_tsensor_calib()
129 actual_tsensor_ft = (shared->base_ft * 32) + sign_extend32(val, 12); in tegra_calc_tsensor_calib()
131 delta_sens = actual_tsensor_ft - actual_tsensor_cp; in tegra_calc_tsensor_calib()
132 delta_temp = shared->actual_temp_ft - shared->actual_temp_cp; in tegra_calc_tsensor_calib()
134 mult = sensor_group->pdiv * sensor->config->tsample_ate; in tegra_calc_tsensor_calib()
135 div = sensor->config->tsample * sensor_group->pdiv_ate; in tegra_calc_tsensor_calib()
137 temp = (s64)delta_temp * (1LL << 13) * mult; in tegra_calc_tsensor_calib()
138 therma = div64_s64_precise(temp, (s64)delta_sens * div); in tegra_calc_tsensor_calib()
140 temp = ((s64)actual_tsensor_ft * shared->actual_temp_cp) - in tegra_calc_tsensor_calib()
141 ((s64)actual_tsensor_cp * shared->actual_temp_ft); in tegra_calc_tsensor_calib()
142 thermb = div64_s64_precise(temp, delta_sens); in tegra_calc_tsensor_calib()
144 temp = (s64)therma * sensor->fuse_corr_alpha; in tegra_calc_tsensor_calib()
145 therma = div64_s64_precise(temp, CALIB_COEFFICIENT); in tegra_calc_tsensor_calib()
147 temp = (s64)thermb * sensor->fuse_corr_alpha + sensor->fuse_corr_beta; in tegra_calc_tsensor_calib()
148 thermb = div64_s64_precise(temp, CALIB_COEFFICIENT); in tegra_calc_tsensor_calib()