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