From 2538f2e40bc3eea4dc3a9ca57a1349e5cef14b76 Mon Sep 17 00:00:00 2001 From: Eunseok Choi Date: Mon, 4 Dec 2017 23:31:03 +0900 Subject: [PATCH] [9810] thermal: samsung: skip CP cold temp margin during suspend skip CP cold temp margin during suspend when CP is on data call. Change-Id: I94fa4c20478a191123dbeed13c4d70aae85c65ce Signed-off-by: Eunseok Choi --- drivers/thermal/samsung/exynos_acpm_tmu.c | 6 +++- drivers/thermal/samsung/exynos_acpm_tmu.h | 2 +- drivers/thermal/samsung/exynos_tmu.c | 34 +++++++++++++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/samsung/exynos_acpm_tmu.c b/drivers/thermal/samsung/exynos_acpm_tmu.c index e03707a59858..df62b800eea5 100644 --- a/drivers/thermal/samsung/exynos_acpm_tmu.c +++ b/drivers/thermal/samsung/exynos_acpm_tmu.c @@ -155,7 +155,7 @@ int exynos_acpm_tmu_set_read_temp(int tz, int *temp, int *stat) /* * TMU_IPC_AP_SUSPEND */ -int exynos_acpm_tmu_set_suspend(void) +int exynos_acpm_tmu_set_suspend(int flag) { struct ipc_config config; union tmu_ipc_message message; @@ -165,6 +165,7 @@ int exynos_acpm_tmu_set_suspend(void) memset(&message, 0, sizeof(message)); message.req.type = TMU_IPC_AP_SUSPEND; + message.req.rsvd = flag; config.cmd = message.data; config.response = true; @@ -263,6 +264,9 @@ int exynos_acpm_tmu_set_resume(void) message.data[3]); } + pr_info("%s: acpm irq %d cold cnt %d stat %d\n", + __func__, message.resp.rsvd2, message.resp.rsvd, message.resp.stat); + return 0; } diff --git a/drivers/thermal/samsung/exynos_acpm_tmu.h b/drivers/thermal/samsung/exynos_acpm_tmu.h index 99607087c150..8d56742d3de7 100644 --- a/drivers/thermal/samsung/exynos_acpm_tmu.h +++ b/drivers/thermal/samsung/exynos_acpm_tmu.h @@ -109,7 +109,7 @@ struct acpm_tmu_cap { int exynos_acpm_tmu_set_init(struct acpm_tmu_cap *cap); int exynos_acpm_tmu_set_read_temp(int tz, int *temp, int *stat); -int exynos_acpm_tmu_set_suspend(void); +int exynos_acpm_tmu_set_suspend(int flag); int exynos_acpm_tmu_set_cp_call(void); int exynos_acpm_tmu_set_resume(void); int exynos_acpm_tmu_ipc_dump(int no, unsigned int dump[]); diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 1664042f4cb7..a5d8cdae9e0c 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -58,6 +58,9 @@ #include "exynos_acpm_tmu.h" #include "soc/samsung/exynos-pmu.h" #endif +#ifdef CONFIG_SOC_EXYNOS9810 +#include "linux/mcu_ipc.h" +#endif /* Exynos generic registers */ #define EXYNOS_TMU_REG_TRIMINFO7_0(p) (((p) - 0) * 4) @@ -192,8 +195,28 @@ static bool is_aud_on(void) exynos_pmu_read(PMUREG_AUD_STATUS, &val); + pr_info("%s AUD_STATUS %d\n", __func__, val); + return ((val & 0xf) == 0xf); } + +#ifdef CONFIG_SOC_EXYNOS9810 +#define CP_MBOX_NUM 3 +#define CP_MBOX_MASK 1 +#define CP_MBOX_SHIFT 25 +static bool is_cp_net_conn(void) +{ + unsigned int val; + + val = mbox_extract_value(MCU_CP, CP_MBOX_NUM, CP_MBOX_MASK, CP_MBOX_SHIFT); + + pr_info("%s CP mobx value %d\n", __func__, val); + + return !!val; +} +#else +#define is_cp_net_conn() false +#endif #else static bool suspended; static DEFINE_MUTEX (thermal_suspend_lock); @@ -1540,6 +1563,7 @@ static int exynos_tmu_suspend(struct device *dev) #ifdef CONFIG_EXYNOS_ACPM_THERMAL struct platform_device *pdev = to_platform_device(dev); struct exynos_tmu_data *data = platform_get_drvdata(pdev); + int cp_state; suspended_count++; disable_irq(data->irq); @@ -1548,13 +1572,14 @@ static int exynos_tmu_suspend(struct device *dev) if (cp_call_mode) { if (suspended_count == num_of_devices) { exynos_acpm_tmu_set_cp_call(); - pr_info("%s: TMU suspend w/ AUD-on complete\n", __func__); + pr_info("%s: TMU suspend w/ AUD-on\n", __func__); } } else { exynos_tmu_control(pdev, false); if (suspended_count == num_of_devices) { - exynos_acpm_tmu_set_suspend(); - pr_info("%s: TMU suspend complete\n", __func__); + cp_state = is_cp_net_conn(); + exynos_acpm_tmu_set_suspend(cp_state); + pr_info("%s: TMU suspend w/ cp_state %d\n", __func__, cp_state); } } #else @@ -1581,6 +1606,9 @@ static int exynos_tmu_resume(struct device *dev) exynos_acpm_tmu_set_read_temp(data->tzd->id, &temp, &stat); + pr_info("%s: thermal zone %d temp %d stat %d\n", + __func__, data->tzd->id, temp, stat); + enable_irq(data->irq); suspended_count--; -- 2.20.1