2 * arch/arch/mach-tegra/timerinfo.c
4 * Copyright (C) 2012 NVIDIA Corporation.
7 * Jon Mayo <jmayo@nvidia.com>
9 * Copyright (C) 2012 NVIDIA Corporation.
11 * This software is licensed under the terms of the GNU General Public
12 * License version 2, as published by the Free Software Foundation, and
13 * may be copied, distributed, and modified under those terms.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
22 #include <linux/init.h>
25 #include <linux/platform_device.h>
26 #include <linux/miscdevice.h>
27 #include <linux/export.h>
28 #include <linux/module.h>
30 #include <mach/iomap.h>
34 static int timerinfo_dev_mmap(struct file *file, struct vm_area_struct *vma);
36 static const struct file_operations timerinfo_dev_fops = {
38 .open = nonseekable_open,
39 .mmap = timerinfo_dev_mmap,
40 .llseek = noop_llseek,
43 static struct miscdevice timerinfo_dev = {
44 .minor = MISC_DYNAMIC_MINOR,
46 .fops = &timerinfo_dev_fops,
49 static int timerinfo_dev_mmap(struct file *file, struct vm_area_struct *vma)
51 /* start at first page containing TIMERUS_CNTR_1US */
52 phys_addr_t addr = TEGRA_TMR1_BASE;
54 if (vma->vm_end - vma->vm_start != PAGE_SIZE)
57 if (vma->vm_flags & VM_WRITE)
60 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
62 if (remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT, PAGE_SIZE,
64 pr_err("%s:remap_pfn_range failed\n", timerinfo_dev.name);
71 static int __init timerinfo_dev_init(void)
73 return misc_register(&timerinfo_dev);
76 module_init(timerinfo_dev_init);
77 MODULE_LICENSE("GPL");