diff options
author | Pierre Gondois <pierre.gondois@arm.com> | 2024-06-10 14:00:00 +0200 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-07-29 13:44:55 +0000 |
commit | d8aa665b31e309a31b59b97d04ba8d003f4fe84e (patch) | |
tree | 4fd0e00a3b2dc926520d31b684a8a4ea21ffcec2 | |
parent | 5782aef055fe76c99acdfd2e27051c148782ad66 (diff) | |
download | edk2-d8aa665b31e309a31b59b97d04ba8d003f4fe84e.tar.gz edk2-d8aa665b31e309a31b59b97d04ba8d003f4fe84e.tar.bz2 edk2-d8aa665b31e309a31b59b97d04ba8d003f4fe84e.zip |
DynamicTablesPkg: FdtHwInfoParserLib: Move IRQ map to arch folder
The interrupts property in DT is arch specific.
Move the current implementation and the way to decode the property
to the Arm folder to prepare for other architecture support.
Suggested-by: Sunil V L <sunilvl@ventanamicro.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
3 files changed, 86 insertions, 71 deletions
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c new file mode 100644 index 0000000000..21b1306e57 --- /dev/null +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/Arm/ArmFdtInterrupt.c @@ -0,0 +1,85 @@ +/** @file
+ Flattened device tree utility.
+
+ Copyright (c) 2021, ARM Limited. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Reference(s):
+ - Device tree Specification - Release v0.3
+ - linux/Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic.yaml
+ - linux//Documentation/devicetree/bindings/interrupt-controller/arm%2Cgic.yaml
+**/
+
+#include <FdtHwInfoParserInclude.h>
+#include "FdtUtility.h"
+
+/** Get the interrupt Id of an interrupt described in a fdt.
+
+ Data must describe a GIC interrupt. A GIC interrupt is on at least
+ 3 UINT32 cells.
+ This function DOES NOT SUPPORT extended SPI range and extended PPI range.
+
+ @param [in] Data Pointer to the first cell of an "interrupts" property.
+
+ @retval The interrupt id.
+**/
+UINT32
+EFIAPI
+FdtGetInterruptId (
+ UINT32 CONST *Data
+ )
+{
+ UINT32 IrqType;
+ UINT32 IrqId;
+
+ ASSERT (Data != NULL);
+
+ IrqType = fdt32_to_cpu (Data[IRQ_TYPE_OFFSET]);
+ IrqId = fdt32_to_cpu (Data[IRQ_NUMBER_OFFSET]);
+
+ switch (IrqType) {
+ case DT_SPI_IRQ:
+ IrqId += SPI_OFFSET;
+ break;
+
+ case DT_PPI_IRQ:
+ IrqId += PPI_OFFSET;
+ break;
+
+ default:
+ ASSERT (0);
+ IrqId = 0;
+ }
+
+ return IrqId;
+}
+
+/** Get the ACPI interrupt flags of an interrupt described in a fdt.
+
+ Data must describe a GIC interrupt. A GIC interrupt is on at least
+ 3 UINT32 cells.
+
+ PPI interrupt cpu mask on bits [15:8] are ignored.
+
+ @param [in] Data Pointer to the first cell of an "interrupts" property.
+
+ @retval The interrupt flags (for ACPI).
+**/
+UINT32
+EFIAPI
+FdtGetInterruptFlags (
+ UINT32 CONST *Data
+ )
+{
+ UINT32 IrqFlags;
+ UINT32 AcpiIrqFlags;
+
+ ASSERT (Data != NULL);
+
+ IrqFlags = fdt32_to_cpu (Data[IRQ_FLAGS_OFFSET]);
+
+ AcpiIrqFlags = DT_IRQ_IS_EDGE_TRIGGERED (IrqFlags) ? BIT0 : 0;
+ AcpiIrqFlags |= DT_IRQ_IS_ACTIVE_LOW (IrqFlags) ? BIT1 : 0;
+
+ return AcpiIrqFlags;
+}
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf index d3010af527..c8511ab4dd 100644 --- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoParserLib.inf @@ -28,6 +28,7 @@ Serial/SerialPortParser.h
[Sources.ARM, Sources.AARCH64]
+ Arm/ArmFdtInterrupt.c
Arm/ArmFdtHwInfoParser.c
Arm/BootArch/ArmBootArchParser.c
Arm/BootArch/ArmBootArchParser.h
diff --git a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c index 5314cf3808..bab2285759 100644 --- a/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c +++ b/DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtUtility.c @@ -13,77 +13,6 @@ #include <FdtHwInfoParserInclude.h>
#include "FdtUtility.h"
-/** Get the interrupt Id of an interrupt described in a fdt.
-
- Data must describe a GIC interrupt. A GIC interrupt is on at least
- 3 UINT32 cells.
- This function DOES NOT SUPPORT extended SPI range and extended PPI range.
-
- @param [in] Data Pointer to the first cell of an "interrupts" property.
-
- @retval The interrupt id.
-**/
-UINT32
-EFIAPI
-FdtGetInterruptId (
- UINT32 CONST *Data
- )
-{
- UINT32 IrqType;
- UINT32 IrqId;
-
- ASSERT (Data != NULL);
-
- IrqType = fdt32_to_cpu (Data[IRQ_TYPE_OFFSET]);
- IrqId = fdt32_to_cpu (Data[IRQ_NUMBER_OFFSET]);
-
- switch (IrqType) {
- case DT_SPI_IRQ:
- IrqId += SPI_OFFSET;
- break;
-
- case DT_PPI_IRQ:
- IrqId += PPI_OFFSET;
- break;
-
- default:
- ASSERT (0);
- IrqId = 0;
- }
-
- return IrqId;
-}
-
-/** Get the ACPI interrupt flags of an interrupt described in a fdt.
-
- Data must describe a GIC interrupt. A GIC interrupt is on at least
- 3 UINT32 cells.
-
- PPI interrupt cpu mask on bits [15:8] are ignored.
-
- @param [in] Data Pointer to the first cell of an "interrupts" property.
-
- @retval The interrupt flags (for ACPI).
-**/
-UINT32
-EFIAPI
-FdtGetInterruptFlags (
- UINT32 CONST *Data
- )
-{
- UINT32 IrqFlags;
- UINT32 AcpiIrqFlags;
-
- ASSERT (Data != NULL);
-
- IrqFlags = fdt32_to_cpu (Data[IRQ_FLAGS_OFFSET]);
-
- AcpiIrqFlags = DT_IRQ_IS_EDGE_TRIGGERED (IrqFlags) ? BIT0 : 0;
- AcpiIrqFlags |= DT_IRQ_IS_ACTIVE_LOW (IrqFlags) ? BIT1 : 0;
-
- return AcpiIrqFlags;
-}
-
/** Check whether a node has the input name.
@param [in] Fdt Pointer to a Flattened Device Tree.
|