From 7684b439cd207100813ed65b1671988534dca3ca Mon Sep 17 00:00:00 2001 From: Bhuvanchandra DV Date: Wed, 10 May 2017 17:57:53 +0530 Subject: colibri_t30: add warning message before reaching critical temperature Print log message before module (local) or SoC (remote) is reaching critical shutdown temperature nT_CRIT as the LM95245 temperature sensor's OVERT_N pin is directly connected to PMIC PWRDN. Signed-off-by: Bhuvanchandra DV Signed-off-by: Marcel Ziswiler --- arch/arm/mach-tegra/board-colibri_t30.c | 43 +++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-tegra/board-colibri_t30.c b/arch/arm/mach-tegra/board-colibri_t30.c index fdd2585c41bf..1a9bd6faf6a1 100644 --- a/arch/arm/mach-tegra/board-colibri_t30.c +++ b/arch/arm/mach-tegra/board-colibri_t30.c @@ -975,6 +975,11 @@ static void __init colibri_t30_spi_init(void) static void *colibri_t30_alert_data; static void (*colibri_t30_alert_func)(void *); +static int colibri_t30_crit_edge_local; +static int colibri_t30_crit_edge_remote; +static int colibri_t30_crit_hysteresis; +static int colibri_t30_crit_limit_local; +static int colibri_t30_crit_limit_remote; static int colibri_t30_low_edge; static int colibri_t30_low_hysteresis; static int colibri_t30_low_limit; @@ -1084,19 +1089,42 @@ static irqreturn_t thermd_alert_irq(int irq, void *data) /* Gets both entered by THERMD_ALERT GPIO interrupt as well as re-scheduled. */ static void thermd_alert_work_func(struct work_struct *work) { - int temp = 0; + int temp_local = 0; + int temp_remote = 0; - lm95245_get_remote_temp(lm95245_device, &temp); + lm95245_get_local_temp(lm95245_device, &temp_local); + lm95245_get_remote_temp(lm95245_device, &temp_remote); /* This emulates NCT1008 low limit behaviour */ - if (!colibri_t30_low_edge && temp <= colibri_t30_low_limit) { + if (!colibri_t30_low_edge && temp_remote <= colibri_t30_low_limit) { colibri_t30_alert_func(colibri_t30_alert_data); colibri_t30_low_edge = 1; - } else if (colibri_t30_low_edge && temp > colibri_t30_low_limit + - colibri_t30_low_hysteresis) { + } else if (colibri_t30_low_edge && temp_remote > colibri_t30_low_limit + + colibri_t30_low_hysteresis) { colibri_t30_low_edge = 0; } + if (!colibri_t30_crit_edge_local && + temp_local >= colibri_t30_crit_limit_local) { + printk(KERN_ALERT "Module reaching critical shutdown " + "temperature nT_CRIT\n"); + colibri_t30_crit_edge_local = 1; + } else if (colibri_t30_crit_edge_local && temp_local < + colibri_t30_crit_limit_local - colibri_t30_crit_hysteresis) { + colibri_t30_crit_edge_local = 0; + } + + if (!colibri_t30_crit_edge_remote && + temp_remote >= colibri_t30_crit_limit_remote) { + printk(KERN_ALERT "SoC reaching critical shutdown " + "temperature nT_CRIT\n"); + colibri_t30_crit_edge_remote = 1; + } else if (colibri_t30_crit_edge_remote && temp_remote < + colibri_t30_crit_limit_remote - colibri_t30_crit_hysteresis) + { + colibri_t30_crit_edge_remote = 0; + } + /* Avoid unbalanced enable for IRQ 367 */ if (thermd_alert_irq_disabled) { colibri_t30_alert_func(colibri_t30_alert_data); @@ -1233,6 +1261,11 @@ static void lm95245_probe_callback(struct device *dev) static void colibri_t30_thermd_alert_init(void) { + colibri_t30_crit_edge_local = 0; + colibri_t30_crit_edge_remote = 0; + colibri_t30_crit_hysteresis = 3000; + colibri_t30_crit_limit_local = 90000; + colibri_t30_crit_limit_remote = 110000; colibri_t30_low_edge = 0; colibri_t30_low_hysteresis = 3000; colibri_t30_low_limit = 0; -- cgit v1.2.3