/*
* Copyright (C) 2004 Gexin TECH
* <[email protected]>
*
This file just for GX-ARM9-2410EP
Sat Feb 7 2004 Zhen-feng Zhao <[email protected]>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*/
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/interrupt.h> /* for in_interrupt */
#include <linux/timer.h>
#include <linux/init.h>
#include <linux/delay.h> /* for udelay */
#include <linux/modversions.h>
#include <linux/version.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/hardware.h>
#define SimpleLED_MAJOR 97
devfs_handle_t dev_handle; /* register handle to store device fs */
int SimpleLED_temp_count=0;
static long ioremap_addr;
ssize_t SimpleLED_read (struct file * file ,char * buf, size_t count, loff_t * f_ops)
{
printk("s3c2410: device file-read operation!\n");
return count;
}
/*=========== SimpleD Write =======================*/
ssize_t SimpleLED_write (struct file * file ,const char * buf, size_t count, loff_t * f_ops)
{
//printk("s3c2410: device file-write operation!\n");
outw(count,ioremap_addr);
return count;
}
/*=========== SimpleD Ioctl =======================*/
ssize_t SimpleLED_ioctl (struct inode * inode ,struct file * file,
unsigned int cmd, long data)
{
printk("s3c2410: device ioctl operation!\n");
}
/*============ SimpleD device open ==============*/
ssize_t SimpleLED_open (struct inode * inode ,struct file * file)
{
return 0;
}
/*============ SimpleD device close =============*/
ssize_t SimpleLED_release (struct inode * inode ,struct file * file)
{
outw(0x0000,ioremap_addr);
return 0;
}
struct file_operations SimpleLED_ops ={
open: SimpleLED_open,
read: SimpleLED_read,
write: SimpleLED_write,
ioctl: SimpleLED_ioctl,
release: SimpleLED_release,
};
static int __init HW_SimpleLED_init(void)
{
int ret = -ENODEV;
int delay ;
ret = devfs_register_chrdev(SimpleLED_MAJOR, "SimpleLED", &SimpleLED_ops);
if( ret < 0 ){
printk (" s3c2410: init_module failed with %d\n", ret);
return ret;
}
else
{
printk(KERN_INFO" S3c2410 SimpleLED register success!!!\n");
;
}
dev_handle = devfs_register( NULL, "SimpleLED", DEVFS_FL_DEFAULT,
SimpleLED_MAJOR, 0, S_IFCHR, &SimpleLED_ops, NULL);
ioremap_addr=ioremap(0x20000000,0x0f);
outw(0x55aa,ioremap_addr);
printk("remap address = %x\n",ioremap_addr);
//!!!!!!!!!!!!!!
return ret;
}
int __init s3c2410_SimpleLED_init(void) {
int ret = -ENODEV;
ret = HW_SimpleLED_init();
if (ret)
return ret;
return 0;
}
int init_module()
{
s3c2410_SimpleLED_init();
}
void cleanup_module()
{
devfs_unregister_chrdev( SimpleLED_MAJOR, "SimpleLED" );
devfs_unregister( dev_handle );
}