[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help needed for Linux driver



Andreas Heiner wrote:
> 
> 1. What is the right way to found my PCI card inside the system and to read
> out the BAR's ?

To find your device, use the following code.  Note that this supports
more than one of your cards in a system:

#include <linux/pci.h>

#define PCI_VENDOR_ID   000     /* as appropriate for your board  */
#define PCI_DEVICE_ID   000     /* as appropriate for your board  */
{
   struct pci_dev *dev;

   dev = NULL;   /* instruct pci_find_device() to start at the beginning
*/

   while(1)
      {
         dev = pci_find_device(PCI_VENDOR_ID, PCI_DEVICE_ID, dev);
         if(dev == NULL)
            {
               break;   /* no (more) devices of this type found */
            }

          /* initialize your device using <dev> as the handle */
      }
}

you can read a BAR using:

pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &val);

Good luck...

-Scott

--------------------------------------------------------------------------
Scott C. Karlin                             Princeton University
Graduate Student                            Department of Computer
Science
Voice: (609) 258-5386                       35 Olden Street
Email: scott@cs.princeton.edu               Princeton, NJ 08544-2087
WWW:   http://www.cs.princeton.edu/~scott
--------------------------------------------------------------------------