[COMMON] thermal: samsung: add CP call test mode
authorEunseok Choi <es10.choi@samsung.com>
Tue, 16 May 2017 14:48:00 +0000 (23:48 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:18:48 +0000 (17:18 +0900)
Change-Id: Ieb22673b09d36a09f0e3dd1d86981f098a370ece
Signed-off-by: Eunseok Choi <es10.choi@samsung.com>
drivers/thermal/samsung/Kconfig
drivers/thermal/samsung/exynos_acpm_tmu.c
drivers/thermal/samsung/exynos_acpm_tmu.h
drivers/thermal/samsung/exynos_tmu.c

index b79c19a3a497c65bf3daa3886201d330b321c0dc..a98e060a59b14a4834b3f78986034f6135f2573a 100644 (file)
@@ -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
index 6bb47304d105f2a0a6229843d4566a8a0afad542..dbe2aa431a6b7862a8664e271aa976784f476b01 100644 (file)
 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;
 }
index a7cee98b85cdad0a4dc9889df0663a455022642f..a44cae459a5b2b549bd94eb8f20db65ae1ba5d88 100644 (file)
@@ -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__ */
index c99b03f9b861ebc6c6a8ee3ff2de27547a415104..34b4f70f8c19cde91b2baa17371ae0a557d3a702 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/gpu_cooling.h>
 #include <linux/isp_cooling.h>
 #include <linux/slab.h>
+#include <linux/debugfs.h>
 #include <linux/exynos-ss.h>
 #include <soc/samsung/tmu.h>
 #include <soc/samsung/ect_parser.h>
@@ -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 <dg77.kim@samsung.com>");
 MODULE_LICENSE("GPL");