@@ -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,7 @@ struct qmp {
struct clk_hw qdss_clk;
struct qmp_cooling_device *cooling_devs;
+ struct dentry *debugfs_file;
};
static void qmp_kick(struct qmp *qmp)
@@ -475,6 +477,32 @@ void qmp_put(struct qmp *qmp)
}
EXPORT_SYMBOL(qmp_put);
+static ssize_t qmp_debugfs_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;
+
+ if (copy_from_user(buf, userstr, len))
+ return -EFAULT;
+ buf[len] = '\0';
+
+ ret = qmp_send(qmp, buf);
+ if (ret < 0)
+ return ret;
+
+ return len;
+}
+
+static const struct file_operations qmp_debugfs_fops = {
+ .open = simple_open,
+ .write = qmp_debugfs_write,
+};
+
static int qmp_probe(struct platform_device *pdev)
{
struct qmp *qmp;
@@ -523,6 +551,9 @@ static int qmp_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, qmp);
+ qmp->debugfs_file = debugfs_create_file("aoss_send_message", 0220, NULL,
+ qmp, &qmp_debugfs_fops);
+
return 0;
err_close_qmp:
@@ -537,6 +568,8 @@ static int qmp_remove(struct platform_device *pdev)
{
struct qmp *qmp = platform_get_drvdata(pdev);
+ debugfs_remove(qmp->debugfs_file);
+
qmp_qdss_clk_remove(qmp);
qmp_cooling_devices_remove(qmp);