blob: 59b4c06e947b027818c674d60cfa60f97161360b [file] [log] [blame]
Zelalem Awekec8bc23e2021-07-09 15:32:21 -05001/*
Javier Almansa Sobrino4165e842022-04-25 17:18:15 +01002 * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
Zelalem Awekec8bc23e2021-07-09 15:32:21 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <common/bl_common.h>
8#include <common/debug.h>
9#include <drivers/arm/pl011.h>
10#include <drivers/console.h>
Javier Almansa Sobrino4165e842022-04-25 17:18:15 +010011#include <services/rmm_core_manifest.h>
12#include <services/rmmd_svc.h>
13#include <services/trp/platform_trp.h>
14#include <trp_helpers.h>
15
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050016#include <plat/arm/common/plat_arm.h>
17#include <platform_def.h>
18
19/*******************************************************************************
Javier Almansa Sobrino4165e842022-04-25 17:18:15 +010020 * Received from boot manifest and populated here
21 ******************************************************************************/
22extern uint32_t trp_boot_manifest_version;
23
24/*******************************************************************************
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050025 * Initialize the UART
26 ******************************************************************************/
27static console_t arm_trp_runtime_console;
28
Javier Almansa Sobrino4165e842022-04-25 17:18:15 +010029static int arm_trp_process_manifest(rmm_manifest_t *manifest)
30{
31 /* Verify the Boot Manifest Version. Only the Major is considered */
32 if (RMMD_MANIFEST_VERSION_MAJOR !=
33 RMMD_GET_MANIFEST_VERSION_MAJOR(manifest->version)) {
34 return E_RMM_BOOT_MANIFEST_VERSION_NOT_SUPPORTED;
35 }
36
37 trp_boot_manifest_version = manifest->version;
38 flush_dcache_range((uintptr_t)manifest, sizeof(rmm_manifest_t));
39
40 return 0;
41}
42
43void arm_trp_early_platform_setup(rmm_manifest_t *manifest)
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050044{
Javier Almansa Sobrino4165e842022-04-25 17:18:15 +010045 int rc;
46
47 rc = arm_trp_process_manifest(manifest);
48 if (rc != 0) {
49 trp_boot_abort(rc);
50 }
51
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050052 /*
53 * Initialize a different console than already in use to display
54 * messages from trp
55 */
Javier Almansa Sobrino4165e842022-04-25 17:18:15 +010056 rc = console_pl011_register(PLAT_ARM_TRP_UART_BASE,
57 PLAT_ARM_TRP_UART_CLK_IN_HZ,
58 ARM_CONSOLE_BAUDRATE,
59 &arm_trp_runtime_console);
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050060 if (rc == 0) {
61 panic();
62 }
63
64 console_set_scope(&arm_trp_runtime_console,
65 CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME);
Javier Almansa Sobrino4165e842022-04-25 17:18:15 +010066
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050067}
68
Javier Almansa Sobrino4165e842022-04-25 17:18:15 +010069void trp_early_platform_setup(rmm_manifest_t *manifest)
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050070{
Javier Almansa Sobrino4165e842022-04-25 17:18:15 +010071 arm_trp_early_platform_setup(manifest);
Zelalem Awekec8bc23e2021-07-09 15:32:21 -050072}