-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '8e5de81824763342dc4a6ba2b85ace7dc575c5b9' into HEAD
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
- Loading branch information
Showing
19 changed files
with
365 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
/* SPDX-License-Identifier: GPL-2.0+ */ | ||
/* | ||
* Copyright 2019 Google LLC | ||
*/ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
|
||
#ifndef __ASM_ACPI_TABLE_H__ | ||
#define __ASM_ACPI_TABLE_H__ | ||
|
||
#ifndef __ACPI__ | ||
|
||
ulong write_acpi_tables(ulong start); | ||
void acpi_write_madt_gicc(struct acpi_madr_gicc *gicc, uint cpu_num, | ||
uint perf_gsiv, ulong phys_base, ulong gicv, | ||
ulong gich, uint vgic_maint_irq, ulong mpidr, | ||
uint efficiency); | ||
|
||
#endif | ||
void acpi_write_madt_gicd(struct acpi_madr_gicd *gicd, uint gic_id, | ||
ulong phys_base, uint gic_version); | ||
|
||
#endif /* !__ACPI__ */ | ||
|
||
#endif /* __ASM_ACPI_TABLE_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
/* | ||
* Based on acpi.c from coreboot | ||
* | ||
* Copyright (C) 2024 9elements GmbH | ||
*/ | ||
|
||
#define LOG_CATEGORY LOGC_ACPI | ||
|
||
#include <common.h> | ||
#include <acpi/acpigen.h> | ||
#include <acpi/acpi_device.h> | ||
#include <acpi/acpi_table.h> | ||
#include <string.h> | ||
|
||
void acpi_write_madt_gicc(struct acpi_madr_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_madr_gicc)); | ||
gicc->type = ACPI_APIC_GICC; | ||
gicc->length = sizeof(struct acpi_madr_gicc); | ||
gicc->cpu_if_num = cpu_num; | ||
gicc->processor_id = cpu_num; | ||
gicc->flags = ACPI_MADRF_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_madr_gicd *gicd, uint gic_id, | ||
ulong phys_base, uint gic_version) | ||
{ | ||
memset(gicd, '\0', sizeof(struct acpi_madr_gicd)); | ||
gicd->type = ACPI_APIC_GICD; | ||
gicd->length = sizeof(struct acpi_madr_gicd); | ||
gicd->gic_id = gic_id; | ||
gicd->phys_base = phys_base; | ||
gicd->gic_version = gic_version; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* (C) Copyright 2024 9elements GmbH | ||
* | ||
* See file CREDITS for list of people who contributed to this | ||
* project. | ||
*/ | ||
|
||
#include <common.h> | ||
#include <acpi/acpi_table.h> | ||
#include <asm/acpi_table.h> | ||
#include <asm/armv8/sec_firmware.h> | ||
#include <tables_csum.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_madr_gicc *gicc; | ||
struct acpi_madr_gicd *gicd; | ||
|
||
madt->lapic_addr = 0; | ||
madt->flags = 0; | ||
|
||
if (!CONFIG_IS_ENABLED(BCM2711_64B)) { | ||
return current; | ||
} | ||
|
||
gicc = current; | ||
acpi_write_madt_gicc(gicc++, 0, 0x30, 0xff842000, 0xff846000, 0xff844000, 0x19, 0, 1); | ||
acpi_write_madt_gicc(gicc++, 1, 0x31, 0xff842000, 0xff846000, 0xff844000, 0x19, 1, 1); | ||
acpi_write_madt_gicc(gicc++, 2, 0x32, 0xff842000, 0xff846000, 0xff844000, 0x19, 2, 1); | ||
acpi_write_madt_gicc(gicc++, 3, 0x33, 0xff842000, 0xff846000, 0xff844000, 0x19, 3, 1); | ||
|
||
gicd = (struct acpi_madr_gicd *)gicc; | ||
acpi_write_madt_gicd(gicd++, 0, 0xff841000, 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; | ||
|
||
if (!CONFIG_IS_ENABLED(BCM2711_64B)) { | ||
return 0; | ||
} | ||
|
||
header = ctx->current; | ||
ctx->tab_start = ctx->current; | ||
|
||
memset(header, '\0', sizeof(struct acpi_table_header)); | ||
|
||
acpi_fill_header(header, "PPTT"); | ||
header->revision = 0; | ||
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); | ||
|
||
|
||
#define GTDT_FLAG_INT_ACTIVE_LOW BIT(1) | ||
#define RPI_GTDT_GTIMER_FLAGS GTDT_FLAG_INT_ACTIVE_LOW | ||
|
||
/* ARM Architectural Timer Interrupt(GIC PPI) numbers */ | ||
#define PcdArmArchTimerSecIntrNum 29 | ||
#define PcdArmArchTimerIntrNum 30 | ||
#define PcdArmArchTimerHypIntrNum 26 | ||
#define PcdArmArchTimerVirtIntrNum 27 | ||
|
||
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 = 3; | ||
|
||
gtdt->cnt_ctrl_base = 0xff80001c; | ||
gtdt->sec_el1_gsiv = PcdArmArchTimerSecIntrNum; | ||
gtdt->sec_el1_flags = RPI_GTDT_GTIMER_FLAGS; | ||
gtdt->el1_gsiv = PcdArmArchTimerIntrNum; | ||
gtdt->el1_flags = RPI_GTDT_GTIMER_FLAGS; | ||
gtdt->virt_el1_gsiv = PcdArmArchTimerVirtIntrNum; | ||
gtdt->virt_el1_flags = RPI_GTDT_GTIMER_FLAGS; | ||
gtdt->el2_gsiv = PcdArmArchTimerHypIntrNum; | ||
gtdt->el2_flags = RPI_GTDT_GTIMER_FLAGS; | ||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.