Lines Matching refs:thermal
18 #include <linux/thermal.h>
114 * struct rockchip_thermal_sensor - hold the information of thermal sensor
115 * @thermal: pointer to the platform/configuration data
116 * @tzd: pointer to a thermal zone
117 * @id: identifier of the thermal sensor
120 struct rockchip_thermal_data *thermal;
126 * struct rockchip_thermal_data - hold the private data of thermal driver
128 * @pdev: platform device of thermal
130 * @sensors: array of thermal sensors
1365 struct rockchip_thermal_data *thermal = dev;
1368 dev_dbg(&thermal->pdev->dev, "thermal alarm\n");
1370 thermal->chip->irq_ack(thermal->regs);
1372 for (i = 0; i < thermal->chip->chn_num; i++)
1373 thermal_zone_device_update(thermal->sensors[i].tzd,
1382 struct rockchip_thermal_data *thermal = sensor->thermal;
1383 const struct rockchip_tsadc_chip *tsadc = thermal->chip;
1385 dev_dbg(&thermal->pdev->dev, "%s: sensor %d: low: %d, high %d\n",
1389 sensor->id, thermal->regs, high);
1395 struct rockchip_thermal_data *thermal = sensor->thermal;
1396 const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip;
1400 sensor->id, thermal->regs, out_temp);
1411 struct rockchip_thermal_data *thermal)
1418 thermal->chip->tshut_temp);
1419 thermal->tshut_temp = thermal->chip->tshut_temp;
1426 thermal->tshut_temp = shut_temp;
1432 thermal->chip->tshut_mode == TSHUT_MODE_GPIO ?
1434 thermal->tshut_mode = thermal->chip->tshut_mode;
1436 thermal->tshut_mode = tshut_mode;
1439 if (thermal->tshut_mode > 1) {
1441 thermal->tshut_mode);
1449 thermal->chip->tshut_polarity == TSHUT_LOW_ACTIVE ?
1451 thermal->tshut_polarity = thermal->chip->tshut_polarity;
1453 thermal->tshut_polarity = tshut_polarity;
1456 if (thermal->tshut_polarity > 1) {
1458 thermal->tshut_polarity);
1465 thermal->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
1466 if (IS_ERR(thermal->grf))
1474 struct rockchip_thermal_data *thermal,
1478 const struct rockchip_tsadc_chip *tsadc = thermal->chip;
1481 tsadc->set_tshut_mode(id, thermal->regs, thermal->tshut_mode);
1483 error = tsadc->set_tshut_temp(&tsadc->table, id, thermal->regs,
1484 thermal->tshut_temp);
1487 __func__, thermal->tshut_temp, error);
1489 sensor->thermal = thermal;
1517 struct rockchip_thermal_data *thermal;
1526 thermal = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_thermal_data),
1528 if (!thermal)
1531 thermal->pdev = pdev;
1533 thermal->chip = device_get_match_data(&pdev->dev);
1534 if (!thermal->chip)
1537 thermal->sensors = devm_kcalloc(&pdev->dev, thermal->chip->chn_num,
1538 sizeof(*thermal->sensors), GFP_KERNEL);
1539 if (!thermal->sensors)
1542 thermal->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
1543 if (IS_ERR(thermal->regs))
1544 return PTR_ERR(thermal->regs);
1546 thermal->reset = devm_reset_control_array_get_exclusive(&pdev->dev);
1547 if (IS_ERR(thermal->reset))
1548 return dev_err_probe(&pdev->dev, PTR_ERR(thermal->reset),
1551 thermal->clk = devm_clk_get_enabled(&pdev->dev, "tsadc");
1552 if (IS_ERR(thermal->clk))
1553 return dev_err_probe(&pdev->dev, PTR_ERR(thermal->clk),
1556 thermal->pclk = devm_clk_get_enabled(&pdev->dev, "apb_pclk");
1557 if (IS_ERR(thermal->pclk))
1558 return dev_err_probe(&pdev->dev, PTR_ERR(thermal->pclk),
1561 rockchip_thermal_reset_controller(thermal->reset);
1563 error = rockchip_configure_from_dt(&pdev->dev, np, thermal);
1568 thermal->chip->initialize(thermal->grf, thermal->regs,
1569 thermal->tshut_polarity);
1571 for (i = 0; i < thermal->chip->chn_num; i++) {
1572 error = rockchip_thermal_register_sensor(pdev, thermal,
1573 &thermal->sensors[i],
1574 thermal->chip->chn_offset + i);
1583 "rockchip_thermal", thermal);
1588 thermal->chip->control(thermal->regs, true);
1590 for (i = 0; i < thermal->chip->chn_num; i++) {
1591 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
1592 error = thermal_add_hwmon_sysfs(thermal->sensors[i].tzd);
1599 platform_set_drvdata(pdev, thermal);
1606 struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev);
1609 for (i = 0; i < thermal->chip->chn_num; i++) {
1610 struct rockchip_thermal_sensor *sensor = &thermal->sensors[i];
1616 thermal->chip->control(thermal->regs, false);
1623 struct rockchip_thermal_data *thermal = dev_get_drvdata(dev);
1626 for (i = 0; i < thermal->chip->chn_num; i++)
1627 rockchip_thermal_toggle_sensor(&thermal->sensors[i], false);
1629 thermal->chip->control(thermal->regs, false);
1631 clk_disable(thermal->pclk);
1632 clk_disable(thermal->clk);
1641 struct rockchip_thermal_data *thermal = dev_get_drvdata(dev);
1645 error = clk_enable(thermal->clk);
1649 error = clk_enable(thermal->pclk);
1651 clk_disable(thermal->clk);
1655 rockchip_thermal_reset_controller(thermal->reset);
1657 thermal->chip->initialize(thermal->grf, thermal->regs,
1658 thermal->tshut_polarity);
1660 for (i = 0; i < thermal->chip->chn_num; i++) {
1661 int id = thermal->sensors[i].id;
1663 thermal->chip->set_tshut_mode(id, thermal->regs,
1664 thermal->tshut_mode);
1666 error = thermal->chip->set_tshut_temp(&thermal->chip->table,
1667 id, thermal->regs,
1668 thermal->tshut_temp);
1671 __func__, thermal->tshut_temp, error);
1674 thermal->chip->control(thermal->regs, true);
1676 for (i = 0; i < thermal->chip->chn_num; i++)
1677 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
1689 .name = "rockchip-thermal",
1702 MODULE_ALIAS("platform:rockchip-thermal");