kvm tools, setup: Create private directory
[linux-2.6/next.git] / arch / avr32 / boards / mimc200 / fram.c
blob9764a1a1073e933aa1c2d6a73e51483553da2dfa
1 /*
2 * FRAM driver for MIMC200 board
4 * Copyright 2008 Mark Jackson <mpfj@mimc.co.uk>
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 */
11 #define FRAM_VERSION "1.0"
13 #include <linux/miscdevice.h>
14 #include <linux/proc_fs.h>
15 #include <linux/mm.h>
16 #include <linux/io.h>
18 #define FRAM_BASE 0xac000000
19 #define FRAM_SIZE 0x20000
22 * The are the file operation function for user access to /dev/fram
25 static int fram_mmap(struct file *filp, struct vm_area_struct *vma)
27 int ret;
29 ret = remap_pfn_range(vma,
30 vma->vm_start,
31 virt_to_phys((void *)((unsigned long)FRAM_BASE)) >> PAGE_SHIFT,
32 vma->vm_end-vma->vm_start,
33 PAGE_SHARED);
35 if (ret != 0)
36 return -EAGAIN;
38 return 0;
41 static const struct file_operations fram_fops = {
42 .owner = THIS_MODULE,
43 .mmap = fram_mmap,
44 .llseek = noop_llseek,
47 #define FRAM_MINOR 0
49 static struct miscdevice fram_dev = {
50 FRAM_MINOR,
51 "fram",
52 &fram_fops
55 static int __init
56 fram_init(void)
58 int ret;
60 ret = misc_register(&fram_dev);
61 if (ret) {
62 printk(KERN_ERR "fram: can't misc_register on minor=%d\n",
63 FRAM_MINOR);
64 return ret;
66 printk(KERN_INFO "FRAM memory driver v" FRAM_VERSION "\n");
67 return 0;
70 static void __exit
71 fram_cleanup_module(void)
73 misc_deregister(&fram_dev);
76 module_init(fram_init);
77 module_exit(fram_cleanup_module);
79 MODULE_LICENSE("GPL");
81 MODULE_ALIAS_MISCDEV(FRAM_MINOR);