next up previous contents
Next: PCI BIOS Functions Up: The PCI Device Driver Previous: The PCI Device Driver

Configuring PCI-PCI Bridges - Assigning PCI Bus Numbers

   

   figure6021
Figure: Configuring a PCI System: Part 1

For PCI-PCI bridges to pass PCI I/O, PCI Memory or PCI Configuration address space reads and writes across them, they need to know the following:

Primary Bus Number
The bus number immediately upstream of the PCI-PCI Bridge,
Secondary Bus Number
The bus number immediately downstream of the PCI-PCI Bridge,
Subordinate Bus Number
The highest bus number of all of the busses that can be reached downstream of the bridge.
PCI I/O and PCI Memory Windows
The window base and size for PCI I/O address space and PCI Memory address space for all addresses downstream of the PCI-PCI Bridge.

The problem is that at the time when you wish to configure any given PCI-PCI bridge you do not know the subordinate bus number for that bridge. You do not know if there are further PCI-PCI bridges downstream and if you did, you do not know what numbers will be assigned to them. The answer is to use a depthwise recursive algorithm and scan each bus for any PCI-PCI bridges assigning them numbers as they are found. As each PCI-PCI bridge is found and its secondary bus numbered, assign it a temporary subordinate number of 0xFF and scan and assign numbers to all PCI-PCI bridges downstream of it. This all seems complicated but the worked example below makes this process clearer.

PCI-PCI Bridge Numbering: Step 1
Taking the topology in Figure gif, the first bridge the scan would find is tex2html_wrap12010 . The PCI bus downstream of tex2html_wrap12010 would be numbered as 1 and tex2html_wrap12010 assigned a secondary bus number of 1 and a temporary subordinate bus number of 0xFF. This means that all Type 1 PCI Configuration addresses specifying a PCI bus number of 1 or higher would be passed across tex2html_wrap12010 and onto PCI Bus 1. They would be translated into Type 0 Configuration cycles if tehy have a bus number of 1 but left untranslated for all other bus numbers. This is exactly what the Linux PCI initialisation code needs to do in order to go and scan PCI Bus 1.

   figure6347
Figure: Configuring a PCI System: Part 2

PCI-PCI Bridge Numbering: Step 2
Linux uses a depthwise algorithm and so the initialisation code goes on to scan PCI Bus 1. Here it finds PCI-PCI tex2html_wrap12011 . There are no further PCI-PCI bridges beyond PCI-PCI tex2html_wrap12011 , so it is assigned a subordinate bus number of 2 which matches the number assigned to its secondary interface. Figure gif shows how the busses and PCI-PCI bridges are numbered at this point.

   figure6594
Figure: Configuring a PCI System: Part 3

PCI-PCI Bridge Numbering: Step 3
The PCI initialisation code returns to scanning PCI Bus 1 and finds another PCI-PCI bridge, tex2html_wrap12012 . It is assigned 1 as its primary bus interface number, 3 as its secondary bus interface number and 0xFF as its subordinate bus number. Figure gif on page gif shows how the system is configured now. Type 1 PCI configuration cycles with a bus number of 1, 2 or 3 wil be correctly delivered to the appropriate PCI buses.

   figure6856
Figure: Configuring a PCI System: Part 4

PCI-PCI Bridge Numbering: Step 4
Linux starts scanning PCI Bus 3, downstream of PCI-PCI tex2html_wrap12012 . PCI Bus 3 has another PCI-PCI bridge ( tex2html_wrap12069 ) on it, it is assigned 3 as its primary bus number and 4 as its secondary bus number. It is the last bridge on this branch and so it is assigned a subordinate bus interface number of 4. The initialisation code returns to PCI-PCI tex2html_wrap12012 and assigns it a subordinate bus number of 4. Finally, the PCI initialisation code can assign 4 as the subordinate bus number for PCI-PCI tex2html_wrap12010 . Figure gif on page gif shows the final bus numbers.


next up previous contents
Next: PCI BIOS Functions Up: The PCI Device Driver Previous: The PCI Device Driver

David A. Rusling
david.rusling@reo.mts.dec.com