Lines Matching full: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; member
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; in rockchip_thermal_alarm_irq_thread() local
1368 dev_dbg(&thermal->pdev->dev, "thermal alarm\n"); in rockchip_thermal_alarm_irq_thread()
1370 thermal->chip->irq_ack(thermal->regs); in rockchip_thermal_alarm_irq_thread()
1372 for (i = 0; i < thermal->chip->chn_num; i++) in rockchip_thermal_alarm_irq_thread()
1373 thermal_zone_device_update(thermal->sensors[i].tzd, in rockchip_thermal_alarm_irq_thread()
1382 struct rockchip_thermal_data *thermal = sensor->thermal; in rockchip_thermal_set_trips() local
1383 const struct rockchip_tsadc_chip *tsadc = thermal->chip; in rockchip_thermal_set_trips()
1385 dev_dbg(&thermal->pdev->dev, "%s: sensor %d: low: %d, high %d\n", in rockchip_thermal_set_trips()
1389 sensor->id, thermal->regs, high); in rockchip_thermal_set_trips()
1395 struct rockchip_thermal_data *thermal = sensor->thermal; in rockchip_thermal_get_temp() local
1396 const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip; in rockchip_thermal_get_temp()
1400 sensor->id, thermal->regs, out_temp); in rockchip_thermal_get_temp()
1411 struct rockchip_thermal_data *thermal) in rockchip_configure_from_dt() argument
1418 thermal->chip->tshut_temp); in rockchip_configure_from_dt()
1419 thermal->tshut_temp = thermal->chip->tshut_temp; in rockchip_configure_from_dt()
1426 thermal->tshut_temp = shut_temp; in rockchip_configure_from_dt()
1432 thermal->chip->tshut_mode == TSHUT_MODE_GPIO ? in rockchip_configure_from_dt()
1434 thermal->tshut_mode = thermal->chip->tshut_mode; in rockchip_configure_from_dt()
1436 thermal->tshut_mode = tshut_mode; in rockchip_configure_from_dt()
1439 if (thermal->tshut_mode > 1) { in rockchip_configure_from_dt()
1441 thermal->tshut_mode); in rockchip_configure_from_dt()
1449 thermal->chip->tshut_polarity == TSHUT_LOW_ACTIVE ? in rockchip_configure_from_dt()
1451 thermal->tshut_polarity = thermal->chip->tshut_polarity; in rockchip_configure_from_dt()
1453 thermal->tshut_polarity = tshut_polarity; in rockchip_configure_from_dt()
1456 if (thermal->tshut_polarity > 1) { in rockchip_configure_from_dt()
1458 thermal->tshut_polarity); in rockchip_configure_from_dt()
1465 thermal->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); in rockchip_configure_from_dt()
1466 if (IS_ERR(thermal->grf)) in rockchip_configure_from_dt()
1474 struct rockchip_thermal_data *thermal, in rockchip_thermal_register_sensor() argument
1478 const struct rockchip_tsadc_chip *tsadc = thermal->chip; in rockchip_thermal_register_sensor()
1481 tsadc->set_tshut_mode(id, thermal->regs, thermal->tshut_mode); in rockchip_thermal_register_sensor()
1483 error = tsadc->set_tshut_temp(&tsadc->table, id, thermal->regs, in rockchip_thermal_register_sensor()
1484 thermal->tshut_temp); in rockchip_thermal_register_sensor()
1487 __func__, thermal->tshut_temp, error); in rockchip_thermal_register_sensor()
1489 sensor->thermal = thermal; in rockchip_thermal_register_sensor()
1517 struct rockchip_thermal_data *thermal; in rockchip_thermal_probe() local
1526 thermal = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_thermal_data), in rockchip_thermal_probe()
1528 if (!thermal) in rockchip_thermal_probe()
1531 thermal->pdev = pdev; in rockchip_thermal_probe()
1533 thermal->chip = device_get_match_data(&pdev->dev); in rockchip_thermal_probe()
1534 if (!thermal->chip) in rockchip_thermal_probe()
1537 thermal->sensors = devm_kcalloc(&pdev->dev, thermal->chip->chn_num, in rockchip_thermal_probe()
1538 sizeof(*thermal->sensors), GFP_KERNEL); in rockchip_thermal_probe()
1539 if (!thermal->sensors) in rockchip_thermal_probe()
1542 thermal->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in rockchip_thermal_probe()
1543 if (IS_ERR(thermal->regs)) in rockchip_thermal_probe()
1544 return PTR_ERR(thermal->regs); in rockchip_thermal_probe()
1546 thermal->reset = devm_reset_control_array_get_exclusive(&pdev->dev); in rockchip_thermal_probe()
1547 if (IS_ERR(thermal->reset)) in rockchip_thermal_probe()
1548 return dev_err_probe(&pdev->dev, PTR_ERR(thermal->reset), in rockchip_thermal_probe()
1551 thermal->clk = devm_clk_get_enabled(&pdev->dev, "tsadc"); in rockchip_thermal_probe()
1552 if (IS_ERR(thermal->clk)) in rockchip_thermal_probe()
1553 return dev_err_probe(&pdev->dev, PTR_ERR(thermal->clk), in rockchip_thermal_probe()
1556 thermal->pclk = devm_clk_get_enabled(&pdev->dev, "apb_pclk"); in rockchip_thermal_probe()
1557 if (IS_ERR(thermal->pclk)) in rockchip_thermal_probe()
1558 return dev_err_probe(&pdev->dev, PTR_ERR(thermal->pclk), in rockchip_thermal_probe()
1561 rockchip_thermal_reset_controller(thermal->reset); in rockchip_thermal_probe()
1563 error = rockchip_configure_from_dt(&pdev->dev, np, thermal); in rockchip_thermal_probe()
1568 thermal->chip->initialize(thermal->grf, thermal->regs, in rockchip_thermal_probe()
1569 thermal->tshut_polarity); in rockchip_thermal_probe()
1571 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_probe()
1572 error = rockchip_thermal_register_sensor(pdev, thermal, in rockchip_thermal_probe()
1573 &thermal->sensors[i], in rockchip_thermal_probe()
1574 thermal->chip->chn_offset + i); in rockchip_thermal_probe()
1583 "rockchip_thermal", thermal); in rockchip_thermal_probe()
1588 thermal->chip->control(thermal->regs, true); in rockchip_thermal_probe()
1590 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_probe()
1591 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); in rockchip_thermal_probe()
1592 error = thermal_add_hwmon_sysfs(thermal->sensors[i].tzd); in rockchip_thermal_probe()
1599 platform_set_drvdata(pdev, thermal); in rockchip_thermal_probe()
1606 struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev); in rockchip_thermal_remove() local
1609 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_remove()
1610 struct rockchip_thermal_sensor *sensor = &thermal->sensors[i]; in rockchip_thermal_remove()
1616 thermal->chip->control(thermal->regs, false); in rockchip_thermal_remove()
1621 struct rockchip_thermal_data *thermal = dev_get_drvdata(dev); in rockchip_thermal_suspend() local
1624 for (i = 0; i < thermal->chip->chn_num; i++) in rockchip_thermal_suspend()
1625 rockchip_thermal_toggle_sensor(&thermal->sensors[i], false); in rockchip_thermal_suspend()
1627 thermal->chip->control(thermal->regs, false); in rockchip_thermal_suspend()
1629 clk_disable(thermal->pclk); in rockchip_thermal_suspend()
1630 clk_disable(thermal->clk); in rockchip_thermal_suspend()
1639 struct rockchip_thermal_data *thermal = dev_get_drvdata(dev); in rockchip_thermal_resume() local
1643 error = clk_enable(thermal->clk); in rockchip_thermal_resume()
1647 error = clk_enable(thermal->pclk); in rockchip_thermal_resume()
1649 clk_disable(thermal->clk); in rockchip_thermal_resume()
1653 rockchip_thermal_reset_controller(thermal->reset); in rockchip_thermal_resume()
1655 thermal->chip->initialize(thermal->grf, thermal->regs, in rockchip_thermal_resume()
1656 thermal->tshut_polarity); in rockchip_thermal_resume()
1658 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_resume()
1659 int id = thermal->sensors[i].id; in rockchip_thermal_resume()
1661 thermal->chip->set_tshut_mode(id, thermal->regs, in rockchip_thermal_resume()
1662 thermal->tshut_mode); in rockchip_thermal_resume()
1664 error = thermal->chip->set_tshut_temp(&thermal->chip->table, in rockchip_thermal_resume()
1665 id, thermal->regs, in rockchip_thermal_resume()
1666 thermal->tshut_temp); in rockchip_thermal_resume()
1669 __func__, thermal->tshut_temp, error); in rockchip_thermal_resume()
1672 thermal->chip->control(thermal->regs, true); in rockchip_thermal_resume()
1674 for (i = 0; i < thermal->chip->chn_num; i++) in rockchip_thermal_resume()
1675 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); in rockchip_thermal_resume()
1687 .name = "rockchip-thermal",
1697 MODULE_DESCRIPTION("ROCKCHIP THERMAL Driver");
1700 MODULE_ALIAS("platform:rockchip-thermal");