zephyr/drivers/pcie
Neil Armstrong 8e0f3d1e5d pcie: controller: add non-recursive pcie busses enumeration
In order to preserve stack, this replaces the single-bus enumeration
loop by a stack based non-recursive pcie hierarchy iteration.

Each stack entry contains a bridge bus enumeration state.

When a bridge endpoint is detected on the current bus, it is
configured and this new bus is pushed on top of the stack in
order to be enumerated at next loop.

When enumeration ends on the bus, the current bus state is
removed from the stack to continue enumeration on the previous
bus.

This enumeration affects a sequential bus number to each new
bus detected in the same order as Linux & U-Boot does.

In this hierarchy:
       [0         1          2   ...   31]
        |         |          |
        EP        |          |
                  |          |
        [0   1  ... 31]   [0  ... 31]
         |   |             |
         |  EP             |
         |              [0 ... 31]
     [0 ... 31]          |
      |                 EP
     EP

We will get the following BDFs enumeration order:
 00:00.0	Endpoint
 00:01.0	Bridge => Bus primary 0 secondary 1
 01:00.0	Bridge => Bus primary 1 secondary 2
 02:00.0	Endpoint
 ... Bus secondary 2 => subordinate 2
 01:01.0	Endpoint
 ... Bus secondary 1 => subordinate 2
 00:02.0	Bridge => Bus primary 0 secondary 3
 03:00.0	Bridge => Bus primary 3 secondary 4
 04:00.0	Endpoint
 ... Bus secondary 4 => subordinate 4
 ... Bus secondary 3 => subordinate 4

The gives the following primary/secondary/subordinate map:
 Bus 0 [0         1              2   ...   31]
        |         |              |
        |      [0:1->2]      [0:3->4]
   EP 00:00.0     |              |
                  |              |
  Bus 1 [0   1  ... 31]  Bus 3 [0  ... 31]
         |   |                  |
         |  EP 01:01.0          |
     [1:2->2]                [3:4->4]
         |                      |
         |            Bus 4  [0 ... 31]
Bus 2 [0 ... 31]              |
       |                     EP 04:00.0
      EP 02:00.0

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2022-01-19 13:37:36 -05:00
..
endpoint drivers: pcie: build as static library 2021-08-17 06:06:03 -04:00
host pcie: controller: add non-recursive pcie busses enumeration 2022-01-19 13:37:36 -05:00
CMakeLists.txt drivers: pcie: refactor pcie directory to make RC and EP independent 2020-07-14 19:35:31 -04:00
Kconfig drivers: pcie: refactor pcie directory to make RC and EP independent 2020-07-14 19:35:31 -04:00