📄 led.c
字号:
/* * 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. * * Copyright (C) 2007, 2010 fengGuojin(fgjnew@163.com) */#include <linux/kernel.h>#include <linux/module.h>#include <linux/init.h>#include <linux/input.h>#include <asm/hardware.h>#include <asm/io.h>#include <asm/arch/regs-gpio.h>#include <asm/arch/regs-timer.h>MODULE_AUTHOR("fgj");MODULE_DESCRIPTION("S3C2410 led driver");MODULE_LICENSE("GPL");#define LED_SI_OUT __raw_writel((__raw_readl(S3C2410_GPFCON)&(~(3<<8)))|(1<<8),S3C2410_GPFCON)#define LED_SI_H __raw_writel(__raw_readl(S3C2410_GPFDAT)|(1<<4),S3C2410_GPFDAT)#define LED_SI_L __raw_writel(__raw_readl(S3C2410_GPFDAT)&(~(1<<4)),S3C2410_GPFDAT)static char s3c2410_LED_name[] = "S3C2410led";static char s3c2410_LED_phys[] = "s3c2410led";static struct input_dev s3c2410_LED_dev;spinlock_t s3c2410_LED_lock = SPIN_LOCK_UNLOCKED;static int s3c2410_LED_event(struct input_dev *dev, unsigned int type, unsigned int code, int value){ printk("s3c2410_LED_event\n"); if (type != EV_LED)return -1; switch (code) { case LED_NUML: break; default: return -1; } switch(value) { case 0: LED_SI_H; break; case 1: LED_SI_L; break; } return 0;}static int __init s3c2410_LED_init(void){ LED_SI_OUT; s3c2410_LED_dev.evbit[0] = BIT(EV_LED); s3c2410_LED_dev.ledbit[0] = BIT(LED_NUML); s3c2410_LED_dev.event = s3c2410_LED_event; s3c2410_LED_dev.name = s3c2410_LED_name; s3c2410_LED_dev.phys = s3c2410_LED_phys; s3c2410_LED_dev.id.bustype = BUS_HOST; s3c2410_LED_dev.id.vendor = 0x001f; s3c2410_LED_dev.id.product = 0x0001; s3c2410_LED_dev.id.version = 0x0100; input_register_device(&s3c2410_LED_dev); printk(KERN_INFO "input: %s\n", s3c2410_LED_name); return 0;}static void __exit s3c2410_LED_exit(void){ input_unregister_device(&s3c2410_LED_dev);}module_init(s3c2410_LED_init);module_exit(s3c2410_LED_exit);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -