Implement ACPI on aarch64
Subsystems (10)
cover Implement ACPI on aarch64
Based on the existing work done by Simon Glass this series adds support for booting aarch64 devices using ACPI only. As target the Raspberry Pi4 was used, which is broadly available and allows easy testing of the proposed solution.
The series is split into ACPI cleanups and code movements, adding Arm specific ACPI tables and finally SoC and mainboard related changes to boot a Linux on the RPi4. Currently only the mandatory ACPI tables are supported, allowing to boot into Linux without errors.
The changes were tested on real hardware as well on QEMU v9.0:
qemu-system-aarch64 -machine raspi4b -kernel u-boot.bin -cpu cortex-a72 \
-smp 4 -m 2G -drive file=raspbian.img,format=raw,index=0 \
-dtb bcm2711-rpi-4-b.dtb -nographic
Please note that the current implementation still requires a DTB to be provided to U-Boot and that the DTB is used within U-Boot to load drivers, to disable/enable certain hardware blocks in ACPI. The DTB is not passed to the OS when using the bootefi cmd.
Tested against FWTS V24.03.00.
Known issues:
- The QEMU support is currently limited as it doesn't emulate PCI, USB or ethernet devices!
- The SMP bringup doesn't work on real hardware, but works in QEMU.
- PCI isn't working on real hardware since the pcie_brcmstb Linux kernel module doesn't support ACPI yet.
Maximilian Brune (3):
acpi: x86: Move SPCR and DBG2 into common code
acpi: x86: Write FADT in common code
serial: serial_pl01x: Implement .getinfo() for PL01
Patrick Rudolph (12):
acpi: x86: Move MADT to common code
acpi: Fix typo
acpi: Add define for GTDT
arm: acpi: Add generic ACPI methods
acpi: acpi_table: Bump revisions
acpi: Add ACPITAB for PPTT and GTDT
arm: mach-bcm283x: Map the ARM local MMIO as well
arm: bcm283x: Write ACPI tables
arm: cpu: Add ACPI parking protocol support
arm: mach-bcm283x: Add ARMV8_MULTIENTRY support
arm: mach-bcm283x: Enable ARMV8_MULTIENTRY
configs: Add RPI4 ACPI defconfig
Simon Glass (2):
arm: mach-bcm283x: Bring in some header files from tianocore
board: raspberrypi: Add ASL files from tianocore
arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/parking_protocol_v8.S | 102 +++++ arch/arm/cpu/armv8/start.S | 4 + arch/arm/include/asm/acpi_table.h | 70 ++++ arch/arm/lib/Makefile | 1 + arch/arm/lib/acpi_table.c | 131 ++++++ arch/arm/mach-bcm283x/Kconfig | 4 + arch/arm/mach-bcm283x/Makefile | 4 + arch/arm/mach-bcm283x/bcm2711_acpi.c | 172 ++++++++ .../mach-bcm283x/include/mach/acpi/bcm2711.h | 152 +++++++ .../mach-bcm283x/include/mach/acpi/bcm2836.h | 127 ++++++ .../include/mach/acpi/bcm2836_gpio.h | 19 + .../include/mach/acpi/bcm2836_gpu.h | 47 +++ .../include/mach/acpi/bcm2836_pwm.h | 33 ++ .../include/mach/acpi/bcm2836_sdhost.h | 18 + .../include/mach/acpi/bcm2836_sdio.h | 21 + arch/arm/mach-bcm283x/init.c | 79 +++- arch/sandbox/lib/Makefile | 9 +- arch/sandbox/lib/acpi_table.c | 7 + arch/x86/cpu/apollolake/acpi.c | 20 +- arch/x86/cpu/baytrail/acpi.c | 17 +- arch/x86/cpu/intel_common/acpi.c | 20 +- arch/x86/cpu/quark/acpi.c | 19 +- arch/x86/cpu/tangier/acpi.c | 31 +- arch/x86/include/asm/acpi_table.h | 26 +- arch/x86/lib/acpi_table.c | 243 +----------- board/raspberrypi/rpi/.gitignore | 3 + board/raspberrypi/rpi/Makefile | 2 + board/raspberrypi/rpi/acpitables.h | 91 +++++ board/raspberrypi/rpi/dsdt.asl | 290 ++++++++++++++ board/raspberrypi/rpi/emmc.asl | 136 +++++++ board/raspberrypi/rpi/gpudevs.asl | 372 ++++++++++++++++++ board/raspberrypi/rpi/pci.asl | 177 +++++++++ board/raspberrypi/rpi/pep.asl | 90 +++++ board/raspberrypi/rpi/rhpx.asl | 195 +++++++++ board/raspberrypi/rpi/rpi.c | 182 +++++++++ board/raspberrypi/rpi/sdhc.asl | 111 ++++++ board/raspberrypi/rpi/uart.asl | 208 ++++++++++ boot/bootflow.c | 8 +- configs/rpi_4_acpi_defconfig | 79 ++++ drivers/pci/pcie_brcmstb.c | 101 +---- drivers/serial/serial_pl01x.c | 24 ++ include/acpi/acpi_table.h | 107 +++-- include/serial.h | 1 + lib/Kconfig | 15 + lib/acpi/acpi_table.c | 317 ++++++++++++++- 46 files changed, 3414 insertions(+), 472 deletions(-) create mode 100644 arch/arm/cpu/armv8/parking_protocol_v8.S create mode 100644 arch/arm/lib/acpi_table.c create mode 100644 arch/arm/mach-bcm283x/bcm2711_acpi.c create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2711.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpio.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpu.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_pwm.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdhost.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdio.h create mode 100644 arch/sandbox/lib/acpi_table.c create mode 100644 board/raspberrypi/rpi/.gitignore create mode 100644 board/raspberrypi/rpi/acpitables.h create mode 100644 board/raspberrypi/rpi/dsdt.asl create mode 100644 board/raspberrypi/rpi/emmc.asl create mode 100644 board/raspberrypi/rpi/gpudevs.asl create mode 100644 board/raspberrypi/rpi/pci.asl create mode 100644 board/raspberrypi/rpi/pep.asl create mode 100644 board/raspberrypi/rpi/rhpx.asl create mode 100644 board/raspberrypi/rpi/sdhc.asl create mode 100644 board/raspberrypi/rpi/uart.asl create mode 100644 configs/rpi_4_acpi_defconfig
Signature · 1 line
2.45.2
PATCH 1/17 acpi: x86: Move SPCR and DBG2 into common code
From: Maximilian Brune <[email protected]>
This moves the SPCR and DBG2 table generation into common code, so that they can be used by architectures other than x86.
--- arch/x86/include/asm/acpi_table.h | 11 -- arch/x86/lib/acpi_table.c | 174 ---------------------- include/acpi/acpi_table.h | 54 ++++--- lib/acpi/acpi_table.c | 232 +++++++++++++++++++++++++++++- 4 files changed, 265 insertions(+), 206 deletions(-)
arch/x86/include/asm/acpi_table.h +0 -11
@@ -45,17 +45,6 @@ int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,*/ int acpi_write_hpet (struct acpi_ctx *ctx); -/** -* acpi_write_dbg2_pci_uart() - Write out a DBG2 table -* -* @ctx: Current ACPI context -* @dev: Debug UART device to describe -* @access_size: Access size for UART (e.g. ACPI_ACCESS_SIZE_DWORD_ACCESS) -* Return: 0 if OK, -ve on error -*/ -int acpi_write_dbg2_pci_uart (struct acpi_ctx *ctx,struct udevice *dev, -uint access_size); -/** * acpi_create_gnvs() - Create a GNVS (Global Non Volatile Storage) table *
arch/x86/lib/acpi_table.c +0 -174
186 lines not on this page · raw message
include/acpi/acpi_table.h +37 -17
66 lines not on this page · raw message
lib/acpi/acpi_table.c +228 -4
249 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH 01/17] acpi: x86: Move SPCR and DBG2 into common code
Quoted 10 lines · Patrick Rudolph
From: Maximilian Brune <[email protected]>
This moves the SPCR and DBG2 table generation into common code, so that they can be used by architectures other than x86.
Signed-off-by Maximilian Brune <[email protected]>Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Bin Meng <[email protected]>
Quoted 6 lines
--- arch/x86/include/asm/acpi_table.h | 11 -- arch/x86/lib/acpi_table.c | 174 ---------------------- include/acpi/acpi_table.h | 54 ++++--- lib/acpi/acpi_table.c | 232 +++++++++++++++++++++++++++++- 4 files changed, 265 insertions(+), 206 deletions(-)
This is adding new code too, so please put that in a separate patch.
Regards,
Simon
PATCH 2/17 acpi: x86: Write FADT in common code
In reply to Patrick RudolphFrom: Maximilian Brune <[email protected]>
Write the FADT in common code since it's used on all architectures. Let the cpu code fill out the FADT body by introducing a new weak function acpi_fill_fadt().
--- arch/x86/cpu/apollolake/acpi.c | 20 +++------------ arch/x86/cpu/baytrail/acpi.c | 17 +------------ arch/x86/cpu/quark/acpi.c | 19 +------------- arch/x86/cpu/tangier/acpi.c | 25 ++---------------- arch/x86/include/asm/acpi_table.h | 12 --------- arch/x86/lib/acpi_table.c | 23 ----------------- include/acpi/acpi_table.h | 9 +++++++ lib/acpi/acpi_table.c | 42 +++++++++++++++++++++++++++++++ 8 files changed, 59 insertions(+), 108 deletions(-)
arch/x86/cpu/apollolake/acpi.c +4 -16
@@ -128,8 +128,10 @@ int arch_madt_sci_irq_polarity(int sci)return MP_IRQ_POLARITY_LOW ; } -void fill_fadt (struct acpi_fadt *fadt) +void acpi_fill_fadt (struct acpi_fadt *fadt) { +intel_acpi_fill_fadt (fadt); + fadt->pm_tmr_blk =IOMAP_ACPI_BASE +PM1_TMR ; fadt->p_lvl2_lat =ACPI_FADT_C2_NOT_SUPPORTED ;
@@ -143,23 +145,9 @@ void fill_fadt(struct acpi_fadt *fadt) fadt->x_pm_tmr_blk.space_id =1 ; fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len *8 ; fadt->x_pm_tmr_blk.addrl =IOMAP_ACPI_BASE +PM1_TMR ; -} - -static int apl_write_fadt (struct acpi_ctx *ctx,const struct acpi_writer *entry) -{ -struct acpi_table_header *header; -struct acpi_fadt *fadt; - - fadt = ctx->current; -acpi_fadt_common (fadt, ctx->facs, ctx->dsdt); -intel_acpi_fill_fadt (fadt); -fill_fadt (fadt); - header = &fadt->header; - header->checksum =table_compute_checksum (fadt, header->length); -return acpi_add_fadt (ctx, fadt); + fadt->preferred_pm_profile =ACPI_PM_MOBILE ; } -ACPI_WRITER(5fadt, "FADT", apl_write_fadt, 0);int apl_acpi_fill_dmar (struct acpi_ctx *ctx) {
arch/x86/cpu/baytrail/acpi.c +1 -16
@@ -15,20 +15,13 @@#include <asm/arch/iomap.h> #include <dm/uclass-internal.h> -static int baytrail_write_fadt (struct acpi_ctx *ctx, -const struct acpi_writer *entry) +void acpi_fill_fadt (struct acpi_fadt *fadt) {struct acpi_table_header *header; -struct acpi_fadt *fadt; - fadt = ctx->current; header = &fadt->header;u16 pmbase =ACPI_BASE_ADDRESS ; -memset (fadt,'\0' ,sizeof (struct acpi_fadt )); - -acpi_fill_header (header,"FACP" ); - header->length =sizeof (struct acpi_fadt ); header->revision =4 ; fadt->preferred_pm_profile =ACPI_PM_MOBILE ;
@@ -77,9 +70,6 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx, fadt->reset_reg.addrh =0 ; fadt->reset_value =SYS_RST |RST_CPU |FULL_RST ; - fadt->x_firmware_ctrl =map_to_sysmem (ctx->facs); - fadt->x_dsdt =map_to_sysmem (ctx->dsdt); - fadt->x_pm1a_evt_blk.space_id =ACPI_ADDRESS_SPACE_IO ; fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len *8 ; fadt->x_pm1a_evt_blk.bit_offset =0 ;
@@ -135,12 +125,7 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx, fadt->x_gpe1_blk.access_size =0 ; fadt->x_gpe1_blk.addrl =0x0 ; fadt->x_gpe1_blk.addrh =0x0 ; - - header->checksum =table_compute_checksum (fadt, header->length); - -return acpi_add_fadt (ctx, fadt); } -ACPI_WRITER(5fadt, "FADT", baytrail_write_fadt, 0);int acpi_create_gnvs (struct acpi_global_nvs *gnvs) {
arch/x86/cpu/quark/acpi.c +1 -18
@@ -11,23 +11,14 @@#include <asm/arch/iomap.h> #include <linux/string.h> -static int quark_write_fadt (struct acpi_ctx *ctx, -const struct acpi_writer *entry) +void acpi_fill_fadt (struct acpi_fadt *fadt) {u16 pmbase =ACPI_PM1_BASE_ADDRESS ;struct acpi_table_header *header; -struct acpi_fadt *fadt; - fadt = ctx->current; header = &fadt->header; - -memset (fadt,'\0' ,sizeof (struct acpi_fadt )); - -acpi_fill_header (header,"FACP" ); - header->length =sizeof (struct acpi_fadt ); header->revision =4 ; - fadt->preferred_pm_profile =ACPI_PM_UNSPECIFIED ; fadt->sci_int =9 ; fadt->smi_cmd =0 ; fadt->acpi_enable =0 ;
@@ -73,9 +64,6 @@ static int quark_write_fadt(struct acpi_ctx *ctx, fadt->reset_reg.addrh =0 ; fadt->reset_value =SYS_RST |RST_CPU |FULL_RST ; - fadt->x_firmware_ctrl =map_to_sysmem (ctx->facs); - fadt->x_dsdt =map_to_sysmem (ctx->dsdt); - fadt->x_pm1a_evt_blk.space_id =ACPI_ADDRESS_SPACE_IO ; fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len *8 ; fadt->x_pm1a_evt_blk.bit_offset =0 ;
@@ -131,12 +119,7 @@ static int quark_write_fadt(struct acpi_ctx *ctx, fadt->x_gpe1_blk.access_size =0 ; fadt->x_gpe1_blk.addrl =0x0 ; fadt->x_gpe1_blk.addrh =0x0 ; - - header->checksum =table_compute_checksum (fadt, header->length); - -return acpi_add_fadt (ctx, fadt); } -ACPI_WRITER(5fadt, "FADT", quark_write_fadt, 0);int acpi_create_gnvs (struct acpi_global_nvs *gnvs) {
arch/x86/cpu/tangier/acpi.c +2 -23
@@ -16,21 +16,8 @@#include <asm/arch/iomap.h> #include <dm/uclass-internal.h> -static int tangier_write_fadt (struct acpi_ctx *ctx, -const struct acpi_writer *entry) +void acpi_fill_fadt (struct acpi_fadt *fadt) { -struct acpi_table_header *header; -struct acpi_fadt *fadt; - - fadt = ctx->current; - header = &fadt->header; - -memset (fadt,'\0' ,sizeof (struct acpi_fadt )); - -acpi_fill_header (header,"FACP" ); - header->length =sizeof (struct acpi_fadt ); - header->revision =6 ; - fadt->preferred_pm_profile =ACPI_PM_UNSPECIFIED ; fadt->iapc_boot_arch = ACPI_FADT_VGA_NOT_PRESENT |
@@ -40,17 +27,9 @@ static int tangier_write_fadt(struct acpi_ctx *ctx,ACPI_FADT_POWER_BUTTON |ACPI_FADT_SLEEP_BUTTON |ACPI_FADT_SEALED_CASE |ACPI_FADT_HEADLESS |ACPI_FADT_HW_REDUCED_ACPI ; - + fadt->header.revision =6 ; fadt->minor_revision =2 ; - - fadt->x_firmware_ctrl =map_to_sysmem (ctx->facs); - fadt->x_dsdt =map_to_sysmem (ctx->dsdt); - - header->checksum =table_compute_checksum (fadt, header->length); - -return acpi_add_fadt (ctx, fadt); } -ACPI_WRITER(5fadt, "FADT", tangier_write_fadt, 0);u32 acpi_fill_madt (u32 current) {
arch/x86/include/asm/acpi_table.h +0 -12
@@ -168,18 +168,6 @@ int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id,int acpi_create_dmar_ds_msi_hpet (struct acpi_ctx *ctx,uint enumeration_id,pci_dev_t bdf); -/** -* acpi_fadt_common() - Handle common parts of filling out an FADT -* -* This sets up the Fixed ACPI Description Table -* -* @fadt: Pointer to place to put FADT -* @facs: Pointer to the FACS -* @dsdt: Pointer to the DSDT -*/ -void acpi_fadt_common (struct acpi_fadt *fadt,struct acpi_facs *facs, -void *dsdt); -/** * intel_acpi_fill_fadt() - Set up the contents of the FADT *
arch/x86/lib/acpi_table.c +0 -23
@@ -381,29 +381,6 @@ int acpi_write_hpet(struct acpi_ctx *ctx)return 0 ; } -void acpi_fadt_common (struct acpi_fadt *fadt,struct acpi_facs *facs, -void *dsdt) -{ -struct acpi_table_header *header = &fadt->header; - -memset ((void *)fadt,'\0' ,sizeof (struct acpi_fadt )); - -acpi_fill_header (header,"FACP" ); - header->length =sizeof (struct acpi_fadt ); - header->revision =4 ; -memcpy (header->oem_id,OEM_ID ,6 ); -memcpy (header->oem_table_id,OEM_TABLE_ID ,8 ); -memcpy (header->creator_id,ASLC_ID ,4 ); - - fadt->x_firmware_ctrl =map_to_sysmem (facs); - fadt->x_dsdt =map_to_sysmem (dsdt); - - fadt->preferred_pm_profile =ACPI_PM_MOBILE ; - -/* Use ACPI 3.0 revision */ - fadt->header.revision =4 ; -} -void acpi_create_dmar_drhd (struct acpi_ctx *ctx,uint flags,uint segment,u64 bar) {
include/acpi/acpi_table.h +9 -0
@@ -926,6 +926,15 @@ void acpi_fill_header(struct acpi_table_header *header, char *signature);*/ int acpi_fill_csrt (struct acpi_ctx *ctx); +/** +* acpi_fill_fadt() - Fill out the body of the FADT +* +* Should be implemented in SoC specific code. +* +* @fadt: Pointer to FADT to update +*/ +void acpi_fill_fadt (struct acpi_fadt *fadt); +/** * acpi_write_dbg2_pci_uart() - Write out a DBG2 table *
lib/acpi/acpi_table.c +42 -0
48 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH 02/17] acpi: x86: Write FADT in common code
Hi Patrick,
Quoted 6 lines · Patrick Rudolph
From: Maximilian Brune <[email protected]>
Write the FADT in common code since it's used on all architectures. Let the cpu code fill out the FADT body by introducing a new weak function
acpi_fill_fadt().
This should be done using the acpi_ops struct...i.e. add a new operation which fills allows a CPU driver to fill out the CPU info.
Quoted 4 lines
Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Bin Meng <[email protected]>
Quoted 10 lines
--- arch/x86/cpu/apollolake/acpi.c | 20 +++------------ arch/x86/cpu/baytrail/acpi.c | 17 +------------ arch/x86/cpu/quark/acpi.c | 19 +------------- arch/x86/cpu/tangier/acpi.c | 25 ++---------------- arch/x86/include/asm/acpi_table.h | 12 --------- arch/x86/lib/acpi_table.c | 23 ----------------- include/acpi/acpi_table.h | 9 +++++++ lib/acpi/acpi_table.c | 42 +++++++++++++++++++++++++++++++ 8 files changed, 59 insertions(+), 108 deletions(-)
Regards,
Simon
Re: [PATCH 02/17] acpi: x86: Write FADT in common code
Quoted 6 lines · Simon Glass
Hi Patrick,
Quoted 1 line · Patrick Rudolph
Quoted 9 lines
Quoted 5 lines
From: Maximilian Brune <[email protected]>
Write the FADT in common code since it's used on all architectures. Let the cpu code fill out the FADT body by introducing a new weak function
acpi_fill_fadt().This should be done using the
acpi_opsstruct...i.e. add a new operation which fills allows a CPU driver to fill out the CPU info.
Which of the fields in FADT are related to the CPU driver? Some fields like "preferred_pm_profile", "iapc_boot_arch" and "flags" seem to be board specific.
How would the board specific code integrate into the acpi_ops? As far as I understand there are no drivers for "mainboard class" devices.
Quoted 17 lines
Quoted 4 lines
Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Bin Meng <[email protected]>Quoted 10 lines
--- arch/x86/cpu/apollolake/acpi.c | 20 +++------------ arch/x86/cpu/baytrail/acpi.c | 17 +------------ arch/x86/cpu/quark/acpi.c | 19 +------------- arch/x86/cpu/tangier/acpi.c | 25 ++---------------- arch/x86/include/asm/acpi_table.h | 12 --------- arch/x86/lib/acpi_table.c | 23 ----------------- include/acpi/acpi_table.h | 9 +++++++ lib/acpi/acpi_table.c | 42 +++++++++++++++++++++++++++++++ 8 files changed, 59 insertions(+), 108 deletions(-)Regards,
Simon
Re: [PATCH 02/17] acpi: x86: Write FADT in common code
Hi Patrick,
Quoted 14 lines · Patrick Rudolph
Quoted 12 lines · Simon Glass
Hi Patrick,
Quoted 6 lines · Patrick Rudolph
From: Maximilian Brune <[email protected]>
Write the FADT in common code since it's used on all architectures. Let the cpu code fill out the FADT body by introducing a new weak function
acpi_fill_fadt().
Quoted 7 lines
Quoted 3 lines
This should be done using the
acpi_opsstruct...i.e. add a new operation which fills allows a CPU driver to fill out the CPU info.Which of the fields in FADT are related to the CPU driver? Some fields like "
preferred_pm_profile", "iapc_boot_arch" and "flags" seem to be board specific.
How would the board specific code integrate into theacpi_ops?
Using properties int the devicetree, or a driver based on the compatible string.
Quoted 1 line
As far as I understand there are no drivers for "mainboard class" devices.
You can use SYSINFO as a driver for that sort of thing.
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Bin Meng <[email protected]>--- arch/x86/cpu/apollolake/acpi.c | 20 +++------------ arch/x86/cpu/baytrail/acpi.c | 17 +------------ arch/x86/cpu/quark/acpi.c | 19 +------------- arch/x86/cpu/tangier/acpi.c | 25 ++---------------- arch/x86/include/asm/acpi_table.h | 12 --------- arch/x86/lib/acpi_table.c | 23 ----------------- include/acpi/acpi_table.h | 9 +++++++ lib/acpi/acpi_table.c | 42 +++++++++++++++++++++++++++++++ 8 files changed, 59 insertions(+), 108 deletions(-)
Quoted 2 lines
Quoted 2 lines
Regards,
Simon
Regards,
Simon
PATCH 3/17 acpi: x86: Move MADT to common code
In reply to Patrick RudolphWrite MADT in common code and let the SoC fill out the body by calling acpi_fill_madt() which must be implemented at SoC level.
--- arch/sandbox/lib/Makefile | 9 +++--- arch/sandbox/lib/acpi_table.c | 7 +++++ arch/x86/cpu/intel_common/acpi.c | 20 +++++++++----- arch/x86/cpu/tangier/acpi.c | 6 +++- arch/x86/include/asm/acpi_table.h | 3 +- arch/x86/lib/acpi_table.c | 46 ++++++------------------------- include/acpi/acpi_table.h | 11 ++++++++ lib/acpi/acpi_table.c | 31 +++++++++++++++++++++ 8 files changed, 81 insertions(+), 52 deletions(-) create mode 100644 arch/sandbox/lib/acpi_table.c
arch/sandbox/lib/Makefile +5 -4
@@ -5,7 +5,8 @@ # (C) Copyright 2002-2006 # Wolfgang Denk, DENX Software Engineering, [email protected]. -obj-y += fdt_fixup.o interrupts.o -obj-$(CONFIG_PCI) += pci_io.o -obj-$(CONFIG_CMD_BOOTM) += bootm.o -obj-$(CONFIG_CMD_BOOTZ) += bootm.o +obj-y += fdt_fixup.o interrupts.o +obj-$(CONFIG_PCI) += pci_io.o +obj-$(CONFIG_CMD_BOOTM) += bootm.o +obj-$(CONFIG_CMD_BOOTZ) += bootm.o +obj-$(CONFIG_$(SPL_)ACPIGEN) += acpi_table.o
arch/sandbox/lib/acpi_table.c new file +7 -0
@@ -0,0 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ +#include <acpi/acpi_table.h> + +void *acpi_fill_madt (struct acpi_madt *madt,void *current) +{ +return current; +}
arch/x86/cpu/intel_common/acpi.c +13 -7
@@ -19,6 +19,7 @@#include <asm/global_data.h> #include <asm/intel_acpi.h> #include <asm/ioapic.h> +#include <asm/lapic.h> #include <asm/mpspec.h> #include <asm/smm.h> #include <asm/turbo.h>
@@ -80,33 +81,38 @@ static int acpi_sci_irq(void)return sci_irq; } -static unsigned long acpi_madt_irq_overrides (unsigned long current) +static void *acpi_madt_irq_overrides (void *current) {int sci =acpi_sci_irq ();u16 flags =MP_IRQ_TRIGGER_LEVEL ; -if (sci <0 ) -return log_msg_ret ("sci irq" , sci); +if (sci <0 ) { +log_err ("sci irq %d" , sci); +return current; + }/* INT_SRC_OVR */ - current +=acpi_create_madt_irqoverride ((void *)current,0 ,0 ,2 ,0 ); + current +=acpi_create_madt_irqoverride (current,0 ,0 ,2 ,0 ); flags |=arch_madt_sci_irq_polarity (sci);/* SCI */ current += -acpi_create_madt_irqoverride ((void *)current,0 , sci, sci, flags); +acpi_create_madt_irqoverride (current,0 , sci, sci, flags);return current; } -u32 acpi_fill_madt (u32 current) +void *acpi_fill_madt (struct acpi_madt *madt,void *current) { + madt->lapic_addr =LAPIC_DEFAULT_BASE ; + madt->flags =ACPI_MADT_PCAT_COMPAT ; +/* Local APICs */ current +=acpi_create_madt_lapics (current);/* IOAPIC */ - current +=acpi_create_madt_ioapic ((void *)current,2 ,IO_APIC_ADDR ,0 ); + current +=acpi_create_madt_ioapic (current,2 ,IO_APIC_ADDR ,0 );return acpi_madt_irq_overrides (current); }
arch/x86/cpu/tangier/acpi.c +5 -1
@@ -10,6 +10,7 @@#include <mapmem.h> #include <acpi/acpi_table.h> #include <asm/ioapic.h> +#include <asm/lapic.h> #include <asm/mpspec.h> #include <asm/tables.h> #include <asm/arch/global_nvs.h>
@@ -31,8 +32,11 @@ void acpi_fill_fadt(struct acpi_fadt *fadt) fadt->minor_revision =2 ; } -u32 acpi_fill_madt (u32 current) +void *acpi_fill_madt (struct acpi_madt *madt,void *current) { + madt->lapic_addr =LAPIC_DEFAULT_BASE ; + madt->flags =ACPI_MADT_PCAT_COMPAT ; + current +=acpi_create_madt_lapics (current); current += acpi_create_madt_ioapic((struct acpi_madt_ioapic *)current,
arch/x86/include/asm/acpi_table.h +1 -2
@@ -24,14 +24,13 @@ struct acpi_table_header;/* These can be used by the target port */ -int acpi_create_madt_lapics (u32 current); +int acpi_create_madt_lapics (void *current);int acpi_create_madt_ioapic (struct acpi_madt_ioapic *ioapic,u8 id,u32 addr,u32 gsi_base);int acpi_create_madt_irqoverride (struct acpi_madt_irqoverride *irqoverride,u8 bus,u8 source,u32 gsirq,u16 flags);int acpi_create_madt_lapic_nmi (struct acpi_madt_lapic_nmi *lapic_nmi,u8 cpu,u16 flags,u8 lint); -u32 acpi_fill_madt (u32 current);int acpi_create_mcfg_mmconfig (struct acpi_mcfg_mmconfig *mmconfig,u32 base,u16 seg_nr,u8 start,u8 end);
arch/x86/lib/acpi_table.c +8 -38
77 lines not on this page · raw message
include/acpi/acpi_table.h +11 -0
@@ -935,6 +935,17 @@ int acpi_fill_csrt(struct acpi_ctx *ctx);*/ void acpi_fill_fadt (struct acpi_fadt *fadt); +/** +* acpi_fill_madt() - Fill out the body of the MADT +* +* Must be implemented in SoC specific code. +* +* @madt: The MADT to update +* @current: Pointer to the MADT body +* @return Pointer to the end of tables, where the next tables can be written +*/ +void *acpi_fill_madt (struct acpi_madt *madt,void *current); +/** * acpi_write_dbg2_pci_uart() - Write out a DBG2 table *
lib/acpi/acpi_table.c +31 -0
@@ -244,6 +244,37 @@ int acpi_write_fadt(struct acpi_ctx *ctx, const struct acpi_writer *entry) ACPI_WRITER(5fadt, "FADT", acpi_write_fadt, 0); +int acpi_write_madt (struct acpi_ctx *ctx,const struct acpi_writer *entry) +{ +struct acpi_table_header *header; +struct acpi_madt *madt; +void *current; + + madt = ctx->current; + +memset (madt,'\0' ,sizeof (struct acpi_madt )); + header = &madt->header; + +/* Fill out header fields */ +acpi_fill_header (header,"APIC" ); + header->length =sizeof (struct acpi_madt ); + header->revision =ACPI_MADT_REV_ACPI_3_0 ; + + current = (void *)madt +sizeof (struct acpi_madt ); + current =acpi_fill_madt (madt, current); + +/* (Re)calculate length and checksum */ + header->length = (uintptr_t )current - (uintptr_t )madt; + + header->checksum =table_compute_checksum ((void *)madt, header->length); +acpi_add_table (ctx, madt); +acpi_inc (ctx, madt->header.length); + +return 0 ; +} + +ACPI_WRITER(5madt, "MADT", acpi_write_madt, 0); + static void acpi_create_dbg2(struct acpi_dbg2_header *dbg2, int port_type, int port_subtype, struct acpi_gen_regaddr *address, u32 address_size,
Signature · 1 line
2.45.2
Re: [PATCH 03/17] acpi: x86: Move MADT to common code
Hi Patrick,
Quoted 7 lines · Patrick Rudolph
Write MADT in common code and let the SoC fill out the body by calling
acpi_fill_madt()which must be implemented at SoC level.Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Bin Meng <[email protected]>
Quoted 11 lines
--- arch/sandbox/lib/Makefile | 9 +++--- arch/sandbox/lib/acpi_table.c | 7 +++++ arch/x86/cpu/intel_common/acpi.c | 20 +++++++++----- arch/x86/cpu/tangier/acpi.c | 6 +++- arch/x86/include/asm/acpi_table.h | 3 +- arch/x86/lib/acpi_table.c | 46 ++++++------------------------- include/acpi/acpi_table.h | 11 ++++++++ lib/acpi/acpi_table.c | 31 +++++++++++++++++++++ 8 files changed, 81 insertions(+), 52 deletions(-) create mode 100644 arch/sandbox/lib/acpi_table.c
Same comment as previous patch.
Regards,
Simon
Re: [PATCH 03/17] acpi: x86: Move MADT to common code
Quoted 24 lines · Simon Glass
Hi Patrick,
Quoted 7 lines · Patrick Rudolph
Write MADT in common code and let the SoC fill out the body by calling
acpi_fill_madt()which must be implemented at SoC level.Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Bin Meng <[email protected]>Quoted 11 lines
--- arch/sandbox/lib/Makefile | 9 +++--- arch/sandbox/lib/acpi_table.c | 7 +++++ arch/x86/cpu/intel_common/acpi.c | 20 +++++++++----- arch/x86/cpu/tangier/acpi.c | 6 +++- arch/x86/include/asm/acpi_table.h | 3 +- arch/x86/lib/acpi_table.c | 46 ++++++------------------------- include/acpi/acpi_table.h | 11 ++++++++ lib/acpi/acpi_table.c | 31 +++++++++++++++++++++ 8 files changed, 81 insertions(+), 52 deletions(-) create mode 100644 arch/sandbox/lib/acpi_table.c
Quoted 1 line
Same comment as previous patch.
While it might be possible to write out GICC and LAPIC or X2APIC using a CPU driver,
how would the other sub-tables integrate into the acpi_ops?
On x86 you have ioapic and irq_overrides and on arm GICR and ITS sub-tables. Would I need to add "Interrupt controller" drivers for each platform, fill it with platform specific data
and then fill out the MADT table using acpi_ops?
While that seems nice to have, it would be quite a lot of work, since none of the interface
or drivers exists at the moment.
It even looks like not all platforms even use a CPU driver and even less use an interrupt controller
driver...
Quoted 3 lines
Regards,
Simon
Re: [PATCH 03/17] acpi: x86: Move MADT to common code
Hi Simon,
Quoted 36 lines · Patrick Rudolph
Quoted 24 lines · Simon Glass
Hi Patrick,
Quoted 7 lines · Patrick Rudolph
Write MADT in common code and let the SoC fill out the body by calling
acpi_fill_madt()which must be implemented at SoC level.Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Bin Meng <[email protected]>Quoted 11 lines
--- arch/sandbox/lib/Makefile | 9 +++--- arch/sandbox/lib/acpi_table.c | 7 +++++ arch/x86/cpu/intel_common/acpi.c | 20 +++++++++----- arch/x86/cpu/tangier/acpi.c | 6 +++- arch/x86/include/asm/acpi_table.h | 3 +- arch/x86/lib/acpi_table.c | 46 ++++++------------------------- include/acpi/acpi_table.h | 11 ++++++++ lib/acpi/acpi_table.c | 31 +++++++++++++++++++++ 8 files changed, 81 insertions(+), 52 deletions(-) create mode 100644 arch/sandbox/lib/acpi_table.cQuoted 1 line
Same comment as previous patch.
While it might be possible to write out GICC and LAPIC or X2APIC using a CPU driver,
how would the other sub-tables integrate into theacpi_ops?On x86 you have ioapic and
irq_overridesand on arm GICR and ITS sub-tables. Would I need to add "Interrupt controller" drivers for each platform, fill it with platform specific data
and then fill out the MADT table usingacpi_ops?
Quoted 7 lines
While that seems nice to have, it would be quite a lot of work, since none of the interface
or drivers exists at the moment.
It even looks like not all platforms even use a CPU driver and even less use an interrupt controller
driver...
I've implemented this in the latest patch series v3.
See commit "drivers/arm: Implement acpi_fill_madt" that implements the driver modelfill_madt for arm and allows to use it on QEMU SBSA. Other platforms are still using the
"old" approach until they have been ported to the driver model.
Quoted 3 lines
Quoted 3 lines
Regards,
Simon
PATCH 4/17 acpi: Fix typo
In reply to Patrick RudolphRename ACPI tables MADR to MADT.
--- include/acpi/acpi_table.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
include/acpi/acpi_table.h +8 -8
@@ -386,20 +386,20 @@ struct __packed acpi_madt_lapic_nmi {u8 lint;/* Local APIC LINT# */ }; -/* flags for acpi_madr_gicc flags word */ +/* flags for acpi_madt_gicc flags word */ enum { -ACPI_MADRF_ENABLED =BIT (0 ), -ACPI_MADRF_PERF =BIT (1 ), -ACPI_MADRF_VGIC =BIT (2 ), +ACPI_MADTF_ENABLED =BIT (0 ), +ACPI_MADTF_PERF =BIT (1 ), +ACPI_MADTF_VGIC =BIT (2 ), };/** -* struct __packed acpi_madr_gicc - GIC CPU interface (type 0xb) +* struct __packed acpi_madt_gicc - GIC CPU interface (type 0xb) * * This holds information about the Generic Interrupt Controller (GIC) CPU * interface. See ACPI Spec v6.3 section 5.2.12.14 */ -struct acpi_madr_gicc { +struct acpi_madt_gicc {u8 type;u8 length;u16 reserved;
@@ -421,12 +421,12 @@ struct acpi_madr_gicc { } __packed;/** -* struct __packed acpi_madr_gicc - GIC distributor (type 0xc) +* struct __packed acpi_madt_gicc - GIC distributor (type 0xc) * * This holds information about the Generic Interrupt Controller (GIC) * Distributor interface. See ACPI Spec v6.3 section 5.2.12.15 */ -struct acpi_madr_gicd { +struct acpi_madt_gicd {u8 type;u8 length;u16 reserved;
Signature · 1 line
2.45.2
Re: [PATCH 04/17] acpi: Fix typo
Quoted 8 lines · Patrick Rudolph
Rename ACPI tables MADR to MADT.
Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>--- include/acpi/acpi_table.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
PATCH 5/17 serial: serial_pl01x: Implement .getinfo() for PL01
In reply to Patrick RudolphFrom: Maximilian Brune <[email protected]>
When ACPI is enabled on arm it will use the getinfo function to fill the SPCR ACPI table.
--- boot/bootflow.c | 8 ++++++-- drivers/serial/serial_pl01x.c | 24 ++++++++++++++++++++++++ include/serial.h | 1 + 3 files changed, 31 insertions(+), 2 deletions(-)
boot/bootflow.c +6 -2
@@ -936,11 +936,15 @@ int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg)return ret; *buf ='\0' ; -if (!strcmp ("earlycon" , arg)) { +if (!strcmp ("earlycon" , arg) && info.type ==SERIAL_CHIP_16550_COMPATIBLE ) {snprintf (buf,sizeof (buf),"uart8250,mmio32,%#lx,%dn8" , info.addr, info.baudrate); - }else if (!strcmp ("console" , arg)) { + }else if (!strcmp ("earlycon" , arg) && info.type ==SERIAL_CHIP_PL01X ) { +snprintf (buf,sizeof (buf), +"pl011,mmio32,%#lx,%dn8" , info.addr, + info.baudrate); + }else if (!strcmp ("console" , arg) && info.type ==SERIAL_CHIP_16550_COMPATIBLE ) {snprintf (buf,sizeof (buf),"ttyS0,%dn8" , info.baudrate); }
drivers/serial/serial_pl01x.c +24 -0
@@ -19,6 +19,7 @@#include <watchdog.h> #include <asm/io.h> #include <serial.h> +#include <spl.h> #include <dm/device_compat.h> #include <dm/platform_data/serial_pl01x.h> #include <linux/compiler.h>
@@ -272,6 +273,28 @@ __weak struct serial_device *default_serial_console(void) return &pl01x_serial_drv; }#else + +static int pl01x_serial_getinfo (struct udevice *dev, +struct serial_device_info *info) +{ +struct pl01x_serial_plat *plat =dev_get_plat (dev); + +/* save code size */ +if (!spl_in_proper ()) +return -ENOSYS ; + + info->type =SERIAL_CHIP_PL01X ; + info->addr_space =SERIAL_ADDRESS_SPACE_MEMORY ; + info->addr = plat->base; + info->size =0x1000 ; + info->reg_width =4 ; + info->reg_shift =2 ; + info->reg_offset =0 ; + info->clock = plat->clock; + +return 0 ; +} +int pl01x_serial_setbrg (struct udevice *dev,int baudrate) {struct pl01x_serial_plat *plat =dev_get_plat (dev);
@@ -341,6 +364,7 @@ static const struct dm_serial_ops pl01x_serial_ops = { .pending = pl01x_serial_pending, .getc = pl01x_serial_getc, .setbrg = pl01x_serial_setbrg, + .getinfo = pl01x_serial_getinfo, };#if CONFIG_IS_ENABLED (OF_REAL )
include/serial.h +1 -0
@@ -124,6 +124,7 @@ enum serial_stop {enum serial_chip_type {SERIAL_CHIP_UNKNOWN =-1 ,SERIAL_CHIP_16550_COMPATIBLE , +SERIAL_CHIP_PL01X , };enum adr_space_type {
Signature · 1 line
2.45.2
Re: [PATCH 05/17] serial: serial_pl01x: Implement .getinfo() for PL01
Quoted 6 lines · Patrick Rudolph
From: Maximilian Brune <[email protected]>
When ACPI is enabled on arm it will use the getinfo function to fill the SPCR ACPI table.
Quoted 8 lines
Signed-off-by Maximilian Brune <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- boot/bootflow.c | 8 ++++++-- drivers/serial/serial_pl01x.c | 24 ++++++++++++++++++++++++ include/serial.h | 1 + 3 files changed, 31 insertions(+), 2 deletions(-)
Re: [PATCH 05/17] serial: serial_pl01x: Implement .getinfo() for PL01
In reply to Patrick RudolphQuoted 9 lines · Patrick Rudolph
From: Maximilian Brune <[email protected]>
When ACPI is enabled on arm it will use the getinfo function to fill the SPCR ACPI table.
Signed-off-by Maximilian Brune <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>
Quoted 92 lines
--- boot/bootflow.c | 8 ++++++-- drivers/serial/serial_pl01x.c | 24 ++++++++++++++++++++++++ include/serial.h | 1 + 3 files changed, 31 insertions(+), 2 deletions(-)boot/bootflow.c +6
-2@@ -936,11 +936,15 @@ int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg)return ret; *buf ='\0' ; -if (!strcmp ("earlycon" , arg)) { +if (!strcmp ("earlycon" , arg) && info.type ==SERIAL_CHIP_16550_COMPATIBLE ) {snprintf (buf,sizeof (buf),"uart8250,mmio32,%#lx,%dn8" , info.addr, info.baudrate); - }else if (!strcmp ("console" , arg)) { + }else if (!strcmp ("earlycon" , arg) && info.type ==SERIAL_CHIP_PL01X ) { +snprintf (buf,sizeof (buf), +"pl011,mmio32,%#lx,%dn8" , info.addr, + info.baudrate); + }else if (!strcmp ("console" , arg) && info.type ==SERIAL_CHIP_16550_COMPATIBLE ) {snprintf (buf,sizeof (buf),"ttyS0,%dn8" , info.baudrate); }drivers/serial/serial_pl01x.c +24
-0@@ -19,6 +19,7 @@#include <watchdog.h> #include <asm/io.h> #include <serial.h> +#include <spl.h> #include <dm/device_compat.h> #include <dm/platform_data/serial_pl01x.h> #include <linux/compiler.h> @@ -272,6 +273,28 @@ __weak struct serial_device *default_serial_console(void) return &pl01x_serial_drv; }#else + +static int pl01x_serial_getinfo (struct udevice *dev, +struct serial_device_info *info) +{ +struct pl01x_serial_plat *plat =dev_get_plat (dev); + +/* save code size */ +if (!spl_in_proper ()) +return -ENOSYS ; + + info->type =SERIAL_CHIP_PL01X ; + info->addr_space =SERIAL_ADDRESS_SPACE_MEMORY ; + info->addr = plat->base; + info->size =0x1000 ; + info->reg_width =4 ; + info->reg_shift =2 ; + info->reg_offset =0 ; + info->clock = plat->clock; + +return 0 ; +} +int pl01x_serial_setbrg (struct udevice *dev,int baudrate) {struct pl01x_serial_plat *plat =dev_get_plat (dev);@@ -341,6 +364,7 @@ static const struct dm_serial_ops pl01x_serial_ops = { .pending = pl01x_serial_pending, .getc = pl01x_serial_getc, .setbrg = pl01x_serial_setbrg, + .getinfo = pl01x_serial_getinfo, };#if CONFIG_IS_ENABLED (OF_REAL )include/serial.h +1
-1@@ -124,6 +124,7 @@ enum serial_stop {enum serial_chip_type {SERIAL_CHIP_UNKNOWN =-1 ,SERIAL_CHIP_16550_COMPATIBLE , +SERIAL_CHIP_PL01X , };enum adr_space_type { --2.45.2
PATCH 6/17 acpi: Add define for GTDT
In reply to Patrick RudolphAdd the interrupt flag used in ACPI GTDT table as define.
--- include/acpi/acpi_table.h | 2 ++ 1 file changed, 2 insertions(+)
include/acpi/acpi_table.h +2 -0
@@ -707,6 +707,8 @@ struct acpi_gtdt {u32 virt_el2_flags; } __packed; +#define GTDT_FLAG_INT_ACTIVE_LOW BIT(1) +/** * struct acpi_bgrt - Boot Graphics Resource Table (BGRT) *
Signature · 1 line
2.45.2
Re: [PATCH 06/17] acpi: Add define for GTDT
Quoted 8 lines · Patrick Rudolph
Add the interrupt flag used in ACPI GTDT table as define.
Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>--- include/acpi/acpi_table.h | 2 ++ 1 file changed, 2 insertions(+)
Re: [PATCH 06/17] acpi: Add define for GTDT
In reply to Patrick RudolphQuoted 23 lines · Patrick Rudolph
Add the interrupt flag used in ACPI GTDT table as define.
Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>--- include/acpi/acpi_table.h | 2 ++ 1 file changed, 2 insertions(+)include/acpi/acpi_table.h +2
-1@@ -707,6 +707,8 @@ struct acpi_gtdt {u32 virt_el2_flags; } __packed; +#define GTDT_FLAG_INT_ACTIVE_LOW BIT(1) +/** * struct acpi_bgrt - Boot Graphics Resource Table (BGRT) * --
Quoted 2 lines
2.45.2
PATCH 7/17 arm: acpi: Add generic ACPI methods
In reply to Patrick RudolphAdd generic ACPI code to generate
- MADT GICC
- MADT GICD
as commonly used on arm platforms.
--- arch/arm/include/asm/acpi_table.h | 18 +++++++++++++ arch/arm/lib/Makefile | 1 + arch/arm/lib/acpi_table.c | 44 +++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 arch/arm/lib/acpi_table.c
arch/arm/include/asm/acpi_table.h +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef __ASM_ACPI_TABLE_H__ +#define __ASM_ACPI_TABLE_H__ + +#ifndef __ACPI__ + +void acpi_write_madt_gicc (struct acpi_madt_gicc *gicc,uint cpu_num, +uint perf_gsiv,ulong phys_base,ulong gicv, +ulong gich,uint vgic_maint_irq,ulong mpidr, +uint efficiency); + +void acpi_write_madt_gicd (struct acpi_madt_gicd *gicd,uint gic_id, +ulong phys_base,uint gic_version); + +#endif /* !__ACPI__ */ + +#endif /* __ASM_ACPI_TABLE_H__ */
arch/arm/lib/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-y += psci-dt.o obj-$(CONFIG_DEBUG_LL) += debug.o obj-$(CONFIG_BLOBLIST) += xferlist.o +obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o # For EABI conformant tool chains, provide eabi_compat() ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
arch/arm/lib/acpi_table.c new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH 07/17] arm: acpi: Add generic ACPI methods
Hi Patrick,
Quoted 26 lines · Patrick Rudolph
Add generic ACPI code to generate
- MADT GICC
- MADT GICDas commonly used on arm platforms.
Signed-off-by Patrick Rudolph <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>--- arch/arm/include/asm/acpi_table.h | 18 +++++++++++++ arch/arm/lib/Makefile | 1 + arch/arm/lib/acpi_table.c | 44 +++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 arch/arm/lib/acpi_table.carch/arm/include/asm/acpi_table.h +4
-0@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef __ASM_ACPI_TABLE_H__ +#define __ASM_ACPI_TABLE_H__
arch/arm/include/asm/acpi_table.h line 14
Quoted 10 lines
arch/arm/include/asm/acpi_table.h +10
-0+ +#ifndef __ACPI__ + +void acpi_write_madt_gicc (struct acpi_madt_gicc *gicc,uint cpu_num, +uint perf_gsiv,ulong phys_base,ulong gicv, +ulong gich,uint vgic_maint_irq,ulong mpidr, +uint efficiency); + +void acpi_write_madt_gicd (struct acpi_madt_gicd *gicd,uint gic_id, +ulong phys_base,uint gic_version);
Exported function should have full comments.
Quoted 67 lines
arch/arm/include/asm/acpi_table.h +4
-0+ +#endif /* !__ACPI__ */ + +#endif /* __ASM_ACPI_TABLE_H__ */ arch/arm/lib/Makefile +1
-0@@ -86,6 +86,7 @@ obj-y += psci-dt.o obj-$(CONFIG_DEBUG_LL) += debug.o obj-$(CONFIG_BLOBLIST) += xferlist.o +obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o # For EABI conformant tool chains, provide eabi_compat() ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))arch/arm/lib/acpi_table.c new file +44
-1@@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Based on acpi.c from coreboot +* +* Copyright (C) 2024 9elements GmbH +*/ + +#define LOG_CATEGORY LOGC_ACPI + +#include <acpi/acpigen.h> +#include <acpi/acpi_device.h> +#include <acpi/acpi_table.h> +#include <string.h> + +void acpi_write_madt_gicc (struct acpi_madt_gicc *gicc,uint cpu_num, +uint perf_gsiv,ulong phys_base,ulong gicv, +ulong gich,uint vgic_maint_irq,ulong mpidr, +uint efficiency) +{ +memset (gicc,'\0' ,sizeof (struct acpi_madt_gicc )); + gicc->type =ACPI_APIC_GICC ; + gicc->length =sizeof (struct acpi_madt_gicc ); + gicc->cpu_if_num = cpu_num; + gicc->processor_id = cpu_num; + gicc->flags =ACPI_MADTF_ENABLED ; + gicc->perf_gsiv = perf_gsiv; + gicc->phys_base = phys_base; + gicc->gicv = gicv; + gicc->gich = gich; + gicc->vgic_maint_irq = vgic_maint_irq; + gicc->mpidr = mpidr; + gicc->efficiency = efficiency; +} + +void acpi_write_madt_gicd (struct acpi_madt_gicd *gicd,uint gic_id, +ulong phys_base,uint gic_version) +{ +memset (gicd,'\0' ,sizeof (struct acpi_madt_gicd )); + gicd->type =ACPI_APIC_GICD ; + gicd->length =sizeof (struct acpi_madt_gicd ); + gicd->gic_id = gic_id; + gicd->phys_base = phys_base; + gicd->gic_version = gic_version; +} --
Quoted 2 lines
2.45.2
REgards,
Simon
Re: [PATCH 07/17] arm: acpi: Add generic ACPI methods
In reply to Patrick RudolphPatrick,
Quoted 78 lines · Patrick Rudolph
Add generic ACPI code to generate
- MADT GICC
- MADT GICDas commonly used on arm platforms.
Signed-off-by Patrick Rudolph <[email protected]>Cc Tom Rini <[email protected]>Cc Simon Glass <[email protected]>--- arch/arm/include/asm/acpi_table.h | 18 +++++++++++++ arch/arm/lib/Makefile | 1 + arch/arm/lib/acpi_table.c | 44 +++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 arch/arm/lib/acpi_table.carch/arm/include/asm/acpi_table.h +18
-0@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef __ASM_ACPI_TABLE_H__ +#define __ASM_ACPI_TABLE_H__ + +#ifndef __ACPI__ + +void acpi_write_madt_gicc (struct acpi_madt_gicc *gicc,uint cpu_num, +uint perf_gsiv,ulong phys_base,ulong gicv, +ulong gich,uint vgic_maint_irq,ulong mpidr, +uint efficiency); + +void acpi_write_madt_gicd (struct acpi_madt_gicd *gicd,uint gic_id, +ulong phys_base,uint gic_version); + +#endif /* !__ACPI__ */ + +#endif /* __ASM_ACPI_TABLE_H__ */ arch/arm/lib/Makefile +1
-0@@ -86,6 +86,7 @@ obj-y += psci-dt.o obj-$(CONFIG_DEBUG_LL) += debug.o obj-$(CONFIG_BLOBLIST) += xferlist.o +obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o # For EABI conformant tool chains, provide eabi_compat() ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))arch/arm/lib/acpi_table.c new file +20
-0@@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Based on acpi.c from coreboot +* +* Copyright (C) 2024 9elements GmbH +*/ + +#define LOG_CATEGORY LOGC_ACPI + +#include <acpi/acpigen.h> +#include <acpi/acpi_device.h> +#include <acpi/acpi_table.h> +#include <string.h> + +void acpi_write_madt_gicc (struct acpi_madt_gicc *gicc,uint cpu_num, +uint perf_gsiv,ulong phys_base,ulong gicv, +ulong gich,uint vgic_maint_irq,ulong mpidr, +uint efficiency) +{ +memset (gicc,'\0' ,sizeof (struct acpi_madt_gicc ));
arch/arm/lib/acpi_table.c line 30
Quoted 10 lines
arch/arm/lib/acpi_table.c new file +10
-0+ gicc->type =ACPI_APIC_GICC ; + gicc->length =sizeof (struct acpi_madt_gicc ); + gicc->cpu_if_num = cpu_num; + gicc->processor_id = cpu_num; + gicc->flags =ACPI_MADTF_ENABLED ; + gicc->perf_gsiv = perf_gsiv; + gicc->phys_base = phys_base; + gicc->gicv = gicv; + gicc->gich = gich; + gicc->vgic_maint_irq = vgic_maint_irq;
I think you're lacking the rdists here?
Quoted 15 lines
arch/arm/lib/acpi_table.c new file +14
-1+ gicc->mpidr = mpidr; + gicc->efficiency = efficiency; +} + +void acpi_write_madt_gicd (struct acpi_madt_gicd *gicd,uint gic_id, +ulong phys_base,uint gic_version) +{ +memset (gicd,'\0' ,sizeof (struct acpi_madt_gicd )); + gicd->type =ACPI_APIC_GICD ; + gicd->length =sizeof (struct acpi_madt_gicd ); + gicd->gic_id = gic_id; + gicd->phys_base = phys_base; + gicd->gic_version = gic_version; +} --
Quoted 2 lines
2.45.2
Cheers,
Moritz
PATCH 8/17 acpi: acpi_table: Bump revisions
In reply to Patrick RudolphThe FADT structure found in U-Boot represents FADT revision 6 and the GICC and GICD structures defined in U-Boot are based on ACPI revision 6.3.
Bump the table revision to fix FWTS failures seen on aarch64.
--- arch/x86/cpu/tangier/acpi.c | 2 -- include/acpi/acpi_table.h | 3 ++- lib/acpi/acpi_table.c | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/cpu/tangier/acpi.c +0 -2
@@ -28,8 +28,6 @@ void acpi_fill_fadt(struct acpi_fadt *fadt)ACPI_FADT_POWER_BUTTON |ACPI_FADT_SLEEP_BUTTON |ACPI_FADT_SEALED_CASE |ACPI_FADT_HEADLESS |ACPI_FADT_HW_REDUCED_ACPI ; - fadt->header.revision =6 ; - fadt->minor_revision =2 ; }void *acpi_fill_madt (struct acpi_madt *madt,void *current)
include/acpi/acpi_table.h +2 -1
@@ -290,7 +290,8 @@ struct __packed acpi_fadt {#define ACPI_MADT_REV_ACPI_3_0 2#define ACPI_MADT_REV_ACPI_4_0 3#define ACPI_MADT_REV_ACPI_5_0 3 -#define ACPI_MADT_REV_ACPI_6_0 5 +#define ACPI_MADT_REV_ACPI_6_2 4 +#define ACPI_MADT_REV_ACPI_6_3 5#define ACPI_MCFG_REV_ACPI_3_0 1
lib/acpi/acpi_table.c +4 -3
@@ -63,9 +63,9 @@ int acpi_get_table_revision(enum acpi_tables table) {switch (table) {case ACPITAB_FADT : -return ACPI_FADT_REV_ACPI_3_0 ; +return ACPI_FADT_REV_ACPI_6_0 ;case ACPITAB_MADT : -return ACPI_MADT_REV_ACPI_3_0 ; +return ACPI_MADT_REV_ACPI_6_2 ;case ACPITAB_MCFG :return ACPI_MCFG_REV_ACPI_3_0 ;case ACPITAB_TCPA :
@@ -223,6 +223,7 @@ int acpi_write_fadt(struct acpi_ctx *ctx, const struct acpi_writer *entry)memcpy (header->oem_table_id,OEM_TABLE_ID ,8 );memcpy (header->creator_id,ASLC_ID ,4 ); header->creator_revision =1 ; + fadt->minor_revision =2 ; fadt->x_firmware_ctrl =map_to_sysmem (ctx->facs); fadt->x_dsdt =map_to_sysmem (ctx->dsdt);
@@ -258,7 +259,7 @@ int acpi_write_madt(struct acpi_ctx *ctx, const struct acpi_writer *entry)/* Fill out header fields */ acpi_fill_header (header,"APIC" ); header->length =sizeof (struct acpi_madt ); - header->revision =ACPI_MADT_REV_ACPI_3_0 ; + header->revision =acpi_get_table_revision (ACPITAB_MADT ); current = (void *)madt +sizeof (struct acpi_madt ); current =acpi_fill_madt (madt, current);
Signature · 1 line
2.45.2
Re: [PATCH 08/17] acpi: acpi_table: Bump revisions
Quoted 7 lines · Patrick Rudolph
The FADT structure found in U-Boot represents FADT revision 6 and the GICC and GICD structures defined in U-Boot are based on ACPI revision 6.3.
Bump the table revision to fix FWTS failures seen on aarch64.
Quoted 9 lines
Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Bin Meng <[email protected]>--- arch/x86/cpu/tangier/acpi.c | 2 -- include/acpi/acpi_table.h | 3 ++- lib/acpi/acpi_table.c | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-)
PATCH 9/17 acpi: Add ACPITAB for PPTT and GTDT
In reply to Patrick RudolphReturn the ACPI table revision in acpi_get_table_revision() for PPTT and GTDT. Match both to ACPI 6.2.
--- include/acpi/acpi_table.h | 2 ++ lib/acpi/acpi_table.c | 4 ++++ 2 files changed, 6 insertions(+)
include/acpi/acpi_table.h +2 -0
@@ -809,12 +809,14 @@ enum acpi_tables {ACPITAB_ECDT ,ACPITAB_FACS ,ACPITAB_FADT , +ACPITAB_GTDT ,ACPITAB_HEST ,ACPITAB_HPET ,ACPITAB_IVRS ,ACPITAB_MADT ,ACPITAB_MCFG ,ACPITAB_NHLT , +ACPITAB_PPTT ,ACPITAB_RSDP ,ACPITAB_RSDT , ACPITAB_SLIT,
lib/acpi/acpi_table.c +4 -0
@@ -107,6 +107,10 @@ int acpi_get_table_revision(enum acpi_tables table)return 1 ;case ACPITAB_SPCR :return 2 ; +case ACPITAB_PPTT :/* ACPI 6.2: 1 */ +return 1 ; +case ACPITAB_GTDT :/* ACPI 6.2: 2, ACPI 6.3: 3 */ +return 2 ;default :return -EINVAL ; }
Signature · 1 line
2.45.2
Re: [PATCH 09/17] acpi: Add ACPITAB for PPTT and GTDT
Quoted 10 lines · Patrick Rudolph
Return the ACPI table revision in
acpi_get_table_revision()for PPTT and GTDT. Match both to ACPI 6.2.Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>--- include/acpi/acpi_table.h | 2 ++ lib/acpi/acpi_table.c | 4 ++++ 2 files changed, 6 insertions(+)
PATCH 10/17 arm: mach-bcm283x: Map the ARM local MMIO as well
In reply to Patrick RudolphCover the "ARM local MMIO" range as well in the default MMU mapping in order to allow future code to access the GIC-400 without crashing. For now the GIC is not touched in u-boot, thus this change is a noop.
See [1](BCM2711 ARM Peripherals) for reference.
TEST: Enabled CONFIG_GICV2 and accessed the GIC in C code without crash.
1: https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf
--- arch/arm/mach-bcm283x/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-bcm283x/init.c +1 -1
@@ -50,7 +50,7 @@ static struct mm_region bcm2711_mem_map[MEM_MAP_MAX_ENTRIES] = { }, { .virt = 0xfc000000UL, .phys = 0xfc000000UL, - .size =0x03800000UL , + .size =0x04000000UL , .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |PTE_BLOCK_NON_SHARE |PTE_BLOCK_PXN |PTE_BLOCK_UXN
Signature · 1 line
2.45.2
PATCH 11/17 arm: mach-bcm283x: Bring in some header files from tianocore
In reply to Patrick RudolphFrom: Simon Glass <sjg () chromium ! org>
These header files presumably duplicate things already in the U-Boot devicetree. For now, bring them in to get the ASL code and ACPI table code to compile.
--- .../mach-bcm283x/include/mach/acpi/bcm2711.h | 152 ++++++++++++++++++ .../mach-bcm283x/include/mach/acpi/bcm2836.h | 127 +++++++++++++++ .../include/mach/acpi/bcm2836_gpio.h | 19 +++ .../include/mach/acpi/bcm2836_gpu.h | 47 ++++++ .../include/mach/acpi/bcm2836_pwm.h | 33 ++++ .../include/mach/acpi/bcm2836_sdhost.h | 18 +++ .../include/mach/acpi/bcm2836_sdio.h | 21 +++ drivers/pci/pcie_brcmstb.c | 101 ++---------- 8 files changed, 427 insertions(+), 91 deletions(-) create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2711.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpio.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpu.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_pwm.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdhost.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdio.h
arch/arm/mach-bcm283x/include/mach/acpi/bcm2711.h new file +152 -0
@@ -0,0 +1,152 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent */ +/** +* +* Copyright (c) 2019, Jeremy Linton +* Copyright (c) 2019, Pete Batard <[email protected]>. +* +**/ + +#ifndef BCM2711_H__ +#define BCM2711_H__ + +#define BCM2711_SOC_REGISTERS 0xfc000000 +#define BCM2711_SOC_REGISTER_LENGTH 0x02000000 + +#define BCM2711_ARM_LOCAL_REGISTERS 0xfe000000 +#define BCM2711_ARM_LOCAL_REGISTER_LENGTH 0x02000000 + +/* arm local addresses */ +#define BCM2711_ARMC_OFFSET 0x0000b000 +#define BCM2711_ARMC_BASE_ADDRESS (BCM2711_ARM_LOCAL_REGISTERS + BCM2711_ARMC_OFFSET) +#define BCM2711_ARMC_LENGTH 0x00000400 + +#define BCM2711_ARM_LOCAL_OFFSET 0x01800000 +#define BCM2711_ARM_LOCAL_BASE_ADDRESS (BCM2711_ARM_LOCAL_REGISTERS + BCM2711_ARM_LOCAL_OFFSET) +#define BCM2711_ARM_LOCAL_LENGTH 0x00000080 + +#define BCM2711_GIC400_OFFSET 0x01840000 +#define BCM2711_GIC400_BASE_ADDRESS (BCM2711_ARM_LOCAL_REGISTERS + BCM2711_GIC400_OFFSET) +#define BCM2711_GIC400_LENGTH 0x00008000 + +/* Generic PCI addresses */ +#define PCIE_TOP_OF_MEM_WIN 0xf8000000 +#define PCIE_CPU_MMIO_WINDOW 0x600000000 +#define PCIE_BRIDGE_MMIO_LEN 0x3ffffff + +/* PCI root bridge control registers location */ +#define PCIE_REG_BASE 0xfd500000 +#define PCIE_REG_LIMIT 0x9310 + +/* PCI root bridge control registers */ +#define BRCM_PCIE_CAP_REGS 0x00ac +#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1 0x0188 +#define VENDOR_SPECIFIC_REG1_LITTLE_ENDIAN 0x0 +#define PCIE_RC_CFG_PRIV1_ID_VAL3 0x043c +#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY 0x04dc +#define LINK_CAPABILITY_ASPM_SUPPORT_MASK 0xc00 + +#define PCIE_RC_DL_MDIO_ADDR 0x1100 +#define PCIE_RC_DL_MDIO_WR_DATA 0x1104 +#define PCIE_RC_DL_MDIO_RD_DATA 0x1108 + +#define PCIE_MISC_MISC_CTRL 0x4008 +#define MISC_CTRL_SCB_ACCESS_EN_MASK 0x1000 +#define MISC_CTRL_CFG_READ_UR_MODE_MASK 0x2000 +#define MISC_CTRL_MAX_BURST_SIZE_MASK 0x300000 +#define MISC_CTRL_MAX_BURST_SIZE_128 0x0 +#define MISC_CTRL_SCB0_SIZE_MASK 0xf8000000 + +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO 0x400c +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI 0x4010 +#define PCIE_MEM_WIN0_LO (win) \ + PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO + ((win) * 4) + +#define PCIE_MEM_WIN0_HI (win) \ + PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI + ((win) * 4) +#define PCIE_MISC_RC_BAR1_CONFIG_LO 0x402c +#define RC_BAR1_CONFIG_LO_SIZE_MASK 0x1f +#define PCIE_MISC_RC_BAR2_CONFIG_LO 0x4034 +#define RC_BAR2_CONFIG_LO_SIZE_MASK 0x1f +#define PCIE_MISC_RC_BAR2_CONFIG_HI 0x4038 +#define PCIE_MISC_RC_BAR3_CONFIG_LO 0x403c +#define RC_BAR3_CONFIG_LO_SIZE_MASK 0x1f +#define PCIE_MISC_PCIE_STATUS 0x4068 +#define STATUS_PCIE_PORT_MASK 0x80 +#define STATUS_PCIE_PORT_SHIFT 7 +#define STATUS_PCIE_DL_ACTIVE_MASK 0x20 +#define STATUS_PCIE_DL_ACTIVE_SHIFT 5 +#define STATUS_PCIE_PHYLINKUP_MASK 0x10 +#define STATUS_PCIE_PHYLINKUP_SHIFT 4 +#define PCIE_MISC_REVISION 0x406c +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT 0x4070 +#define MEM_WIN0_BASE_LIMIT_LIMIT_MASK 0xfff00000 +#define MEM_WIN0_BASE_LIMIT_BASE_MASK 0xfff0 +#define MEM_WIN0_BASE_LIMIT_BASE_HI_SHIFT 12 +#define PCIE_MEM_WIN0_BASE_LIMIT (win) \ + PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT + ((win) * 4) +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI 0x4080 +#define MEM_WIN0_BASE_HI_BASE_MASK 0xff +#define PCIE_MEM_WIN0_BASE_HI (win) \ + PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI + ((win) * 8) +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI 0x4084 +#define PCIE_MEM_WIN0_LIMIT_HI_LIMIT_MASK 0xff +#define PCIE_MEM_WIN0_LIMIT_HI (win) \ + PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI + ((win) * 8) + +#define PCIE_MISC_HARD_PCIE_HARD_DEBUG 0x4204 +#define PCIE_HARD_DEBUG_SERDES_IDDQ_MASK 0x08000000 + +#define PCIE_INTR2_CPU_STATUS 0x4300 +#define PCIE_INTR2_CPU_SET 0x4304 +#define PCIE_INTR2_CPU_CLR 0x4308 +#define PCIE_INTR2_CPU_MASK_STATUS 0x430c +#define PCIE_INTR2_CPU_MASK_SET 0x4310 +#define PCIE_INTR2_CPU_MASK_CLR 0x4314 + +#define PCIE_MSI_INTR2_CLR 0x4508 +#define PCIE_MSI_INTR2_MASK_SET 0x4510 + +#define PCIE_RGR1_SW_INIT_1 0x9210 +#define PCIE_EXT_CFG_INDEX 0x9000 +/* A small window pointing at the ECAM of the device selected by CFG_INDEX */ +#define PCIE_EXT_CFG_DATA 0x8000 + +#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK 0xc +#define PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK 0xffffff + +#define PCIE_MISC_MISC_CTRL_SCB_ACCESS_EN_MASK 0x1000 +#define PCIE_MISC_MISC_CTRL_CFG_READ_UR_MODE_MASK 0x2000 +#define PCIE_MISC_MISC_CTRL_MAX_BURST_SIZE_MASK 0x300000 +#define PCIE_MISC_MISC_CTRL_SCB0_SIZE_MASK 0xf8000000 +#define PCIE_MISC_MISC_CTRL_SCB1_SIZE_MASK 0x7c00000 +#define PCIE_MISC_MISC_CTRL_SCB2_SIZE_MASK 0x1f +#define PCIE_MISC_RC_BAR2_CONFIG_LO_SIZE_MASK 0x1f + +#define PCIE_RGR1_SW_INIT_1_INIT_MASK 0x2 +#define PCIE_RGR1_SW_INIT_1_PERST_MASK 0x1 + +#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK 0x08000000 + +#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK 0x2 + +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT_LIMIT_MASK 0xfff00000 +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT_BASE_MASK 0xfff0 +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI_BASE_MASK 0xff +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI_LIMIT_MASK 0xff +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_MASK_BITS 0xc + +#define PCIE_MISC_REVISION_MAJMIN_MASK 0xffff + +#define BURST_SIZE_128 0 +#define BURST_SIZE_256 1 +#define BURST_SIZE_512 2 + +#define BCM2711_THERM_SENSOR_OFFSET 0x015d2200 +#define BCM2711_THERM_SENSOR_BASE_ADDRESS (BCM2711_SOC_REGISTERS + BCM2711_THERM_SENSOR_OFFSET) +#define BCM2711_THERM_SENSOR_LENGTH 0x00000008 + +#define BCM2711_GENET_BASE_OFFSET 0x01580000 +#define BCM2711_GENET_BASE_ADDRESS (BCM2711_SOC_REGISTERS + BCM2711_GENET_BASE_OFFSET) +#define BCM2711_GENET_LENGTH 0x10000 + +#endif /* BCM2711_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836.h new file +127 -0
127 lines not on this page · raw message
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpio.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent */ +/** +* +* Copyright (c) 2020, Pete Batard <[email protected]> +* Copyright (c) 2018, Andrei Warkentin <[email protected]> +* Copyright (c) Microsoft Corporation. All rights reserved. +* +**/ + +#include <asm/arch/acpi/bcm2836.h> + +#ifndef __BCM2836_GPIO_H__ +#define __BCM2836_GPIO_H__ + +#define GPIO_OFFSET 0x00200000 +#define GPIO_BASE_ADDRESS (BCM2836_SOC_REGISTERS + GPIO_OFFSET) +#define GPIO_LENGTH 0x000000B4 + +#endif /* __BCM2836_GPIO_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpu.h new file +47 -0
47 lines not on this page · raw message
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_pwm.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent */ +/** +* +* Copyright (c) 2020, Pete Batard <[email protected]> +* +**/ + +#include <asm/arch/acpi/bcm2836.h> + +#ifndef __BCM2836_PWM_H__ +#define __BCM2836_PWM_H__ + +/* PWM controller constants */ + +#define BCM2836_PWM_DMA_OFFSET 0x00007B00 +#define BCM2836_PWM_DMA_BASE_ADDRESS (BCM2836_SOC_REGISTERS + BCM2836_PWM_DMA_OFFSET) +#define BCM2836_PWM_DMA_LENGTH 0x00000100 + +#define BCM2836_PWM_CLK_OFFSET 0x001010A0 +#define BCM2836_PWM_CLK_BASE_ADDRESS (BCM2836_SOC_REGISTERS + BCM2836_PWM_CLK_OFFSET) +#define BCM2836_PWM_CLK_LENGTH 0x00000008 + +#define BCM2836_PWM_CTRL_OFFSET 0x0020C000 +#define BCM2836_PWM_CTRL_BASE_ADDRESS (BCM2836_SOC_REGISTERS + BCM2836_PWM_CTRL_OFFSET) +#define BCM2836_PWM_CTRL_LENGTH 0x00000028 + +#define BCM2836_PWM_BUS_BASE_ADDRESS 0x7E20C000 +#define BCM2836_PWM_BUS_LENGTH 0x00000028 + +#define BCM2836_PWM_CTRL_UNCACHED_BASE_ADDRESS 0xFF20C000 +#define BCM2836_PWM_CTRL_UNCACHED_LENGTH 0x00000028 + +#endif /* __BCM2836_PWM_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdhost.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent */ +/** +* +* Copyright (c) 2017, Andrei Warkentin <[email protected]> +* Copyright (c) Microsoft Corporation. All rights reserved. +* +**/ + +#include <asm/arch/acpi/bcm2836.h> + +#ifndef __BCM2836_SDHOST_H__ +#define __BCM2836_SDHOST_H__ + +#define SDHOST_OFFSET 0x00202000 +#define SDHOST_BASE_ADDRESS (BCM2836_SOC_REGISTERS + SDHOST_OFFSET) +#define SDHOST_LENGTH 0x00000100 + +#endif /*__BCM2836_SDHOST_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdio.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-2-Clause-Patent */ +/** +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +**/ + +#include <asm/arch/acpi/bcm2836.h> + +#ifndef __BCM2836_SDIO_H__ +#define __BCM2836_SDIO_H__ + +// MMC/SD/SDIO1 register definitions. +#define MMCHS1_OFFSET 0x00300000 +#define MMCHS2_OFFSET 0x00340000 +#define MMCHS1_BASE (BCM2836_SOC_REGISTERS + MMCHS1_OFFSET) +#define MMCHS2_BASE (BCM2836_SOC_REGISTERS + MMCHS2_OFFSET) +#define MMCHS1_LENGTH 0x00000100 +#define MMCHS2_LENGTH 0x00000100 + +#endif /* __BCM2836_SDIO_H__ */
drivers/pci/pcie_brcmstb.c +10 -91
161 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH 12/17 arm: bcm283x: Write ACPI tables
In reply to Patrick RudolphAllocate a 64KiB buffer for ACPI tables and provide SoC specific tables for BCM2711:
- MADT
- FADT
- PPTT
- GTDT
- SPCR
Board specific tables like DSDT and SSDT are added in a separate patch.
When ACPI is enabled for a different SoC compliation will fail by design, indicating the required functions that needs to be implemented. When ACPI is not enabled the added code does nothing, keeping existing behaviour.
TEST: Booted on RPi4 with only ACPI enabled, providing no FDT to the OS.
--- arch/arm/mach-bcm283x/Makefile | 4 + arch/arm/mach-bcm283x/bcm2711_acpi.c | 172 +++++++++++++++++++++++++++ arch/arm/mach-bcm283x/init.c | 30 +++++ 3 files changed, 206 insertions(+) create mode 100644 arch/arm/mach-bcm283x/bcm2711_acpi.c
arch/arm/mach-bcm283x/Makefile +4 -0
@@ -4,3 +4,7 @@ obj-$(CONFIG_BCM2835) += lowlevel_init.o obj-y += init.o reset.o mbox.o msg.o phys2bus.o + +ifeq ($(CONFIG_GENERATE_ACPI_TABLE),y) +obj-$(CONFIG_BCM2711) += bcm2711_acpi.o +endif
arch/arm/mach-bcm283x/bcm2711_acpi.c new file +172 -0
173 lines not on this page · raw message
arch/arm/mach-bcm283x/init.c +30 -0
@@ -6,11 +6,13 @@* project. */ +#include <acpi/acpi_table.h> #include <cpu_func.h> #include <init.h> #include <dm/device.h> #include <fdt_support.h> #include <asm/global_data.h> +#include <malloc.h> #define BCM2711_RPI4_PCIE_XHCI_MMIO_PHYS 0x600000000UL#define BCM2711_RPI4_PCIE_XHCI_MMIO_SIZE 0x400000UL
@@ -240,3 +242,31 @@ void enable_caches(void) dcache_enable(); }#endif + +#ifdef CONFIG_GENERATE_ACPI_TABLE +static int last_stage_init (void ) +{ +ulong end; +void *ptr; + +/* Reserve 64K for ACPI tables, aligned to a 4K boundary */ + ptr =memalign (SZ_4K ,SZ_64K ); + +/* Generate ACPI tables */ + end =write_acpi_tables ((uintptr_t )ptr); +if (end <0 ) { +log_err ("Failed to write tables\n" ); +return log_msg_ret ("table" , end); + } +if (end > ((ulong )ptr +SZ_64K )) { +log_err ("ACPI tables overflowed\n" ); +return 0 ; + } + + gd->arch.table_start = (uintptr_t )ptr; + gd->arch.table_end = end; + +return 0 ; +} +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init); +#endif
Signature · 1 line
2.45.2
Re: [PATCH 12/17] arm: bcm283x: Write ACPI tables
Hi Patrick,
arch/arm/mach-bcm283x/init.c
Quoted 223 lines · Patrick Rudolph
Allocate a 64KiB buffer for ACPI tables and provide SoC specific tables for BCM2711:
- MADT
- FADT
- PPTT
- GTDT
- SPCRBoard specific tables like DSDT and SSDT are added in a separate patch.
When ACPI is enabled for a different SoC compliation will fail by design, indicating the required functions that needs to be implemented. When ACPI is not enabled the added code does nothing, keeping existing behaviour.
TEST: Booted on RPi4 with only ACPI enabled, providing no FDT to the OS.
Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Matthias Brugger <[email protected]>Cc Peter Robinson <[email protected]>Cc Tom Rini <[email protected]>--- arch/arm/mach-bcm283x/Makefile | 4 + arch/arm/mach-bcm283x/bcm2711_acpi.c | 172 +++++++++++++++++++++++++++ arch/arm/mach-bcm283x/init.c | 30 +++++ 3 files changed, 206 insertions(+) create mode 100644 arch/arm/mach-bcm283x/bcm2711_acpi.carch/arm/mach-bcm283x/Makefile +4
-0@@ -4,3 +4,7 @@ obj-$(CONFIG_BCM2835) += lowlevel_init.o obj-y += init.o reset.o mbox.o msg.o phys2bus.o + +ifeq ($(CONFIG_GENERATE_ACPI_TABLE),y) +obj-$(CONFIG_BCM2711) += bcm2711_acpi.o +endifarch/arm/mach-bcm283x/bcm2711_acpi.c new file +172
-0@@ -0,0 +1,172 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* (C) Copyright 2024 9elements GmbH +* +* See file CREDITS for list of people who contributed to this +* project. +*/ + +#include <acpi/acpi_table.h> +#include <asm/acpi_table.h> +#include <asm/armv8/sec_firmware.h> +#include <asm/arch/acpi/bcm2711.h> +#include <tables_csum.h> +#include <string.h> + +void acpi_fill_fadt (struct acpi_fadt *fadt) +{ + fadt->flags =ACPI_FADT_HW_REDUCED_ACPI |ACPI_FADT_LOW_PWR_IDLE_S0 ; + +if (CONFIG_IS_ENABLED (SEC_FIRMWARE_ARMV8_PSCI ) && +sec_firmware_support_psci_version () !=PSCI_INVALID_VER ) + fadt->arm_boot_arch =ACPI_ARM_PSCI_COMPLIANT ; +} + +void *acpi_fill_madt (struct acpi_madt *madt,void *current) +{ +struct acpi_madt_gicc *gicc; +struct acpi_madt_gicd *gicd; + + madt->lapic_addr =0 ; + madt->flags =0 ; + + gicc = current; +for (int i =0 ; i <4 ; i++) { +acpi_write_madt_gicc (gicc++, i,0x30 + i,BCM2711_GIC400_BASE_ADDRESS +0x2000 , +BCM2711_GIC400_BASE_ADDRESS +0x6000 , +BCM2711_GIC400_BASE_ADDRESS +0x4000 , +0x19 , i,1 ); + } + + gicd = (struct acpi_madt_gicd *)gicc; +acpi_write_madt_gicd (gicd++,0 ,BCM2711_GIC400_BASE_ADDRESS +0x1000 ,2 ); +return gicd; +} + +static u32 *add_proc (struct acpi_ctx *ctx,int flags,int parent,int proc_id, +int num_resources) +{ +struct acpi_pptt_proc *proc = ctx->current; +u32 *resource_list; + + proc->hdr.type =ACPI_PPTT_TYPE_PROC ; + proc->flags = flags; + proc->parent = parent; + proc->proc_id = proc_id; + proc->num_resources = num_resources; + proc->hdr.length =sizeof (struct acpi_pptt_proc ) + +sizeof (u32) * num_resources; + resource_list = ctx->current +sizeof (struct acpi_pptt_proc ); +acpi_inc (ctx, proc->hdr.length); + +return resource_list; +} + +static int add_cache (struct acpi_ctx *ctx,int flags,int size,int sets, +int assoc,int attributes,int line_size) +{ +struct acpi_pptt_cache *cache = ctx->current; +int ofs; + + ofs = ctx->current - ctx->tab_start; + cache->hdr.type =ACPI_PPTT_TYPE_CACHE ; + cache->hdr.length =sizeof (struct acpi_pptt_cache ); + cache->flags = flags; + cache->next_cache_level =0 ; + cache->size = size; + cache->sets = sets; + cache->assoc = assoc; + cache->attributes = attributes; + cache->line_size = line_size; +acpi_inc (ctx, cache->hdr.length); + +return ofs; +} + +static int acpi_write_pptt (struct acpi_ctx *ctx,const struct acpi_writer *entry) +{ +struct acpi_table_header *header; +int proc_ofs; +u32 *proc_ptr; +int ofs, ofs0, ofs1, i; + + header = ctx->current; + ctx->tab_start = ctx->current; + +memset (header,'\0' ,sizeof (struct acpi_table_header )); + +acpi_fill_header (header,"PPTT" ); + header->revision =acpi_get_table_revision (ACPITAB_PPTT ); +acpi_inc (ctx,sizeof (*header)); + + proc_ofs = ctx->current - ctx->tab_start; + proc_ptr =add_proc (ctx,ACPI_PPTT_PHYSICAL_PACKAGE | +ACPI_PPTT_CHILDREN_IDENTICAL ,0 ,0 ,1 ); + + ofs =add_cache (ctx,ACPI_PPTT_ALL_VALID ,0x100000 ,0x400 ,0x10 , +ACPI_PPTT_WRITE_ALLOC | + (ACPI_PPTT_CACHE_TYPE_UNIFIED << +ACPI_PPTT_CACHE_TYPE_SHIFT ),0x40 ); + *proc_ptr = ofs; + +for (i =0 ; i <4 ; i++) { + proc_ptr =add_proc (ctx,ACPI_PPTT_CHILDREN_IDENTICAL | +ACPI_PPTT_NODE_IS_LEAF |ACPI_PPTT_PROC_ID_VALID , + proc_ofs, i,2 ); + + ofs0 =add_cache (ctx,ACPI_PPTT_ALL_VALID ,0x8000 ,0x100 ,2 , +ACPI_PPTT_WRITE_ALLOC ,0x40 ); + + ofs1 =add_cache (ctx,ACPI_PPTT_ALL_BUT_WRITE_POL ,0xc000 ,0x100 ,3 , +ACPI_PPTT_CACHE_TYPE_INSTR << +ACPI_PPTT_CACHE_TYPE_SHIFT ,0x40 ); + proc_ptr[0 ] = ofs0; + proc_ptr[1 ] = ofs1; + } + + header->length = ctx->current - ctx->tab_start; + header->checksum =table_compute_checksum (header, header->length); + +acpi_inc (ctx, header->length); +acpi_add_table (ctx, header); + +return 0 ; +}; + +ACPI_WRITER(5pptt, "PPTT", acpi_write_pptt, 0); + +static int rpi_write_gtdt (struct acpi_ctx *ctx,const struct acpi_writer *entry) +{ +struct acpi_table_header *header; +struct acpi_gtdt *gtdt; + + gtdt = ctx->current; + header = >dt->header; + +memset (gtdt,'\0' ,sizeof (struct acpi_gtdt )); + +acpi_fill_header (header,"GTDT" ); + header->length =sizeof (struct acpi_gtdt ); + header->revision =acpi_get_table_revision (ACPITAB_GTDT ); + + gtdt->cnt_ctrl_base =BCM2711_ARM_LOCAL_BASE_ADDRESS +0x1c ; + gtdt->sec_el1_gsiv =29 ; + gtdt->sec_el1_flags =GTDT_FLAG_INT_ACTIVE_LOW ; + gtdt->el1_gsiv =30 ; + gtdt->el1_flags =GTDT_FLAG_INT_ACTIVE_LOW ; + gtdt->virt_el1_gsiv =27 ; + gtdt->virt_el1_flags =GTDT_FLAG_INT_ACTIVE_LOW ; + gtdt->el2_gsiv =26 ; + gtdt->el2_flags =GTDT_FLAG_INT_ACTIVE_LOW ; + gtdt->cnt_read_base =0xffffffffffffffff ; + + header->checksum =table_compute_checksum (header, header->length); + +acpi_add_table (ctx, gtdt); + +acpi_inc (ctx,sizeof (struct acpi_gtdt )); + +return 0 ; +}; + +ACPI_WRITER(5gtdt, "GTDT", rpi_write_gtdt, 0);arch/arm/mach-bcm283x/init.c +0
-0
This should be in arch/arm/lib or similar, i.e. generic code.
Quoted 20 lines
index
7a1de22e0a..80a10f2212100644arch/arm/mach-bcm283x/init.c +2
-0@@ -6,11 +6,13 @@* project. */ +#include <acpi/acpi_table.h> #include <cpu_func.h> #include <init.h> #include <dm/device.h> #include <fdt_support.h> #include <asm/global_data.h> +#include <malloc.h> #define BCM2711_RPI4_PCIE_XHCI_MMIO_PHYS 0x600000000UL#define BCM2711_RPI4_PCIE_XHCI_MMIO_SIZE 0x400000UL@@ -240,3 +242,31 @@ void enable_caches(void)dcache_enable (); }
arch/arm/mach-bcm283x/init.c void enable_caches(void) · line 253
Quoted 10 lines
arch/arm/mach-bcm283x/init.c +9
-0#endif + +#ifdef CONFIG_GENERATE_ACPI_TABLE +static int last_stage_init (void ) +{ +ulong end; +void *ptr; + +/* Reserve 64K for ACPI tables, aligned to a 4K boundary */ + ptr =memalign (SZ_4K ,SZ_64K );
We should really put tables in a bloblist on ARM. This is an option on x86 but we should make it mandatory on ARM. We may have other tables, such as SMBIOS.
Quoted 10 lines
arch/arm/mach-bcm283x/init.c +10
-0+ +/* Generate ACPI tables */ + end =write_acpi_tables ((uintptr_t )ptr); +if (end <0 ) { +log_err ("Failed to write tables\n" ); +return log_msg_ret ("table" , end); + } +if (end > ((ulong )ptr +SZ_64K )) { +log_err ("ACPI tables overflowed\n" ); +return 0 ;
arch/arm/mach-bcm283x/init.c void enable_caches(void) · line 272
Quoted 10 lines
arch/arm/mach-bcm283x/init.c +9
-0+ } + + gd->arch.table_start = (uintptr_t )ptr; + gd->arch.table_end = end; + +return 0 ; +} +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init); +#endif
But there should be :-)
Quoted 3 lines
--
2.45.2
Regards,
Simon
PATCH 13/17 board: raspberrypi: Add ASL files from tianocore
In reply to Patrick RudolphFrom: Simon Glass <sjg () chromium ! org>
Add the necessary DSDT files copied from tianocore to boot the RPi4. In addition generate a board specific SSDT to dynamically enable/disable ACPI devices based on FDT. This is required to support the various variants and boot options. It also allows to test the code on QEMU 9.0 without modifications, since it doesn't emulate PCIe yet.
--- board/raspberrypi/rpi/.gitignore | 3 + board/raspberrypi/rpi/Makefile | 2 + board/raspberrypi/rpi/acpitables.h | 91 +++++++ board/raspberrypi/rpi/dsdt.asl | 290 ++++++++++++++++++++++ board/raspberrypi/rpi/emmc.asl | 136 +++++++++++ board/raspberrypi/rpi/gpudevs.asl | 372 +++++++++++++++++++++++++++++ board/raspberrypi/rpi/pci.asl | 177 ++++++++++++++ board/raspberrypi/rpi/pep.asl | 90 +++++++ board/raspberrypi/rpi/rhpx.asl | 195 +++++++++++++++ board/raspberrypi/rpi/rpi.c | 182 ++++++++++++++ board/raspberrypi/rpi/sdhc.asl | 111 +++++++++ board/raspberrypi/rpi/uart.asl | 208 ++++++++++++++++ 12 files changed, 1857 insertions(+) create mode 100644 board/raspberrypi/rpi/.gitignore create mode 100644 board/raspberrypi/rpi/acpitables.h create mode 100644 board/raspberrypi/rpi/dsdt.asl create mode 100644 board/raspberrypi/rpi/emmc.asl create mode 100644 board/raspberrypi/rpi/gpudevs.asl create mode 100644 board/raspberrypi/rpi/pci.asl create mode 100644 board/raspberrypi/rpi/pep.asl create mode 100644 board/raspberrypi/rpi/rhpx.asl create mode 100644 board/raspberrypi/rpi/sdhc.asl create mode 100644 board/raspberrypi/rpi/uart.asl
board/raspberrypi/rpi/.gitignore new file +3 -0
@@ -0,0 +1,3 @@ +dsdt_generated.aml +dsdt_generated.asl.tmp +dsdt_generated.c
board/raspberrypi/rpi/Makefile +2 -0
@@ -4,3 +4,5 @@ obj-y := rpi.o obj-y += lowlevel_init.o + +obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
board/raspberrypi/rpi/acpitables.h new file +91 -0
91 lines not on this page · raw message
board/raspberrypi/rpi/dsdt.asl new file +290 -0
290 lines not on this page · raw message
board/raspberrypi/rpi/emmc.asl new file +136 -0
136 lines not on this page · raw message
board/raspberrypi/rpi/gpudevs.asl new file +372 -0
373 lines not on this page · raw message
board/raspberrypi/rpi/pci.asl new file +177 -0
178 lines not on this page · raw message
board/raspberrypi/rpi/pep.asl new file +90 -0
90 lines not on this page · raw message
board/raspberrypi/rpi/rhpx.asl new file +195 -0
195 lines not on this page · raw message
board/raspberrypi/rpi/rpi.c +182 -0
191 lines not on this page · raw message
board/raspberrypi/rpi/sdhc.asl new file +111 -0
112 lines not on this page · raw message
board/raspberrypi/rpi/uart.asl new file +208 -0
208 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH 13/17] board: raspberrypi: Add ASL files from tianocore
Hi Patrick,
Quoted 2 lines · Patrick Rudolph
From: Simon Glass <sjg () chromium ! org>
broken email address
Quoted 28 lines
Add the necessary DSDT files copied from tianocore to boot the RPi4. In addition generate a board specific SSDT to dynamically enable/disable ACPI devices based on FDT. This is required to support the various variants and boot options. It also allows to test the code on QEMU 9.0 without modifications, since it doesn't emulate PCIe yet.
Signed-off-by Simon Glass <[email protected]>Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Matthias Brugger <[email protected]>Cc Peter Robinson <[email protected]>--- board/raspberrypi/rpi/.gitignore | 3 + board/raspberrypi/rpi/Makefile | 2 + board/raspberrypi/rpi/acpitables.h | 91 +++++++ board/raspberrypi/rpi/dsdt.asl | 290 ++++++++++++++++++++++ board/raspberrypi/rpi/emmc.asl | 136 +++++++++++ board/raspberrypi/rpi/gpudevs.asl | 372 +++++++++++++++++++++++++++++ board/raspberrypi/rpi/pci.asl | 177 ++++++++++++++ board/raspberrypi/rpi/pep.asl | 90 +++++++ board/raspberrypi/rpi/rhpx.asl | 195 +++++++++++++++ board/raspberrypi/rpi/rpi.c | 182 ++++++++++++++ board/raspberrypi/rpi/sdhc.asl | 111 +++++++++ board/raspberrypi/rpi/uart.asl | 208 ++++++++++++++++ 12 files changed, 1857 insertions(+) create mode 100644 board/raspberrypi/rpi/.gitignore create mode 100644 board/raspberrypi/rpi/acpitables.h
Quoted 9 lines
create mode 100644 board/raspberrypi/rpi/dsdt.asl create mode 100644 board/raspberrypi/rpi/emmc.asl create mode 100644 board/raspberrypi/rpi/gpudevs.asl create mode 100644 board/raspberrypi/rpi/pci.asl create mode 100644 board/raspberrypi/rpi/pep.asl create mode 100644 board/raspberrypi/rpi/rhpx.asl create mode 100644 board/raspberrypi/rpi/sdhc.asl create mode 100644 board/raspberrypi/rpi/uart.asl
PATCH 14/17 arm: cpu: Add ACPI parking protocol support
In reply to Patrick RudolphOn Arm platforms that use ACPI they cannot rely on the "spin-table" CPU bringup usually defined in the FDT. Thus implement the 'ACPI Multi-processor Startup for ARM Platforms', also referred to as 'ACPI parking protocol'.
The ACPI parking protocol works similar to the spin-table mechanism, but the specification also covers lots of shortcomings of the spin-table implementations.
Every CPU defined in the ACPI MADT table has it's own 4K page where the spinloop code and the OS mailbox resides. When selected the U-Boot board code must make sure that the secondary CPUs enter u-boot after relocation as well, so that they can enter the spinloop code residing in the ACPI parking protocol pages.
The OS will then write to the mailbox and generate an IPI to release the CPUs from the spinloop code.
For now it's only implemented on ARMv8, but can easily be extended to other platforms.
TEST: Boots all CPUs on qemu-system-aarch64 -machine raspi4b
--- arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/parking_protocol_v8.S | 102 +++++++++++++++++++++++ arch/arm/cpu/armv8/start.S | 4 + arch/arm/include/asm/acpi_table.h | 52 ++++++++++++ arch/arm/lib/acpi_table.c | 87 +++++++++++++++++++ include/acpi/acpi_table.h | 10 +++ lib/Kconfig | 15 ++++ lib/acpi/acpi_table.c | 3 + 8 files changed, 274 insertions(+) create mode 100644 arch/arm/cpu/armv8/parking_protocol_v8.S
arch/arm/cpu/armv8/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_ARM_SMCCC) += smccc-call.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_ARMV8_SPIN_TABLE) += spin_table.o spin_table_v8.o +obj-$(CONFIG_ACPI_PARKING_PROTOCOL) += parking_protocol_v8.o else obj-$(CONFIG_ARCH_SUNXI) += fel_utils.o endif
arch/arm/cpu/armv8/parking_protocol_v8.S new file +102 -0
102 lines not on this page · raw message
arch/arm/cpu/armv8/start.S +4 -0
@@ -178,6 +178,10 @@ pie_fixup_done: branch_if_master x0, master_cpu b spin_table_secondary_jump /* never return */ +#elif defined(CONFIG_ACPI_PARKING_PROTOCOL) && !defined(CONFIG_SPL_BUILD) + branch_if_master x0, master_cpu + b acpi_parking_protocol_secondary_jump + /* never return */ #elif defined(CONFIG_ARMV8_MULTIENTRY) branch_if_master x0, master_cpu
arch/arm/include/asm/acpi_table.h +52 -0
64 lines not on this page · raw message
arch/arm/lib/acpi_table.c +87 -0
97 lines not on this page · raw message
include/acpi/acpi_table.h +10 -0
@@ -951,6 +951,16 @@ void acpi_fill_fadt(struct acpi_fadt *fadt);*/ void *acpi_fill_madt (struct acpi_madt *madt,void *current); +/** +* acpi_write_parking_protocol() - Installs the ACPI parking protocol. +* +* Sets up the ACPI parking protocol and installs the spinning code for +* secondary CPUs. +* +* @madt: The MADT to update +*/ +void acpi_write_parking_protocol (struct acpi_madt *madt); +/** * acpi_write_dbg2_pci_uart() - Write out a DBG2 table *
lib/Kconfig +15 -0
@@ -314,6 +314,21 @@ config GENERATE_ACPI_TABLE by the operating system. It defines platform-independent interfaces for configuration and power management monitoring. +config ACPI_PARKING_PROTOCOL + bool "Support ACPI parking protocol method" + depends on GENERATE_ACPI_TABLE + depends on ARMV8_MULTIENTRY + default y if !SEC_FIRMWARE_ARMV8_PSCI && !ARMV8_PSCI + help + Say Y here to support "ACPI parking protocol" enable method + for booting Linux. + + To use this feature, you must do: + - Bring secondary CPUs into U-Boot proper in a board specific + manner. This must be done *after* relocation. Otherwise, the + secondary CPUs will spin in unprotected memory area because the + master CPU protects the relocated spin code. + config SPL_TINY_MEMSET bool "Use a very small memset() in SPL" depends on SPL
lib/acpi/acpi_table.c +3 -0
@@ -271,6 +271,9 @@ int acpi_write_madt(struct acpi_ctx *ctx, const struct acpi_writer *entry)/* (Re)calculate length and checksum */ header->length = (uintptr_t )current - (uintptr_t )madt; +if (IS_ENABLED (CONFIG_ACPI_PARKING_PROTOCOL )) +acpi_write_parking_protocol (madt); + header->checksum =table_compute_checksum ((void *)madt, header->length);acpi_add_table (ctx, madt);acpi_inc (ctx, madt->header.length);
Signature · 1 line
2.45.2
Re: [PATCH 14/17] arm: cpu: Add ACPI parking protocol support
Hi Patrick,
Quoted 6 lines · Patrick Rudolph
On Arm platforms that use ACPI they cannot rely on the "spin-table" CPU bringup usually defined in the FDT. Thus implement the 'ACPI Multi-processor Startup for ARM Platforms', also referred to as 'ACPI parking protocol'.
Quoted 7 lines
The ACPI parking protocol works similar to the spin-table mechanism, but the specification also covers lots of shortcomings of the spin-table implementations.
Every CPU defined in the ACPI MADT table has it's own 4K page where the spinloop code and the OS mailbox resides. When selected the U-Boot board code must make sure that the secondary CPUs enter u-boot after relocation
U-Boot
arch/arm/cpu/armv8/parking_protocol_v8.S
Quoted 39 lines
as well, so that they can enter the spinloop code residing in the ACPI parking protocol pages.
The OS will then write to the mailbox and generate an IPI to release the CPUs from the spinloop code.
For now it's only implemented on ARMv8, but can easily be extended to other platforms.
TEST: Boots all CPUs on qemu-system-aarch64 -machine raspi4b
Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/parking_protocol_v8.S | 102 +++++++++++++++++++++++ arch/arm/cpu/armv8/start.S | 4 + arch/arm/include/asm/acpi_table.h | 52 ++++++++++++ arch/arm/lib/acpi_table.c | 87 +++++++++++++++++++ include/acpi/acpi_table.h | 10 +++ lib/Kconfig | 15 ++++ lib/acpi/acpi_table.c | 3 + 8 files changed, 274 insertions(+) create mode 100644 arch/arm/cpu/armv8/parking_protocol_v8.Sarch/arm/cpu/armv8/Makefile +1
-0@@ -29,6 +29,7 @@ obj-$(CONFIG_ARM_SMCCC) += smccc-call.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_ARMV8_SPIN_TABLE) += spin_table.o spin_table_v8.o +obj-$(CONFIG_ACPI_PARKING_PROTOCOL) += parking_protocol_v8.o else obj-$(CONFIG_ARCH_SUNXI) += fel_utils.o endifarch/arm/cpu/armv8/parking_protocol_v8.S +0
-0
How about acpi_park_v8.S as it is shorter?
Quoted 15 lines
new file mode 100644
index 0000000000..b7f6abbd85arch/arm/cpu/armv8/parking_protocol_v8.S new file +10
-0@@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2024 9elements GmbH + * Author: Patrick Rudolph <[email protected]> + */ + +#include <linux/linkage.h> +#include <asm/acpi_table.h> + +__secondary_cpuif_id:
arch/arm/cpu/armv8/parking_protocol_v8.S line 20
Quoted 10 lines
arch/arm/cpu/armv8/parking_protocol_v8.S new file +10
-0+ .quad 0 + +__secondary_parking_protocol_tables: + .quad 0 + +__secondary_parking_protocol_ncpus: + .quad 0 + +.global acpi_parking_protocol_code_size +acpi_parking_protocol_code_size:
acpi_park_code_size
acpi_parking_protocol is just too long
arch/arm/cpu/armv8/parking_protocol_v8.S line 21
Quoted 1 line
arch/arm/cpu/armv8/parking_protocol_v8.S new file +1
-0+ .word __secondary_parking_protocol_code_end - __secondary_parking_protocol_code_start
Is there a 'primary'? Does this refer to the code run by the secondary CPUs?
Quoted 109 lines
arch/arm/cpu/armv8/parking_protocol_v8.S new file +81
-0+ +.global acpi_parking_protocol_install +ENTRY(acpi_parking_protocol_install) + ldr x2, =__secondary_parking_protocol_ncpus + str x1, [x2] + ldr x2, =__secondary_parking_protocol_tables + str x0, [x2] + dsb ishst + sev + ret +ENDPROC(acpi_parking_protocol_install) + +.global acpi_parking_protocol_secondary_jump +ENTRY(acpi_parking_protocol_secondary_jump) +0: + /* Store a unique cpuif id in x0 */ + ldr x2, =__secondary_cpuif_id + ldaxr w0, [x2] + add w0, w0, #1 // =1 + stlxr w1, w0, [x2] + cbnz w1, 0b + +0: /* Check if parking protocol table is ready */ + ldr x1, =__secondary_parking_protocol_tables + ldr x2, [x1] + cbnz x2, 0f + wfe + b 0b + +0: /* Sanity check cpuif id */ + ldr x1, =__secondary_parking_protocol_ncpus + ldr x3, [x1] + cmp w0, w3 + b.lt 0f + +hlt: wfi + b hlt /* Should never happen. */ + + /* Find spinning code in ACPI parking protocol table */ +0: mov x1, #ACPI_PP_PAGE_SIZE + mul x3, x0, x1 + add x2, x2, x3 + mov x0, x2 /* Backup ACPI page ptr for later use */ + + mov x1, #ACPI_PP_CPU_CODE_OFFSET + add x2, x2, x1 + + /* Jump to spin code in own parking protocol page */ + br x2 +ENDPROC(acpi_parking_protocol_secondary_jump) + +.align 8 +__secondary_parking_protocol_code_start: +.global acpi_parking_protocol_code_start +ENTRY(acpi_parking_protocol_code_start) + /* x0 points to the 4K aligned parking protocol page */ + + /* Prepare defines for spinning code */ + mov w3, #ACPI_PP_CPU_ID_INVALID + mov x2, #ACPI_PP_JMP_ADR_INVALID + +0: wfe + ldr w1, [x0, #ACPI_PP_CPU_ID_OFFSET] + + /* Check CPU ID is not invalid */ + cmp w1, w3 + b.eq 0b + + /* Check jump address not invalid */ + ldr x1, [x0, #ACPI_PP_CPU_JMP_ADDR_OFFSET] + cmp x1, x2 + b.eq 0b + + /* Clear jump address before jump */ + str x2, [x0, #ACPI_PP_CPU_JMP_ADDR_OFFSET] + dsb sy + + br x1 +ENDPROC(acpi_parking_protocol_code_start) + /* Secondary Boot Code ends here */ +__secondary_parking_protocol_code_end:arch/arm/cpu/armv8/start.S +4
-0@@ -178,6 +178,10 @@ pie_fixup_done: branch_if_master x0, master_cpu b spin_table_secondary_jump /* never return */ +#elif defined(CONFIG_ACPI_PARKING_PROTOCOL) && !defined(CONFIG_SPL_BUILD) + branch_if_master x0, master_cpu + b acpi_parking_protocol_secondary_jump + /* never return */ #elif defined(CONFIG_ARMV8_MULTIENTRY) branch_if_master x0, master_cpuarch/arm/include/asm/acpi_table.h +1
-0@@ -4,6 +4,7 @@#define __ASM_ACPI_TABLE_H__#ifndef __ACPI__ +#ifndef __ASSEMBLY__ void acpi_write_madt_gicc(struct acpi_madt_gicc *gicc, uint cpu_num, uint perf_gsiv, ulong phys_base, ulong gicv,
arch/arm/include/asm/acpi_table.h void acpi_write_madt_gicc(struct acpi_madt_gicc *gicc, uint cpu_num, · line 17
Quoted 4 lines
arch/arm/include/asm/acpi_table.h +1
-0@@ -13,6 +14,57 @@ void acpi_write_madt_gicc(struct acpi_madt_gicc *gicc, uint cpu_num,void acpi_write_madt_gicd (struct acpi_madt_gicd *gicd,uint gic_id,ulong phys_base,uint gic_version); +/* Multi-processor Startup for ARM Platforms */
please add full comments for members
arch/arm/include/asm/acpi_table.h void acpi_write_madt_gicc(struct acpi_madt_gicc *gicc, uint cpu_num, · line 30
Quoted 13 lines
arch/arm/include/asm/acpi_table.h +13
-0+struct acpi_parking_protocol_page { +u32 cpu_id; +u32 reserved; +u64 jumping_address; +u8 os_reserved[2032 ]; +u8 cpu_spinning_code[2048 ]; +} __packed; + +/* Architecture specific functions */ +/** +* acpi_parking_protocol_code_size - Spinloop code size * +*/ +extern u32 acpi_parking_protocol_code_size;
u32 but it says .word in the code...isn't that 16 bits?
Quoted 73 lines
arch/arm/include/asm/acpi_table.h +37
-0+ +/** +* parking_protocol_code_start() - Spinloop code +* +* Architectural spinloop code to be installed in each parking protocol +* page. The spinloop code must be less than 2048 bytes. +* +* The spinloop code will be entered after calling +* acpi_parking_protocol_install(). +* +*/ +void acpi_parking_protocol_code_start (void ); + +/** +* acpi_parking_protocol_install() - Installs the parking protocol. +* +* Installs the reserved memory containing the spinloop code and the +* OS mailbox as required by the ACPI Multi-processor Startup for +* ARM Platforms specification. +* +* The secondary CPUs will wait for this function to be called in order +* to enter the spinloop code residing in the tables. +* +* @tables: ACPI parking protocol tables. +* @num_cpus: Number of allocated pages. +*/ +void acpi_parking_protocol_install (uintptr_t tables,size_t num_cpus); + +#endif /* !__ASSEMBLY__ */ #endif /* !__ACPI__ */ +#define ACPI_PP_CPU_ID_INVALID 0xffffffff +#define ACPI_PP_JMP_ADR_INVALID 0 +#define ACPI_PP_PAGE_SIZE 4096 +#define ACPI_PP_CPU_ID_OFFSET 0 +#define ACPI_PP_CPU_JMP_ADDR_OFFSET 8 +#define ACPI_PP_CPU_CODE_OFFSET 2048 +#define ACPI_PP_VERSION 1 +#endif /* __ASM_ACPI_TABLE_H__ */ arch/arm/lib/acpi_table.c +17
-0@@ -10,7 +10,11 @@#include <acpi/acpigen.h> #include <acpi/acpi_device.h> #include <acpi/acpi_table.h> +#include <cpu_func.h> +#include <efi_loader.h> +#include <malloc.h> #include <string.h> +#include <tables_csum.h> void acpi_write_madt_gicc(struct acpi_madt_gicc *gicc, uint cpu_num, uint perf_gsiv, ulong phys_base, ulong gicv,@@ -42,3 +46,86 @@ void acpi_write_madt_gicd(struct acpi_madt_gicd *gicd, uint gic_id, gicd->phys_base = phys_base; gicd->gic_version = gic_version; } + +void acpi_write_parking_protocol (struct acpi_madt *madt) +{ +struct acpi_parking_protocol_page *page; +struct acpi_madt_gicc *gicc; +void *reloc_addr; +u64 start; +int ncpus =0 ; + +/* According to the "Multi-processor Startup for ARM Platforms": +* - Every CPU as specified by MADT GICC has it's own 4K page +* - Every page is divided into two sections: OS and FW reserved +* - Memory occupied by "Parking Protocol" must be marked 'Reserved'
arch/arm/lib/acpi_table.c void acpi_write_madt_gicd(struct acpi_madt_gicd *gicd, uint gic_id, · line 71
Quoted 10 lines
arch/arm/lib/acpi_table.c +10
-0+* - Spinloop code should reside in FW reserved 2048 bytes +* - Spinloop code will check the mailbox in OS reserved area +*/ + +if (acpi_parking_protocol_code_size >sizeof (page->cpu_spinning_code)) { +log_err ("Spinning code too big to fit: %d\n" , + acpi_parking_protocol_code_size); + } + +/* Count all cores including BSP */
Ick, that's a very strange way of counting CPUs. You can use uclass_id_count(UCLASS_CPU).
Quoted 4 lines
arch/arm/lib/acpi_table.c +4
-0+for (int i =sizeof (struct acpi_madt ); i < madt->header.length; ) { + gicc = (struct acpi_madt_gicc *)((void *)madt + i); +if (gicc->type !=ACPI_APIC_GICC ) { + i += gicc->length;
arch/arm/lib/acpi_table.c void acpi_write_madt_gicd(struct acpi_madt_gicd *gicd, uint gic_id, · line 85
Quoted 10 lines
arch/arm/lib/acpi_table.c +10
-0+continue ; + } + ncpus++; + i += gicc->length; + } +debug ("Found %d GICCs in MADT\n" , ncpus); + +/* Allocate pages linearly due to assembly code requirements */ + page =memalign (ACPI_PP_PAGE_SIZE ,ACPI_PP_PAGE_SIZE * ncpus); + start = (u64 )(uintptr_t )page;
Again, this should go in the bloblist.
arch/arm/lib/acpi_table.c void acpi_write_madt_gicd(struct acpi_madt_gicd *gicd, uint gic_id, · line 93
Quoted 8 lines
arch/arm/lib/acpi_table.c +8
-0+ +#if CONFIG_IS_ENABLED (EFI_LOADER ) +int ret =efi_add_memory_map (start, ncpus *ACPI_PP_PAGE_SIZE ,EFI_RESERVED_MEMORY_TYPE ); + +if (ret !=EFI_SUCCESS ) +log_err ("Reserved memory mapping failed addr %llx size %x\n" , + start, ncpus *ACPI_PP_PAGE_SIZE ); +#endif
This map will overlap the one that EFI creates for the malloc() region, won't it?
arch/arm/lib/acpi_table.c void acpi_write_madt_gicd(struct acpi_madt_gicd *gicd, uint gic_id, · line 96
Quoted 3 lines
arch/arm/lib/acpi_table.c +3
-0+ +/* Prepare the parking protocol pages */ +for (int i =sizeof (struct acpi_madt ); i < madt->header.length; ) {
please use 'pos' instead of 'i' as this isn't really an index
arch/arm/lib/acpi_table.c void acpi_write_madt_gicd(struct acpi_madt_gicd *gicd, uint gic_id, · line 97
Quoted 1 line
arch/arm/lib/acpi_table.c +1
-0+ gicc = (struct acpi_madt_gicc *)((void *)madt + i);
Can you put the loop code in a separate function? This is getting a bit long for one function
arch/arm/lib/acpi_table.c void acpi_write_madt_gicd(struct acpi_madt_gicd *gicd, uint gic_id, · line 108
Quoted 11 lines
arch/arm/lib/acpi_table.c +11
-0+if (gicc->type !=ACPI_APIC_GICC ) { + i += gicc->length; +continue ; + } + +/* Update GICC */ + gicc->parking_proto =ACPI_PP_VERSION ; + gicc->parked_addr = (uint64_t )(uintptr_t )page; + +/* Prepare parking protocol page */ +memset (page,0 ,sizeof (struct acpi_parking_protocol_page ));
'\0'
Quoted 85 lines
arch/arm/lib/acpi_table.c +23
-0+ page->cpu_id =ACPI_PP_CPU_ID_INVALID ; + page->jumping_address =ACPI_PP_JMP_ADR_INVALID ; + +/* Relocate spinning code */ + reloc_addr = &page->cpu_spinning_code[0 ]; + +debug ("Relocating spin table from %p to %p (size %x)\n" , + &acpi_parking_protocol_code_start, reloc_addr, + acpi_parking_protocol_code_size); +memcpy (reloc_addr, &acpi_parking_protocol_code_start, + acpi_parking_protocol_code_size); + +if (!CONFIG_IS_ENABLED (SYS_DCACHE_OFF )) +flush_dcache_range ((unsigned long )page, + (unsigned long )page + +sizeof (struct acpi_parking_protocol_page )); + page++; + i += gicc->length; + } + +/* Point secondary CPUs to new spin loop code */ +acpi_parking_protocol_install (start, ncpus); +}include/acpi/acpi_table.h +10
-0@@ -951,6 +951,16 @@ void acpi_fill_fadt(struct acpi_fadt *fadt);*/ void *acpi_fill_madt (struct acpi_madt *madt,void *current); +/** +* acpi_write_parking_protocol() - Installs the ACPI parking protocol. +* +* Sets up the ACPI parking protocol and installs the spinning code for +* secondary CPUs. +* +* @madt: The MADT to update +*/ +void acpi_write_parking_protocol (struct acpi_madt *madt); +/** * acpi_write_dbg2_pci_uart() - Write out a DBG2 table * lib/Kconfig +15
-0@@ -314,6 +314,21 @@ config GENERATE_ACPI_TABLE by the operating system. It defines platform-independent interfaces for configuration and power management monitoring. +config ACPI_PARKING_PROTOCOL + bool "Support ACPI parking protocol method" + depends on GENERATE_ACPI_TABLE + depends on ARMV8_MULTIENTRY + default y if !SEC_FIRMWARE_ARMV8_PSCI && !ARMV8_PSCI + help + Say Y here to support "ACPI parking protocol" enable method + for booting Linux. + + To use this feature, you must do: + - Bring secondary CPUs into U-Boot proper in a board specific + manner. This must be done *after* relocation. Otherwise, the + secondary CPUs will spin in unprotected memory area because the + master CPU protects the relocated spin code. + config SPL_TINY_MEMSET bool "Use a very small memset() in SPL" depends on SPLlib/acpi/acpi_table.c +3
-1@@ -271,6 +271,9 @@ int acpi_write_madt(struct acpi_ctx *ctx, const struct acpi_writer *entry)/* (Re)calculate length and checksum */ header->length = (uintptr_t )current - (uintptr_t )madt; +if (IS_ENABLED (CONFIG_ACPI_PARKING_PROTOCOL )) +acpi_write_parking_protocol (madt); + header->checksum =table_compute_checksum ((void *)madt, header->length);acpi_add_table (ctx, madt);acpi_inc (ctx, madt->header.length); --
Quoted 2 lines
2.45.2
Regards,
Simon
PATCH 15/17 arm: mach-bcm283x: Add ARMV8_MULTIENTRY support
In reply to Patrick RudolphWhen ACPI is enabled over FDT the APs cannot be brought out of reset by the OS using the "FDT spin-table" mechanism, as no FDT is provided to the OS. The APs must be released out of reset in u-boot and then brought up in an ACPI compliant fashion.
When ARMV8_MULTIENTRY is specified the APs are released from reset and will enter U-Boot after it has been relocated as well.
By default ARMV8_MULTIENTRY is not selected, keeping existing behaviour.
TEST: All APs enter U-Boot when run on qemu-system-aarch64
--- arch/arm/mach-bcm283x/Kconfig | 2 ++ arch/arm/mach-bcm283x/init.c | 47 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)
arch/arm/mach-bcm283x/Kconfig +2 -0
@@ -12,6 +12,7 @@ config BCM2836 config BCM2837 bool "Broadcom BCM2837 SoC support" depends on ARCH_BCM283X + select ARCH_EARLY_INIT_R config BCM2837_32B bool "Broadcom BCM2837 SoC 32-bit support"
@@ -29,6 +30,7 @@ config BCM2837_64B config BCM2711 bool "Broadcom BCM2711 SoC support" depends on ARCH_BCM283X + select ARCH_EARLY_INIT_R config BCM2711_32B bool "Broadcom BCM2711 SoC 32-bit support"
arch/arm/mach-bcm283x/init.c +47 -0
59 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH 15/17] arm: mach-bcm283x: Add ARMV8_MULTIENTRY support
Hi Patrick,
Quoted 63 lines · Patrick Rudolph
When ACPI is enabled over FDT the APs cannot be brought out of reset by the OS using the "FDT spin-table" mechanism, as no FDT is provided to the OS. The APs must be released out of reset in u-boot and then brought up in an ACPI compliant fashion.
When
ARMV8_MULTIENTRYis specified the APs are released from reset and will enter U-Boot after it has been relocated as well.By default
ARMV8_MULTIENTRYis not selected, keeping existing behaviour.TEST: All APs enter U-Boot when run on qemu-system-aarch64
Signed-off-by Patrick Rudolph <[email protected]>Cc Matthias Brugger <[email protected]>Cc Peter Robinson <[email protected]>Cc Tom Rini <[email protected]>--- arch/arm/mach-bcm283x/Kconfig | 2 ++ arch/arm/mach-bcm283x/init.c | 47 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)arch/arm/mach-bcm283x/Kconfig +2
-0@@ -12,6 +12,7 @@ config BCM2836 config BCM2837 bool "Broadcom BCM2837 SoC support" depends on ARCH_BCM283X + select ARCH_EARLY_INIT_R config BCM2837_32B bool "Broadcom BCM2837 SoC 32-bit support"@@ -29,6 +30,7 @@ config BCM2837_64B config BCM2711 bool "Broadcom BCM2711 SoC support" depends on ARCH_BCM283X + select ARCH_EARLY_INIT_R config BCM2711_32B bool "Broadcom BCM2711 SoC 32-bit support"arch/arm/mach-bcm283x/init.c +6
-0@@ -7,6 +7,7 @@*/ #include <acpi/acpi_table.h> +#include <asm-generic/sections.h> #include <cpu_func.h> #include <init.h> #include <dm/device.h> @@ -201,6 +202,52 @@ int mach_cpu_init(void) "brcm,bcm2712-pm");if (offset > soc) rpi_wdog_base =fdt_get_base_address (gd->fdt_blob, offset); +return 0 ; +} + +int arch_early_init_r (void ) +{
arch/arm/mach-bcm283x/init.c int mach_cpu_init(void) · line 219
Quoted 10 lines
arch/arm/mach-bcm283x/init.c +10
-0+int cpus, offset; +const char *prop; +u64 release_addr64; +uintptr_t *start_address; + +if (CONFIG_IS_ENABLED (ARMV8_MULTIENTRY )) { +/* +* Release CPUs from reset after u-boot has been relocated. +*/ + cpus =fdt_path_offset (gd->fdt_blob,"/cpus" );
We should not go hacking around in the devicetree. We need a way to handle this through driver model. See cpu.h and perhaps add a new operation if needed?
Quoted 35 lines
arch/arm/mach-bcm283x/init.c +31
-1+if (cpus <0 ) +return -ENODEV ; + +for (offset =fdt_first_subnode (gd->fdt_blob, cpus); + offset >=0 ; + offset =fdt_next_subnode (gd->fdt_blob, offset)) { + prop =fdt_getprop (gd->fdt_blob, offset,"device_type" ,NULL ); +if (!prop ||strcmp (prop,"cpu" )) +continue ; + + prop =fdt_getprop (gd->fdt_blob, offset,"enable-method" ,NULL ); +if (!prop ||strcmp (prop,"spin-table" )) +continue ; + + release_addr64 =fdtdec_get_uint64 (gd->fdt_blob, offset, +"cpu-release-addr" , ~0ULL ); +if (release_addr64 == ~0ULL ) +continue ; + +/* Point to U-Boot start */ + start_address = (uintptr_t *)(uintptr_t )release_addr64; + *start_address = (uintptr_t )_start; + +if (!CONFIG_IS_ENABLED (SYS_DCACHE_OFF )) +flush_dcache_range (release_addr64, + release_addr64 +sizeof (uintptr_t )); +/* Send an event to wake up the secondary CPU. */ + asm("dsb ishst\n" +"sev" ); + } + }return 0 ; } --
Quoted 2 lines
2.45.2
Regards,
Simon
PATCH 16/17 arm: mach-bcm283x: Enable ARMV8_MULTIENTRY
In reply to Patrick RudolphOn FDT platforms the APs are brought out of reset using the spin-table as defined in the DT. On ACPI enabled platforms there's no FDT, thus enable the ARMV8_MULTIENTRY to use the ACPI parking protocol instead.
TEST: - Aps enter U-Boot when run on qemu-system-aarch64 -machine raspi4b
- APs on real hardware do not enter U-Boot! To be investigated.
--- arch/arm/mach-bcm283x/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-bcm283x/Kconfig +2 -0
@@ -26,6 +26,7 @@ config BCM2837_64B depends on ARCH_BCM283X select BCM2837 select ARM64 + select ARMV8_MULTIENTRY if GENERATE_ACPI_TABLE config BCM2711 bool "Broadcom BCM2711 SoC support"
@@ -45,6 +46,7 @@ config BCM2711_64B depends on ARCH_BCM283X select BCM2711 select ARM64 + select ARMV8_MULTIENTRY if GENERATE_ACPI_TABLE menu "Broadcom BCM283X family" depends on ARCH_BCM283X
Signature · 1 line
2.45.2
Re: [PATCH 16/17] arm: mach-bcm283x: Enable ARMV8_MULTIENTRY
Quoted 8 lines · Patrick Rudolph
On FDT platforms the APs are brought out of reset using the spin-table as defined in the DT. On ACPI enabled platforms there's no FDT, thus enable the
ARMV8_MULTIENTRYto use the ACPI parking protocol instead.TEST: - Aps enter U-Boot when run on qemu-system-aarch64 -machine raspi4b
- APs on real hardware do not enter U-Boot! To be investigated.
Quoted 8 lines
Signed-off-by Patrick Rudolph <[email protected]>Cc Matthias Brugger <[email protected]>Cc Peter Robinson <[email protected]>Cc Tom Rini <[email protected]>--- arch/arm/mach-bcm283x/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
PATCH 17/17 configs: Add RPI4 ACPI defconfig
In reply to Patrick RudolphAllows to build the RPi4 with ACPI enabled.
TEST: - Boots on qemu-system-aarch64 -machine raspi4b
- Boots on real hardware with arm_64bit=1 in config.txt
--- configs/rpi_4_acpi_defconfig | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 configs/rpi_4_acpi_defconfig
configs/rpi_4_acpi_defconfig new file +79 -0
@@ -0,0 +1,79 @@ +CONFIG_ARM=y +CONFIG_ARCH_BCM283X=y +CONFIG_TEXT_BASE=0x00080000 +CONFIG_TARGET_RPI_4=y +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe30 +CONFIG_ENV_SIZE=0x4000 +CONFIG_DEFAULT_DEVICE_TREE="bcm2711-rpi-4-b" +CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_DM_RESET=y +CONFIG_SYS_LOAD_ADDR=0x1000000 +CONFIG_PCI=y +CONFIG_BOOTSTD_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y +CONFIG_FDT_SIMPLEFB=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start;" +CONFIG_SYS_PBSIZE=1049 +# CONFIG_DISPLAY_CPUINFO is not set +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_LAST_STAGE_INIT=y +CONFIG_MISC_INIT_R=y +CONFIG_SYS_PROMPT="U-Boot> " +CONFIG_CMD_DFU=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_MMC=y +CONFIG_CMD_PCI=y +CONFIG_CMD_USB=y +CONFIG_CMD_FS_UUID=y +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y +CONFIG_TFTP_TSIZE=y +CONFIG_DM_DMA=y +CONFIG_DFU_MMC=y +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000 +CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000 +CONFIG_BCM2835_GPIO=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y +CONFIG_MMC_SDHCI_BCM2835=y +CONFIG_BCMGENET=y +CONFIG_PCI_BRCMSTB=y +CONFIG_PINCTRL=y +# CONFIG_PINCTRL_GENERIC is not set +CONFIG_DM_RNG=y +CONFIG_RNG_IPROC200=y +# CONFIG_REQUIRE_SERIAL_CONSOLE is not set +CONFIG_SYSINFO=y +CONFIG_SYSINFO_SMBIOS=y +CONFIG_USB=y +CONFIG_DM_USB_GADGET=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_PCI=y +CONFIG_USB_KEYBOARD=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="FSL" +CONFIG_USB_GADGET_VENDOR_NUM=0x0525 +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 +CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_VIDEO=y +# CONFIG_VIDEO_BPP8 is not set +# CONFIG_VIDEO_BPP16 is not set +CONFIG_SYS_WHITE_ON_BLACK=y +CONFIG_VIDEO_BCM2835=y +CONFIG_CONSOLE_SCROLL_LINES=10 +CONFIG_PHYS_TO_BUS=y +CONFIG_OF_LIBFDT_OVERLAY=y + +CONFIG_GENERATE_ACPI_TABLE=y +CONFIG_ACPI=y +CONFIG_ACPI_PARKING_PROTOCOL=y +CONFIG_CMD_ACPI=y +CONFIG_BOOTM_EFI=y +CONFIG_CMD_BOOTEFI=y +CONFIG_EFI_VARIABLE_NO_STORE=y +#CONFIG_EFI_RT_VOLATILE_STORE=y +CONFIG_HEXDUMP=y
Signature · 1 line
2.45.2
Re: [PATCH 17/17] configs: Add RPI4 ACPI defconfig
Hi Patrick,
Quoted 6 lines · Patrick Rudolph
Allows to build the RPi4 with ACPI enabled.
TEST: - Boots on qemu-system-aarch64 -machine raspi4b
- Boots on real hardware with arm_64bit=1 in config.txt
Quoted 8 lines
Signed-off-by Patrick Rudolph <[email protected]>Cc Simon Glass <[email protected]>Cc Matthias Brugger <[email protected]>Cc Peter Robinson <[email protected]>--- configs/rpi_4_acpi_defconfig | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 configs/rpi_4_acpi_defconfig
Can you please add some docs on this to doc/board/broadcom/raspberrypi.rst ?
Quoted 45 lines
configs/rpi_4_acpi_defconfig new file +38
-0@@ -0,0 +1,79 @@ +CONFIG_ARM=y +CONFIG_ARCH_BCM283X=y +CONFIG_TEXT_BASE=0x00080000 +CONFIG_TARGET_RPI_4=y +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe30 +CONFIG_ENV_SIZE=0x4000 +CONFIG_DEFAULT_DEVICE_TREE="bcm2711-rpi-4-b" +CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_DM_RESET=y +CONFIG_SYS_LOAD_ADDR=0x1000000 +CONFIG_PCI=y +CONFIG_BOOTSTD_DEFAULTS=y +CONFIG_OF_BOARD_SETUP=y +CONFIG_FDT_SIMPLEFB=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start;" +CONFIG_SYS_PBSIZE=1049 +# CONFIG_DISPLAY_CPUINFO is not set +# CONFIG_DISPLAY_BOARDINFO is not set +CONFIG_LAST_STAGE_INIT=y +CONFIG_MISC_INIT_R=y +CONFIG_SYS_PROMPT="U-Boot> " +CONFIG_CMD_DFU=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_MMC=y +CONFIG_CMD_PCI=y +CONFIG_CMD_USB=y +CONFIG_CMD_FS_UUID=y +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y +CONFIG_TFTP_TSIZE=y +CONFIG_DM_DMA=y +CONFIG_DFU_MMC=y +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000 +CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000 +CONFIG_BCM2835_GPIO=y
configs/rpi_4_acpi_defconfig line 48
Quoted 10 lines
configs/rpi_4_acpi_defconfig new file +10
-0+CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y +CONFIG_MMC_SDHCI_BCM2835=y +CONFIG_BCMGENET=y +CONFIG_PCI_BRCMSTB=y +CONFIG_PINCTRL=y +# CONFIG_PINCTRL_GENERIC is not set +CONFIG_DM_RNG=y +CONFIG_RNG_IPROC200=y +# CONFIG_REQUIRE_SERIAL_CONSOLE is not set
How come?
Quoted 12 lines
configs/rpi_4_acpi_defconfig new file +12
-0+CONFIG_SYSINFO=y +CONFIG_SYSINFO_SMBIOS=y +CONFIG_USB=y +CONFIG_DM_USB_GADGET=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_PCI=y +CONFIG_USB_KEYBOARD=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_MANUFACTURER="FSL" +CONFIG_USB_GADGET_VENDOR_NUM=0x0525 +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 +CONFIG_USB_GADGET_DWC2_OTG=y
configs/rpi_4_acpi_defconfig line 70
Quoted 10 lines
configs/rpi_4_acpi_defconfig new file +10
-0+CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_VIDEO=y +# CONFIG_VIDEO_BPP8 is not set +# CONFIG_VIDEO_BPP16 is not set +CONFIG_SYS_WHITE_ON_BLACK=y +CONFIG_VIDEO_BCM2835=y +CONFIG_CONSOLE_SCROLL_LINES=10 +CONFIG_PHYS_TO_BUS=y +CONFIG_OF_LIBFDT_OVERLAY=y +
Please drop blank line
configs/rpi_4_acpi_defconfig line 78
Quoted 8 lines
configs/rpi_4_acpi_defconfig new file +8
-0+CONFIG_GENERATE_ACPI_TABLE=y +CONFIG_ACPI=y +CONFIG_ACPI_PARKING_PROTOCOL=y +CONFIG_CMD_ACPI=y +CONFIG_BOOTM_EFI=y +CONFIG_CMD_BOOTEFI=y +CONFIG_EFI_VARIABLE_NO_STORE=y +#CONFIG_EFI_RT_VOLATILE_STORE=y
Should this have 'is not set' ?
Quoted 4 lines
configs/rpi_4_acpi_defconfig new file +1
-1+CONFIG_HEXDUMP=y --2.45.2
It looks like the ordering is wrong above...so please check with 'make savedefconfig'.
Regards,
Simon
Hi Patrick,
Quoted 22 lines · Patrick Rudolph
Based on the existing work done by Simon Glass this series adds support for booting aarch64 devices using ACPI only. As target the Raspberry Pi4 was used, which is broadly available and allows easy testing of the proposed solution.
The series is split into ACPI cleanups and code movements, adding Arm specific ACPI tables and finally SoC and mainboard related changes to boot a Linux on the RPi4. Currently only the mandatory ACPI tables are supported, allowing to boot into Linux without errors.
The changes were tested on real hardware as well on QEMU v9.0:
qemu-system-aarch64 -machine raspi4b -kernel u-boot.bin -cpu cortex-a72 \
(quoted diff) +0
-2-smp 4 -m 2G -drive file=raspbian.img,format=raw,index=0 \ -dtb bcm2711-rpi-4-b.dtb -nographicPlease note that the current implementation still requires a DTB to be provided to U-Boot and that the DTB is used within U-Boot to load drivers, to disable/enable certain hardware blocks in ACPI. The DTB is not passed to the OS when using the bootefi cmd.
Quoted 8 lines
Tested against FWTS V24.03.00.
Known issues:
- The QEMU support is currently limited as it doesn't emulate PCI, USB or ethernet devices!
- The SMP bringup doesn't work on real hardware, but works in QEMU.
- PCI isn't working on real hardware since thepcie_brcmstbLinux kernel module doesn't support ACPI yet.
Thank you for picking this up!
Quoted 94 lines
Maximilian Brune (3):
acpi: x86: Move SPCR and DBG2 into common code
acpi: x86: Write FADT in common code
serial:serial_pl01x: Implement .getinfo() for PL01Patrick Rudolph (12):
acpi: x86: Move MADT to common code
acpi: Fix typo
acpi: Add define for GTDT
arm: acpi: Add generic ACPI methods
acpi:acpi_table: Bump revisions
acpi: Add ACPITAB for PPTT and GTDT
arm: mach-bcm283x: Map the ARM local MMIO as well
arm: bcm283x: Write ACPI tables
arm: cpu: Add ACPI parking protocol support
arm: mach-bcm283x: AddARMV8_MULTIENTRYsupport
arm: mach-bcm283x: EnableARMV8_MULTIENTRY
configs: Add RPI4 ACPI defconfigSimon Glass (2):
arm: mach-bcm283x: Bring in some header files from tianocore
board: raspberrypi: Add ASL files from tianocorearch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/parking_protocol_v8.S | 102 +++++ arch/arm/cpu/armv8/start.S | 4 + arch/arm/include/asm/acpi_table.h | 70 ++++ arch/arm/lib/Makefile | 1 + arch/arm/lib/acpi_table.c | 131 ++++++ arch/arm/mach-bcm283x/Kconfig | 4 + arch/arm/mach-bcm283x/Makefile | 4 + arch/arm/mach-bcm283x/bcm2711_acpi.c | 172 ++++++++ .../mach-bcm283x/include/mach/acpi/bcm2711.h | 152 +++++++ .../mach-bcm283x/include/mach/acpi/bcm2836.h | 127 ++++++ .../include/mach/acpi/bcm2836_gpio.h | 19 + .../include/mach/acpi/bcm2836_gpu.h | 47 +++ .../include/mach/acpi/bcm2836_pwm.h | 33 ++ .../include/mach/acpi/bcm2836_sdhost.h | 18 + .../include/mach/acpi/bcm2836_sdio.h | 21 + arch/arm/mach-bcm283x/init.c | 79 +++- arch/sandbox/lib/Makefile | 9 +- arch/sandbox/lib/acpi_table.c | 7 + arch/x86/cpu/apollolake/acpi.c | 20 +- arch/x86/cpu/baytrail/acpi.c | 17 +- arch/x86/cpu/intel_common/acpi.c | 20 +- arch/x86/cpu/quark/acpi.c | 19 +- arch/x86/cpu/tangier/acpi.c | 31 +- arch/x86/include/asm/acpi_table.h | 26 +- arch/x86/lib/acpi_table.c | 243 +----------- board/raspberrypi/rpi/.gitignore | 3 + board/raspberrypi/rpi/Makefile | 2 + board/raspberrypi/rpi/acpitables.h | 91 +++++ board/raspberrypi/rpi/dsdt.asl | 290 ++++++++++++++ board/raspberrypi/rpi/emmc.asl | 136 +++++++ board/raspberrypi/rpi/gpudevs.asl | 372 ++++++++++++++++++ board/raspberrypi/rpi/pci.asl | 177 +++++++++ board/raspberrypi/rpi/pep.asl | 90 +++++ board/raspberrypi/rpi/rhpx.asl | 195 +++++++++ board/raspberrypi/rpi/rpi.c | 182 +++++++++ board/raspberrypi/rpi/sdhc.asl | 111 ++++++ board/raspberrypi/rpi/uart.asl | 208 ++++++++++ boot/bootflow.c | 8 +- configs/rpi_4_acpi_defconfig | 79 ++++ drivers/pci/pcie_brcmstb.c | 101 +---- drivers/serial/serial_pl01x.c | 24 ++ include/acpi/acpi_table.h | 107 +++-- include/serial.h | 1 + lib/Kconfig | 15 + lib/acpi/acpi_table.c | 317 ++++++++++++++- 46 files changed, 3414 insertions(+), 472 deletions(-) create mode 100644 arch/arm/cpu/armv8/parking_protocol_v8.S create mode 100644 arch/arm/lib/acpi_table.c create mode 100644 arch/arm/mach-bcm283x/bcm2711_acpi.c create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2711.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpio.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpu.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_pwm.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdhost.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdio.h create mode 100644 arch/sandbox/lib/acpi_table.c create mode 100644 board/raspberrypi/rpi/.gitignore create mode 100644 board/raspberrypi/rpi/acpitables.h create mode 100644 board/raspberrypi/rpi/dsdt.asl create mode 100644 board/raspberrypi/rpi/emmc.asl create mode 100644 board/raspberrypi/rpi/gpudevs.asl create mode 100644 board/raspberrypi/rpi/pci.asl create mode 100644 board/raspberrypi/rpi/pep.asl create mode 100644 board/raspberrypi/rpi/rhpx.asl create mode 100644 board/raspberrypi/rpi/sdhc.asl create mode 100644 board/raspberrypi/rpi/uart.asl create mode 100644 configs/rpi_4_acpi_defconfig
Quoted 3 lines
--
2.45.2
Regards,
Simon
Hi Patrick,
Quoted 4 lines
Based on the existing work done by Simon Glass this series adds support for booting aarch64 devices using ACPI only. As target the Raspberry Pi4 was used, which is broadly available and allows easy testing of the proposed solution.
Rather than just RPi4 support we should add generic qemu support, as opposed to emulated RPi4 in qemu support as qemu already supports ACPI on aarch64 for generic SystemReady support with pci/network etc that way the support is much easier to test in CI.
Also are the ACPI tables you use here compatible with the tianocore raspberry pi 4 support so users don't end up with weird differences between firmware?
Quoted 121 lines
The series is split into ACPI cleanups and code movements, adding Arm specific ACPI tables and finally SoC and mainboard related changes to boot a Linux on the RPi4. Currently only the mandatory ACPI tables are supported, allowing to boot into Linux without errors.
The changes were tested on real hardware as well on QEMU v9.0:
qemu-system-aarch64 -machine raspi4b -kernel u-boot.bin -cpu cortex-a72 \
(quoted diff) +0
-2-smp 4 -m 2G -drive file=raspbian.img,format=raw,index=0 \ -dtb bcm2711-rpi-4-b.dtb -nographicPlease note that the current implementation still requires a DTB to be provided to U-Boot and that the DTB is used within U-Boot to load drivers, to disable/enable certain hardware blocks in ACPI. The DTB is not passed to the OS when using the bootefi cmd.
Tested against FWTS V24.03.00.
Known issues:
- The QEMU support is currently limited as it doesn't emulate PCI, USB or ethernet devices!
- The SMP bringup doesn't work on real hardware, but works in QEMU.
- PCI isn't working on real hardware since thepcie_brcmstbLinux kernel module doesn't support ACPI yet.Maximilian Brune (3):
acpi: x86: Move SPCR and DBG2 into common code
acpi: x86: Write FADT in common code
serial:serial_pl01x: Implement .getinfo() for PL01Patrick Rudolph (12):
acpi: x86: Move MADT to common code
acpi: Fix typo
acpi: Add define for GTDT
arm: acpi: Add generic ACPI methods
acpi:acpi_table: Bump revisions
acpi: Add ACPITAB for PPTT and GTDT
arm: mach-bcm283x: Map the ARM local MMIO as well
arm: bcm283x: Write ACPI tables
arm: cpu: Add ACPI parking protocol support
arm: mach-bcm283x: AddARMV8_MULTIENTRYsupport
arm: mach-bcm283x: EnableARMV8_MULTIENTRY
configs: Add RPI4 ACPI defconfigSimon Glass (2):
arm: mach-bcm283x: Bring in some header files from tianocore
board: raspberrypi: Add ASL files from tianocorearch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/parking_protocol_v8.S | 102 +++++ arch/arm/cpu/armv8/start.S | 4 + arch/arm/include/asm/acpi_table.h | 70 ++++ arch/arm/lib/Makefile | 1 + arch/arm/lib/acpi_table.c | 131 ++++++ arch/arm/mach-bcm283x/Kconfig | 4 + arch/arm/mach-bcm283x/Makefile | 4 + arch/arm/mach-bcm283x/bcm2711_acpi.c | 172 ++++++++ .../mach-bcm283x/include/mach/acpi/bcm2711.h | 152 +++++++ .../mach-bcm283x/include/mach/acpi/bcm2836.h | 127 ++++++ .../include/mach/acpi/bcm2836_gpio.h | 19 + .../include/mach/acpi/bcm2836_gpu.h | 47 +++ .../include/mach/acpi/bcm2836_pwm.h | 33 ++ .../include/mach/acpi/bcm2836_sdhost.h | 18 + .../include/mach/acpi/bcm2836_sdio.h | 21 + arch/arm/mach-bcm283x/init.c | 79 +++- arch/sandbox/lib/Makefile | 9 +- arch/sandbox/lib/acpi_table.c | 7 + arch/x86/cpu/apollolake/acpi.c | 20 +- arch/x86/cpu/baytrail/acpi.c | 17 +- arch/x86/cpu/intel_common/acpi.c | 20 +- arch/x86/cpu/quark/acpi.c | 19 +- arch/x86/cpu/tangier/acpi.c | 31 +- arch/x86/include/asm/acpi_table.h | 26 +- arch/x86/lib/acpi_table.c | 243 +----------- board/raspberrypi/rpi/.gitignore | 3 + board/raspberrypi/rpi/Makefile | 2 + board/raspberrypi/rpi/acpitables.h | 91 +++++ board/raspberrypi/rpi/dsdt.asl | 290 ++++++++++++++ board/raspberrypi/rpi/emmc.asl | 136 +++++++ board/raspberrypi/rpi/gpudevs.asl | 372 ++++++++++++++++++ board/raspberrypi/rpi/pci.asl | 177 +++++++++ board/raspberrypi/rpi/pep.asl | 90 +++++ board/raspberrypi/rpi/rhpx.asl | 195 +++++++++ board/raspberrypi/rpi/rpi.c | 182 +++++++++ board/raspberrypi/rpi/sdhc.asl | 111 ++++++ board/raspberrypi/rpi/uart.asl | 208 ++++++++++ boot/bootflow.c | 8 +- configs/rpi_4_acpi_defconfig | 79 ++++ drivers/pci/pcie_brcmstb.c | 101 +---- drivers/serial/serial_pl01x.c | 24 ++ include/acpi/acpi_table.h | 107 +++-- include/serial.h | 1 + lib/Kconfig | 15 + lib/acpi/acpi_table.c | 317 ++++++++++++++- 46 files changed, 3414 insertions(+), 472 deletions(-) create mode 100644 arch/arm/cpu/armv8/parking_protocol_v8.S create mode 100644 arch/arm/lib/acpi_table.c create mode 100644 arch/arm/mach-bcm283x/bcm2711_acpi.c create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2711.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpio.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpu.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_pwm.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdhost.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdio.h create mode 100644 arch/sandbox/lib/acpi_table.c create mode 100644 board/raspberrypi/rpi/.gitignore create mode 100644 board/raspberrypi/rpi/acpitables.h create mode 100644 board/raspberrypi/rpi/dsdt.asl create mode 100644 board/raspberrypi/rpi/emmc.asl create mode 100644 board/raspberrypi/rpi/gpudevs.asl create mode 100644 board/raspberrypi/rpi/pci.asl create mode 100644 board/raspberrypi/rpi/pep.asl create mode 100644 board/raspberrypi/rpi/rhpx.asl create mode 100644 board/raspberrypi/rpi/sdhc.asl create mode 100644 board/raspberrypi/rpi/uart.asl create mode 100644 configs/rpi_4_acpi_defconfig--
2.45.2
Hi Peter,
Quoted 5 lines
Rather than just RPi4 support we should add generic qemu support, as opposed to emulated RPi4 in qemu support as qemu already supports ACPI on aarch64 for generic SystemReady support with pci/network etc that way the support is much easier to test in CI.
That sounds reasonable. I'll look into that as well.
Quoted 4 lines
Also are the ACPI tables you use here compatible with the tianocore raspberry pi 4 support so users don't end up with weird differences between firmware?
The ACPI code is identical to the tianocore one. However the U-Boot implementation
is a bare minimum to boot a Linux OS, thus yes there are differences between those
firmwares. EDK2 has more quirks for various boards and reads in UEFI variables to
enable/disable certain devices or features.