Skip to content

Commit

Permalink
Platform/RPi4: Prepare ACPI code for factorization
Browse files Browse the repository at this point in the history
* Update the OEM IDs and base revision numbers.
* Move RPI_SYSTEM_TIMER_BASE_ADDRESS to AcpiTables.h.
* Add RPi3 constants and conditional blocks according to model.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
  • Loading branch information
pbatard authored and Ard Biesheuvel committed Mar 2, 2020
1 parent 3627ffc commit 223bfea
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 7 deletions.
48 changes: 42 additions & 6 deletions Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/** @file
*
* RPi4 defines for constructing ACPI tables
* RPi defines for constructing ACPI tables
*
* Copyright (c) 2020, Pete Batard <pete@akeo.ie>
* Copyright (c) 2019, ARM Ltd. All rights reserved.
* Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
* Copyright (c) Microsoft Corporation. All rights reserved.
Expand All @@ -23,11 +24,15 @@
CreateDwordField (^BufName, ^MemName._BAS, VarName) \
Add (BCM2836_SOC_REGISTERS, Offset, VarName)

#define EFI_ACPI_OEM_ID {'M','C','R','S','F','T'} // OEMID 6 bytes long
#define EFI_ACPI_OEM_TABLE_ID SIGNATURE_64 ('R','P','I','4','E','D','K','2') // OEM table id 8 bytes long
#define EFI_ACPI_OEM_REVISION 0x02000820
#define EFI_ACPI_CREATOR_ID SIGNATURE_32 ('R','P','I','4')
#define EFI_ACPI_CREATOR_REVISION 0x00000097
#if (RPI_MODEL == 3)
#define EFI_ACPI_OEM_ID {'B','C','2','8','3','6'}
#else
#define EFI_ACPI_OEM_ID {'M','C','R','S','F','T'}
#endif
#define EFI_ACPI_OEM_TABLE_ID SIGNATURE_64 ('R','P','I','_','E','D','K','2')
#define EFI_ACPI_OEM_REVISION 0x00000100
#define EFI_ACPI_CREATOR_ID SIGNATURE_32 ('E','D','K','2')
#define EFI_ACPI_CREATOR_REVISION 0x00000100

#define EFI_ACPI_VENDOR_ID SIGNATURE_32 ('M','S','F','T')

Expand All @@ -52,6 +57,12 @@
#define RPI_DMA_CHANNEL_COUNT 10 // All 10 DMA channels are listed, including the reserved ones
#define RPI_DMA_USED_CHANNEL_COUNT 5 // Use 5 DMA channels

#if (RPI_MODEL == 3)
#define RPI_SYSTEM_TIMER_BASE_ADDRESS 0x4000001C
#elif (RPI_MODEL == 4)
#define RPI_SYSTEM_TIMER_BASE_ADDRESS 0xFF80001C
#endif

#define EFI_ACPI_5_1_CSRT_REVISION 0x00000000

typedef enum
Expand Down Expand Up @@ -100,6 +111,30 @@ typedef struct
//------------------------------------------------------------------------
// Interrupts. These are specific to each platform
//------------------------------------------------------------------------
#if (RPI_MODEL == 3)
#define BCM2836_V3D_BUS_INTERRUPT 0x2A
#define BCM2836_DMA_INTERRUPT 0x3B
#define BCM2836_SPI1_INTERRUPT 0x3D
#define BCM2836_SPI2_INTERRUPT 0x3D
#define BCM2836_HVS_INTERRUPT 0x41
#define BCM2836_HDMI0_INTERRUPT 0x48
#define BCM2836_HDMI1_INTERRUPT 0x49
#define BCM2836_PV2_INTERRUPT 0x4A
#define BCM2836_PV0_INTERRUPT 0x4D
#define BCM2836_PV1_INTERRUPT 0x4E
#define BCM2836_MBOX_INTERRUPT 0x61
#define BCM2836_VCHIQ_INTERRUPT 0x62
#define BCM2386_GPIO_INTERRUPT0 0x51
#define BCM2386_GPIO_INTERRUPT1 0x53
#define BCM2836_I2C1_INTERRUPT 0x55
#define BCM2836_I2C2_INTERRUPT 0x55
#define BCM2836_SPI0_INTERRUPT 0x56
#define BCM2836_USB_INTERRUPT 0x29
#define BCM2836_SDHOST_INTERRUPT 0x58
#define BCM2836_MMCHS1_INTERRUPT 0x5E
#define BCM2836_MINI_UART_INTERRUPT 0x3D
#define BCM2836_PL011_UART_INTERRUPT 0x59
#elif (RPI_MODEL == 4)
#define BCM2836_V3D_BUS_INTERRUPT 0x2A
#define BCM2836_DMA_INTERRUPT 0x3B
#define BCM2836_SPI1_INTERRUPT 0x3D
Expand All @@ -124,5 +159,6 @@ typedef struct
#define BCM2836_PL011_UART_INTERRUPT 0x99
#define GENET_INTERRUPT0 0xBD
#define GENET_INTERRUPT1 0xBE
#endif

#endif // __ACPITABLES_H__
4 changes: 4 additions & 0 deletions Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
{
include ("Sdhc.asl")
include ("Pep.asl")
#if (RPI_MODEL == 4)
include ("Xhci.asl")
#endif

Device (CPU0)
{
Expand Down Expand Up @@ -286,6 +288,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
}
}

#if (RPI_MODEL == 4)
Device (ETH0)
{
Name (_HID, "BCM6E4E")
Expand Down Expand Up @@ -314,6 +317,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2)
}
})
}
#endif

// Description: I2C
Device (I2C1)
Expand Down
1 change: 0 additions & 1 deletion Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "AcpiTables.h"

#define RPI_SYSTEM_TIMER_BASE_ADDRESS 0xFF80001C
#define RPI_GTDT_GLOBAL_FLAGS 0
#define RPI_GTDT_GTIMER_FLAGS EFI_ACPI_5_1_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY

Expand Down
15 changes: 15 additions & 0 deletions Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
typedef struct {
EFI_ACPI_5_1_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER Header;
EFI_ACPI_5_1_GIC_STRUCTURE GicInterfaces[4];
#if (RPI_MODEL != 3)
EFI_ACPI_5_1_GIC_DISTRIBUTOR_STRUCTURE GicDistributor;
#endif
} PI_MULTIPLE_APIC_DESCRIPTION_TABLE;

#pragma pack ()
Expand All @@ -42,6 +44,16 @@ PI_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
0, // Flags
},
{
#if (RPI_MODEL == 3)
EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
1, 1, GET_MPID(0, 1), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
2, 2, GET_MPID(0, 2), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 0x09, 0x40000000, 0, 0, 0, 0),
#elif (RPI_MODEL == 4)
EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 48, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
0xFF846000, 0xFF844000, 0x19, 0),
Expand All @@ -54,8 +66,11 @@ PI_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
EFI_ACPI_5_1_GICC_STRUCTURE_INIT(
3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 51, FixedPcdGet64 (PcdGicInterruptInterfaceBase),
0xFF846000, 0xFF844000, 0x19, 0),
#endif
},
#if (RPI_MODEL != 3)
EFI_ACPI_5_0_GIC_DISTRIBUTOR_INIT(0, FixedPcdGet64 (PcdGicDistributorBase), 0)
#endif
};

//
Expand Down

0 comments on commit 223bfea

Please sign in to comment.