soc: qcom: aoss: Add debugfs entry

It can be useful to control the different power states of various
parts of hardware for device testing. Add a debugfs node for qmp so
messages can be sent to aoss for debugging and testing purposes.

Change-Id: I8a147461c550e3b3a54ce168ffaf42a086a5c420
Signed-off-by: Chris Lew <clew@codeaurora.org>
Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>
This commit is contained in:
Deepak Kumar Singh 2021-08-16 17:09:14 +05:30 committed by Chris Lew
parent 175bec148a
commit f513b883da

View File

@ -3,6 +3,7 @@
* Copyright (c) 2019, Linaro Ltd
*/
#include <linux/clk-provider.h>
#include <linux/debugfs.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/mailbox_client.h>
@ -82,6 +83,9 @@ struct qmp {
struct clk_hw qdss_clk;
struct qmp_cooling_device *cooling_devs;
#if IS_ENABLED(CONFIG_DEBUG_FS)
struct dentry *debugfs_file;
#endif /* CONFIG_DEBUG_FS */
};
static void qmp_kick(struct qmp *qmp)
@ -474,6 +478,32 @@ void qmp_put(struct qmp *qmp)
}
EXPORT_SYMBOL(qmp_put);
#if IS_ENABLED(CONFIG_DEBUG_FS)
static ssize_t aoss_dbg_write(struct file *file, const char __user *userstr,
size_t len, loff_t *pos)
{
struct qmp *qmp = file->private_data;
char buf[QMP_MSG_LEN] = {};
int ret;
if (!len || len >= QMP_MSG_LEN)
return -EINVAL;
ret = copy_from_user(buf, userstr, len);
if (ret)
return -EFAULT;
ret = qmp_send(qmp, strim(buf), QMP_MSG_LEN);
return ret ? ret : len;
}
static const struct file_operations aoss_dbg_fops = {
.open = simple_open,
.write = aoss_dbg_write,
};
#endif /* CONFIG_DEBUG_FS */
static int qmp_probe(struct platform_device *pdev)
{
struct qmp *qmp;
@ -522,6 +552,11 @@ static int qmp_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, qmp);
#if IS_ENABLED(CONFIG_DEBUG_FS)
qmp->debugfs_file = debugfs_create_file("aoss_send_message", 0220, NULL,
qmp, &aoss_dbg_fops);
#endif /* CONFIG_DEBUG_FS */
return 0;
err_close_qmp:
@ -536,6 +571,10 @@ static int qmp_remove(struct platform_device *pdev)
{
struct qmp *qmp = platform_get_drvdata(pdev);
#if IS_ENABLED(CONFIG_DEBUG_FS)
debugfs_remove(qmp->debugfs_file);
#endif /* CONFIG_DEBUG_FS */
qmp_qdss_clk_remove(qmp);
qmp_cooling_devices_remove(qmp);