/*掩码处理*/ con &= ~mask; /*把[11:10]位置0,其余位保留*/ /*就是空出[11:10]位,好用来添加功能值*/
/*添加功能*/ con |= function; /*把[11:10]位添加为10*/ /*可见,bankB以后的寄存器,都是一次处理两位*/
/*写入寄存器*/ __raw_writel(con, base + 0x00); /*往bankH寄存器里写值*/
/*中断恢复*/ local_irq_restore(flags); }
这样s3c2410_gpio_setpin()就不难理解了: void s3c2410_gpio_setpin(unsigned int pin, unsigned int to) { void __iomem *base = S3C2410_GPIO_BASE(pin); unsigned long offs = S3C2410_GPIO_OFFSET(pin); unsigned long flags; unsigned long dat; local_irq_save(flags); dat = __raw_readl(base + 0x04); dat &= ~(1 << offs); dat |= to << offs; __raw_writel(dat, base + 0x04); local_irq_restore(flags); }