Path: blob/master/arch/avr32/boards/mimc200/fram.c
10819 views
/*1* FRAM driver for MIMC200 board2*3* Copyright 2008 Mark Jackson <[email protected]>4*5* This module adds *very* simply support for the system's FRAM device.6* At the moment, this is hard-coded to the MIMC200 platform, and only7* supports mmap().8*/910#define FRAM_VERSION "1.0"1112#include <linux/miscdevice.h>13#include <linux/proc_fs.h>14#include <linux/mm.h>15#include <linux/io.h>1617#define FRAM_BASE 0xac00000018#define FRAM_SIZE 0x200001920/*21* The are the file operation function for user access to /dev/fram22*/2324static int fram_mmap(struct file *filp, struct vm_area_struct *vma)25{26int ret;2728ret = remap_pfn_range(vma,29vma->vm_start,30virt_to_phys((void *)((unsigned long)FRAM_BASE)) >> PAGE_SHIFT,31vma->vm_end-vma->vm_start,32PAGE_SHARED);3334if (ret != 0)35return -EAGAIN;3637return 0;38}3940static const struct file_operations fram_fops = {41.owner = THIS_MODULE,42.mmap = fram_mmap,43.llseek = noop_llseek,44};4546#define FRAM_MINOR 04748static struct miscdevice fram_dev = {49FRAM_MINOR,50"fram",51&fram_fops52};5354static int __init55fram_init(void)56{57int ret;5859ret = misc_register(&fram_dev);60if (ret) {61printk(KERN_ERR "fram: can't misc_register on minor=%d\n",62FRAM_MINOR);63return ret;64}65printk(KERN_INFO "FRAM memory driver v" FRAM_VERSION "\n");66return 0;67}6869static void __exit70fram_cleanup_module(void)71{72misc_deregister(&fram_dev);73}7475module_init(fram_init);76module_exit(fram_cleanup_module);7778MODULE_LICENSE("GPL");7980MODULE_ALIAS_MISCDEV(FRAM_MINOR);818283