]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - arch/arm/mach-tegra/timerinfo.c
ARM: tegra11: clock: Use tabulated EMC clock register
[linux-2.6.git] / arch / arm / mach-tegra / timerinfo.c
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 <linux/export.h>
28 #include <linux/module.h>
29
30 #include <mach/iomap.h>
31
32 #include "timer.h"
33
34 static int timerinfo_dev_mmap(struct file *file, struct vm_area_struct *vma);
35
36 static const struct file_operations timerinfo_dev_fops = {
37         .owner = THIS_MODULE,
38         .open = nonseekable_open,
39         .mmap = timerinfo_dev_mmap,
40         .llseek = noop_llseek,
41 };
42
43 static struct miscdevice timerinfo_dev = {
44         .minor = MISC_DYNAMIC_MINOR,
45         .name = "timerinfo",
46         .fops = &timerinfo_dev_fops,
47 };
48
49 static int timerinfo_dev_mmap(struct file *file, struct vm_area_struct *vma)
50 {
51         /* start at first page containing TIMERUS_CNTR_1US */
52         phys_addr_t addr = TEGRA_TMR1_BASE;
53
54         if (vma->vm_end  - vma->vm_start != PAGE_SIZE)
55                 return -EINVAL;
56
57         if (vma->vm_flags & VM_WRITE)
58                 return -EPERM;
59
60         vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
61
62         if (remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT, PAGE_SIZE,
63                 vma->vm_page_prot)) {
64                 pr_err("%s:remap_pfn_range failed\n", timerinfo_dev.name);
65                 return -EAGAIN;
66         }
67
68         return 0;
69 }
70
71 static int __init timerinfo_dev_init(void)
72 {
73         return misc_register(&timerinfo_dev);
74 }
75
76 module_init(timerinfo_dev_init);
77 MODULE_LICENSE("GPL");