Hello,
I am writing a simple driver for National Instruments PCI-DIO-96 digital
I/O board. I obtained the base address using pci_find_device() and remaped
it to the kernel address space by ioremap(). I set the port as output, use
writeb() to write data to the port. But I could not see the output when I
loaded the module. Is there anything else I have to do to make I/O board
function correctly? The code is as follows:
unsigned char * baseptr;
int init_module(void) {
struct pci_dev *dev = NULL;
unsigned long base_addr;
dev=pci_find_device(VENDOR_NI, DIO96_ID, dev);
pci_read_config_byte(dev, PCI_COMMAND, &pci_cmd);
pci_cmd |= PCI_COMMAND_MEMORY;
pci_write_config_byte(dev, PCI_COMMAND, pci_cmd);
/* base_address[1] is the base address of board register */
base_addr = dev->base_address[1];
base_addr &= PCI_BASE_ADDRESS_MEM_MASK;
baseptr = ioremap(base_addr, 1024*4);
writeb(0x80,(baseptr+0x03)); /* set port as output*/
writeb(0x0,baseptr);
return 0;
}
void cleanup_module(void) {
iounmap(baseptr);
return;
}
void * ioremap (unsigned long offset, unsigned long size)
{
return __ioremap(offset, size, 0);
}
Thanks a lot.
Ben
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/