aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/timerinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/timerinfo.c')
-rw-r--r--arch/arm/mach-tegra/timerinfo.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/timerinfo.c b/arch/arm/mach-tegra/timerinfo.c
new file mode 100644
index 00000000000..b64ea821f4a
--- /dev/null
+++ b/arch/arm/mach-tegra/timerinfo.c
@@ -0,0 +1,74 @@
1/*
2 * arch/arch/mach-tegra/timerinfo.c
3 *
4 * Copyright (C) 2012 NVIDIA Corporation.
5 *
6 * Author:
7 * Jon Mayo <jmayo@nvidia.com>
8 *
9 * Copyright (C) 2012 NVIDIA Corporation.
10 *
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.
14 *
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.
19 *
20 */
21
22#include <linux/init.h>
23#include <linux/fs.h>
24#include <linux/mm.h>
25#include <linux/platform_device.h>
26#include <linux/miscdevice.h>
27#include <mach/iomap.h>
28
29#include "timer.h"
30
31static int timerinfo_dev_mmap(struct file *file, struct vm_area_struct *vma);
32
33static const struct file_operations timerinfo_dev_fops = {
34 .owner = THIS_MODULE,
35 .open = nonseekable_open,
36 .mmap = timerinfo_dev_mmap,
37 .llseek = noop_llseek,
38};
39
40static struct miscdevice timerinfo_dev = {
41 .minor = MISC_DYNAMIC_MINOR,
42 .name = "timerinfo",
43 .fops = &timerinfo_dev_fops,
44};
45
46static int timerinfo_dev_mmap(struct file *file, struct vm_area_struct *vma)
47{
48 /* start at first page containing TIMERUS_CNTR_1US */
49 phys_addr_t addr = TEGRA_TMR1_BASE;
50
51 if (vma->vm_end - vma->vm_start != PAGE_SIZE)
52 return -EINVAL;
53
54 if (vma->vm_flags & VM_WRITE)
55 return -EPERM;
56
57 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
58
59 if (remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT, PAGE_SIZE,
60 vma->vm_page_prot)) {
61 pr_err("%s:remap_pfn_range failed\n", timerinfo_dev.name);
62 return -EAGAIN;
63 }
64
65 return 0;
66}
67
68static int __init timerinfo_dev_init(void)
69{
70 return misc_register(&timerinfo_dev);
71}
72
73module_init(timerinfo_dev_init);
74MODULE_LICENSE("GPL");