Lines Matching refs:thermal

115 	struct rockchip_thermal_data *thermal;  member
504 struct rockchip_thermal_data *thermal = dev; in rockchip_thermal_alarm_irq_thread() local
507 dev_dbg(&thermal->pdev->dev, "thermal alarm\n"); in rockchip_thermal_alarm_irq_thread()
509 thermal->chip->irq_ack(thermal->regs); in rockchip_thermal_alarm_irq_thread()
511 for (i = 0; i < thermal->chip->chn_num; i++) in rockchip_thermal_alarm_irq_thread()
512 thermal_zone_device_update(thermal->sensors[i].tzd); in rockchip_thermal_alarm_irq_thread()
520 struct rockchip_thermal_data *thermal = sensor->thermal; in rockchip_thermal_get_temp() local
521 const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip; in rockchip_thermal_get_temp()
525 sensor->id, thermal->regs, out_temp); in rockchip_thermal_get_temp()
526 dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %d, retval: %d\n", in rockchip_thermal_get_temp()
538 struct rockchip_thermal_data *thermal) in rockchip_configure_from_dt() argument
545 thermal->chip->tshut_temp); in rockchip_configure_from_dt()
546 thermal->tshut_temp = thermal->chip->tshut_temp; in rockchip_configure_from_dt()
553 thermal->tshut_temp = shut_temp; in rockchip_configure_from_dt()
559 thermal->chip->tshut_mode == TSHUT_MODE_GPIO ? in rockchip_configure_from_dt()
561 thermal->tshut_mode = thermal->chip->tshut_mode; in rockchip_configure_from_dt()
563 thermal->tshut_mode = tshut_mode; in rockchip_configure_from_dt()
566 if (thermal->tshut_mode > 1) { in rockchip_configure_from_dt()
568 thermal->tshut_mode); in rockchip_configure_from_dt()
576 thermal->chip->tshut_polarity == TSHUT_LOW_ACTIVE ? in rockchip_configure_from_dt()
578 thermal->tshut_polarity = thermal->chip->tshut_polarity; in rockchip_configure_from_dt()
580 thermal->tshut_polarity = tshut_polarity; in rockchip_configure_from_dt()
583 if (thermal->tshut_polarity > 1) { in rockchip_configure_from_dt()
585 thermal->tshut_polarity); in rockchip_configure_from_dt()
594 struct rockchip_thermal_data *thermal, in rockchip_thermal_register_sensor() argument
598 const struct rockchip_tsadc_chip *tsadc = thermal->chip; in rockchip_thermal_register_sensor()
601 tsadc->set_tshut_mode(id, thermal->regs, thermal->tshut_mode); in rockchip_thermal_register_sensor()
602 tsadc->set_tshut_temp(tsadc->table, id, thermal->regs, in rockchip_thermal_register_sensor()
603 thermal->tshut_temp); in rockchip_thermal_register_sensor()
605 sensor->thermal = thermal; in rockchip_thermal_register_sensor()
632 struct rockchip_thermal_data *thermal; in rockchip_thermal_probe() local
649 thermal = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_thermal_data), in rockchip_thermal_probe()
651 if (!thermal) in rockchip_thermal_probe()
654 thermal->pdev = pdev; in rockchip_thermal_probe()
656 thermal->chip = (const struct rockchip_tsadc_chip *)match->data; in rockchip_thermal_probe()
657 if (!thermal->chip) in rockchip_thermal_probe()
661 thermal->regs = devm_ioremap_resource(&pdev->dev, res); in rockchip_thermal_probe()
662 if (IS_ERR(thermal->regs)) in rockchip_thermal_probe()
663 return PTR_ERR(thermal->regs); in rockchip_thermal_probe()
665 thermal->reset = devm_reset_control_get(&pdev->dev, "tsadc-apb"); in rockchip_thermal_probe()
666 if (IS_ERR(thermal->reset)) { in rockchip_thermal_probe()
667 error = PTR_ERR(thermal->reset); in rockchip_thermal_probe()
672 thermal->clk = devm_clk_get(&pdev->dev, "tsadc"); in rockchip_thermal_probe()
673 if (IS_ERR(thermal->clk)) { in rockchip_thermal_probe()
674 error = PTR_ERR(thermal->clk); in rockchip_thermal_probe()
679 thermal->pclk = devm_clk_get(&pdev->dev, "apb_pclk"); in rockchip_thermal_probe()
680 if (IS_ERR(thermal->pclk)) { in rockchip_thermal_probe()
681 error = PTR_ERR(thermal->pclk); in rockchip_thermal_probe()
687 error = clk_prepare_enable(thermal->clk); in rockchip_thermal_probe()
694 error = clk_prepare_enable(thermal->pclk); in rockchip_thermal_probe()
700 rockchip_thermal_reset_controller(thermal->reset); in rockchip_thermal_probe()
702 error = rockchip_configure_from_dt(&pdev->dev, np, thermal); in rockchip_thermal_probe()
709 thermal->chip->initialize(thermal->regs, thermal->tshut_polarity); in rockchip_thermal_probe()
711 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_probe()
712 error = rockchip_thermal_register_sensor(pdev, thermal, in rockchip_thermal_probe()
713 &thermal->sensors[i], in rockchip_thermal_probe()
714 thermal->chip->chn_id[i]); in rockchip_thermal_probe()
721 thermal->sensors[j].tzd); in rockchip_thermal_probe()
729 "rockchip_thermal", thermal); in rockchip_thermal_probe()
736 thermal->chip->control(thermal->regs, true); in rockchip_thermal_probe()
738 for (i = 0; i < thermal->chip->chn_num; i++) in rockchip_thermal_probe()
739 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); in rockchip_thermal_probe()
741 platform_set_drvdata(pdev, thermal); in rockchip_thermal_probe()
748 thermal->sensors[i].tzd); in rockchip_thermal_probe()
751 clk_disable_unprepare(thermal->pclk); in rockchip_thermal_probe()
753 clk_disable_unprepare(thermal->clk); in rockchip_thermal_probe()
760 struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev); in rockchip_thermal_remove() local
763 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_remove()
764 struct rockchip_thermal_sensor *sensor = &thermal->sensors[i]; in rockchip_thermal_remove()
770 thermal->chip->control(thermal->regs, false); in rockchip_thermal_remove()
772 clk_disable_unprepare(thermal->pclk); in rockchip_thermal_remove()
773 clk_disable_unprepare(thermal->clk); in rockchip_thermal_remove()
781 struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev); in rockchip_thermal_suspend() local
784 for (i = 0; i < thermal->chip->chn_num; i++) in rockchip_thermal_suspend()
785 rockchip_thermal_toggle_sensor(&thermal->sensors[i], false); in rockchip_thermal_suspend()
787 thermal->chip->control(thermal->regs, false); in rockchip_thermal_suspend()
789 clk_disable(thermal->pclk); in rockchip_thermal_suspend()
790 clk_disable(thermal->clk); in rockchip_thermal_suspend()
800 struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev); in rockchip_thermal_resume() local
804 error = clk_enable(thermal->clk); in rockchip_thermal_resume()
808 error = clk_enable(thermal->pclk); in rockchip_thermal_resume()
812 rockchip_thermal_reset_controller(thermal->reset); in rockchip_thermal_resume()
814 thermal->chip->initialize(thermal->regs, thermal->tshut_polarity); in rockchip_thermal_resume()
816 for (i = 0; i < thermal->chip->chn_num; i++) { in rockchip_thermal_resume()
817 int id = thermal->sensors[i].id; in rockchip_thermal_resume()
819 thermal->chip->set_tshut_mode(id, thermal->regs, in rockchip_thermal_resume()
820 thermal->tshut_mode); in rockchip_thermal_resume()
821 thermal->chip->set_tshut_temp(thermal->chip->table, in rockchip_thermal_resume()
822 id, thermal->regs, in rockchip_thermal_resume()
823 thermal->tshut_temp); in rockchip_thermal_resume()
826 thermal->chip->control(thermal->regs, true); in rockchip_thermal_resume()
828 for (i = 0; i < thermal->chip->chn_num; i++) in rockchip_thermal_resume()
829 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); in rockchip_thermal_resume()