Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ unexport MAKEFILE_LIST

# Automatically delete corrupt targets (file updated but recipe exits with a
# nonzero status). Useful since a few recipes use shell redirection.
# adding other comment
.DELETE_ON_ERROR:

include mk/macros.mk
Expand Down
34 changes: 9 additions & 25 deletions core/arch/arm/plat-qcom/conf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,15 @@ $(call force,CFG_CRYPTO_WITH_CE,y)
ta-targets = ta_arm64
supported-ta-targets ?= ta_arm64

ifneq (,$(filter $(PLATFORM_FLAVOR),kodiak lemans))
include core/arch/arm/cpu/cortex-armv8-0.mk
$(call force,CFG_TEE_CORE_NB_CORE,8)
# Architecture family mapping
HOYA_ARCH_CHIPSETS := kodiak lemans

$(call force,CFG_QCOM_RAMBLUR_PIMEM_V3,y)
CFG_QCOM_RAMBLUR_TA_WINDOW_ID ?= 2

$(call force,CFG_QCOM_PRNG,y)

CFG_TZDRAM_START ?= 0x1c300000
CFG_TEE_RAM_VA_SIZE ?= 0x200000
CFG_TA_RAM_VA_SIZE ?= 0x1c00000
CFG_TZDRAM_SIZE ?= (CFG_TEE_RAM_VA_SIZE + CFG_TA_RAM_VA_SIZE)
CFG_NUM_THREADS ?= 8
endif

ifneq (,$(filter $(PLATFORM_FLAVOR),kodiak))
CFG_DRIVERS_CLK ?= y
CFG_QCOM_PAS_PTA ?= y
endif

ifeq ($(CFG_QCOM_PAS_PTA),y)
# Increase late mappings to cover all PAS resources
CFG_RESERVED_VASPACE_SIZE ?= (60 * 1024 * 1024)
$(call force,CFG_DRIVERS_QCOM_CLK,y,Mandated by CFG_QCOM_PAS_PTA)
CFG_IN_TREE_EARLY_TAS += qcom_pas/cff7d191-7ca0-4784-af13-48223b9a4fbe
ifneq (,$(filter $(PLATFORM_FLAVOR),$(HOYA_ARCH_CHIPSETS)))
QCOM_ARCH_FAMILY := hoya
else
$(error Unsupported PLATFORM_FLAVOR: $(PLATFORM_FLAVOR))
endif

