📄 s3c2410state.c
字号:
/*
* s3c2410-state.c
*
* S3C2410 state_led
*
* Date : $Date: 2006/12/13 17:15:00 $
*
* $Revision: 1.2.1.1 $
*
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/miscdevice.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/poll.h>
#include <linux/spinlock.h>
#include <linux/irq.h>
#include <linux/delay.h>
#include <asm/hardware.h>
#define DEVICE_NAME "state"
#define STATE_MAJOR 230
static int STATE_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
int key,frequency,count,n,m,i,j;
switch(cmd)
{
case 1:
write_gpio_bit(GPIO_A15, 0);
break;
case 0:
write_gpio_bit(GPIO_A15, 1);
break;
default:
return -EINVAL;
break;
}
return 0;
}
static struct file_operations STATE_fops = {
owner: THIS_MODULE,
ioctl: STATE_ioctl,
};
static devfs_handle_t devfs_handle;
static int __init STATE_init(void)
{
int ret;
int k;
ret = register_chrdev(STATE_MAJOR, DEVICE_NAME, &STATE_fops);
if (ret < 0)
{
printk(DEVICE_NAME "Can't register major number\n");
return ret;
}
devfs_handle = devfs_register(NULL, DEVICE_NAME, DEVFS_FL_DEFAULT,
STATE_MAJOR, 0, S_IFCHR | S_IRUSR | S_IWUSR, &STATE_fops, NULL);
GPACON = GPACON & ~(1<<15);
write_gpio_bit(GPIO_A15, 0);
printk("\nARMSYS-"DEVICE_NAME " initialized, it will indicate the status of 2410MU.\n");
return 0;
}
static void __exit STATE_exit(void)
{
devfs_unregister(devfs_handle);
unregister_chrdev(STATE_MAJOR, DEVICE_NAME);
}
module_init(STATE_init);
module_exit(STATE_exit);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -