[edk2-platforms PATCH 6/6] Marvell: IcuLib: Rework default interrupt map


Marcin Wojtas
 

The ICU to GIC interrupt mapping was fixed to support
the maximum of two CP11x south bridge units. Rework
the default map to use only the interrupts wired
to controllers supported in the ACPI tables.
Thanks to above all necessary IRQs from the CN913x
SoCs (maximum 3 CP11x) can be mapped and passed to the OS.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
Silicon/Marvell/Armada7k8k/AcpiTables/IcuInterrupts.h | 48 ++++----
Silicon/Marvell/Library/IcuLib/IcuLib.h | 6 +-
Silicon/Marvell/OcteonTx/AcpiTables/T91/IcuInterrupts.h | 61 +++++++----
Silicon/Marvell/Library/IcuLib/IcuLib.c | 115 ++++++------=
--------
4 files changed, 95 insertions(+), 135 deletions(-)

diff --git a/Silicon/Marvell/Armada7k8k/AcpiTables/IcuInterrupts.h b/Silico=
n/Marvell/Armada7k8k/AcpiTables/IcuInterrupts.h
index b106790913..a2b7b00b0d 100644
--- a/Silicon/Marvell/Armada7k8k/AcpiTables/IcuInterrupts.h
+++ b/Silicon/Marvell/Armada7k8k/AcpiTables/IcuInterrupts.h
@@ -11,28 +11,28 @@
=0D
**/=0D
=0D
-#define CP_GIC_SPI_CP0_PCI0 64=0D
-#define CP_GIC_SPI_CP0_PCI1 65=0D
-#define CP_GIC_SPI_CP0_PCI2 66=0D
-#define CP_GIC_SPI_CP0_SDMMC 67=0D
-#define CP_GIC_SPI_PP2_CP0_PORT0 69, 72, 75, 78, 81, 127=0D
-#define CP_GIC_SPI_PP2_CP0_PORT1 70, 73, 76, 79, 82, 126=0D
-#define CP_GIC_SPI_PP2_CP0_PORT2 71, 74, 77, 80, 83, 125=0D
-#define CP_GIC_SPI_CP0_EIP_RNG0 105=0D
-#define CP_GIC_SPI_CP0_USB_H1 112=0D
-#define CP_GIC_SPI_CP0_USB_H0 113=0D
-#define CP_GIC_SPI_CP0_SATA_H0 114=0D
-#define CP_GIC_SPI_CP0_UART0 121=0D
-#define CP_GIC_SPI_CP0_UART1 122=0D
+#define CP_GIC_SPI_CP0_SDMMC 64=0D
+#define CP_GIC_SPI_PP2_CP0_PORT0 65, 68, 71, 74, 77, 90=0D
+#define CP_GIC_SPI_PP2_CP0_PORT1 66, 69, 72, 75, 78, 89=0D
+#define CP_GIC_SPI_PP2_CP0_PORT2 67, 70, 73, 76, 79, 88=0D
+#define CP_GIC_SPI_CP0_EIP_RNG0 80=0D
+#define CP_GIC_SPI_CP0_USB_H1 81=0D
+#define CP_GIC_SPI_CP0_USB_H0 82=0D
+#define CP_GIC_SPI_CP0_SATA_H0 83=0D
+#define CP_GIC_SPI_CP0_UART0 84=0D
+#define CP_GIC_SPI_CP0_UART1 85=0D
+#define CP_GIC_SPI_CP0_UART2 86=0D
+#define CP_GIC_SPI_CP0_UART3 87=0D
=0D
-#define CP_GIC_SPI_CP1_PCI0 288=0D
-#define CP_GIC_SPI_CP1_PCI1 289=0D
-#define CP_GIC_SPI_CP1_PCI2 290=0D
-#define CP_GIC_SPI_CP1_SDMMC 291=0D
-#define CP_GIC_SPI_PP2_CP1_PORT0 293, 296, 299, 302, 305, 351=0D
-#define CP_GIC_SPI_PP2_CP1_PORT1 294, 297, 300, 303, 306, 350=0D
-#define CP_GIC_SPI_PP2_CP1_PORT2 295, 298, 301, 304, 307, 349=0D
-#define CP_GIC_SPI_CP1_EIP_RNG0 329=0D
-#define CP_GIC_SPI_CP1_USB_H1 336=0D
-#define CP_GIC_SPI_CP1_USB_H0 337=0D
-#define CP_GIC_SPI_CP1_SATA_H0 338=0D
+#define CP_GIC_SPI_CP1_SDMMC 96=0D
+#define CP_GIC_SPI_PP2_CP1_PORT0 97, 100, 103, 106, 109, 122=0D
+#define CP_GIC_SPI_PP2_CP1_PORT1 98, 101, 104, 107, 110, 121=0D
+#define CP_GIC_SPI_PP2_CP1_PORT2 99, 102, 105, 108, 111, 120=0D
+#define CP_GIC_SPI_CP1_EIP_RNG0 112=0D
+#define CP_GIC_SPI_CP1_USB_H1 113=0D
+#define CP_GIC_SPI_CP1_USB_H0 114=0D
+#define CP_GIC_SPI_CP1_SATA_H0 115=0D
+#define CP_GIC_SPI_CP1_UART0 116=0D
+#define CP_GIC_SPI_CP1_UART1 117=0D
+#define CP_GIC_SPI_CP1_UART2 118=0D
+#define CP_GIC_SPI_CP1_UART3 119=0D
diff --git a/Silicon/Marvell/Library/IcuLib/IcuLib.h b/Silicon/Marvell/Libr=
ary/IcuLib/IcuLib.h
index 22027f6bc0..cc1fc5754b 100644
--- a/Silicon/Marvell/Library/IcuLib/IcuLib.h
+++ b/Silicon/Marvell/Library/IcuLib/IcuLib.h
@@ -22,7 +22,7 @@
#include <Library/PcdLib.h>=0D
#include <Library/UefiBootServicesTableLib.h>=0D
=0D
-#define ICU_REG_BASE(Cp) (ArmadaSoCDescCpBaseGet (CpIndex) + 0x1E00=
00)=0D
+#define ICU_REG_BASE(CpIndex) (ArmadaSoCDescCpBaseGet (CpIndex) + 0x1E00=
00)=0D
=0D
#define ICU_GROUP_REGISTER_BASE_OFFSET 0x10=0D
#define ICU_SET_SPI_AL(x) (0x10 + (ICU_GROUP_REGISTER_BASE_OFFSET * =
x))=0D
@@ -35,7 +35,7 @@
#define ICU_IS_EDGE_OFFSET 28=0D
#define ICU_GROUP_OFFSET 29=0D
=0D
-#define ICU_MAX_SUPPORTED_UNITS 2=0D
-#define ICU_MAX_IRQS_PER_CP 64=0D
+#define ICU_MAX_SUPPORTED_UNITS 3=0D
+#define ICU_SPI_OFFSET(CpIndex) ((CpIndex) * 32)=0D
=0D
#define MAX_ICU_IRQS 207=0D
diff --git a/Silicon/Marvell/OcteonTx/AcpiTables/T91/IcuInterrupts.h b/Sili=
con/Marvell/OcteonTx/AcpiTables/T91/IcuInterrupts.h
index 83006ebd8a..fea820f9ed 100644
--- a/Silicon/Marvell/OcteonTx/AcpiTables/T91/IcuInterrupts.h
+++ b/Silicon/Marvell/OcteonTx/AcpiTables/T91/IcuInterrupts.h
@@ -11,28 +11,41 @@
=0D
**/=0D
=0D
-#define CP_GIC_SPI_CP0_PCI0 64=0D
-#define CP_GIC_SPI_CP0_PCI1 65=0D
-#define CP_GIC_SPI_CP0_PCI2 66=0D
-#define CP_GIC_SPI_CP0_SDMMC 67=0D
-#define CP_GIC_SPI_PP2_CP0_PORT0 69, 72, 75, 78, 81, 127=0D
-#define CP_GIC_SPI_PP2_CP0_PORT1 70, 73, 76, 79, 82, 126=0D
-#define CP_GIC_SPI_PP2_CP0_PORT2 71, 74, 77, 80, 83, 125=0D
-#define CP_GIC_SPI_CP0_EIP_RNG0 105=0D
-#define CP_GIC_SPI_CP0_USB_H1 112=0D
-#define CP_GIC_SPI_CP0_USB_H0 113=0D
-#define CP_GIC_SPI_CP0_SATA_H0 114=0D
-#define CP_GIC_SPI_CP0_UART0 121=0D
-#define CP_GIC_SPI_CP0_UART1 122=0D
+#define CP_GIC_SPI_CP0_SDMMC 64=0D
+#define CP_GIC_SPI_PP2_CP0_PORT0 65, 68, 71, 74, 77, 90=0D
+#define CP_GIC_SPI_PP2_CP0_PORT1 66, 69, 72, 75, 78, 89=0D
+#define CP_GIC_SPI_PP2_CP0_PORT2 67, 70, 73, 76, 79, 88=0D
+#define CP_GIC_SPI_CP0_EIP_RNG0 80=0D
+#define CP_GIC_SPI_CP0_USB_H1 81=0D
+#define CP_GIC_SPI_CP0_USB_H0 82=0D
+#define CP_GIC_SPI_CP0_SATA_H0 83=0D
+#define CP_GIC_SPI_CP0_UART0 84=0D
+#define CP_GIC_SPI_CP0_UART1 85=0D
+#define CP_GIC_SPI_CP0_UART2 86=0D
+#define CP_GIC_SPI_CP0_UART3 87=0D
=0D
-#define CP_GIC_SPI_CP1_PCI0 288=0D
-#define CP_GIC_SPI_CP1_PCI1 289=0D
-#define CP_GIC_SPI_CP1_PCI2 290=0D
-#define CP_GIC_SPI_CP1_SDMMC 291=0D
-#define CP_GIC_SPI_PP2_CP1_PORT0 293, 296, 299, 302, 305, 351=0D
-#define CP_GIC_SPI_PP2_CP1_PORT1 294, 297, 300, 303, 306, 350=0D
-#define CP_GIC_SPI_PP2_CP1_PORT2 295, 298, 301, 304, 307, 349=0D
-#define CP_GIC_SPI_CP1_EIP_RNG0 329=0D
-#define CP_GIC_SPI_CP1_USB_H1 336=0D
-#define CP_GIC_SPI_CP1_USB_H0 337=0D
-#define CP_GIC_SPI_CP1_SATA_H0 338=0D
+#define CP_GIC_SPI_CP1_SDMMC 96=0D
+#define CP_GIC_SPI_PP2_CP1_PORT0 97, 100, 103, 106, 109, 122=0D
+#define CP_GIC_SPI_PP2_CP1_PORT1 98, 101, 104, 107, 110, 121=0D
+#define CP_GIC_SPI_PP2_CP1_PORT2 99, 102, 105, 108, 111, 120=0D
+#define CP_GIC_SPI_CP1_EIP_RNG0 112=0D
+#define CP_GIC_SPI_CP1_USB_H1 113=0D
+#define CP_GIC_SPI_CP1_USB_H0 114=0D
+#define CP_GIC_SPI_CP1_SATA_H0 115=0D
+#define CP_GIC_SPI_CP1_UART0 116=0D
+#define CP_GIC_SPI_CP1_UART1 117=0D
+#define CP_GIC_SPI_CP1_UART2 118=0D
+#define CP_GIC_SPI_CP1_UART3 119=0D
+=0D
+#define CP_GIC_SPI_CP2_SDMMC 288=0D
+#define CP_GIC_SPI_PP2_CP2_PORT0 289, 292, 295, 298, 301, 314=0D
+#define CP_GIC_SPI_PP2_CP2_PORT1 290, 293, 296, 299, 302, 313=0D
+#define CP_GIC_SPI_PP2_CP2_PORT2 291, 294, 297, 300, 303, 312=0D
+#define CP_GIC_SPI_CP2_EIP_RNG0 304=0D
+#define CP_GIC_SPI_CP2_USB_H1 305=0D
+#define CP_GIC_SPI_CP2_USB_H0 306=0D
+#define CP_GIC_SPI_CP2_SATA_H0 307=0D
+#define CP_GIC_SPI_CP2_UART0 308=0D
+#define CP_GIC_SPI_CP2_UART1 309=0D
+#define CP_GIC_SPI_CP2_UART2 310=0D
+#define CP_GIC_SPI_CP2_UART3 311=0D
diff --git a/Silicon/Marvell/Library/IcuLib/IcuLib.c b/Silicon/Marvell/Libr=
ary/IcuLib/IcuLib.c
index 4d9f17445e..e4cb993c7e 100644
--- a/Silicon/Marvell/Library/IcuLib/IcuLib.c
+++ b/Silicon/Marvell/Library/IcuLib/IcuLib.c
@@ -16,73 +16,34 @@
STATIC EFI_EVENT mEfiExitBootServicesEvent;=0D
=0D
STATIC CONST ICU_IRQ IrqMapNonSecure[] =3D {=0D
- {22, 0, IcuIrqTypeLevel}, /* PCIx4 INT A interrupt */=0D
- {23, 1, IcuIrqTypeLevel}, /* PCIx1 INT A interrupt */=0D
- {24, 2, IcuIrqTypeLevel}, /* PCIx1 INT A interrupt */=0D
- {27, 3, IcuIrqTypeLevel}, /* SD/MMC */=0D
- {33, 4, IcuIrqTypeLevel}, /* PPv2 DBG AXI monitor */=0D
- {34, 4, IcuIrqTypeLevel}, /* HB1 AXI monitor */=0D
- {35, 4, IcuIrqTypeLevel}, /* AP AXI monitor */=0D
- {36, 4, IcuIrqTypeLevel}, /* PPv2 AXI monitor */=0D
- {39, 5, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {40, 6, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {41, 7, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {43, 8, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {44, 9, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {45, 10, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {47, 11, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {48, 12, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {49, 13, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {51, 14, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {52, 15, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {53, 16, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {55, 17, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {56, 18, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {57, 19, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {59, 20, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {60, 21, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {61, 22, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {63, 23, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {64, 24, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {65, 25, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {67, 26, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {68, 27, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {69, 28, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {71, 29, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {72, 30, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {73, 31, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
- {78, 32, IcuIrqTypeLevel}, /* MG Irq */=0D
- {79, 33, IcuIrqTypeLevel}, /* GPIO 56-63 */=0D
- {80, 34, IcuIrqTypeLevel}, /* GPIO 48-55 */=0D
- {81, 35, IcuIrqTypeLevel}, /* GPIO 40-47 */=0D
- {82, 36, IcuIrqTypeLevel}, /* GPIO 32-39 */=0D
- {83, 37, IcuIrqTypeLevel}, /* GPIO 24-31 */=0D
- {84, 38, IcuIrqTypeLevel}, /* GPIO 16-23 */=0D
- {85, 39, IcuIrqTypeLevel}, /* GPIO 8-15 */=0D
- {86, 40, IcuIrqTypeLevel}, /* GPIO 0-7 */=0D
- {88, 41, IcuIrqTypeLevel}, /* EIP-197 ring-0 */=0D
- {89, 42, IcuIrqTypeLevel}, /* EIP-197 ring-1 */=0D
- {90, 43, IcuIrqTypeLevel}, /* EIP-197 ring-2 */=0D
- {91, 44, IcuIrqTypeLevel}, /* EIP-197 ring-3 */=0D
- {92, 45, IcuIrqTypeLevel}, /* EIP-197 int */=0D
- {95, 46, IcuIrqTypeLevel}, /* EIP-150 Irq */=0D
- {102, 47, IcuIrqTypeLevel}, /* USB3 Device Irq */=0D
- {105, 48, IcuIrqTypeLevel}, /* USB3 Host-1 Irq */=0D
- {106, 49, IcuIrqTypeLevel}, /* USB3 Host-0 Irq */=0D
- {107, 50, IcuIrqTypeLevel}, /* SATA Host-1 Irq */=0D
- {109, 50, IcuIrqTypeLevel}, /* SATA Host-0 Irq */=0D
- {115, 52, IcuIrqTypeLevel}, /* NAND Irq */=0D
- {117, 53, IcuIrqTypeLevel}, /* SPI-1 Irq */=0D
- {118, 54, IcuIrqTypeLevel}, /* SPI-0 Irq */=0D
- {120, 55, IcuIrqTypeLevel}, /* I2C 0 Irq */=0D
- {121, 56, IcuIrqTypeLevel}, /* I2C 1 Irq */=0D
- {122, 57, IcuIrqTypeLevel}, /* UART 0 Irq */=0D
- {123, 58, IcuIrqTypeLevel}, /* UART 1 Irq */=0D
- {124, 59, IcuIrqTypeLevel}, /* UART 2 Irq */=0D
- {125, 60, IcuIrqTypeLevel}, /* UART 3 Irq */=0D
- {127, 61, IcuIrqTypeLevel}, /* GOP-3 Irq */=0D
- {128, 62, IcuIrqTypeLevel}, /* GOP-2 Irq */=0D
- {129, 63, IcuIrqTypeLevel}, /* GOP-0 Irq */=0D
+ {27, 0, IcuIrqTypeLevel}, /* SD/MMC */=0D
+ {39, 1, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {40, 2, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {41, 3, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {43, 4, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {44, 5, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {45, 6, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {47, 7, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {48, 8, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {49, 9, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {51, 10, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {52, 11, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {53, 12, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {55, 13, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {56, 14, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {57, 15, IcuIrqTypeLevel}, /* PPv2 Irq */=0D
+ {88, 16, IcuIrqTypeLevel}, /* EIP-197 ring-0 */=0D
+ {105, 17, IcuIrqTypeLevel}, /* USB3 Host-1 Irq */=0D
+ {106, 18, IcuIrqTypeLevel}, /* USB3 Host-0 Irq */=0D
+ {107, 19, IcuIrqTypeLevel}, /* SATA Host-1 Irq */=0D
+ {109, 19, IcuIrqTypeLevel}, /* SATA Host-0 Irq */=0D
+ {122, 20, IcuIrqTypeLevel}, /* UART 0 Irq */=0D
+ {123, 21, IcuIrqTypeLevel}, /* UART 1 Irq */=0D
+ {124, 22, IcuIrqTypeLevel}, /* UART 2 Irq */=0D
+ {125, 23, IcuIrqTypeLevel}, /* UART 3 Irq */=0D
+ {127, 24, IcuIrqTypeLevel}, /* GOP-3 Irq */=0D
+ {128, 25, IcuIrqTypeLevel}, /* GOP-2 Irq */=0D
+ {129, 26, IcuIrqTypeLevel}, /* GOP-0 Irq */=0D
};=0D
=0D
/*=0D
@@ -177,7 +138,7 @@ IcuConfigure (
/* Get the base of the GIC SPI ID in the MSI message */=0D
SpiBase =3D IcuDesc->IcuSpiBase;=0D
/* Get multiple CP110 instances SPI ID shift */=0D
- SpiOffset =3D CpIndex * ICU_MAX_IRQS_PER_CP;=0D
+ SpiOffset =3D ICU_SPI_OFFSET (CpIndex);=0D
/* Get MSI addresses per interrupt group */=0D
Msi =3D IcuDesc->IcuMsi;=0D
=0D
@@ -230,7 +191,7 @@ IcuClearGicSpi (
/* Get the base of the GIC SPI ID in the MSI message */=0D
SpiBase =3D IcuDesc->IcuSpiBase;=0D
/* Get multiple CP110 instances SPI ID shift */=0D
- SpiOffset =3D CpIndex * ICU_MAX_IRQS_PER_CP;=0D
+ SpiOffset =3D ICU_SPI_OFFSET (CpIndex);=0D
/* Get MSI addresses per interrupt group */=0D
Msi =3D IcuDesc->IcuMsi;=0D
=0D
@@ -254,10 +215,6 @@ IcuCleanUp (
IcuDesc =3D Context;=0D
=0D
CpCount =3D FixedPcdGet8 (PcdMaxCpCount);=0D
- if (CpCount > ICU_MAX_SUPPORTED_UNITS) {=0D
- CpCount =3D ICU_MAX_SUPPORTED_UNITS;=0D
- }=0D
-=0D
for (CpIndex =3D 0; CpIndex < CpCount; CpIndex++) {=0D
IcuClearGicSpi (CpIndex, IcuDesc);=0D
}=0D
@@ -272,18 +229,8 @@ ArmadaIcuInitialize (
UINTN CpCount, CpIndex;=0D
EFI_STATUS Status;=0D
=0D
- /*=0D
- * Due to limited amount of interrupt lanes, only 2 units can be=0D
- * wired to the GIC.=0D
- */=0D
CpCount =3D FixedPcdGet8 (PcdMaxCpCount);=0D
- if (CpCount > ICU_MAX_SUPPORTED_UNITS) {=0D
- DEBUG ((DEBUG_ERROR,=0D
- "%a: Default ICU to GIC mapping is available for maximum %d CP110 un=
its",=0D
- __FUNCTION__,=0D
- ICU_MAX_SUPPORTED_UNITS));=0D
- CpCount =3D ICU_MAX_SUPPORTED_UNITS;=0D
- }=0D
+ ASSERT (CpCount <=3D ICU_MAX_SUPPORTED_UNITS);=0D
=0D
/* Obtain SoC description of the ICU */=0D
Status =3D ArmadaSoCDescIcuGet (&IcuDesc);=0D
--=20
2.29.0