2 * Written by Pekka Paalanen, 2008 <pq@iki.fi>
4 #include <linux/module.h>
7 #define MODULE_NAME "testmmiotrace"
9 static unsigned long mmio_address;
10 module_param(mmio_address, ulong, 0);
11 MODULE_PARM_DESC(mmio_address, "Start address of the mapping of 16 kB.");
13 static void do_write_test(void __iomem *p)
16 for (i = 0; i < 256; i++)
18 for (i = 1024; i < (5 * 1024); i += 2)
19 iowrite16(i * 12 + 7, p + i);
20 for (i = (5 * 1024); i < (16 * 1024); i += 4)
21 iowrite32(i * 212371 + 13, p + i);
24 static void do_read_test(void __iomem *p)
27 for (i = 0; i < 256; i++)
29 for (i = 1024; i < (5 * 1024); i += 2)
31 for (i = (5 * 1024); i < (16 * 1024); i += 4)
35 static void do_test(void)
37 void __iomem *p = ioremap_nocache(mmio_address, 0x4000);
39 pr_err(MODULE_NAME ": could not ioremap, aborting.\n");
47 static int __init init(void)
49 if (mmio_address == 0) {
50 pr_err(MODULE_NAME ": you have to use the module argument "
52 pr_err(MODULE_NAME ": DO NOT LOAD THIS MODULE UNLESS"
53 " YOU REALLY KNOW WHAT YOU ARE DOING!\n");
57 pr_warning(MODULE_NAME ": WARNING: mapping 16 kB @ 0x%08lx "
58 "in PCI address space, and writing "
59 "rubbish in there.\n", mmio_address);
64 static void __exit cleanup(void)
66 pr_debug(MODULE_NAME ": unloaded.\n");
71 MODULE_LICENSE("GPL");