From b7372154d43b1d881d29f9d78fe7fa22b75d883f 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 44dd2486496a..ae0b6008c152 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -1496,6 +1496,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 platform_device *pdev = to_platform_device(dev); @@ -1572,6 +1587,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);