下面是2440板子上的4个按键的驱动程序中的一些代码:
struct button_irq_desc {
int irq;
int pin;
int pin_setting;
int number;
char *name;
};
static struct button_irq_desc button_irqs [] = {
{IRQ_EINT19, S3C2410_GPG11, S3C2410_GPG11_EINT19, 0, "KEY1"}, /* K1 */ {IRQ_EINT11, S3C2410_GPG3, S3C2410_GPG3_EINT11, 1, "KEY2"}, /* K2 */
{IRQ_EINT2, S3C2410_GPF2, S3C2410_GPF2_EINT2, 2, "KEY3"}, /* K3 */
{IRQ_EINT0, S3C2410_GPF0, S3C2410_GPF0_EINT0, 3, "KEY4"}, /* K4 */
};
...
s3c2410_gpio_cfgpin(button_irqs.pin,button_irqs.pin_setting);
...
以下我们以i=0为例:
S3C2410_GPG11, S3C2410_GPG11_EINT19等,都是在regs-gpio.h里定义的:
#define S3C2410_GPIONO(bank,offset) ((bank) + (offset))
#define S3C2410_GPIO_BANKG (32*6)
#define S3C2410_GPG11 S3C2410_GPIONO(S3C2410_GPIO_BANKG, 11)
#define S3C2410_GPG11_INP (0x00 << 22)
#define S3C2410_GPG11_OUTP (0x01 << 22)
#define S3C2410_GPG11_EINT19 (0x02 << 22)
#define S3C2410_GPG11_TCLK1 (0x03 << 22)
通过计算,S3C2410_GPG11的值为(32*6 + 11), S3C2410_GPG11_EINT19的值为(0x02 << 22),
所以S3C2410_GPG11=0xCB,S3C2410_GPG11_EINT19=0x800000
s3c2410_gpio_cfgpin()函数是在hardware.h中定义的:
/* s3c2410_gpio_cfgpin
*
* set the configuration of the given pin to the value passed.
*
* eg:
* s3c2410_gpio_cfgpin(S3C2410_GPA0, S3C2410_GPA0_ADDR0);
* s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_SDDAT1);
*/
我看了,觉得s3c2410_gpio_cfgpin函数的意思是通过传入的参数,设置对应的引脚,对于
S3C2410_GPG11_EINT19=0x800000转化为二进制为1000 0000 0000 0000 0000 0000正好
[23:22]位为10,表示EINT[19],设置GPG11为第19个中断。通过查2440的datasheet,发现就
是应该对控制寄存器GPGCON做这样的设置。那为什么传入s3c2410_gpio_cfgpin函数的第一个
参数不是GPGCON的地址,而是S3C2410_GPG11而且S3C2410_GPG11的值还为0xCB这样的数 ,而
且GPGCON的地址值在regs-gpio.h中也已经给出了,如:
#define S3C2410_GPGCON S3C2410_GPIOREG(0x60)
#define S3C2410_GPGDAT S3C2410_GPIOREG(0x64)
#define S3C2410_GPGUP S3C2410_GPIOREG(0x68)
为什么不用,而要传入一个S3C2410_GPG11值?而且值为0xCB,是什么意思?
还请高手们不吝赐教啊,先谢谢了!