# Include architecture-specific configuration
include core/arch/arm/plat-qcom/$(QCOM_ARCH_FAMILY)/arch.mk
include core/arch/arm/plat-qcom/$(QCOM_ARCH_FAMILY)/$(PLATFORM_FLAVOR)/target.mk
133 changes: 133 additions & 0 deletions core/arch/arm/plat-qcom/diag_log.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// SPDX-License-Identifier: BSD-2-Clause
/*
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/

#include <io.h>
#include <kernel/misc.h>
#include <mm/core_memprot.h>
#include <mm/core_mmu.h>
#include <platform_config.h>
#include <string.h>
#include <trace.h>

#include "diag_log.h"

register_phys_mem_pgdir(MEM_AREA_IO_SEC, DIAG_BASE, DIAG_SIZE);
register_phys_mem_pgdir(MEM_AREA_IO_SEC,
(DIAG_LOG_START_INFO & ~SMALL_PAGE_MASK),
SMALL_PAGE_SIZE);
register_phys_mem_pgdir(MEM_AREA_IO_SEC,
(TCSR_BOOT_MISC_DETECT & ~SMALL_PAGE_MASK),
SMALL_PAGE_SIZE);

#define DIAG_VERSION_V1 1
#define DIAG_MAGIC_INIT 0x47414944
#define DIAG_MAGIC_FAILED 0xDEADBEEF
#define DIAG_MAGIC_DLOAD 0xD15AB1ED
#define DLOAD_MAGIC_COOKIE 0x10

struct diag_hdr {
uint32_t version;
uint32_t magic;
};

struct diag_conf {
uint32_t buf_offset;
uint32_t buf_size;
};

struct circ_wo_buf {
uint32_t wrap;
uint32_t head;
uint8_t buf[];
};

struct diag {
struct diag_hdr hdr;
struct diag_conf conf;
struct circ_wo_buf wo_cbuf;
};

static struct diag *global_diag;

static struct diag *get_diag_region(void)
{
struct diag *diag;
uint32_t *tcsr_reg;

tcsr_reg = phys_to_virt(TCSR_BOOT_MISC_DETECT, MEM_AREA_IO_SEC,
sizeof(uint32_t));
diag = phys_to_virt(DIAG_BASE, MEM_AREA_IO_SEC, DIAG_SIZE);

if (!tcsr_reg || !diag) {
EMSG("DIAG: Failed to map regions");
return NULL;
}

if (io_read32((vaddr_t)tcsr_reg) == DLOAD_MAGIC_COOKIE) {
diag->hdr.magic = DIAG_MAGIC_DLOAD;
dsb();
return NULL;
}

return diag;
}

void qcom_diag_log_init(void)
{
struct diag *diag;
uint32_t *diag_info_addr;

if (!IS_ENABLED(CFG_QCOM_DIAG_LOG)) {
IMSG("DIAG: Feature not available");
return;
}

diag = get_diag_region();
if (!diag)
return;

memset(diag, 0, DIAG_SIZE);

diag->hdr.version = DIAG_VERSION_V1;
diag->hdr.magic = DIAG_MAGIC_INIT;
diag->conf.buf_offset = offsetof(struct diag, wo_cbuf.buf);
diag->conf.buf_size = ROUNDDOWN2(DIAG_SIZE - diag->conf.buf_offset, 16);

if (diag->conf.buf_offset >= DIAG_SIZE || diag->conf.buf_size == 0) {
EMSG("DIAG: Invalid buffer configuration (offset=%u, size=%u)",
diag->conf.buf_offset, diag->conf.buf_size);
diag->hdr.magic = DIAG_MAGIC_FAILED;
return;
}

diag_info_addr = phys_to_virt(DIAG_LOG_START_INFO, MEM_AREA_IO_SEC,
2 * sizeof(uint32_t));
if (diag_info_addr) {
io_write32((vaddr_t)&diag_info_addr[0], DIAG_BASE);
io_write32((vaddr_t)&diag_info_addr[1], DIAG_SIZE);
}

dsb();

global_diag = diag;
}

void qcom_diag_log_puts(const char *str)
{
struct diag *diag = global_diag;
const char *p;

if (!diag || !str)
return;

for (p = str; *p; p++) {
diag->wo_cbuf.buf[diag->wo_cbuf.head++] = *p;
if (diag->wo_cbuf.head >= diag->conf.buf_size) {
diag->wo_cbuf.head = 0;
if (diag->wo_cbuf.wrap < UINT32_MAX)
diag->wo_cbuf.wrap++;
}
}
}
23 changes: 23 additions & 0 deletions core/arch/arm/plat-qcom/diag_log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/

#ifndef __DIAG_LOG_H
#define __DIAG_LOG_H

#include <compiler.h>
#include <config.h>
#include <platform_config.h>
#include <util.h>

#define IMEM_DIAG_OFFSET UL(0x720)
#define DIAG_LOG_START_INFO (IMEM_BASE + IMEM_DIAG_OFFSET)
#define TCSR_BOOT_MISC_DETECT UL(0x1FD3000)
#define DIAG_SIZE UL(0x3000)
#define DIAG_BASE (IMEM_BASE + IMEM_SIZE - DIAG_SIZE)

void qcom_diag_log_init(void);
void qcom_diag_log_puts(const char *str);

#endif /* __DIAG_LOG_H */
15 changes: 15 additions & 0 deletions core/arch/arm/plat-qcom/hoya/arch.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# HOYA architecture configuration

