[COMMON] thermal: samsung: add acpm tmu ipc dump
authorEunseok Choi <es10.choi@samsung.com>
Fri, 16 Jun 2017 08:43:06 +0000 (17:43 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:22:01 +0000 (17:22 +0900)
Change-Id: Id5ed7f57e445b0e956d4f18a4ae2a3091f7e1f43
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 916a9d994e5a8e787e6783313d4957cb78f72d48..5f90faea08d067c9796be5fc458049a5affe55da 100644 (file)
@@ -271,6 +271,45 @@ int exynos_acpm_tmu_set_resume(void)
        return 0;
 }
 
+int exynos_acpm_tmu_ipc_dump(int no, unsigned int dump[])
+{
+       struct ipc_config config;
+       union tmu_ipc_message message;
+       unsigned long long before, after, latency;
+       int ret;
+
+       memset(&message, 0, sizeof(message));
+
+       message.req.type = TMU_IPC_READ_TEMP;
+       message.req.tzid = no;
+
+       config.cmd = message.data;
+       config.response = true;
+       config.indirection = false;
+
+       before = sched_clock();
+       ret = acpm_ipc_send_data(acpm_tmu_ch_num, &config);
+       after = sched_clock();
+       latency = after - before;
+
+       acpm_ipc_err_check();
+       acpm_ipc_latency_check();
+
+       memcpy(message.data, config.cmd, sizeof(message.data));
+       if (acpm_tmu_log) {
+               pr_info("[acpm_tmu_dump] 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]);
+       }
+
+       dump[0] = message.data[2];
+       dump[1] = message.data[3];
+
+       return 0;
+}
+
 static int __init exynos_acpm_tmu_init(void)
 {
        struct device_node *np;
index 43c941ed39411f3246d7cd822c129945408fbb78..1243706ffe020444527a39e7e6535e6df7191976 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);
+int exynos_acpm_tmu_ipc_dump(int no, unsigned int dump[]);
 bool exynos_acpm_tmu_is_test_mode(void);
 void exynos_acpm_tmu_set_test_mode(bool mode);
 void exynos_acpm_tmu_log(bool mode);
index 4215d6a8b032df1b7481992b42544d1e3809b667..7e94ccdb23d3ba39feedd55500e1344c822a3388 100644 (file)
@@ -2453,6 +2453,62 @@ static const struct file_operations acpm_tmu_log_ops = {
        .write = acpm_tmu_log_write,
        .llseek = default_llseek,
 };
+
+static ssize_t ipc_dump1_read(struct file *file, char __user *user_buf,
+                                       size_t count, loff_t *ppos)
+{
+       union {
+               unsigned int dump[2];
+               unsigned char val[8];
+       } data;
+       char buf[48];
+       ssize_t ret;
+
+       exynos_acpm_tmu_ipc_dump(0, data.dump);
+
+       ret = snprintf(buf, sizeof(buf), "%3d %3d %3d %3d %3d %3d %3d\n",
+                       data.val[1], data.val[2], data.val[3],
+                       data.val[4], data.val[5], data.val[6], data.val[7]);
+       if (ret < 0)
+               return ret;
+
+       return simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+}
+
+static ssize_t ipc_dump2_read(struct file *file, char __user *user_buf,
+                                       size_t count, loff_t *ppos)
+{
+       union {
+               unsigned int dump[2];
+               unsigned char val[8];
+       } data;
+       char buf[48];
+       ssize_t ret;
+
+       exynos_acpm_tmu_ipc_dump(2, data.dump);
+
+       ret = snprintf(buf, sizeof(buf), "%3d %3d %3d %3d %3d %3d %3d\n",
+                       data.val[1], data.val[2], data.val[3],
+                       data.val[4], data.val[5], data.val[6], data.val[7]);
+       if (ret < 0)
+               return ret;
+
+       return simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+
+}
+
+static const struct file_operations ipc_dump1_fops = {
+       .open = simple_open,
+       .read = ipc_dump1_read,
+       .llseek = default_llseek,
+};
+
+static const struct file_operations ipc_dump2_fops = {
+       .open = simple_open,
+       .read = ipc_dump2_read,
+       .llseek = default_llseek,
+};
+
 #endif
 
 static struct dentry *debugfs_root;
@@ -2468,6 +2524,8 @@ 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);
+       debugfs_create_file("ipc_dump1", 0644, debugfs_root, NULL, &ipc_dump1_fops);
+       debugfs_create_file("ipc_dump2", 0644, debugfs_root, NULL, &ipc_dump2_fops);
 #endif
        return 0;
 }