Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | e0b757d | 2018-08-24 16:30:29 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, 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 | |
| 7 | #include <arch.h> |
| 8 | #include <assert.h> |
| 9 | #include <bl_common.h> |
| 10 | #include <console.h> |
| 11 | #include <debug.h> |
| 12 | #include <errno.h> |
| 13 | #include <mmio.h> |
| 14 | #include <platform.h> |
| 15 | #include <platform_def.h> |
| 16 | #include <xlat_mmu_helpers.h> |
| 17 | |
| 18 | #include "uniphier.h" |
| 19 | |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 20 | #define BL31_SIZE ((BL31_END) - (BL31_BASE)) |
| 21 | |
| 22 | static entry_point_info_t bl32_image_ep_info; |
| 23 | static entry_point_info_t bl33_image_ep_info; |
| 24 | |
| 25 | entry_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 | |
| 31 | void bl31_early_platform_setup(void *from_bl2, void *plat_params_from_bl2) |
| 32 | { |
| 33 | bl_params_node_t *bl_params = ((bl_params_t *)from_bl2)->head; |
| 34 | |
| 35 | uniphier_console_setup(); |
| 36 | |
| 37 | while (bl_params) { |
| 38 | if (bl_params->image_id == BL32_IMAGE_ID) |
| 39 | bl32_image_ep_info = *bl_params->ep_info; |
| 40 | |
| 41 | if (bl_params->image_id == BL33_IMAGE_ID) |
| 42 | bl33_image_ep_info = *bl_params->ep_info; |
| 43 | |
| 44 | bl_params = bl_params->next_params_info; |
| 45 | } |
| 46 | |
| 47 | if (bl33_image_ep_info.pc == 0) |
| 48 | panic(); |
| 49 | } |
| 50 | |
| 51 | #define UNIPHIER_SYS_CNTCTL_BASE 0x60E00000 |
| 52 | |
| 53 | void bl31_platform_setup(void) |
| 54 | { |
| 55 | unsigned int soc; |
| 56 | |
| 57 | soc = uniphier_get_soc_id(); |
| 58 | if (soc == UNIPHIER_SOC_UNKNOWN) { |
| 59 | ERROR("unsupported SoC\n"); |
| 60 | plat_error_handler(-ENOTSUP); |
| 61 | } |
| 62 | |
| 63 | uniphier_cci_init(soc); |
| 64 | uniphier_cci_enable(); |
| 65 | |
| 66 | /* Initialize the GIC driver, cpu and distributor interfaces */ |
| 67 | uniphier_gic_driver_init(soc); |
| 68 | uniphier_gic_init(); |
| 69 | |
| 70 | /* Enable and initialize the System level generic timer */ |
| 71 | mmio_write_32(UNIPHIER_SYS_CNTCTL_BASE + CNTCR_OFF, |
Antonio Nino Diaz | e0b757d | 2018-08-24 16:30:29 +0100 | [diff] [blame] | 72 | CNTCR_FCREQ(0U) | CNTCR_EN); |
Masahiro Yamada | 574388c | 2016-09-03 11:37:40 +0900 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void bl31_plat_arch_setup(void) |
| 76 | { |
| 77 | uniphier_mmap_setup(BL31_BASE, BL31_SIZE, NULL); |
| 78 | enable_mmu_el3(0); |
| 79 | } |
| 80 | |
| 81 | void bl31_plat_runtime_setup(void) |
| 82 | { |
| 83 | /* Suppress any runtime logs unless DEBUG is defined */ |
| 84 | #if !DEBUG |
| 85 | console_uninit(); |
| 86 | #endif |
| 87 | } |