blob: 587b797d7615a930162961bc7649d704f807cf8a [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
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00007#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 Paladugufe4af662018-09-25 18:44:58 +053013#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 */
21const 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
28const mmap_region_t *plat_versal_get_mmap(void)
29{
30 return plat_versal_mmap;
31}
32
33static void versal_print_platform_name(void)
34{
35 NOTICE("ATF running on Xilinx %s\n", PLATFORM_NAME);
36}
37
38void 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
64unsigned int plat_get_syscnt_freq2(void)
65{
66 return VERSAL_CPU_CLOCK;
67}
68
69uintptr_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}