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
70 * @A: calibration parameters
71 * @B: calibration parameters
72 * @m: calibration parameters
73 * @n: calibration parameters
86 * @u_efuse_off: register offset to read fused calibration value
87 * @calibration_parameters: calibration parameters structure pointer
99 const struct amlogic_thermal_data *data; member
115 pdata->data->calibration_parameters; in amlogic_thermal_code_to_millicelsius()
119 uefuse = pdata->trim_info & TSENSOR_TRIM_SIGN_MASK ? in amlogic_thermal_code_to_millicelsius()
120 ~(pdata->trim_info & TSENSOR_TRIM_TEMP_MASK) + 1 : in amlogic_thermal_code_to_millicelsius()
121 (pdata->trim_info & TSENSOR_TRIM_TEMP_MASK); in amlogic_thermal_code_to_millicelsius()
123 factor = param->n * temp_code; in amlogic_thermal_code_to_millicelsius()
126 Uptat = temp_code * param->m; in amlogic_thermal_code_to_millicelsius()
131 temp = (Uptat + uefuse) * param->A; in amlogic_thermal_code_to_millicelsius()
133 temp = (temp - param->B) * 100; in amlogic_thermal_code_to_millicelsius()
143 regmap_read(pdata->sec_ao_map, pdata->data->u_efuse_off, in amlogic_thermal_initialize()
144 &pdata->trim_info); in amlogic_thermal_initialize()
146 ver = TSENSOR_TRIM_VERSION(pdata->trim_info); in amlogic_thermal_initialize()
149 ret = -EINVAL; in amlogic_thermal_initialize()
150 dev_err(&pdata->pdev->dev, in amlogic_thermal_initialize()
151 "tsensor thermal calibration not supported: 0x%x!\n", in amlogic_thermal_initialize()
158 static int amlogic_thermal_enable(struct amlogic_thermal *data) in amlogic_thermal_enable() argument
162 ret = clk_prepare_enable(data->clk); in amlogic_thermal_enable()
166 regmap_update_bits(data->regmap, TSENSOR_CFG_REG1, in amlogic_thermal_enable()
172 static int amlogic_thermal_disable(struct amlogic_thermal *data) in amlogic_thermal_disable() argument
174 regmap_update_bits(data->regmap, TSENSOR_CFG_REG1, in amlogic_thermal_disable()
176 clk_disable_unprepare(data->clk); in amlogic_thermal_disable()
181 static int amlogic_thermal_get_temp(void *data, int *temp) in amlogic_thermal_get_temp() argument
184 struct amlogic_thermal *pdata = data; in amlogic_thermal_get_temp()
186 if (!data) in amlogic_thermal_get_temp()
187 return -EINVAL; in amlogic_thermal_get_temp()
189 regmap_read(pdata->regmap, TSENSOR_STAT0, &tval); in amlogic_thermal_get_temp()
229 .compatible = "amlogic,g12a-ddr-thermal",
230 .data = &amlogic_thermal_g12a_ddr_param,
233 .compatible = "amlogic,g12a-cpu-thermal",
234 .data = &amlogic_thermal_g12a_cpu_param,
243 struct device *dev = &pdev->dev; in amlogic_thermal_probe()
249 return -ENOMEM; in amlogic_thermal_probe()
251 pdata->data = of_device_get_match_data(dev); in amlogic_thermal_probe()
252 pdata->pdev = pdev; in amlogic_thermal_probe()
261 pdata->regmap = devm_regmap_init_mmio(dev, base, in amlogic_thermal_probe()
262 pdata->data->regmap_config); in amlogic_thermal_probe()
263 if (IS_ERR(pdata->regmap)) in amlogic_thermal_probe()
264 return PTR_ERR(pdata->regmap); in amlogic_thermal_probe()
266 pdata->clk = devm_clk_get(dev, NULL); in amlogic_thermal_probe()
267 if (IS_ERR(pdata->clk)) { in amlogic_thermal_probe()
268 if (PTR_ERR(pdata->clk) != -EPROBE_DEFER) in amlogic_thermal_probe()
270 return PTR_ERR(pdata->clk); in amlogic_thermal_probe()
273 pdata->sec_ao_map = syscon_regmap_lookup_by_phandle in amlogic_thermal_probe()
274 (pdev->dev.of_node, "amlogic,ao-secure"); in amlogic_thermal_probe()
275 if (IS_ERR(pdata->sec_ao_map)) { in amlogic_thermal_probe()
277 return PTR_ERR(pdata->sec_ao_map); in amlogic_thermal_probe()
280 pdata->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, in amlogic_thermal_probe()
284 if (IS_ERR(pdata->tzd)) { in amlogic_thermal_probe()
285 ret = PTR_ERR(pdata->tzd); in amlogic_thermal_probe()
301 struct amlogic_thermal *data = platform_get_drvdata(pdev); in amlogic_thermal_remove() local
303 return amlogic_thermal_disable(data); in amlogic_thermal_remove()
308 struct amlogic_thermal *data = dev_get_drvdata(dev); in amlogic_thermal_suspend() local
310 return amlogic_thermal_disable(data); in amlogic_thermal_suspend()
315 struct amlogic_thermal *data = dev_get_drvdata(dev); in amlogic_thermal_resume() local
317 return amlogic_thermal_enable(data); in amlogic_thermal_resume()