RTDM : Obtaining PCI base address
Hi,
In order to introduce myself to RTDM and driver development in Xenomai, I'm trying to develop a simple "driver" for an advantech PCI-1711 card.
First thing I need to do is obtaining the PCI base address of the card. To do this I used an old code I already have :
struct pci_dev *pcidev;
printk("PCI-1711 DETECT PCI \n");
pcidev=NULL;
pcidev =pci_get_device (PCI_VENDOR_, PCI_DEVICE_, pcidev );
if (pcidev==NULL){
printk("PCI-1711 CANNOT BE FOUND \n");
}
else{
printk("PCI-1711 LOCATED \n");
if (pci_enable_device(pcidev)){
printk("PCI-1711 NOT ENABLED \n");
return(-EIO);
}
else{
printk("PCI-1711 ENABLED \n");
}
PCI_BASE_ADRESS_1711= pci_resource_start(pcidev, 1)& PCI_BASE_ADDRESS_MEM_MASK;
printk("PCI-1711 DETECT PCI %x \n",PCI_BASE_ADRESS_1711);
}Unfortunatelly PCI_BASE_ADRESS_1711 always takes de 0 value.
Is this type of code already valid in current linux kernels ? Could anyone point me to a similar code ?
Thank you in advance
Ramon
Quoted 32 lines · Ramon
Hi,
In order to introduce myself to RTDM and driver development in Xenomai, I'm trying to develop a simple "driver"
for an advantech PCI-1711 card.First thing I need to do is obtaining the PCI base address of the card. To do this I used an old code I already have :
struct
pci_dev*pcidev;
printk("PCI-1711 DETECT PCI \n");
pcidev=NULL;
pcidev =pci_get_device (PCI_VENDOR_,PCI_DEVICE_, pcidev );if (pcidev==NULL){ printk("PCI-1711 CANNOT BE FOUND \n"); } else{ printk("PCI-1711 LOCATED \n"); if (pci_enable_device(pcidev)){ printk("PCI-1711 NOT ENABLED \n"); return(-EIO); } else{ printk("PCI-1711 ENABLED \n"); } PCI_BASE_ADRESS_1711= pci_resource_start(pcidev, 1)&
PCI_BASE_ADDRESS_MEM_MASK;printk("PCI-1711 DETECT PCI %x \n",PCI_BASE_ADRESS_1711); }
Quoted 7 lines
Unfortunatelly
PCI_BASE_ADRESS_1711always takes de 0 value.Is this type of code already valid in current linux kernels ? Could anyone point me to a similar code ?
Thank you in advance
Ramon
Are you sure you have the right BAR for this card ?
Refering to the Comedi driver, they use pci_resource_start(pcidev, 2) to obtain the IO base address (without using PCI_BASE_ADDRESS_MEM_MASK).
Regards, Paul.