Lines Matching full:thermal
18 #include <linux/thermal.h>
129 * struct rockchip_thermal_sensor - hold the information of thermal sensor
130 * @thermal: pointer to the platform/configuration data
131 * @tzd: pointer to a thermal zone
132 * @id: identifier of the thermal sensor
135 struct rockchip_thermal_data *thermal; member
141 * struct rockchip_thermal_data - hold the private data of thermal driver
143 * @pdev: platform device of thermal
145 * @sensors: array of thermal sensors
1079 struct rockchip_thermal_data *thermal = dev; in rockchip_thermal_alarm_irq_thread() local
1082 dev_dbg(&thermal->pdev->dev, "thermal alarm\n"); in rockchip_thermal_alarm_irq_thread()
1084 thermal->chip->irq_ack(thermal->regs); in rockchip_thermal_alarm_irq_thread()
1086 for (i = 0; i < thermal->chip->chn_num; i++) in rockchip_thermal_alarm_irq_thread()
1087 thermal_zone_device_update(thermal->sensors[i].tzd, in rockchip_thermal_alarm_irq_thread()
1096 struct rockchip_thermal_data *thermal = sensor->thermal; in rockchip_thermal_set_trips() local
1097 const struct rockchip_tsadc_chip *tsadc = thermal->chip; in rockchip_thermal_set_trips()
1099 dev_dbg(&thermal->pdev->dev, "%s: sensor %d: low: %d, high %d\n", in rockchip_thermal_set_trips()
1103 sensor->id, thermal->regs, high); in rockchip_thermal_set_trips()
1109 struct rockchip_thermal_data *thermal = sensor->thermal; in rockchip_thermal_get_temp() local
1110 const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip; in rockchip_thermal_get_temp()
1114 sensor->id, thermal->regs, out_temp); in rockchip_thermal_get_temp()
1115 dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %d, retval: %d\n", in rockchip_thermal_get_temp()
1128 struct rockchip_thermal_data *thermal) in rockchip_configure_from_dt() argument
1135 thermal->chip->tshut_temp); in rockchip_configure_from_dt()
1136 thermal->tshut_temp = thermal->chip->tshut_temp; in rockchip_configure_from_dt()
1143 thermal->tshut_temp = shut_temp; in rockchip_configure_from_dt()
1149 thermal->chip->tshut_mode == TSHUT_MODE_GPIO ? in rockchip_configure_from_dt()
1151 thermal->tshut_mode = thermal->chip->tshut_mode; in rockchip_configure_from_dt()
1153 thermal->tshut_mode = tshut_mode; in rockchip_configure_from_dt()
1156 if (thermal->tshut_mode > 1) { in rockchip_configure_from_dt()
1158 thermal->tshut_mode); in rockchip_configure_from_dt()
1166 thermal->chip->tshut_polarity == TSHUT_LOW_ACTIVE ? in rockchip_configure_from_dt()
1168 thermal->tshut_polarity = thermal->chip->tshut_polarity; in rockchip_configure_from_dt()
1170 thermal->tshut_polarity = tshut_polarity; in rockchip_configure_from_dt()
1173 if (thermal->tshut_polarity > 1) { in rockchip_configure_from_dt()
1175 thermal->tshut_polarity); in rockchip_configure_from_dt()
1182 thermal->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); in rockchip_configure_from_dt()
1183 if (IS_ERR(thermal->grf)) in rockchip_configure_from_dt()
1191 struct rockchip_thermal_data *thermal, in rockchip_thermal_register_sensor() argument
1195 const struct rockchip_tsadc_chip *tsadc = thermal->chip; in rockchip_thermal_register_sensor()
1198 tsadc->set_tshut_mode(id, thermal->regs, thermal->tshut_mode); in rockchip_thermal_register_sensor()
1200 error = tsadc->set_tshut_temp(&tsadc->table, id, thermal->regs, in rockchip_thermal_register_sensor()
1201 thermal->tshut_temp); in rockchip_thermal_register_sensor()
1204 __func__, thermal->tshut_temp, error); in rockchip_thermal_register_sensor()
1206 sensor->thermal = thermal; in rockchip_thermal_register_sensor()
1234 struct rockchip_thermal_data *thermal; in rockchip_thermal_probe() local
1249 thermal = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_thermal_data), in rockchip_thermal_probe()
1251 if (!thermal) in rockchip_thermal_probe()
1254 thermal->pdev = pdev; in rockchip_thermal_probe()
1256 thermal->chip = (const struct rockchip_tsadc_chip *)match->data; in rockchip_thermal_probe()
1257 if (!thermal->chip) in rockchip_thermal_probe()
1261 thermal->regs = devm_ioremap_resource(&pdev->dev, res); in rockchip_thermal_probe()
1262 if (IS_ERR(thermal->regs)) in rockchip_thermal_probe()
1263 return PTR_ERR(thermal->regs); in rockchip_thermal_probe()
1265 thermal->reset = devm_reset_control_get(&pdev->dev, "tsadc-apb"); in rockchip_thermal_probe()
1266 if (IS_ERR(thermal->reset)) { in rockchip_thermal_probe()
1267 error = PTR_ERR(thermal->reset); in rockchip_thermal_probe()
1272 thermal->clk = devm_clk_get(&pdev->dev, "tsadc"); in rockchip_thermal_probe()
1273 if (IS_ERR(thermal->clk)) { in rockchip_thermal_probe()
1274 error = PTR_ERR(thermal->clk); in rockchip_thermal_probe()
1279 thermal->pclk = devm_clk_get(&pdev->dev, "apb_pclk"); in rockchip_thermal_probe()
1280 if (IS_ERR(thermal->pclk)) { in rockchip_thermal_probe()
1281 error = PTR_ERR(thermal->pclk); in rockchip_thermal_probe()
1287 error = clk_prepare_enable(thermal->clk); in rockchip_thermal_probe()
1294 error = clk_prepare_enable(thermal->pclk); in rockchip_thermal_probe()
1300 rockchip_thermal_reset_controller(thermal->reset); in rockchip_thermal_probe()
1302 error = rockchip_configure_from_dt(&pdev->dev, np, thermal); in rockchip_thermal_probe()
1309 thermal->chip->initialize(thermal->grf, thermal->regs, in rockchip_thermal_probe()
1310 thermal->tshut_polarity); in rockchip_thermal_probe()
1312 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_probe()
1313 error = rockchip_thermal_register_sensor(pdev, thermal, in rockchip_thermal_probe()
1314 &thermal->sensors[i], in rockchip_thermal_probe()
1315 thermal->chip->chn_id[i]); in rockchip_thermal_probe()
1327 "rockchip_thermal", thermal); in rockchip_thermal_probe()
1334 thermal->chip->control(thermal->regs, true); in rockchip_thermal_probe()
1336 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_probe()
1337 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); in rockchip_thermal_probe()
1338 thermal->sensors[i].tzd->tzp->no_hwmon = false; in rockchip_thermal_probe()
1339 error = thermal_add_hwmon_sysfs(thermal->sensors[i].tzd); in rockchip_thermal_probe()
1346 platform_set_drvdata(pdev, thermal); in rockchip_thermal_probe()
1351 clk_disable_unprepare(thermal->pclk); in rockchip_thermal_probe()
1353 clk_disable_unprepare(thermal->clk); in rockchip_thermal_probe()
1360 struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev); in rockchip_thermal_remove() local
1363 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_remove()
1364 struct rockchip_thermal_sensor *sensor = &thermal->sensors[i]; in rockchip_thermal_remove()
1370 thermal->chip->control(thermal->regs, false); in rockchip_thermal_remove()
1372 clk_disable_unprepare(thermal->pclk); in rockchip_thermal_remove()
1373 clk_disable_unprepare(thermal->clk); in rockchip_thermal_remove()
1380 struct rockchip_thermal_data *thermal = dev_get_drvdata(dev); in rockchip_thermal_suspend() local
1383 for (i = 0; i < thermal->chip->chn_num; i++) in rockchip_thermal_suspend()
1384 rockchip_thermal_toggle_sensor(&thermal->sensors[i], false); in rockchip_thermal_suspend()
1386 thermal->chip->control(thermal->regs, false); in rockchip_thermal_suspend()
1388 clk_disable(thermal->pclk); in rockchip_thermal_suspend()
1389 clk_disable(thermal->clk); in rockchip_thermal_suspend()
1398 struct rockchip_thermal_data *thermal = dev_get_drvdata(dev); in rockchip_thermal_resume() local
1402 error = clk_enable(thermal->clk); in rockchip_thermal_resume()
1406 error = clk_enable(thermal->pclk); in rockchip_thermal_resume()
1408 clk_disable(thermal->clk); in rockchip_thermal_resume()
1412 rockchip_thermal_reset_controller(thermal->reset); in rockchip_thermal_resume()
1414 thermal->chip->initialize(thermal->grf, thermal->regs, in rockchip_thermal_resume()
1415 thermal->tshut_polarity); in rockchip_thermal_resume()
1417 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_resume()
1418 int id = thermal->sensors[i].id; in rockchip_thermal_resume()
1420 thermal->chip->set_tshut_mode(id, thermal->regs, in rockchip_thermal_resume()
1421 thermal->tshut_mode); in rockchip_thermal_resume()
1423 error = thermal->chip->set_tshut_temp(&thermal->chip->table, in rockchip_thermal_resume()
1424 id, thermal->regs, in rockchip_thermal_resume()
1425 thermal->tshut_temp); in rockchip_thermal_resume()
1428 __func__, thermal->tshut_temp, error); in rockchip_thermal_resume()
1431 thermal->chip->control(thermal->regs, true); in rockchip_thermal_resume()
1433 for (i = 0; i < thermal->chip->chn_num; i++) in rockchip_thermal_resume()
1434 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); in rockchip_thermal_resume()
1446 .name = "rockchip-thermal",
1456 MODULE_DESCRIPTION("ROCKCHIP THERMAL Driver");
1459 MODULE_ALIAS("platform:rockchip-thermal");