summaryrefslogtreecommitdiff
path: root/drivers/iommu/iommu-debug.c
diff options
context:
space:
mode:
authorMitchel Humpherys <mitchelh@codeaurora.org>2016-02-01 16:53:39 -0800
committerJeevan Shriram <jshriram@codeaurora.org>2016-05-20 19:24:03 -0700
commit0a70cf0fac2960a23bb1a21578a7e27411d34810 (patch)
tree39325b7fa3c97908cae9fa5d3c4b8c814229a223 /drivers/iommu/iommu-debug.c
parent6d871ad17d4738291d03e19ed4896ea4f4807bc7 (diff)
iommu/iommu-debug: Add debugfs file to enable config clocks
It's fairly common while debugging to need to enable the config clocks for an SMMU so that you can poke around at the registers. Add a debugfs file to do this. CRs-Fixed: 997751 Change-Id: I31b90d64c2facb0a681f9da586e2c90803776819 Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Diffstat (limited to 'drivers/iommu/iommu-debug.c')
-rw-r--r--drivers/iommu/iommu-debug.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/iommu/iommu-debug.c b/drivers/iommu/iommu-debug.c
index 55badca6b90c..a97c082d18d8 100644
--- a/drivers/iommu/iommu-debug.c
+++ b/drivers/iommu/iommu-debug.c
@@ -1830,6 +1830,53 @@ static const struct file_operations iommu_debug_unmap_fops = {
.write = iommu_debug_unmap_write,
};
+static ssize_t iommu_debug_config_clocks_write(struct file *file,
+ const char __user *ubuf,
+ size_t count, loff_t *offset)
+{
+ char buf;
+ struct iommu_debug_device *ddev = file->private_data;
+ struct device *dev = ddev->dev;
+
+ /* we're expecting a single character plus (optionally) a newline */
+ if (count > 2) {
+ dev_err(dev, "Invalid value\n");
+ return -EINVAL;
+ }
+
+ if (!ddev->domain) {
+ dev_err(dev, "No domain. Did you already attach?\n");
+ return -EINVAL;
+ }
+
+ if (copy_from_user(&buf, ubuf, 1)) {
+ dev_err(dev, "Couldn't copy from user\n");
+ return -EFAULT;
+ }
+
+ switch (buf) {
+ case '0':
+ dev_err(dev, "Disabling config clocks\n");
+ iommu_disable_config_clocks(ddev->domain);
+ break;
+ case '1':
+ dev_err(dev, "Enabling config clocks\n");
+ if (iommu_enable_config_clocks(ddev->domain))
+ dev_err(dev, "Failed!\n");
+ break;
+ default:
+ dev_err(dev, "Invalid value. Should be 0 or 1.\n");
+ return -EINVAL;
+ }
+
+ return count;
+}
+
+static const struct file_operations iommu_debug_config_clocks_fops = {
+ .open = simple_open,
+ .write = iommu_debug_config_clocks_write,
+};
+
/*
* The following will only work for drivers that implement the generic
* device tree bindings described in
@@ -1938,6 +1985,13 @@ static int snarf_iommu_devices(struct device *dev, const char *name)
goto err_rmdir;
}
+ if (!debugfs_create_file("config_clocks", S_IWUSR, dir, ddev,
+ &iommu_debug_config_clocks_fops)) {
+ pr_err("Couldn't create iommu/devices/%s/config_clocks debugfs file\n",
+ name);
+ goto err_rmdir;
+ }
+
list_add(&ddev->list, &iommu_debug_devices);
return 0;