#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/input.h>
#include <linux/miscdevice.h>
#include <asm/io.h>
#define LED_MINOR 245
#define LED_ON 0
#define LED_OFF 1
#define GPC1CON 0xe0200080
#define GPC1DAT 0xe0200084
volatile unsigned long *gpc1con;
volatile unsigned long *gpc1dat;
static int s3c_led_open(struct inode *inode, struct file *file)
{
gpc1con = (volatile unsigned long *)ioremap(GPC1CON,16);
gpc1dat = gpc1con + 1;
*gpc1con &= ~((0xf << 12)+(0xf << 16));
*gpc1con |= ((0x1 << 12)+(0x1 << 16));
return 0;
}
static long s3c_led_ioctl(struct inode *inode, struct file *file,unsigned int cmd, unsigned long arg)
{
switch (cmd) {
case LED_ON:
*gpc1dat |= (0x1 << (3+arg));
return 0;
case LED_OFF:
*gpc1dat &= ~(0x1 << (3+arg));
return 0;
default:
return -ENOIOCTLCMD;
}
}
static struct file_operations s3c_led_fops = {
.owner = THIS_MODULE,
.open = s3c_led_open,
.ioctl = s3c_led_ioctl,
};
static struct miscdevice s3c_led_miscdev = {
.minor = LED_MINOR,
.name = "led",
.fops = &s3c_led_fops,
};
int __init s3c_led_init(void)
{
int ret;
ret = misc_register(&s3c_led_miscdev);
return ret;
}
void __exit s3c_led_exit(void)
{
int ret;
ret=misc_deregister(&s3c_led_miscdev);
}
module_init(s3c_led_init);
module_exit(s3c_led_exit);
MODULE_AUTHOR("tarena");
MODULE_DESCRIPTION("CW210 LED driver");
MODULE_LICENSE("GPL");