t = request_mem_region(MKG_MEM_BASE, MKG_MEM_LEN, "ip_mkg"); 146. 147. //===ioremap mkg registers 148. 149. g_mkg_mem_base = ioremap(MKG_MEM_BASE,MKG_MEM_LEN); 150. if(NULL == g_mkg_mem_base) 151. { 152. printk(KERN_ERR "mkg ioremap error!\n"); 153. return -1; 154. } 155. else 156. { 157. ;//printk("mkg ioremap addr:%d!\n",g_mkg_mem_base); 158. } 159. 160. printk("mkg module init done!\n"); 161. 162. iowrite32(0x1,g_mkg_mem_base); 163. printk("mkg write1!\n"); 164. iowrite32(0x2,g_mkg_mem_base+4); 165. printk("mkg write2!\n"); 166. 167. while(loop--) 168. printk("======%d======read:%d\n",loop,ioread32(g_mkg_mem_base+4*loop)); 169. 170. return 0; 171.} 172. 173.void cleanup_module() 174.{ 175. release_mem_region(MKG_MEM_BASE, MKG_MEM_LEN); 176. 177. unregister_chrdev(MAJOR_NUM, DEVICE_NAME); 178.} 179. 180.MODULE_LICENSE("GPL"); 181.MODULE_AUTHOR("Rill zhen:rill_zhen@126.com"); /* * * rill mkg driver * */ #include <linux/vmalloc.h> #include <linux/slab.h>
#include <linux/kernel.h> #include <linux/module.h> #include <linux/fs.h> #include <asm/uaccess.h> /* get_user and put_user */ //#include <linux/clk.h> //#include <linux/ioport.h> #include <asm/io.h> /*ioremap*/ #include <linux/platform_device.h> /*cleanup_module*/
#include "ip_mkg.h" 论文网
void __iomem *g_mkg_mem_base = NULL;
static int device_open(struct inode *inode, struct file *file) { g_mkg_mem_base = ioremap(MKG_MEM_BASE,MKG_MEM_LEN); if(NULL == g_mkg_mem_base) { printk(KERN_ERR "mkg open ioremap error!\n"); return -1; } else { printk("mkg ioremap addr:%d!\n",(int)g_mkg_mem_base); }
return 0; }
static int device_release(struct inode *inode, struct file *file) { return 0; }
static ssize_t device_read(struct file *filp, char *buffer, size_t length, loff_t *offset) { /*int ret_val = 0;
char * data = NU << 上一页 [11] [12] [13] [14] 下一页
|