include core/arch/arm/cpu/cortex-armv8-0.mk
$(call force,CFG_TEE_CORE_NB_CORE,8)

$(call force,CFG_QCOM_RAMBLUR_PIMEM_V3,y)
CFG_QCOM_RAMBLUR_TA_WINDOW_ID ?= 2

$(call force,CFG_QCOM_PRNG,y)

CFG_TZDRAM_START ?= 0x1c300000
CFG_TEE_RAM_VA_SIZE ?= 0x200000
CFG_TA_RAM_VA_SIZE ?= 0x1c00000
CFG_TZDRAM_SIZE ?= (CFG_TEE_RAM_VA_SIZE + CFG_TA_RAM_VA_SIZE)
CFG_NUM_THREADS ?= 8
28 changes: 28 additions & 0 deletions core/arch/arm/plat-qcom/hoya/arch_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2024, Linaro Limited
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/

#ifndef ARCH_CONFIG_H
#define ARCH_CONFIG_H

#define GICD_BASE UL(0x17a00000)
#define GICR_BASE UL(0x17a60000)

#define RAMBLUR_PIMEM_REG_BASE UL(0x610000)
#define SEC_PRNG_REG_BASE UL(0x010D1000)

#define AOP_MSG_RAM_BASE UL(0x0C300000)
#define AOP_MSG_RAM_SIZE UL(0x00100000)

#define RPMH_BASE_ADDR UL(0x18200000)
#define RPMH_RSC_SIZE UL(0x40000)

#define SECURITY_CONTROL_BASE UL(0x00780000)
#define SECURITY_CONTROL_SIZE UL(0x10000)

#define TCSR_MUTEX_BASE UL(0x01F40000)
#define TCSR_MUTEX_SIZE UL(0x40000)

#endif /* ARCH_CONFIG_H */
21 changes: 21 additions & 0 deletions core/arch/arm/plat-qcom/hoya/kodiak/target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CFG_DRIVERS_CLK ?= y
CFG_DRIVERS_QCOM_CLK ?= y

CFG_QCOM_DIAG_LOG ?= $(if $(filter y,$(CFG_TEE_CORE_DEBUG)),y,n)

CFG_QCOM_QFPROM_FUSEPROV ?= $(if $(filter y,$(CFG_INSECURE)),n,y)

_qcom_fuseprov_deps = $(if $(filter y,$(CFG_QCOM_QFPROM_FUSEPROV)),y,n)
CFG_QCOM_CMD_DB ?= $(_qcom_fuseprov_deps)
CFG_QCOM_RPMH_CLIENT ?= $(_qcom_fuseprov_deps)
CFG_QCOM_QFPROM ?= $(_qcom_fuseprov_deps)

CFG_QCOM_PAS_PTA ?= y
# Kodiak requires MX voltage rail workaround for QFPROM fuse blowing
$(call force,CFG_QFPROM_MX_RAIL_WA,y)

ifeq ($(CFG_QCOM_PAS_PTA),y)
# Increase late mappings to cover all PAS resources
CFG_RESERVED_VASPACE_SIZE ?= (60 * 1024 * 1024)
CFG_IN_TREE_EARLY_TAS += qcom_pas/cff7d191-7ca0-4784-af13-48223b9a4fbe
endif
43 changes: 43 additions & 0 deletions core/arch/arm/plat-qcom/hoya/kodiak/target_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2024, Linaro Limited
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/

#ifndef TARGET_CONFIG_H
#define TARGET_CONFIG_H

#define GCC_BASE UL(0x100000)
#define GCC_SIZE UL(0x100000)

#define CFG_SEC_ELF_DDR_ADDR UL(0x808FF000)
#define CFG_SEC_ELF_DDR_SIZE UL(0x1000)

