Calling PCI Autoconfig again

Wyse, Chris chris.wyse at
Wed Mar 8 01:17:11 EST 2006


This code will do the rescan of the PCI that we need for the FPGA.
However, it currently only supports a single execution after the FPGA
gets loaded.  Additional calls will continue to add FPGA devices to the
PCI device list data structure.  I'm going to make some changes to it to
handle multiple calls and to support multiple device ids.  I'm expecting
it to take a day or two, but I'll make an initial cut at it today that
will let us load the Spartan FPGA (only once).  This driver will be
loaded when the kernel boots, so I believe that we'll just need to make
a call into it (we won't have to dynamically load it like the phob


For the FPGA loader, you should load the FPGA, then make a call to
pci_rescan_bus0() (I'm renaming check_hw() to pci_rescan_bus0()).  Next,
you need to do a pci_find_device() to detect the newly loaded FPGA.  If
the pci_find_device() fails, assume that the FPGA load has not
completed, so delay for some time frame (100 ms??), then rescan again.
If still not found, rescan up to MAX_PCI_RESCANS (probably set it to 3)
times, then return an error that the FPGA load failed. 

Chris Wyse
Member of Technical Staff
Embedded Technologies
860-749-1556 office
860-978-0849 cell
413-778-9101 fax

-----Original Message-----
From: Wyse, Chris 
Sent: Tuesday, March 07, 2006 8:49 AM
To: 'David Hawkins'
Cc: 'linuxppc-embedded at'; Touron, Emmanuel; McComb, Michael
Subject: RE: Calling PCI Autoconfig again

Hi Dave,

Thanks for the input.

I was thinking about making the FPGA a hotplug device.  I was really
hoping that I could just enable CONFIG_HOTPLUG in the kernel build, but
after some research, I don't believe that will work.  The hotplug
approach was more work than I wanted, but after your response, I decided
to look into it some more, specifically looking for an FPGA
implementation similar to ours.  I searched the linux-hotplug-devel list
for FPGA, and found this:

It implements a rescan of the PCI bus for a newly loaded FPGA device
(although despite the group name, it doesn't use HotPlug).

I'm going to try to use the code from the above link rather than
implement a hotplug driver.  

Thanks again for the help.

Chris Wyse
Member of Technical Staff
Embedded Technologies
860-749-1556 office
860-978-0849 cell
413-778-9101 fax

-----Original Message-----
From: David Hawkins [mailto:dwh at]
Sent: Monday, March 06, 2006 11:33 PM
To: Wyse, Chris
Cc: linuxppc-embedded at
Subject: Re: Calling PCI Autoconfig again

Wyse, Chris wrote:
> Hi,
> I'm working on a board (PPC440GX CPU) that has an FPGA on it.  The 
> FPGA software has a PCI interface.  If I load the FPGA, then boot the 
> Linux kernel, the FPGA is recognized as a device on the PCI bus.
> However, I'd like to load the FPGA after the kernel has booted, then 
> run autoconfig again to detect the device.  What's the best way to do
> Please send responses directly to me (in addition to the list), since 
> I am not subscribed to the list.

Hi Chris,

I haven't had to do this, but I've thought about how I might do it.

In compact PCI, you can hot-swap a PCI device, and the Linux host is
supposed to go and re-enumerate the PCI bus. There is a pci (host-side)
hotplug skeleton in the source;


I believe you can do the following;

   - consider the 440GX is a hotplug controller
     (and write a hotplug driver appropriately)
   - when Linux loads the FPGA, the FPGA generates a hotplug
     event, i.e., it just got plugged in
     (I'm not sure what signal is generated, perhaps a
      power-management interrupt PME#?)
   - the 440GX hotplug controller re-enumerates the PCI bus
     and finds the device

I'm sure you can get an idea from the hotplug skeleton what
re-enumeration entails.


More information about the Linuxppc-embedded mailing list