KERN_ERR "mkg check_mem_region bussy error!\n"); return -1; }
ret_from_request = request_mem_region(MKG_MEM_BASE, MKG_MEM_LEN, "ip_mkg");
//===ioremap mkg registers
g_mkg_mem_base = ioremap(MKG_MEM_BASE,MKG_MEM_LEN); if(NULL == g_mkg_mem_base) { printk(KERN_ERR "mkg ioremap error!\n"); return -1; } else { ;//printk("mkg ioremap addr:%d!\n",g_mkg_mem_base); }
printk("mkg module init done!\n");
iowrite32(0x1,g_mkg_mem_base); printk("mkg write1!\n"); iowrite32(0x2,g_mkg_mem_base+4); printk("mkg write2!\n");
while(loop--) printk("======%d======read:%d\n",loop,ioread32(g_mkg_mem_base+4*loop)); 论文网
return 0; }
void cleanup_module() { release_mem_region(MKG_MEM_BASE, MKG_MEM_LEN);
unregister_chrdev(MAJOR_NUM, DEVICE_NAME); }
MODULE_LICENSE("GPL"); MODULE_AUTHOR("Rill zhen:rill_zhen@126.com"); 2》ip_mkg.h [html] view plaincopyprint? 01.#ifndef __IP_MKG_H__ 02.#define __IP_MKG_H__ 03. 04.#define MAJOR_NUM 102 05.#define DEVICE_NAME "ip_mkg" 06.#define MKG_MEM_BASE 0x97000000 07.#define MKG_MEM_LEN 32 08. 09.#define IOCTL_REG_SET 0 10.#define IOCTL_REG_GET 1 11. 12. 13. 14.struct reg_data 15.{ 16. unsigned short addr; 17. int value; 18.}; 19. 20.#endif #ifndef __IP_MKG_H__ #define __IP_MKG_H__
#define MAJOR_NUM 102 #define DEVICE_NAME "ip_mkg" #define MKG_MEM_BASE 0x97000000 #define MKG_MEM_LEN 32
#define IOCTL_REG_SET 0 #define IOCTL_REG_GET 1 struct reg_data { unsigned short addr; int value; }; #endif 3》Makefile
[html] view plaincopyprint? 01.# To build modules outside of the kernel tree, we run "make" 02.# in the kernel source tree; the Makefile these then includes this 03.# Makefile once again. 04.# This conditional selects whether we are being included from the 05.# kernel Makefile or not. 06.ifeq ($(KERNELRELEASE),) 07. 08. # Assume the source tree is where the running kernel was built 09. # You should set KERNELDIR in the environment if it's elsewhere 10. KERNELDIR ?= /home/openrisc/soc-design/linux 11. # The current directory is passed to sub-makes as argument 12. PWD := $(shell pwd) 13. 14.modules: 15. << 上一页 [11] [12] [13] [14] 下一页
|