Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 1 | /* |
Michal Simek | 2a47faa | 2023-04-14 08:43:51 +0200 | [diff] [blame] | 2 | * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved. |
Maheedhar Bollapalli | ae8e013 | 2024-07-24 09:54:15 +0530 | [diff] [blame] | 3 | * Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved. |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | */ |
| 7 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <common/debug.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | #include <lib/mmio.h> |
Michal Simek | 058251a | 2023-04-13 13:19:11 +0200 | [diff] [blame] | 10 | #include <lib/xlat_tables/xlat_tables_v2.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <plat/common/platform.h> |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 12 | |
Akshay Belsare | 589ccce | 2023-05-08 19:00:53 +0530 | [diff] [blame] | 13 | #include <plat_common.h> |
| 14 | #include <plat_ipi.h> |
| 15 | #include <plat_private.h> |
| 16 | #include <pm_api_sys.h> |
| 17 | #include <versal_def.h> |
| 18 | |
| 19 | uint32_t platform_id, platform_version; |
Maheedhar Bollapalli | ae8e013 | 2024-07-24 09:54:15 +0530 | [diff] [blame] | 20 | uint32_t cpu_clock; |
Akshay Belsare | 589ccce | 2023-05-08 19:00:53 +0530 | [diff] [blame] | 21 | |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 22 | /* |
| 23 | * Table of regions to map using the MMU. |
| 24 | * This doesn't include TZRAM as the 'mem_layout' argument passed to |
| 25 | * configure_mmu_elx() will give the available subset of that, |
| 26 | */ |
| 27 | const mmap_region_t plat_versal_mmap[] = { |
| 28 | MAP_REGION_FLAT(DEVICE0_BASE, DEVICE0_SIZE, MT_DEVICE | MT_RW | MT_SECURE), |
| 29 | MAP_REGION_FLAT(DEVICE1_BASE, DEVICE1_SIZE, MT_DEVICE | MT_RW | MT_SECURE), |
| 30 | MAP_REGION_FLAT(CRF_BASE, CRF_SIZE, MT_DEVICE | MT_RW | MT_SECURE), |
Michal Simek | 467e16e | 2023-04-14 08:39:49 +0200 | [diff] [blame] | 31 | MAP_REGION_FLAT(PLAT_ARM_CCI_BASE, PLAT_ARM_CCI_SIZE, MT_DEVICE | MT_RW | |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 32 | MT_SECURE), |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 33 | { 0 } |
| 34 | }; |
| 35 | |
Prasad Kummari | 0b37714 | 2023-10-26 16:32:26 +0530 | [diff] [blame] | 36 | const mmap_region_t *plat_get_mmap(void) |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 37 | { |
| 38 | return plat_versal_mmap; |
| 39 | } |
| 40 | |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 41 | void versal_config_setup(void) |
| 42 | { |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 43 | /* Configure IPI data for versal */ |
| 44 | versal_ipi_config_table_init(); |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 45 | } |
| 46 | |
Akshay Belsare | 589ccce | 2023-05-08 19:00:53 +0530 | [diff] [blame] | 47 | void board_detection(void) |
| 48 | { |
| 49 | uint32_t plat_info[2]; |
| 50 | |
| 51 | if (pm_get_chipid(plat_info) != PM_RET_SUCCESS) { |
| 52 | /* If the call is failed we cannot proceed with further |
| 53 | * setup. TF-A to panic in this situation. |
| 54 | */ |
| 55 | NOTICE("Failed to read the chip information"); |
| 56 | panic(); |
| 57 | } |
| 58 | |
| 59 | platform_id = FIELD_GET(PLATFORM_MASK, plat_info[1]); |
| 60 | platform_version = FIELD_GET(PLATFORM_VERSION_MASK, plat_info[1]); |
Akshay Belsare | fc74bf1 | 2024-09-13 15:56:00 +0530 | [diff] [blame] | 61 | |
| 62 | if (platform_id == VERSAL_COSIM) { |
| 63 | platform_id = VERSAL_QEMU; |
| 64 | } |
Akshay Belsare | 589ccce | 2023-05-08 19:00:53 +0530 | [diff] [blame] | 65 | } |
Prasad Kummari | e7e8f86 | 2023-10-04 10:20:30 +0530 | [diff] [blame] | 66 | |
Maheedhar Bollapalli | ae8e013 | 2024-07-24 09:54:15 +0530 | [diff] [blame] | 67 | const char *board_name_decode(void) |
| 68 | { |
| 69 | const char *platform; |
| 70 | |
| 71 | switch (platform_id) { |
| 72 | case VERSAL_SPP: |
| 73 | platform = "IPP"; |
| 74 | break; |
| 75 | case VERSAL_EMU: |
| 76 | platform = "EMU"; |
| 77 | break; |
| 78 | case VERSAL_QEMU: |
| 79 | platform = "QEMU"; |
| 80 | break; |
| 81 | case VERSAL_SILICON: |
| 82 | platform = "SILICON"; |
| 83 | break; |
| 84 | default: |
| 85 | platform = "unknown"; |
| 86 | } |
| 87 | |
| 88 | return platform; |
| 89 | } |
| 90 | |
Prasad Kummari | e7e8f86 | 2023-10-04 10:20:30 +0530 | [diff] [blame] | 91 | uint32_t get_uart_clk(void) |
| 92 | { |
Maheedhar Bollapalli | ae8e013 | 2024-07-24 09:54:15 +0530 | [diff] [blame] | 93 | uint32_t uart_clock; |
| 94 | |
| 95 | switch (platform_id) { |
| 96 | case VERSAL_SPP: |
| 97 | uart_clock = 25000000; |
| 98 | break; |
| 99 | case VERSAL_EMU: |
| 100 | uart_clock = 212000; |
| 101 | break; |
| 102 | case VERSAL_QEMU: |
Maheedhar Bollapalli | ae8e013 | 2024-07-24 09:54:15 +0530 | [diff] [blame] | 103 | case VERSAL_SILICON: |
| 104 | uart_clock = 100000000; |
| 105 | break; |
| 106 | default: |
| 107 | panic(); |
| 108 | } |
| 109 | |
| 110 | return uart_clock; |
Prasad Kummari | e7e8f86 | 2023-10-04 10:20:30 +0530 | [diff] [blame] | 111 | } |