Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 7 | #include <common/debug.h> |
| 8 | #include <drivers/generic_delay_timer.h> |
| 9 | #include <lib/mmio.h> |
| 10 | #include <lib/xlat_tables/xlat_tables.h> |
| 11 | #include <plat/common/platform.h> |
| 12 | |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 13 | #include "../versal_def.h" |
| 14 | #include "../versal_private.h" |
| 15 | |
| 16 | /* |
| 17 | * Table of regions to map using the MMU. |
| 18 | * This doesn't include TZRAM as the 'mem_layout' argument passed to |
| 19 | * configure_mmu_elx() will give the available subset of that, |
| 20 | */ |
| 21 | const mmap_region_t plat_versal_mmap[] = { |
| 22 | MAP_REGION_FLAT(DEVICE0_BASE, DEVICE0_SIZE, MT_DEVICE | MT_RW | MT_SECURE), |
| 23 | MAP_REGION_FLAT(DEVICE1_BASE, DEVICE1_SIZE, MT_DEVICE | MT_RW | MT_SECURE), |
| 24 | MAP_REGION_FLAT(CRF_BASE, CRF_SIZE, MT_DEVICE | MT_RW | MT_SECURE), |
| 25 | { 0 } |
| 26 | }; |
| 27 | |
| 28 | const mmap_region_t *plat_versal_get_mmap(void) |
| 29 | { |
| 30 | return plat_versal_mmap; |
| 31 | } |
| 32 | |
| 33 | static void versal_print_platform_name(void) |
| 34 | { |
| 35 | NOTICE("ATF running on Xilinx %s\n", PLATFORM_NAME); |
| 36 | } |
| 37 | |
| 38 | void versal_config_setup(void) |
| 39 | { |
| 40 | uint32_t val; |
| 41 | |
| 42 | versal_print_platform_name(); |
| 43 | |
| 44 | mmio_write_32(VERSAL_CRL_IOU_SWITCH_CTRL, |
| 45 | VERSAL_IOU_SWITCH_CTRL_CLKACT_BIT | |
| 46 | (0x20 << VERSAL_IOU_SWITCH_CTRL_DIVISOR0_SHIFT)); |
| 47 | |
| 48 | /* Global timer init - Program time stamp reference clk */ |
| 49 | val = mmio_read_32(VERSAL_CRL_TIMESTAMP_REF_CTRL); |
| 50 | val |= VERSAL_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT_BIT; |
| 51 | mmio_write_32(VERSAL_CRL_TIMESTAMP_REF_CTRL, val); |
| 52 | |
| 53 | /* Clear reset of timestamp reg */ |
| 54 | mmio_write_32(VERSAL_CRL_RST_TIMESTAMP_OFFSET, 0x0); |
| 55 | |
| 56 | /* Program freq register in System counter and enable system counter. */ |
| 57 | mmio_write_32(VERSAL_IOU_SCNTRS_BASE_FREQ, VERSAL_CPU_CLOCK); |
| 58 | mmio_write_32(VERSAL_IOU_SCNTRS_COUNTER_CONTROL_REG, |
| 59 | VERSAL_IOU_SCNTRS_CONTROL_EN); |
| 60 | |
| 61 | generic_delay_timer_init(); |
| 62 | } |
| 63 | |
| 64 | unsigned int plat_get_syscnt_freq2(void) |
| 65 | { |
| 66 | return VERSAL_CPU_CLOCK; |
| 67 | } |
| 68 | |
| 69 | uintptr_t plat_get_ns_image_entrypoint(void) |
| 70 | { |
| 71 | #ifdef PRELOADED_BL33_BASE |
| 72 | return PRELOADED_BL33_BASE; |
| 73 | #else |
| 74 | return PLAT_VERSAL_NS_IMAGE_OFFSET; |
| 75 | #endif |
| 76 | } |