#define DRAM0_BASE UL(0x80000000)
#define DRAM0_SIZE UL(0x80000000)
#define DRAM1_BASE ULL(0x100000000)
#define DRAM1_SIZE ULL(0x100000000)

#define RAMBLUR_PIMEM_VAULT_TA_BASE ULL(0xc1800000)
#define RAMBLUR_PIMEM_VAULT_TA_SIZE ULL(0x01c00000)

#define GENI_UART_REG_BASE UL(0x994000)

#define IMEM_BASE UL(0x14680000)
#define IMEM_SIZE UL(0x19000)

#define WPSS_BASE UL(0x8a00000)
#define WPSS_SIZE UL(0x200000)
#define TURING_BASE UL(0x09800000)
#define TURING_SIZE ULL(0x00e00000)
#define LPASS_BASE UL(0x02c00000)
#define LPASS_SIZE ULL(0x01080000)
#define IRIS_BASE UL(0x0aa00000)
#define IRIS_SIZE ULL(0x00200000)

#define PAS_ID_QDSP6 1
#define PAS_ID_WPSS 6
#define PAS_ID_VENUS 9
#define PAS_ID_TURING 18

#endif /* TARGET_CONFIG_H */
11 changes: 11 additions & 0 deletions core/arch/arm/plat-qcom/hoya/lemans/target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CFG_DRIVERS_CLK ?= y
CFG_DRIVERS_QCOM_CLK ?= y

CFG_QCOM_DIAG_LOG ?= $(if $(filter y,$(CFG_TEE_CORE_DEBUG)),y,n)

CFG_QCOM_QFPROM_FUSEPROV ?= $(if $(filter y,$(CFG_INSECURE)),n,y)

_qcom_fuseprov_deps = $(if $(filter y,$(CFG_QCOM_QFPROM_FUSEPROV)),y,n)
CFG_QCOM_CMD_DB ?= $(_qcom_fuseprov_deps)
CFG_QCOM_RPMH_CLIENT ?= $(_qcom_fuseprov_deps)
CFG_QCOM_QFPROM ?= $(_qcom_fuseprov_deps)
29 changes: 29 additions & 0 deletions core/arch/arm/plat-qcom/hoya/lemans/target_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2024, Linaro Limited
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/

#ifndef TARGET_CONFIG_H
#define TARGET_CONFIG_H

#define GCC_BASE UL(0x110000)
#define GCC_SIZE UL(0x100000)

#define CFG_SEC_ELF_DDR_ADDR UL(0x908FF000)
#define CFG_SEC_ELF_DDR_SIZE UL(0x1000)

#define DRAM0_BASE UL(0x80000000)
#define DRAM0_SIZE UL(0x380000000)
#define DRAM1_BASE ULL(0x800000000)
#define DRAM1_SIZE ULL(0x800000000)

#define RAMBLUR_PIMEM_VAULT_TA_BASE ULL(0xd1900000)
#define RAMBLUR_PIMEM_VAULT_TA_SIZE ULL(0x01c00000)

#define GENI_UART_REG_BASE UL(0xa8c000)

#define IMEM_BASE UL(0x14680000)
#define IMEM_SIZE UL(0x32000)

#endif /* TARGET_CONFIG_H */
12 changes: 12 additions & 0 deletions core/arch/arm/plat-qcom/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <mm/core_mmu.h>
#include <platform_config.h>

#include "diag_log.h"

/*
* Register the physical memory area for peripherals etc. Here we are
* registering the UART console.
Expand All @@ -28,6 +30,16 @@ register_ddr(DRAM1_BASE, DRAM1_SIZE);

static struct qcom_geni_uart_data console_data;

void plat_trace_ext_puts(const char *str)
{
qcom_diag_log_puts(str);
}

void plat_trace_init(void)
{
qcom_diag_log_init();
}

void plat_console_init(void)
{
qcom_geni_uart_init(&console_data, GENI_UART_REG_BASE);
Expand Down
Loading
Loading