13 #include <linux/module.h>
17 #include <linux/slab.h>
31 static struct dentry *iommu_debug_root;
34 size_t count, loff_t *ppos)
39 p +=
sprintf(p,
"H/W version: %d.%d\n", (ver >> 4) & 0xf , ver & 0xf);
44 static ssize_t debug_read_regs(
struct file *file,
char __user *userbuf,
45 size_t count, loff_t *ppos)
48 struct omap_iommu *obj = dev_to_omap_iommu(dev);
68 static ssize_t debug_read_tlb(
struct file *file,
char __user *userbuf,
69 size_t count, loff_t *ppos)
72 struct omap_iommu *obj = dev_to_omap_iommu(dev);
83 p +=
sprintf(p,
"%8s %8s\n",
"cam:",
"ram:");
84 p +=
sprintf(p,
"-----------------------------------------\n");
85 rest = count - (p -
buf);
96 static ssize_t debug_write_pagetable(
struct file *file,
97 const char __user *userbuf,
size_t count, loff_t *ppos)
103 struct omap_iommu *obj = dev_to_omap_iommu(dev);
106 count =
min(count,
sizeof(buf));
115 if (!
cr.cam || !
cr.ram) {
123 dev_err(obj->
dev,
"%s: fail to store cr\n", __func__);
129 #define dump_ioptable_entry_one(lv, da, val) \
133 const int maxcol = 22; \
134 const char *str = "%d: %08x %08x\n"; \
135 bytes = snprintf(p, maxcol, str, lv, da, val); \
187 static ssize_t debug_read_pagetable(
struct file *file,
char __user *userbuf,
188 size_t count, loff_t *ppos)
191 struct omap_iommu *obj = dev_to_omap_iommu(dev);
200 p +=
sprintf(p,
"L: %8s %8s\n",
"da:",
"pa:");
201 p +=
sprintf(p,
"-----------------------------------------\n");
206 p += dump_ioptable(obj, p, bytes);
216 static ssize_t debug_read_mmap(
struct file *file,
char __user *userbuf,
217 size_t count, loff_t *ppos)
220 struct omap_iommu *obj = dev_to_omap_iommu(dev);
231 p +=
sprintf(p,
"%-3s %-8s %-8s %6s %8s\n",
232 "No",
"start",
"end",
"size",
"flags");
233 p +=
sprintf(p,
"-------------------------------------------------\n");
239 const char *
str =
"%3d %08x-%08x %6x %8x\n";
240 const int maxcol = 39;
259 static ssize_t debug_read_mem(
struct file *file,
char __user *userbuf,
260 size_t count, loff_t *ppos)
292 static ssize_t debug_write_mem(
struct file *file,
const char __user *userbuf,
293 size_t count, loff_t *ppos)
326 #define DEBUG_FOPS(name) \
327 static const struct file_operations debug_##name##_fops = { \
328 .open = simple_open, \
329 .read = debug_read_##name, \
330 .write = debug_write_##name, \
331 .llseek = generic_file_llseek, \
334 #define DEBUG_FOPS_RO(name) \
335 static const struct file_operations debug_##name##_fops = { \
336 .open = simple_open, \
337 .read = debug_read_##name, \
338 .llseek = generic_file_llseek, \
348 #define __DEBUG_ADD_FILE(attr, mode) \
350 struct dentry *dent; \
351 dent = debugfs_create_file(#attr, mode, parent, \
352 dev, &debug_##attr##_fops); \
357 #define DEBUG_ADD_FILE(name) __DEBUG_ADD_FILE(name, 600)
358 #define DEBUG_ADD_FILE_RO(name) __DEBUG_ADD_FILE(name, 400)
360 static int iommu_debug_register(
struct device *dev,
void *
data)
363 struct omap_iommu *obj = platform_get_drvdata(pdev);
367 if (!obj || !obj->
dev)
370 arch_data = kzalloc(
sizeof(*arch_data),
GFP_KERNEL);
402 static int iommu_debug_unregister(
struct device *dev,
void *
data)
414 static int __init iommu_debug_init(
void)
422 iommu_debug_root =
d;
435 static
void __exit iommu_debugfs_exit(
void)