Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3219225
  • 博文数量: 1805
  • 博客积分: 135
  • 博客等级: 入伍新兵
  • 技术积分: 3345
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-19 20:01
文章分类

全部博文(1805)

文章存档

2017年(19)

2016年(80)

2015年(341)

2014年(438)

2013年(349)

2012年(332)

2011年(248)

分类:

2012-12-07 01:02:20

原文地址:IOREMAP的使用 作者:xuxiyao8888

#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);
阅读(573) | 评论(0) | 转发(0) |
0

上一篇:平台设备

下一篇:linux中内核延时编程

给主人留下些什么吧!~~