s3c2410_gpio_cfgpin(S3C2410_GPG(0), S3C2410_GPIO_OUTPUT);
s3c2410_gpio_cfgpin()的定义在arch/arm/march-2410/include/mach/gpio-fns.h
S3C2410_GPG()的定义在arch/arm/march-2410/include/mach/gpio-nrs.h
S3C2410_GPIO_OUTPUT的定义在arch/arm/march-2410/include/mach/regs-gpio.h
我要用GPF0~6 和GPG0,则根据头文件
arch/arm/march-2410/include/mach/gpio-nrs.h中
/* GPIO bank sizes */
#define S3C2410_GPIO_A_NR (32)
#define S3C2410_GPIO_B_NR (32)
#define S3C2410_GPIO_C_NR (32)
#define S3C2410_GPIO_D_NR (32)
#define S3C2410_GPIO_E_NR (32)
#define S3C2410_GPIO_F_NR (32)
#define S3C2410_GPIO_G_NR (32)
#define S3C2410_GPIO_H_NR (32)
#define S3C2410_GPIO_J_NR (32) /* technically 16. */
#define S3C2410_GPIO_K_NR (32) /* technically 16. */
#define S3C2410_GPIO_L_NR (32) /* technically 15. */
#define S3C2410_GPIO_M_NR (32) /* technically 2. */
#if CONFIG_S3C_GPIO_SPACE != 0
#error CONFIG_S3C_GPIO_SPACE cannot be zero at the moment
#endif
#define S3C2410_GPIO_NEXT(__gpio) /
((__gpio##_START) + (__gpio##_NR) + CONFIG_S3C_GPIO_SPACE + 0)
//这里的CONFIG_S3C_GPIO_SPAC是内核配置选项,在.config中可以找到,一般配置都是:
CONFIG_S3C_GPIO_SPACE = 0
蓝色字体的意思就是宏定义传递,比如我要用GPG0,则
S3C2410_GPIO_NEXT(S3C2410_GPIO_F) +0 =>
(S3C2410_GPIO_F_START + S3C2410_GPIO_F_NR + CONFIG_S3C_GPIO_SPACE + 0) + 0 =>
这样一步一步传递,可以得出GPG0的地址
所以才有S3C2410_GPG(0)