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