From: Eunseok Choi Date: Tue, 16 May 2017 14:48:00 +0000 (+0900) Subject: [COMMON] thermal: samsung: add CP call test mode X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=96d35e1f2cb0bfe1520c31efe60e055db2a810c6;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] thermal: samsung: add CP call test mode Change-Id: Ieb22673b09d36a09f0e3dd1d86981f098a370ece Signed-off-by: Eunseok Choi --- diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig index b79c19a3a497..a98e060a59b1 100644 --- a/drivers/thermal/samsung/Kconfig +++ b/drivers/thermal/samsung/Kconfig @@ -15,3 +15,11 @@ config EXYNOS_ACPM_THERMAL depends on EXYNOS_THERMAL help This feature supports ACPM TMU plug-in for Exynos thermal driver. + +config EXYNOS_THERMAL_DEBUG + bool + prompt "Exynos thermal debug support" + depends on DEBUG_FS + depends on EXYNOS_THERMAL + help + Create debugfs for debugging exynos thermal diff --git a/drivers/thermal/samsung/exynos_acpm_tmu.c b/drivers/thermal/samsung/exynos_acpm_tmu.c index 6bb47304d105..dbe2aa431a6b 100644 --- a/drivers/thermal/samsung/exynos_acpm_tmu.c +++ b/drivers/thermal/samsung/exynos_acpm_tmu.c @@ -34,6 +34,20 @@ static bool cold_comp; static unsigned int acpm_tmu_ch_num, acpm_tmu_size; +#ifdef CONFIG_EXYNOS_THERMAL_DEBUG +static bool acpm_tmu_test_mode; + +bool exynos_acpm_tmu_is_test_mode(void) +{ + return acpm_tmu_test_mode; +} + +void exynos_acpm_tmu_set_test_mode(bool mode) +{ + acpm_tmu_test_mode = mode; +} +#endif + #define acpm_ipc_err_check() \ do { \ if (ret < 0) { \ @@ -102,6 +116,11 @@ int exynos_acpm_tmu_set_read_temp(int tz, int *cur_temp) *cur_temp = 0; +#ifdef CONFIG_EXYNOS_THERMAL_DEBUG + if (acpm_tmu_test_mode) + return -1; +#endif + memset(&message, 0, sizeof(message)); message.req.type = TMU_IPC_READ_TEMP; @@ -154,6 +173,13 @@ int exynos_acpm_tmu_set_suspend(void) acpm_ipc_latency_check(); memcpy(message.data, config.cmd, sizeof(message.data)); +#ifdef CONFIG_EXYNOS_THERMAL_DEBUG + pr_info("[acpm_tmu] data 0:0x%08x 1:0x%08x 2:0x%08x 3:0x%08x\n", + message.data[0], + message.data[1], + message.data[2], + message.data[3]); +#endif cold_comp = message.resp.cold; @@ -187,6 +213,13 @@ int exynos_acpm_tmu_set_cp_call(void) acpm_ipc_latency_check(); memcpy(&message.data, config.cmd, sizeof(message.data)); +#ifdef CONFIG_EXYNOS_THERMAL_DEBUG + pr_info("[acpm_tmu] data 0:0x%08x 1:0x%08x 2:0x%08x 3:0x%08x\n", + message.data[0], + message.data[1], + message.data[2], + message.data[3]); +#endif return 0; } @@ -218,6 +251,13 @@ int exynos_acpm_tmu_set_resume(void) acpm_ipc_latency_check(); memcpy(&message.data, config.cmd, sizeof(message.data)); +#ifdef CONFIG_EXYNOS_THERMAL_DEBUG + pr_info("[acpm_tmu] data 0:0x%08x 1:0x%08x 2:0x%08x 3:0x%08x\n", + message.data[0], + message.data[1], + message.data[2], + message.data[3]); +#endif return 0; } diff --git a/drivers/thermal/samsung/exynos_acpm_tmu.h b/drivers/thermal/samsung/exynos_acpm_tmu.h index a7cee98b85cd..a44cae459a5b 100644 --- a/drivers/thermal/samsung/exynos_acpm_tmu.h +++ b/drivers/thermal/samsung/exynos_acpm_tmu.h @@ -112,6 +112,7 @@ int exynos_acpm_tmu_set_read_temp(int tz, int *temp); int exynos_acpm_tmu_set_suspend(void); int exynos_acpm_tmu_set_cp_call(void); int exynos_acpm_tmu_set_resume(void); +bool exynos_acpm_tmu_is_test_mode(void); void exynos_acpm_tmu_set_test_mode(bool mode); #endif /* __EXYNOS_ACPM_TMU_H__ */ diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index c99b03f9b861..34b4f70f8c19 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -2312,6 +2313,75 @@ static struct platform_driver exynos_tmu_driver = { module_platform_driver(exynos_tmu_driver); +#ifdef CONFIG_EXYNOS_THERMAL_DEBUG +#ifdef CONFIG_EXYNOS_ACPM_THERMAL +static void exynos_acpm_tmu_test_cp_call(bool mode) +{ + struct exynos_tmu_data *devnode; + + if (mode) { + list_for_each_entry(devnode, &dtm_dev_list, node) { + disable_irq(devnode->irq); + } + exynos_acpm_tmu_set_cp_call(); + } else { + exynos_acpm_tmu_set_resume(); + list_for_each_entry(devnode, &dtm_dev_list, node) { + enable_irq(devnode->irq); + } + } +} + +static ssize_t test_cp_call_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + ssize_t len; + char buf[32]; + + len = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); + if (len < 0) + return len; + + buf[len] = '\0'; + + if (buf[0] == '1' && exynos_acpm_tmu_is_test_mode() == false) { + exynos_acpm_tmu_set_test_mode(true); + exynos_acpm_tmu_test_cp_call(true); + } else if (buf[0] == '0' && exynos_acpm_tmu_is_test_mode() == true) { + exynos_acpm_tmu_set_test_mode(false); + exynos_acpm_tmu_test_cp_call(false); + } else + return -EINVAL; + + return len; +} + +static const struct file_operations test_cp_call_ops = { + .open = simple_open, + .write = test_cp_call_write, + .llseek = default_llseek, +}; +#endif + +static struct dentry *debugfs_root; + +static int exynos_thermal_create_debugfs(void) +{ + debugfs_root = debugfs_create_dir("exynos-thermal", NULL); + if (!debugfs_root) { + pr_err("Failed to create exynos thermal debugfs\n"); + return 0; + } + +#ifdef CONFIG_EXYNOS_ACPM_THERMAL + debugfs_create_file("test_cp_call", 0x200, debugfs_root, NULL, &test_cp_call_ops); + pr_info("Created exynos thermal debugfs\n"); +#endif + return 0; +} +arch_initcall(exynos_thermal_create_debugfs); +#endif + MODULE_DESCRIPTION("EXYNOS TMU Driver"); MODULE_AUTHOR("Donggeun Kim "); MODULE_LICENSE("GPL");