in_word(addr) 和out_word(addr, data)在bootloader的调试作用
in_word(addr)是读对应的寄存器的值,out_word是对寄存器写。驱动程序一般最终是经过多层封装后最终还是通过读写寄存器的接口对寄存器操作。
比如对某个GPIO的状态可以用in_word的函数
#define TLMM_BASE_ADDR 0x00800000
#define GPIO_IN_OUT_ADDR(x) (TLMM_BASE_ADDR + 0x1004 + (x)*0x10)
gpio59 3b
0x00800000+0x1004+0x590= 0x008013b4
;
{
if (in_word(0x008013b4))
printk(“gpio59为高电平\n”)
else
printk(“gpio59为低电平\n”)
}
如果对某个GPIO写1或者0可以用out_word(addr, data)
对gpio59设置为低电平
out_word(0x008013b4, 0);
对gpio59设置为高电平
out_word(0x008013b4, 1);