Lines Matching refs:thermal
73 struct rockchip_thermal_data *thermal; member
356 struct rockchip_thermal_data *thermal = dev; in rockchip_thermal_alarm_irq_thread() local
359 dev_dbg(&thermal->pdev->dev, "thermal alarm\n"); in rockchip_thermal_alarm_irq_thread()
361 thermal->chip->irq_ack(thermal->regs); in rockchip_thermal_alarm_irq_thread()
363 for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++) in rockchip_thermal_alarm_irq_thread()
364 thermal_zone_device_update(thermal->sensors[i].tzd); in rockchip_thermal_alarm_irq_thread()
372 struct rockchip_thermal_data *thermal = sensor->thermal; in rockchip_thermal_get_temp() local
373 const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip; in rockchip_thermal_get_temp()
376 retval = tsadc->get_temp(sensor->id, thermal->regs, out_temp); in rockchip_thermal_get_temp()
377 dev_dbg(&thermal->pdev->dev, "sensor %d - temp: %ld, retval: %d\n", in rockchip_thermal_get_temp()
389 struct rockchip_thermal_data *thermal) in rockchip_configure_from_dt() argument
396 thermal->chip->tshut_temp); in rockchip_configure_from_dt()
397 thermal->tshut_temp = thermal->chip->tshut_temp; in rockchip_configure_from_dt()
399 thermal->tshut_temp = shut_temp; in rockchip_configure_from_dt()
402 if (thermal->tshut_temp > INT_MAX) { in rockchip_configure_from_dt()
404 thermal->tshut_temp); in rockchip_configure_from_dt()
411 thermal->chip->tshut_mode == TSHUT_MODE_GPIO ? in rockchip_configure_from_dt()
413 thermal->tshut_mode = thermal->chip->tshut_mode; in rockchip_configure_from_dt()
415 thermal->tshut_mode = tshut_mode; in rockchip_configure_from_dt()
418 if (thermal->tshut_mode > 1) { in rockchip_configure_from_dt()
420 thermal->tshut_mode); in rockchip_configure_from_dt()
428 thermal->chip->tshut_polarity == TSHUT_LOW_ACTIVE ? in rockchip_configure_from_dt()
430 thermal->tshut_polarity = thermal->chip->tshut_polarity; in rockchip_configure_from_dt()
432 thermal->tshut_polarity = tshut_polarity; in rockchip_configure_from_dt()
435 if (thermal->tshut_polarity > 1) { in rockchip_configure_from_dt()
437 thermal->tshut_polarity); in rockchip_configure_from_dt()
446 struct rockchip_thermal_data *thermal, in rockchip_thermal_register_sensor() argument
450 const struct rockchip_tsadc_chip *tsadc = thermal->chip; in rockchip_thermal_register_sensor()
453 tsadc->set_tshut_mode(id, thermal->regs, thermal->tshut_mode); in rockchip_thermal_register_sensor()
454 tsadc->set_tshut_temp(id, thermal->regs, thermal->tshut_temp); in rockchip_thermal_register_sensor()
456 sensor->thermal = thermal; in rockchip_thermal_register_sensor()
483 struct rockchip_thermal_data *thermal; in rockchip_thermal_probe() local
500 thermal = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_thermal_data), in rockchip_thermal_probe()
502 if (!thermal) in rockchip_thermal_probe()
505 thermal->pdev = pdev; in rockchip_thermal_probe()
507 thermal->chip = (const struct rockchip_tsadc_chip *)match->data; in rockchip_thermal_probe()
508 if (!thermal->chip) in rockchip_thermal_probe()
512 thermal->regs = devm_ioremap_resource(&pdev->dev, res); in rockchip_thermal_probe()
513 if (IS_ERR(thermal->regs)) in rockchip_thermal_probe()
514 return PTR_ERR(thermal->regs); in rockchip_thermal_probe()
516 thermal->reset = devm_reset_control_get(&pdev->dev, "tsadc-apb"); in rockchip_thermal_probe()
517 if (IS_ERR(thermal->reset)) { in rockchip_thermal_probe()
518 error = PTR_ERR(thermal->reset); in rockchip_thermal_probe()
523 thermal->clk = devm_clk_get(&pdev->dev, "tsadc"); in rockchip_thermal_probe()
524 if (IS_ERR(thermal->clk)) { in rockchip_thermal_probe()
525 error = PTR_ERR(thermal->clk); in rockchip_thermal_probe()
530 thermal->pclk = devm_clk_get(&pdev->dev, "apb_pclk"); in rockchip_thermal_probe()
531 if (IS_ERR(thermal->pclk)) { in rockchip_thermal_probe()
532 error = PTR_ERR(thermal->pclk); in rockchip_thermal_probe()
538 error = clk_prepare_enable(thermal->clk); in rockchip_thermal_probe()
545 error = clk_prepare_enable(thermal->pclk); in rockchip_thermal_probe()
551 rockchip_thermal_reset_controller(thermal->reset); in rockchip_thermal_probe()
553 error = rockchip_configure_from_dt(&pdev->dev, np, thermal); in rockchip_thermal_probe()
560 thermal->chip->initialize(thermal->regs, thermal->tshut_polarity); in rockchip_thermal_probe()
562 error = rockchip_thermal_register_sensor(pdev, thermal, in rockchip_thermal_probe()
563 &thermal->sensors[0], in rockchip_thermal_probe()
571 error = rockchip_thermal_register_sensor(pdev, thermal, in rockchip_thermal_probe()
572 &thermal->sensors[1], in rockchip_thermal_probe()
583 "rockchip_thermal", thermal); in rockchip_thermal_probe()
590 thermal->chip->control(thermal->regs, true); in rockchip_thermal_probe()
592 for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++) in rockchip_thermal_probe()
593 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); in rockchip_thermal_probe()
595 platform_set_drvdata(pdev, thermal); in rockchip_thermal_probe()
600 thermal_zone_of_sensor_unregister(&pdev->dev, thermal->sensors[1].tzd); in rockchip_thermal_probe()
602 thermal_zone_of_sensor_unregister(&pdev->dev, thermal->sensors[0].tzd); in rockchip_thermal_probe()
604 clk_disable_unprepare(thermal->pclk); in rockchip_thermal_probe()
606 clk_disable_unprepare(thermal->clk); in rockchip_thermal_probe()
613 struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev); in rockchip_thermal_remove() local
616 for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++) { in rockchip_thermal_remove()
617 struct rockchip_thermal_sensor *sensor = &thermal->sensors[i]; in rockchip_thermal_remove()
623 thermal->chip->control(thermal->regs, false); in rockchip_thermal_remove()
625 clk_disable_unprepare(thermal->pclk); in rockchip_thermal_remove()
626 clk_disable_unprepare(thermal->clk); in rockchip_thermal_remove()
634 struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev); in rockchip_thermal_suspend() local
637 for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++) in rockchip_thermal_suspend()
638 rockchip_thermal_toggle_sensor(&thermal->sensors[i], false); in rockchip_thermal_suspend()
640 thermal->chip->control(thermal->regs, false); in rockchip_thermal_suspend()
642 clk_disable(thermal->pclk); in rockchip_thermal_suspend()
643 clk_disable(thermal->clk); in rockchip_thermal_suspend()
651 struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev); in rockchip_thermal_resume() local
655 error = clk_enable(thermal->clk); in rockchip_thermal_resume()
659 error = clk_enable(thermal->pclk); in rockchip_thermal_resume()
663 rockchip_thermal_reset_controller(thermal->reset); in rockchip_thermal_resume()
665 thermal->chip->initialize(thermal->regs, thermal->tshut_polarity); in rockchip_thermal_resume()
667 for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++) { in rockchip_thermal_resume()
668 enum sensor_id id = thermal->sensors[i].id; in rockchip_thermal_resume()
670 thermal->chip->set_tshut_mode(id, thermal->regs, in rockchip_thermal_resume()
671 thermal->tshut_mode); in rockchip_thermal_resume()
672 thermal->chip->set_tshut_temp(id, thermal->regs, in rockchip_thermal_resume()
673 thermal->tshut_temp); in rockchip_thermal_resume()
676 thermal->chip->control(thermal->regs, true); in rockchip_thermal_resume()
678 for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++) in rockchip_thermal_resume()
679 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); in rockchip_thermal_resume()