diff options
author | Sumit Singh <sumsingh@nvidia.com> | 2014-01-13 11:54:48 +0530 |
---|---|---|
committer | Sachin Nikam <snikam@nvidia.com> | 2014-02-25 04:08:49 -0800 |
commit | e392dd5d6fa08ab41a65f719e0db7e17e607c0c7 (patch) | |
tree | ab7eff244908b1172356a02d02afe29a9317f5c3 /drivers/misc | |
parent | 2e717fd62d7508aafd69d7c58556e21206f3e20d (diff) |
ARM: tegra: move timerinfo to drivers/misc/
Bug 1380001
Change-Id: I0cb9a887ad85b67ba14626e3ab5543525cf26a00
Signed-off-by: Sumit Singh <sumsingh@nvidia.com>
Reviewed-on: http://git-master/r/354930
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sri Krishna Chowdary <schowdary@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/Makefile | 1 | ||||
-rw-r--r-- | drivers/misc/tegra_timerinfo.c | 75 |
2 files changed, 76 insertions, 0 deletions
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 997a7b6f3779..fd744b89a148 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_TEGRA_PROFILER) += tegra-profiler/ obj-$(CONFIG_MTK_GPS) += gps/ obj-y += tegra-fuse/ obj-$(CONFIG_DENVER_CPU) += force_idle_t132.o +obj-$(CONFIG_ARCH_TEGRA) +=tegra_timerinfo.o diff --git a/drivers/misc/tegra_timerinfo.c b/drivers/misc/tegra_timerinfo.c new file mode 100644 index 000000000000..ad38b75eb94c --- /dev/null +++ b/drivers/misc/tegra_timerinfo.c @@ -0,0 +1,75 @@ +/* + * drivers/misc/tegra_timerinfo.c + * + * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved. + * + * Author: + * Jon Mayo <jmayo@nvidia.com> + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <linux/init.h> +#include <linux/fs.h> +#include <linux/mm.h> +#include <linux/platform_device.h> +#include <linux/miscdevice.h> +#include <linux/export.h> +#include <linux/module.h> +#include <linux/tegra-timer.h> + +static int timerinfo_dev_mmap(struct file *file, struct vm_area_struct *vma); + +static const struct file_operations timerinfo_dev_fops = { + .owner = THIS_MODULE, + .open = nonseekable_open, + .mmap = timerinfo_dev_mmap, + .llseek = noop_llseek, +}; + +static struct miscdevice timerinfo_dev = { + .minor = MISC_DYNAMIC_MINOR, + .name = "timerinfo", + .fops = &timerinfo_dev_fops, +}; + +static int timerinfo_dev_mmap(struct file *file, struct vm_area_struct *vma) +{ + /* start at first page containing TIMERUS_CNTR_1US */ + if (IS_ERR_OR_NULL(timer_reg_base_pa)) { + pr_err("%s: Invalid timer_base_address\n", __func__); + return -EINVAL; + } + + if (vma->vm_end - vma->vm_start != PAGE_SIZE) + return -EINVAL; + + if (vma->vm_flags & VM_WRITE) + return -EPERM; + + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + + if (remap_pfn_range(vma, vma->vm_start, timer_reg_base_pa >> PAGE_SHIFT, + PAGE_SIZE, vma->vm_page_prot)) { + pr_err("%s: remap_pfn_range failed\n", timerinfo_dev.name); + return -EAGAIN; + } + + return 0; +} + +static int __init timerinfo_dev_init(void) +{ + return misc_register(&timerinfo_dev); +} + +module_init(timerinfo_dev_init); +MODULE_LICENSE("GPL"); |