device: Add support for multiple PCI segment groups

Add initial support for multiple PCI segment groups. Instead of
modifying secondary in the bus struct introduce a new segment_group
struct element and keep existing common code.

Since all platforms currently only use 1 segment this is not a
functional change. On platforms that support more than 1 segment the
segment has to be set when creating the PCI domain.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: Ied3313c41896362dd989ee2ab1b1bcdced840aa8
Reviewed-on: https://review.coreboot.org/c/coreboot/+/79927
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com>
diff --git a/src/device/Kconfig b/src/device/Kconfig
index 5202c18..e5b90bb 100644
--- a/src/device/Kconfig
+++ b/src/device/Kconfig
@@ -589,6 +589,13 @@
 config ECAM_MMCONF_BUS_NUMBER
 	int
 	depends on ECAM_MMCONF_SUPPORT
+	help
+	  Total number of PCI buses in the system across all segment groups.
+	  The number needs to be a power of 2. For values <= 256,
+	  PCI_BUSES_PER_SEGMENT_GROUP is CONFIG_ECAM_MMCONF_BUS_NUMBER and
+	  PCI_SEGMENT_GROUP_COUNT is 1. For values > 256,
+	  PCI_BUSES_PER_SEGMENT_GROUP is 256 and PCI_SEGMENT_GROUP_COUNT is
+	  CONFIG_ECAM_MMCONF_BUS_NUMBER / 256.
 
 config ECAM_MMCONF_LENGTH
 	hex
@@ -597,6 +604,8 @@
 	default 0x04000000 if ECAM_MMCONF_BUS_NUMBER = 64
 	default 0x08000000 if ECAM_MMCONF_BUS_NUMBER = 128
 	default 0x10000000 if ECAM_MMCONF_BUS_NUMBER = 256
+	default 0x20000000 if ECAM_MMCONF_BUS_NUMBER = 512
+	default 0x80000000 if ECAM_MMCONF_BUS_NUMBER = 1024
 	default 0x0
 
 config PCI_ALLOW_BUS_MASTER