From 6f808b70dcf8d8845422bc8faa9150409838d168 Mon Sep 17 00:00:00 2001 From: Eunseok Choi Date: Fri, 16 Jun 2017 17:43:06 +0900 Subject: [PATCH] [COMMON] thermal: samsung: add acpm tmu ipc dump Change-Id: Id5ed7f57e445b0e956d4f18a4ae2a3091f7e1f43 Signed-off-by: Eunseok Choi --- drivers/thermal/samsung/exynos_acpm_tmu.c | 39 +++++++++++++++ drivers/thermal/samsung/exynos_acpm_tmu.h | 1 + drivers/thermal/samsung/exynos_tmu.c | 58 +++++++++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/drivers/thermal/samsung/exynos_acpm_tmu.c b/drivers/thermal/samsung/exynos_acpm_tmu.c index 916a9d994e5a..5f90faea08d0 100644 --- a/drivers/thermal/samsung/exynos_acpm_tmu.c +++ b/drivers/thermal/samsung/exynos_acpm_tmu.c @@ -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; diff --git a/drivers/thermal/samsung/exynos_acpm_tmu.h b/drivers/thermal/samsung/exynos_acpm_tmu.h index 43c941ed3941..1243706ffe02 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); +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); diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 4215d6a8b032..7e94ccdb23d3 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -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; } -- 2.20.1