Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | e30ec7f | 2020-01-17 13:46:38 +0900 | [diff] [blame] | 2 | * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 7 | #include <assert.h> |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 8 | #include <errno.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 10 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | |
| 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> |
| 17 | #include <lib/xlat_tables/xlat_mmu_helpers.h> |
| 18 | #include <plat/common/platform.h> |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 19 | |
| 20 | #include "uniphier.h" |
| 21 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 22 | static entry_point_info_t bl32_image_ep_info; |
| 23 | static entry_point_info_t bl33_image_ep_info; |
Masahiro Yamada | ca971b5 | 2020-02-03 19:45:16 +0900 | [diff] [blame] | 24 | static unsigned int uniphier_soc = UNIPHIER_SOC_UNKNOWN; |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 25 | |
| 26 | entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) |
| 27 | { |
| 28 | assert(sec_state_is_valid(type)); |
| 29 | return type == NON_SECURE ? &bl33_image_ep_info : &bl32_image_ep_info; |
| 30 | } |
| 31 | |
Antonio Nino Diaz | cb9c5a7 | 2018-09-24 17:16:35 +0100 | [diff] [blame] | 32 | void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, |
| 33 | u_register_t arg2, u_register_t arg3) |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 34 | { |
Antonio Nino Diaz | cb9c5a7 | 2018-09-24 17:16:35 +0100 | [diff] [blame] | 35 | void *from_bl2; |
| 36 | |
Masahiro Yamada | 501b88b | 2019-07-26 20:04:28 +0900 | [diff] [blame] | 37 | from_bl2 = (void *)arg0; |
Antonio Nino Diaz | cb9c5a7 | 2018-09-24 17:16:35 +0100 | [diff] [blame] | 38 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 39 | bl_params_node_t *bl_params = ((bl_params_t *)from_bl2)->head; |
| 40 | |
Masahiro Yamada | ca971b5 | 2020-02-03 19:45:16 +0900 | [diff] [blame] | 41 | uniphier_soc = uniphier_get_soc_id(); |
| 42 | if (uniphier_soc == UNIPHIER_SOC_UNKNOWN) |
| 43 | plat_error_handler(-ENOTSUP); |
| 44 | |
| 45 | uniphier_console_setup(uniphier_soc); |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 46 | |
| 47 | while (bl_params) { |
| 48 | if (bl_params->image_id == BL32_IMAGE_ID) |
| 49 | bl32_image_ep_info = *bl_params->ep_info; |
| 50 | |
| 51 | if (bl_params->image_id == BL33_IMAGE_ID) |
| 52 | bl33_image_ep_info = *bl_params->ep_info; |
| 53 | |
| 54 | bl_params = bl_params->next_params_info; |
| 55 | } |
| 56 | |
| 57 | if (bl33_image_ep_info.pc == 0) |
| 58 | panic(); |
| 59 | } |
| 60 | |
Masahiro Yamada | 0317e1b | 2020-02-03 19:45:37 +0900 | [diff] [blame] | 61 | static const uintptr_t uniphier_cntctl_base[] = { |
| 62 | [UNIPHIER_SOC_LD11] = 0x60e00000, |
| 63 | [UNIPHIER_SOC_LD20] = 0x60e00000, |
| 64 | [UNIPHIER_SOC_PXS3] = 0x60e00000, |
| 65 | }; |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 66 | |
| 67 | void bl31_platform_setup(void) |
| 68 | { |
Masahiro Yamada | 0317e1b | 2020-02-03 19:45:37 +0900 | [diff] [blame] | 69 | uintptr_t cntctl_base; |
| 70 | |
Masahiro Yamada | ca971b5 | 2020-02-03 19:45:16 +0900 | [diff] [blame] | 71 | uniphier_cci_init(uniphier_soc); |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 72 | uniphier_cci_enable(); |
| 73 | |
| 74 | /* Initialize the GIC driver, cpu and distributor interfaces */ |
Masahiro Yamada | ca971b5 | 2020-02-03 19:45:16 +0900 | [diff] [blame] | 75 | uniphier_gic_driver_init(uniphier_soc); |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 76 | uniphier_gic_init(); |
| 77 | |
Masahiro Yamada | 0317e1b | 2020-02-03 19:45:37 +0900 | [diff] [blame] | 78 | assert(uniphier_soc < ARRAY_SIZE(uniphier_cntctl_base)); |
| 79 | cntctl_base = uniphier_cntctl_base[uniphier_soc]; |
| 80 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 81 | /* Enable and initialize the System level generic timer */ |
Masahiro Yamada | 0317e1b | 2020-02-03 19:45:37 +0900 | [diff] [blame] | 82 | mmio_write_32(cntctl_base + CNTCR_OFF, CNTCR_FCREQ(0U) | CNTCR_EN); |
Masahiro Yamada | 4e37140 | 2020-02-03 19:46:00 +0900 | [diff] [blame] | 83 | |
| 84 | uniphier_psci_init(uniphier_soc); |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | void bl31_plat_arch_setup(void) |
| 88 | { |
Masahiro Yamada | 1a741d9 | 2020-02-03 19:46:15 +0900 | [diff] [blame] | 89 | uniphier_mmap_setup(uniphier_soc); |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 90 | enable_mmu_el3(0); |
| 91 | } |