2 * Written by Pekka Paalanen, 2008 <pq@iki.fi>
4 #include <linux/module.h>
6 #include <linux/mmiotrace.h>
8 #define MODULE_NAME "testmmiotrace"
10 static unsigned long mmio_address;
11 module_param(mmio_address, ulong, 0);
12 MODULE_PARM_DESC(mmio_address, "Start address of the mapping of 16 kB.");
14 static void do_write_test(void __iomem *p)
17 mmiotrace_printk("Write test.\n");
18 for (i = 0; i < 256; i++)
20 for (i = 1024; i < (5 * 1024); i += 2)
21 iowrite16(i * 12 + 7, p + i);
22 for (i = (5 * 1024); i < (16 * 1024); i += 4)
23 iowrite32(i * 212371 + 13, p + i);
26 static void do_read_test(void __iomem *p)
29 mmiotrace_printk("Read test.\n");
30 for (i = 0; i < 256; i++)
32 for (i = 1024; i < (5 * 1024); i += 2)
34 for (i = (5 * 1024); i < (16 * 1024); i += 4)
38 static void do_test(void)
40 void __iomem *p = ioremap_nocache(mmio_address, 0x4000);
42 pr_err(MODULE_NAME ": could not ioremap, aborting.\n");
45 mmiotrace_printk("ioremap returned %p.\n", p);
51 static int __init init(void)
53 if (mmio_address == 0) {
54 pr_err(MODULE_NAME ": you have to use the module argument "
56 pr_err(MODULE_NAME ": DO NOT LOAD THIS MODULE UNLESS"
57 " YOU REALLY KNOW WHAT YOU ARE DOING!\n");
61 pr_warning(MODULE_NAME ": WARNING: mapping 16 kB @ 0x%08lx "
62 "in PCI address space, and writing "
63 "rubbish in there.\n", mmio_address);
68 static void __exit cleanup(void)
70 pr_debug(MODULE_NAME ": unloaded.\n");
75 MODULE_LICENSE("GPL");