From b6d5f24ad5c374ca93b6529f0b4ebe7a71ac6372 Mon Sep 17 00:00:00 2001 From: Rocky Hao Date: Wed, 28 Mar 2018 17:46:31 +0800 Subject: [PATCH] thermal: rockchip: add shutdown callback function Tsadc has a tshut pin which is designed to reset the pmic or soc, when the temperature inside soc is too high. we should switch off the tshut function and change the pin to gpio function in reboot process, eg, software reset. If not, the tsadc module will WRONGLY pull high the tshut pin during its reset process and then WRONGLY reset the pmic or soc, which incurred a hardware reset. The hardware reset will reset everything inside soc, even includes the power on reason flag, which is set by software before reboot process. we also change over-temperature protection mode to cru mode, since the tshut pin have be changed to gpio function. Change-Id: Iac3dacf55a4b5536fccd2eb05a6a9e6923a082c0 Signed-off-by: Rocky Hao Signed-off-by: Elaine Zhang --- drivers/thermal/rockchip_thermal.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index e6ad8b50310a..8f82ff0f34eb 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -1474,6 +1474,21 @@ static int rockchip_thermal_remove(struct platform_device *pdev) return 0; } +static void rockchip_thermal_shutdown(struct platform_device *pdev) +{ + struct rockchip_thermal_data *thermal = platform_get_drvdata(pdev); + int i; + + for (i = 0; i < thermal->chip->chn_num; i++) { + int id = thermal->sensors[i].id; + + if (thermal->tshut_mode != TSHUT_MODE_CRU) + thermal->chip->set_tshut_mode(id, thermal->regs, + TSHUT_MODE_CRU); + } + pinctrl_pm_select_sleep_state(&pdev->dev); +} + static int __maybe_unused rockchip_thermal_suspend(struct device *dev) { struct rockchip_thermal_data *thermal = dev_get_drvdata(dev); @@ -1548,6 +1563,7 @@ static struct platform_driver rockchip_thermal_driver = { }, .probe = rockchip_thermal_probe, .remove = rockchip_thermal_remove, + .shutdown = rockchip_thermal_shutdown, }; module_platform_driver(rockchip_thermal_driver);