blob: c2baebde9270967e097a42c96cad6a97c3cf049c [file] [log] [blame]
Masahiro Yamada574388c2016-09-03 11:37:40 +09001/*
Masahiro Yamadae30ec7f2020-01-17 13:46:38 +09002 * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
Masahiro Yamada574388c2016-09-03 11:37:40 +09003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Masahiro Yamada574388c2016-09-03 11:37:40 +09007#include <assert.h>
Masahiro Yamada574388c2016-09-03 11:37:40 +09008#include <errno.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009
Masahiro Yamada574388c2016-09-03 11:37:40 +090010#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011
12#include <arch.h>
13#include <common/bl_common.h>
14#include <common/debug.h>
15#include <drivers/console.h>
16#include <lib/mmio.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000017#include <plat/common/platform.h>
Masahiro Yamada574388c2016-09-03 11:37:40 +090018
19#include "uniphier.h"
20
Masahiro Yamada574388c2016-09-03 11:37:40 +090021static entry_point_info_t bl32_image_ep_info;
22static entry_point_info_t bl33_image_ep_info;
Masahiro Yamadaca971b52020-02-03 19:45:16 +090023static unsigned int uniphier_soc = UNIPHIER_SOC_UNKNOWN;
Masahiro Yamada574388c2016-09-03 11:37:40 +090024
25entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
26{
27 assert(sec_state_is_valid(type));
28 return type == NON_SECURE ? &bl33_image_ep_info : &bl32_image_ep_info;
29}
30
Antonio Nino Diazcb9c5a72018-09-24 17:16:35 +010031void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
32 u_register_t arg2, u_register_t arg3)
Masahiro Yamada574388c2016-09-03 11:37:40 +090033{
Antonio Nino Diazcb9c5a72018-09-24 17:16:35 +010034 void *from_bl2;
35
Masahiro Yamada501b88b2019-07-26 20:04:28 +090036 from_bl2 = (void *)arg0;
Antonio Nino Diazcb9c5a72018-09-24 17:16:35 +010037
Masahiro Yamada574388c2016-09-03 11:37:40 +090038 bl_params_node_t *bl_params = ((bl_params_t *)from_bl2)->head;
39
Masahiro Yamadaca971b52020-02-03 19:45:16 +090040 uniphier_soc = uniphier_get_soc_id();
41 if (uniphier_soc == UNIPHIER_SOC_UNKNOWN)
42 plat_error_handler(-ENOTSUP);
43
44 uniphier_console_setup(uniphier_soc);
Masahiro Yamada574388c2016-09-03 11:37:40 +090045
46 while (bl_params) {
47 if (bl_params->image_id == BL32_IMAGE_ID)
48 bl32_image_ep_info = *bl_params->ep_info;
49
50 if (bl_params->image_id == BL33_IMAGE_ID)
51 bl33_image_ep_info = *bl_params->ep_info;
52
53 bl_params = bl_params->next_params_info;
54 }
55
56 if (bl33_image_ep_info.pc == 0)
57 panic();
58}
59
Masahiro Yamada0317e1b2020-02-03 19:45:37 +090060static const uintptr_t uniphier_cntctl_base[] = {
61 [UNIPHIER_SOC_LD11] = 0x60e00000,
62 [UNIPHIER_SOC_LD20] = 0x60e00000,
63 [UNIPHIER_SOC_PXS3] = 0x60e00000,
64};
Masahiro Yamada574388c2016-09-03 11:37:40 +090065
66void bl31_platform_setup(void)
67{
Masahiro Yamada0317e1b2020-02-03 19:45:37 +090068 uintptr_t cntctl_base;
69
Masahiro Yamadaca971b52020-02-03 19:45:16 +090070 uniphier_cci_init(uniphier_soc);
Masahiro Yamada574388c2016-09-03 11:37:40 +090071 uniphier_cci_enable();
72
73 /* Initialize the GIC driver, cpu and distributor interfaces */
Masahiro Yamadaca971b52020-02-03 19:45:16 +090074 uniphier_gic_driver_init(uniphier_soc);
Masahiro Yamada574388c2016-09-03 11:37:40 +090075 uniphier_gic_init();
76
Masahiro Yamada0317e1b2020-02-03 19:45:37 +090077 assert(uniphier_soc < ARRAY_SIZE(uniphier_cntctl_base));
78 cntctl_base = uniphier_cntctl_base[uniphier_soc];
79
Masahiro Yamada574388c2016-09-03 11:37:40 +090080 /* Enable and initialize the System level generic timer */
Masahiro Yamada0317e1b2020-02-03 19:45:37 +090081 mmio_write_32(cntctl_base + CNTCR_OFF, CNTCR_FCREQ(0U) | CNTCR_EN);
Masahiro Yamada4e371402020-02-03 19:46:00 +090082
83 uniphier_psci_init(uniphier_soc);
Masahiro Yamada574388c2016-09-03 11:37:40 +090084}
85
86void bl31_plat_arch_setup(void)
87{
Masahiro Yamada1a741d92020-02-03 19:46:15 +090088 uniphier_mmap_setup(uniphier_soc);
Masahiro Yamada574388c2016-09-03 11:37:40 +090089}