Merge tag 'pci-v3.15-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaa...
[deliverable/linux.git] / arch / avr32 / boards / mimc200 / fram.c
CommitLineData
5b50c166
MJ
1/*
2 * FRAM driver for MIMC200 board
3 *
4 * Copyright 2008 Mark Jackson <mpfj@mimc.co.uk>
5 *
6 * This module adds *very* simply support for the system's FRAM device.
7 * At the moment, this is hard-coded to the MIMC200 platform, and only
8 * supports mmap().
9 */
10
11#define FRAM_VERSION "1.0"
12
13#include <linux/miscdevice.h>
5745d6a4 14#include <linux/module.h>
5b50c166
MJ
15#include <linux/proc_fs.h>
16#include <linux/mm.h>
17#include <linux/io.h>
18
19#define FRAM_BASE 0xac000000
20#define FRAM_SIZE 0x20000
21
22/*
23 * The are the file operation function for user access to /dev/fram
24 */
25
26static int fram_mmap(struct file *filp, struct vm_area_struct *vma)
27{
28 int ret;
29
30 ret = remap_pfn_range(vma,
31 vma->vm_start,
32 virt_to_phys((void *)((unsigned long)FRAM_BASE)) >> PAGE_SHIFT,
33 vma->vm_end-vma->vm_start,
34 PAGE_SHARED);
35
36 if (ret != 0)
37 return -EAGAIN;
38
39 return 0;
40}
41
42static const struct file_operations fram_fops = {
43 .owner = THIS_MODULE,
44 .mmap = fram_mmap,
6038f373 45 .llseek = noop_llseek,
5b50c166
MJ
46};
47
48#define FRAM_MINOR 0
49
50static struct miscdevice fram_dev = {
51 FRAM_MINOR,
52 "fram",
53 &fram_fops
54};
55
56static int __init
57fram_init(void)
58{
59 int ret;
60
61 ret = misc_register(&fram_dev);
62 if (ret) {
63 printk(KERN_ERR "fram: can't misc_register on minor=%d\n",
64 FRAM_MINOR);
65 return ret;
66 }
67 printk(KERN_INFO "FRAM memory driver v" FRAM_VERSION "\n");
68 return 0;
69}
70
71static void __exit
72fram_cleanup_module(void)
73{
74 misc_deregister(&fram_dev);
75}
76
77module_init(fram_init);
78module_exit(fram_cleanup_module);
79
80MODULE_LICENSE("GPL");
81
82MODULE_ALIAS_MISCDEV(FRAM_MINOR);
This page took 0.320331 seconds and 5 git commands to generate.