W83977芯片驱动程序疑问
这个是网上一个大侠写的W83977驱动程序。我不明白其中一些为什么那样也,看手册头都看晕了都没办法。
//KBD port--------------------------------------------
w977_select_device(W977_DEVICE_KBC, efbase[1]); //select logic device
w977_write_reg(0x60, 0x0, efbase[1]); //address 这里把0X60和0X0写到0X3F0和0X3F1是什么意思,手册上不是这样的啊
{CR60, CR 61 (Default 0x00, 0x60 if PENKBC= 1 during POR, default 0x00 otherwise)
These two registers select the first KBC I/O base address [0x100:0xFFF] on 1 byte boundary.
CR62, CR 63 (Default 0x00, 0x64 if PENKBC= 1 during POR, default 0x00 otherwise)
These two registers select the second KBC I/O base address [0x100:0xFFF] on 1 byte boundary.这一段是手册上写的}
w977_write_reg(0x61, 0x60, efbase[1]); //address--0x060
w977_write_reg(0x62, 0x0, efbase[1]); //address
w977_write_reg(0x63, 0x64, efbase[1]); //address--0x064
蓝色的代码不清楚为什么要这样写,这几个函数定义在下面贴出来
//set irq number
w977_write_reg(0x70, 0x05, efbase[1]); //irq for keyboard irq5--active H
w977_write_reg(0x72, 0x04, efbase[1]); //irq for mouse irq4--active H
//12MHZ, disable port 92
w977_write_reg(0xf0, 0x80, efbase[1]);
/* Activate device */
w977_write_reg(0x30, 0x01, efbase[1]);
下面是上面要用到的子函数
static unsigned int efbase[] = { W977_EFIO_BASE+nGCS7, W977_EFIO2_BASE+nGCS7 };
static unsigned int efio = W977_EFIO_BASE;
#define readb(x) (*(volatile unsigned char *)x)
#define writeb(val, x) (*(volatile unsigned char *)x)=val
#define readw(x) (*(volatile unsigned short *)x)
#define writew(val, x) (*(volatile unsigned short *)x)=val
static void w977_write_reg(unsigned char reg, unsigned char value, unsigned int efio)
{
unsigned int addr;
writeb(reg, efio);
addr=efio+1;
writeb(value, addr);
}