终于中断注册上了,原因如下:
(1)内核中arch/arm/mach-s3c24xx/mach-mini2440.c中:
/* DM9000AEP 10/100 ethernet controller */ static struct resource mini2440_dm9k_resource[] = { [0] = DEFINE_RES_MEM(MACH_MINI2440_DM9K_BASE, 4), [1] = DEFINE_RES_MEM(MACH_MINI2440_DM9K_BASE + 4, 4), [2] = DEFINE_RES_NAMED(IRQ_EINT7, 1, NULL, IORESOURCE_IRQ \ | IORESOURCE_IRQ_HIGHEDGE), };
#define S3C2410_CPUIRQ_OFFSET (16) #define S3C2410_IRQ(x) ((x) + S3C2410_CPUIRQ_OFFSET) /* main cpu interrupts */ #define IRQ_EINT0 S3C2410_IRQ(0) /* 16 */ #define IRQ_EINT1 S3C2410_IRQ(1) #define IRQ_EINT2 S3C2410_IRQ(2) #define IRQ_EINT3 S3C2410_IRQ(3) #define IRQ_EINT4t7 S3C2410_IRQ(4) /* 20 */ /* interrupts generated from the external interrupts sources */ #define IRQ_EINT0_2412 S3C2410_IRQ(32) #define IRQ_EINT1_2412 S3C2410_IRQ(33) #define IRQ_EINT2_2412 S3C2410_IRQ(34) #define IRQ_EINT3_2412 S3C2410_IRQ(35) #define IRQ_EINT4 S3C2410_IRQ(36) /* 52 */ #define IRQ_EINT5 S3C2410_IRQ(37) #define IRQ_EINT6 S3C2410_IRQ(38) #define IRQ_EINT7 S3C2410_IRQ(39)
#define IRQ_EINT4t7 S3C2410_IRQ(4) /* 20 */
还有一个分开的宏:
#define IRQ_EINT4 S3C2410_IRQ(36) /* 52 */ #define IRQ_EINT5 S3C2410_IRQ(37) #define IRQ_EINT6 S3C2410_IRQ(38) #define IRQ_EINT7 S3C2410_IRQ(39)而DM9000中使用的是IRQ_EINT7,所以,我key.c中是否可以使用IRQ_EINT4呢?试一下:
将key.c的如下部分:
// ret = request_irq(IRQ_EINT4t7, kobox_gpio_irq_handle, IRQF_SHARED, "key2", (void *)&nouse); ret = request_irq(IRQ_EINT4, kobox_gpio_irq_handle, IRQF_SHARED, "key2", (void *)&nouse); if(ret) { printk("[func:%s][line:%d] request_irq failed, ret:%d!\n", __FUNCTION__,__LINE__,ret); } else { printk("[func:%s][line:%d] request_irq ok, irq:%d!\n", __FUNCTION__,__LINE__, IRQ_EINT4); }
[\u@\h \W]# insmod key.ko
#####enter key_drv_init!
[func:request_irq_for_gpio][line:273] request_irq ok, irq:17!
[func:request_irq_for_gpio][line:293] request_irq ok, irq:52!
[func:request_irq_for_gpio][line:311] request_irq ok, irq:18!
[func:request_irq_for_gpio][line:328] request_irq ok, irq:16!
#####key_drv_init ok!
[\u@\h \W]# cat /proc/interrupts
CPU0
16: 0 s3c-ext0 0 key4
17: 0 s3c-ext0 1 key1
18: 0 s3c-ext0 2 key3
24: 0 s3c 8 s3c2410-rtc tick
29: 6965 s3c 13 samsung_time_irq
32: 0 s3c 16 s3c2410-lcd
37: 0 s3c 21 s3c-mci
42: 0 s3c 26 ohci_hcd:usb1
43: 0 s3c 27 s3c2440-i2c.0
46: 0 s3c 30 s3c2410-rtc alarm
52: 0 s3c-ext 4 key2
55: 494 s3c-ext 7 eth0
也就是说,注册的时候,将IRQ_EINT4t7改成IRQ_EINT4就好,至于为什么会有IRQ_EINT4t7,还有IRQ_EINT4
这两个宏有什么差别?什么时候该使用IRQ_EINT4?什么时候使用IRQ_EINT4t7?
还有就是为什么最后注册下去,都是外部20号中断呢?这里又是哪里转化的呢?
为什么cat /proc/interrupts中会显示52、55号中断呢?
把这些弄清楚,就揭开了谜底!后面继续研究!