Lines Matching +full:calibration +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0+
10 * U = ---------, Uptat = ---------
13 * Temperature = A * ( Uptat + u_efuse / 2^16 )- B
15 * A B m n : calibration parameters
16 * u_efuse : fused calibration value, it's a signed 16 bits value
68 * @A: calibration parameters
69 * @B: calibration parameters
70 * @m: calibration parameters
71 * @n: calibration parameters
84 * @u_efuse_off: register offset to read fused calibration value
85 * @calibration_parameters: calibration parameters structure pointer
97 const struct amlogic_thermal_data *data; member
113 pdata->data->calibration_parameters; in amlogic_thermal_code_to_millicelsius()
117 uefuse = pdata->trim_info & TSENSOR_TRIM_SIGN_MASK ? in amlogic_thermal_code_to_millicelsius()
118 ~(pdata->trim_info & TSENSOR_TRIM_TEMP_MASK) + 1 : in amlogic_thermal_code_to_millicelsius()
119 (pdata->trim_info & TSENSOR_TRIM_TEMP_MASK); in amlogic_thermal_code_to_millicelsius()
121 factor = param->n * temp_code; in amlogic_thermal_code_to_millicelsius()
124 Uptat = temp_code * param->m; in amlogic_thermal_code_to_millicelsius()
129 temp = (Uptat + uefuse) * param->A; in amlogic_thermal_code_to_millicelsius()
131 temp = (temp - param->B) * 100; in amlogic_thermal_code_to_millicelsius()
141 regmap_read(pdata->sec_ao_map, pdata->data->u_efuse_off, in amlogic_thermal_initialize()
142 &pdata->trim_info); in amlogic_thermal_initialize()
144 ver = TSENSOR_TRIM_VERSION(pdata->trim_info); in amlogic_thermal_initialize()
147 ret = -EINVAL; in amlogic_thermal_initialize()
148 dev_err(&pdata->pdev->dev, in amlogic_thermal_initialize()
149 "tsensor thermal calibration not supported: 0x%x!\n", in amlogic_thermal_initialize()
156 static int amlogic_thermal_enable(struct amlogic_thermal *data) in amlogic_thermal_enable() argument
160 ret = clk_prepare_enable(data->clk); in amlogic_thermal_enable()
164 regmap_update_bits(data->regmap, TSENSOR_CFG_REG1, in amlogic_thermal_enable()
170 static void amlogic_thermal_disable(struct amlogic_thermal *data) in amlogic_thermal_disable() argument
172 regmap_update_bits(data->regmap, TSENSOR_CFG_REG1, in amlogic_thermal_disable()
174 clk_disable_unprepare(data->clk); in amlogic_thermal_disable()
183 return -EINVAL; in amlogic_thermal_get_temp()
185 regmap_read(pdata->regmap, TSENSOR_STAT0, &tval); in amlogic_thermal_get_temp()
231 .compatible = "amlogic,g12a-ddr-thermal",
232 .data = &amlogic_thermal_g12a_ddr_param,
235 .compatible = "amlogic,g12a-cpu-thermal",
236 .data = &amlogic_thermal_g12a_cpu_param,
239 .compatible = "amlogic,a1-cpu-thermal",
240 .data = &amlogic_thermal_a1_cpu_param,
249 struct device *dev = &pdev->dev; in amlogic_thermal_probe()
255 return -ENOMEM; in amlogic_thermal_probe()
257 pdata->data = of_device_get_match_data(dev); in amlogic_thermal_probe()
258 pdata->pdev = pdev; in amlogic_thermal_probe()
265 pdata->regmap = devm_regmap_init_mmio(dev, base, in amlogic_thermal_probe()
266 pdata->data->regmap_config); in amlogic_thermal_probe()
267 if (IS_ERR(pdata->regmap)) in amlogic_thermal_probe()
268 return PTR_ERR(pdata->regmap); in amlogic_thermal_probe()
270 pdata->clk = devm_clk_get(dev, NULL); in amlogic_thermal_probe()
271 if (IS_ERR(pdata->clk)) in amlogic_thermal_probe()
272 return dev_err_probe(dev, PTR_ERR(pdata->clk), "failed to get clock\n"); in amlogic_thermal_probe()
274 pdata->sec_ao_map = syscon_regmap_lookup_by_phandle in amlogic_thermal_probe()
275 (pdev->dev.of_node, "amlogic,ao-secure"); in amlogic_thermal_probe()
276 if (IS_ERR(pdata->sec_ao_map)) { in amlogic_thermal_probe()
278 return PTR_ERR(pdata->sec_ao_map); in amlogic_thermal_probe()
281 pdata->tzd = devm_thermal_of_zone_register(&pdev->dev, in amlogic_thermal_probe()
285 if (IS_ERR(pdata->tzd)) { in amlogic_thermal_probe()
286 ret = PTR_ERR(pdata->tzd); in amlogic_thermal_probe()
291 devm_thermal_add_hwmon_sysfs(&pdev->dev, pdata->tzd); in amlogic_thermal_probe()
304 struct amlogic_thermal *data = platform_get_drvdata(pdev); in amlogic_thermal_remove() local
306 amlogic_thermal_disable(data); in amlogic_thermal_remove()
311 struct amlogic_thermal *data = dev_get_drvdata(dev); in amlogic_thermal_suspend() local
313 amlogic_thermal_disable(data); in amlogic_thermal_suspend()
320 struct amlogic_thermal *data = dev_get_drvdata(dev); in amlogic_thermal_resume() local
322 return amlogic_thermal_enable(data); in amlogic_thermal_resume()