[COMMON] thermal: samsung: suppress acpm tmu log
authorEunseok Choi <es10.choi@samsung.com>
Wed, 24 May 2017 15:33:03 +0000 (00:33 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:18:51 +0000 (17:18 +0900)
Change-Id: I8f749ef443c468ff53a63b4d3c86f086bfa280ce
Signed-off-by: Eunseok Choi <es10.choi@samsung.com>
drivers/thermal/samsung/exynos_acpm_tmu.c
drivers/thermal/samsung/exynos_acpm_tmu.h
drivers/thermal/samsung/exynos_tmu.c

index dbe2aa431a6b7862a8664e271aa976784f476b01..0e6bdb7e82c4e7e16782d1e47110ef943e0c8f20 100644 (file)
@@ -36,6 +36,7 @@ static unsigned int acpm_tmu_ch_num, acpm_tmu_size;
 
 #ifdef CONFIG_EXYNOS_THERMAL_DEBUG
 static bool acpm_tmu_test_mode;
+static bool acpm_tmu_log;
 
 bool exynos_acpm_tmu_is_test_mode(void)
 {
@@ -46,22 +47,28 @@ void exynos_acpm_tmu_set_test_mode(bool mode)
 {
        acpm_tmu_test_mode = mode;
 }
-#endif
 
-#define acpm_ipc_err_check() \
+void exynos_acpm_tmu_log(bool mode)
+{
+       acpm_tmu_log = mode;
+}
+
+#define acpm_ipc_latency_check() \
        do { \
-               if (ret < 0) { \
-                       pr_warn("[acpm_tmu] IPC error! type 0x%02x latency %llu ns ret %d\n", \
+               if (acpm_tmu_log) { \
+                       pr_info("[acpm_tmu] type 0x%02x latency %llu ns ret %d\n", \
                                        message.req.type, latency, ret); \
-                       return -1; \
                } \
        } while (0)
 
-#define acpm_ipc_latency_check() \
+#endif
+
+#define acpm_ipc_err_check() \
        do { \
-               if (latency > 2000000) { \
-                       pr_info("[acpm_tmu] type 0x%02x latency %llu ns ret %d\n", \
+               if (ret < 0) { \
+                       pr_warn("[acpm_tmu] IPC error! type 0x%02x latency %llu ns ret %d\n", \
                                        message.req.type, latency, ret); \
+                       return -1; \
                } \
        } while (0)
 
@@ -72,8 +79,10 @@ int exynos_acpm_tmu_set_init(struct acpm_tmu_cap *cap)
 {
        struct ipc_config config;
        union tmu_ipc_message message;
-       unsigned long long before, after, latency;
        int ret;
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
+       unsigned long long before, after, latency;
+#endif
 
        memset(&message, 0, sizeof(message));
 
@@ -83,10 +92,14 @@ int exynos_acpm_tmu_set_init(struct acpm_tmu_cap *cap)
        config.response = true;
        config.indirection = false;
 
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
        before = sched_clock();
+#endif
        ret = acpm_ipc_send_data(acpm_tmu_ch_num, &config);
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
        after = sched_clock();
        latency = after - before;
+#endif
 
        acpm_ipc_err_check();
        acpm_ipc_latency_check();
@@ -111,8 +124,10 @@ int exynos_acpm_tmu_set_read_temp(int tz, int *cur_temp)
 {
        struct ipc_config config;
        union tmu_ipc_message message;
-       unsigned long long before, after, latency;
        int ret;
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
+       unsigned long long before, after, latency;
+#endif
 
        *cur_temp = 0;
 
@@ -130,15 +145,28 @@ int exynos_acpm_tmu_set_read_temp(int tz, int *cur_temp)
        config.response = true;
        config.indirection = false;
 
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
        before = sched_clock();
+#endif
        ret = acpm_ipc_send_data(acpm_tmu_ch_num, &config);
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
        after = sched_clock();
        latency = after - before;
+#endif
 
        acpm_ipc_err_check();
        acpm_ipc_latency_check();
 
        memcpy(message.data, config.cmd, sizeof(message.data));
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
+       if (acpm_tmu_log) {
+               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;
        *cur_temp = message.resp.temp;
@@ -153,8 +181,10 @@ int exynos_acpm_tmu_set_suspend(void)
 {
        struct ipc_config config;
        union tmu_ipc_message message;
-       unsigned long long before, after, latency;
        int ret;
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
+       unsigned long long before, after, latency;
+#endif
 
        memset(&message, 0, sizeof(message));
 
@@ -164,21 +194,27 @@ int exynos_acpm_tmu_set_suspend(void)
        config.response = true;
        config.indirection = false;
 
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
        before = sched_clock();
+#endif
        ret = acpm_ipc_send_data(acpm_tmu_ch_num, &config);
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
        after = sched_clock();
        latency = after - before;
+#endif
 
        acpm_ipc_err_check();
        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]);
+       if (acpm_tmu_log) {
+               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;
@@ -193,8 +229,10 @@ int exynos_acpm_tmu_set_cp_call(void)
 {
        struct ipc_config config;
        union tmu_ipc_message message;
-       unsigned long long before, after, latency;
        int ret;
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
+       unsigned long long before, after, latency;
+#endif
 
        memset(&message, 0, sizeof(message));
 
@@ -204,21 +242,27 @@ int exynos_acpm_tmu_set_cp_call(void)
        config.response = true;
        config.indirection = false;
 
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
        before = sched_clock();
+#endif
        ret = acpm_ipc_send_data(acpm_tmu_ch_num, &config);
+#ifdef CONFIG_EXYNOS_THERMAL_DEBUG
        after = sched_clock();
        latency = after - before;
+#endif
 
        acpm_ipc_err_check();
        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]);
+       if (acpm_tmu_log) {
+               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;
@@ -252,11 +296,13 @@ int exynos_acpm_tmu_set_resume(void)
 
        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]);
+       if (acpm_tmu_log) {
+               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 a44cae459a5b2b549bd94eb8f20db65ae1ba5d88..43c941ed39411f3246d7cd822c129945408fbb78 100644 (file)
@@ -114,5 +114,6 @@ 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);
+void exynos_acpm_tmu_log(bool mode);
 
 #endif /* __EXYNOS_ACPM_TMU_H__ */
index d314878f3481a3e8203dde85bc15ff3c58a7747d..00295011dfbab618b18394c9b4e6085d85bd3d34 100644 (file)
@@ -1029,6 +1029,11 @@ static int exynos9810_tmu_initialize(struct platform_device *pdev)
                        rising_threshold &= ~(EXYNOS_TMU_TEMP_MASK << bit_off);
                        rising_threshold |= threshold_code << bit_off;
                        writel(rising_threshold, data->base + reg_off);
+#ifdef TMU_DEBUG
+                       pr_info("[TMU%d:%d:%d] addr 0x%04x bit-shift %d rise 0x%08x code 0x%x temp %d\n",
+                                       data->id, sensor, i, reg_off, bit_off,
+                                       rising_threshold, threshold_code, temp);
+#endif
 
                        /* Set 9-bit temperature code for falling threshold levels */
                        threshold_code = temp_to_code_with_sensorinfo(data, temp_hist, &data->sensor_info[count]);
@@ -1036,6 +1041,11 @@ static int exynos9810_tmu_initialize(struct platform_device *pdev)
                        falling_threshold &= ~(EXYNOS_TMU_TEMP_MASK << bit_off);
                        falling_threshold |= threshold_code << bit_off;
                        writel(falling_threshold, data->base + reg_off + 0x10);
+#ifdef TMU_DEBUG
+                       pr_info("[TMU%d:%d:%d] addr 0x%04x bit-shift %d fall 0x%08x code 0x%x hyst %d\n",
+                                       data->id, sensor, i, reg_off + 0x10, bit_off,
+                                       falling_threshold, threshold_code, temp_hist);
+#endif
 
                        interrupt_count++;
                }
@@ -2369,6 +2379,34 @@ static const struct file_operations test_cp_call_ops = {
        .write = test_cp_call_write,
        .llseek = default_llseek,
 };
+
+static ssize_t acpm_tmu_log_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_log(true);
+       else if (buf[0] == '0')
+               exynos_acpm_tmu_log(false);
+       else
+               return -EINVAL;
+
+       return len;
+}
+
+static const struct file_operations acpm_tmu_log_ops = {
+       .open = simple_open,
+       .write = acpm_tmu_log_write,
+       .llseek = default_llseek,
+};
 #endif
 
 static struct dentry *debugfs_root;
@@ -2383,6 +2421,7 @@ static int exynos_thermal_create_debugfs(void)
 
 #ifdef CONFIG_EXYNOS_ACPM_THERMAL
        debugfs_create_file("test_cp_call", 0x200, debugfs_root, NULL, &test_cp_call_ops);
+       debugfs_create_file("acpm_tmu_log", 0x200, debugfs_root, NULL, &acpm_tmu_log_ops);
        pr_info("Created exynos thermal debugfs\n");
 #endif
        return 0;