Chinaunix首页 | 论坛 | 博客
  • 博客访问: 652324
  • 博文数量: 121
  • 博客积分: 4034
  • 博客等级: 上校
  • 技术积分: 1439
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-28 12:42
文章分类

全部博文(121)

文章存档

2017年(8)

2016年(10)

2013年(2)

2012年(3)

2011年(18)

2010年(80)

分类: LINUX

2010-07-28 15:34:39

#include 
#include
#include
#include
#include
#include
#define GPFCON_DANCY 0x56000050
#define GPFCON_SIZE 0x20
static void __iomem *io_base;
static struct resource *io_mem;
MODULE_LICENSE("GPL");
static int hello_init(void)
{
int dancy;
static unsigned long io_cntl;
printk("Hello world\n");
io_mem = request_region(GPFCON_DANCY, GPFCON_SIZE, "io");
if (io_mem == NULL)
{
printk("failed to get memory region\n");
}
io_base = ioremap(GPFCON_DANCY, GPFCON_SIZE);
if (io_base == 0)
{
printk("failed to ioremap() region\n");
}
printk("io_base = %p\n",io_base);
io_cntl = 0x00007dee;
writel(io_cntl, io_base);
dancy = 50;
while(dancy--)
{
io_cntl = ~0x10;
writel(io_cntl, io_base + 0x4);
msleep(0x10);
io_cntl = ~0x80;
writel(io_cntl, io_base + 0x4);
msleep(0x10);
}
printk("Hello world\n");
return 0;
}
static void hello_exit(void)
{
release_resource(io_mem);
kfree(io_mem);
iounmap(io_base);
printk("Goodbye world\n");
}
module_init(hello_init);
module_exit(hello_exit);
阅读(3848) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~