分类: 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);