diff options
author | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> | 2015-04-07 15:16:03 +0100 |
---|---|---|
committer | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> | 2015-04-07 15:16:03 +0100 |
commit | 8cb3a2dfb116925da331ce743b81fde4d9201267 (patch) | |
tree | 74f1432f12f73546599c317c5c7f25d15db2e33a /drivers/soc/qcom/rpm-smd-debug.c | |
parent | 0b9702eefb577338e5ee6fea30fde1487f2fa1a7 (diff) | |
parent | bf2ae3fb98a15e9ca6f947fe3a1ce0706f9ef882 (diff) |
Merge branch 'tracking-qcomlt-msm8916-smd-rpm' into integration-linux-qcomlttracking-integration-linux-qcomlt-ll-20150416.0tracking-integration-linux-qcomlt-ll-20150414.0qcomlt-v4.0-rc7
* tracking-qcomlt-msm8916-smd-rpm:
smd: perform SMD channel scanning synchronously at probe
regulator: add support for RPM SMD regulator - build fix
regulator: add support for RPM SMD regulator
soc: qcom: add RPM SMD driver
soc: qcom: add support for SMD
soc: qcom: add subsystem_restart.h header file
soc: qcom: add SMSM header file
qcom: add support for SMEM
qcom: add subsystem_notif header file
qcom: ramdump: add header file
msm: add ipc logging header
hwspinlock: msm: add hardware spinlock support
Conflicts:
drivers/soc/qcom/Kconfig
drivers/soc/qcom/Makefile
Diffstat (limited to 'drivers/soc/qcom/rpm-smd-debug.c')
-rw-r--r-- | drivers/soc/qcom/rpm-smd-debug.c | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/drivers/soc/qcom/rpm-smd-debug.c b/drivers/soc/qcom/rpm-smd-debug.c new file mode 100644 index 000000000000..c08668149636 --- /dev/null +++ b/drivers/soc/qcom/rpm-smd-debug.c @@ -0,0 +1,141 @@ +/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#define pr_fmt(fmt) "rpm-smd-debug: %s(): " fmt, __func__ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/debugfs.h> +#include <linux/list.h> +#include <linux/io.h> +#include <linux/uaccess.h> +#include <linux/slab.h> +#include <soc/qcom/rpm-smd.h> + +#define MAX_MSG_BUFFER 350 +#define MAX_KEY_VALUE_PAIRS 20 + +static struct dentry *rpm_debugfs_dir; + +static u32 string_to_uint(const u8 *str) +{ + int i, len; + u32 output = 0; + + len = strnlen(str, sizeof(u32)); + for (i = 0; i < len; i++) + output |= str[i] << (i * 8); + + return output; +} + +static ssize_t rsc_ops_write(struct file *fp, const char __user *user_buffer, + size_t count, loff_t *position) +{ + char buf[MAX_MSG_BUFFER], rsc_type_str[6] = {}, rpm_set[8] = {}, + key_str[6] = {}; + int i, pos, set = -1, nelems; + char *cmp; + uint32_t rsc_type, rsc_id, key, data; + struct msm_rpm_request *req; + + count = min(count, sizeof(buf) - 1); + if (copy_from_user(&buf, user_buffer, count)) + return -EFAULT; + buf[count] = '\0'; + cmp = strstrip(buf); + + sscanf(cmp, "%7s %5s %u %d %n", rpm_set, rsc_type_str, &rsc_id, + &nelems, &pos); + if (strlen(rpm_set) > 6 || strlen(rsc_type_str) > 4) { + pr_err("Invalid value of set or resource type\n"); + goto err; + } + + if (!strcmp(rpm_set, "active")) + set = 0; + else if (!strcmp(rpm_set, "sleep")) + set = 1; + + rsc_type = string_to_uint(rsc_type_str); + + if (set < 0 || nelems < 0) { + pr_err("Invalid value of set or nelems\n"); + goto err; + } + if (nelems > MAX_KEY_VALUE_PAIRS) { + pr_err("Exceeded max no of key-value entries\n"); + goto err; + } + + req = msm_rpm_create_request(set, rsc_type, rsc_id, nelems); + if (!req) + return -ENOMEM; + + for (i = 0; i < nelems; i++) { + cmp += pos; + sscanf(cmp, "%5s %n", key_str, &pos); + if (strlen(key_str) > 4) { + pr_err("Key value cannot be more than 4 charecters"); + goto err; + } + key = string_to_uint(key_str); + if (!key) { + pr_err("Key values entered incorrectly\n"); + goto err; + } + + cmp += pos; + sscanf(cmp, "%u %n", &data, &pos); + if (msm_rpm_add_kvp_data(req, key, + (void *)&data, sizeof(data))) + goto err_request; + } + + if (msm_rpm_wait_for_ack(msm_rpm_send_request(req))) + pr_err("Sending the RPM message failed\n"); + else + pr_info("RPM message sent succesfully\n"); + +err_request: + msm_rpm_free_request(req); +err: + return count; +} + +static const struct file_operations rsc_ops = { + .write = rsc_ops_write, +}; + +static int __init rpm_smd_debugfs_init(void) +{ + rpm_debugfs_dir = debugfs_create_dir("rpm_send_msg", NULL); + if (!rpm_debugfs_dir) + return -ENOMEM; + + if (!debugfs_create_file("message", S_IWUSR, rpm_debugfs_dir, NULL, + &rsc_ops)) + return -ENOMEM; + + return 0; +} +late_initcall(rpm_smd_debugfs_init); + +static void __exit rpm_smd_debugfs_exit(void) +{ + debugfs_remove_recursive(rpm_debugfs_dir); +} +module_exit(rpm_smd_debugfs_exit); + +MODULE_DESCRIPTION("RPM SMD Debug Driver"); +MODULE_LICENSE("GPL"); |