Lines Matching +full:g12a +full:- +full:cpu +full:- +full:thermal
1 // SPDX-License-Identifier: GPL-2.0+
3 * Amlogic Thermal Sensor Driver
10 * U = ---------, Uptat = ---------
13 * Temperature = A * ( Uptat + u_efuse / 2^16 )- B
27 #include <linux/thermal.h>
73 * This structure is required for configuration of amlogic thermal driver.
87 * This structure is required for configuration of amlogic thermal driver.
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()
160 ret = clk_prepare_enable(data->clk); in amlogic_thermal_enable()
164 regmap_update_bits(data->regmap, TSENSOR_CFG_REG1, in amlogic_thermal_enable()
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",
235 .compatible = "amlogic,g12a-cpu-thermal",
239 .compatible = "amlogic,a1-cpu-thermal",
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()
342 MODULE_DESCRIPTION("Amlogic thermal driver");