1ec48b6c9SMichal Simek // SPDX-License-Identifier: GPL-2.0+
2ec48b6c9SMichal Simek /*
3ec48b6c9SMichal Simek * (C) Copyright 2014 - 2018 Xilinx, Inc.
4ec48b6c9SMichal Simek * Michal Simek <michal.simek@xilinx.com>
5ec48b6c9SMichal Simek */
6ec48b6c9SMichal Simek
7ec48b6c9SMichal Simek #include <common.h>
8ec48b6c9SMichal Simek #include <fdtdec.h>
9ec48b6c9SMichal Simek #include <malloc.h>
10ec48b6c9SMichal Simek #include <asm/io.h>
11ec48b6c9SMichal Simek #include <asm/arch/hardware.h>
12ec48b6c9SMichal Simek
13ec48b6c9SMichal Simek DECLARE_GLOBAL_DATA_PTR;
14ec48b6c9SMichal Simek
board_init(void)15ec48b6c9SMichal Simek int board_init(void)
16ec48b6c9SMichal Simek {
17ec48b6c9SMichal Simek printf("EL Level:\tEL%d\n", current_el());
18ec48b6c9SMichal Simek
19ec48b6c9SMichal Simek return 0;
20ec48b6c9SMichal Simek }
21ec48b6c9SMichal Simek
board_early_init_r(void)22ec48b6c9SMichal Simek int board_early_init_r(void)
23ec48b6c9SMichal Simek {
24ec48b6c9SMichal Simek u32 val;
25ec48b6c9SMichal Simek
26fb771793SMichal Simek if (current_el() != 3)
27fb771793SMichal Simek return 0;
28fb771793SMichal Simek
29*47a766f9SMichal Simek debug("iou_switch ctrl div0 %x\n",
30*47a766f9SMichal Simek readl(&crlapb_base->iou_switch_ctrl));
31*47a766f9SMichal Simek
32ec48b6c9SMichal Simek writel(IOU_SWITCH_CTRL_CLKACT_BIT |
33*47a766f9SMichal Simek (CONFIG_IOU_SWITCH_DIVISOR0 << IOU_SWITCH_CTRL_DIVISOR0_SHIFT),
34ec48b6c9SMichal Simek &crlapb_base->iou_switch_ctrl);
35ec48b6c9SMichal Simek
36ec48b6c9SMichal Simek /* Global timer init - Program time stamp reference clk */
37ec48b6c9SMichal Simek val = readl(&crlapb_base->timestamp_ref_ctrl);
38ec48b6c9SMichal Simek val |= CRL_APB_TIMESTAMP_REF_CTRL_CLKACT_BIT;
39ec48b6c9SMichal Simek writel(val, &crlapb_base->timestamp_ref_ctrl);
40ec48b6c9SMichal Simek
41ec48b6c9SMichal Simek debug("ref ctrl 0x%x\n",
42ec48b6c9SMichal Simek readl(&crlapb_base->timestamp_ref_ctrl));
43ec48b6c9SMichal Simek
44ec48b6c9SMichal Simek /* Clear reset of timestamp reg */
45ec48b6c9SMichal Simek writel(0, &crlapb_base->rst_timestamp);
46ec48b6c9SMichal Simek
47ec48b6c9SMichal Simek /*
48ec48b6c9SMichal Simek * Program freq register in System counter and
49ec48b6c9SMichal Simek * enable system counter.
50ec48b6c9SMichal Simek */
51ec48b6c9SMichal Simek writel(COUNTER_FREQUENCY,
52ec48b6c9SMichal Simek &iou_scntr_secure->base_frequency_id_register);
53ec48b6c9SMichal Simek
54ec48b6c9SMichal Simek debug("counter val 0x%x\n",
55ec48b6c9SMichal Simek readl(&iou_scntr_secure->base_frequency_id_register));
56ec48b6c9SMichal Simek
57ec48b6c9SMichal Simek writel(IOU_SCNTRS_CONTROL_EN,
58ec48b6c9SMichal Simek &iou_scntr_secure->counter_control_register);
59ec48b6c9SMichal Simek
60ec48b6c9SMichal Simek debug("scntrs control 0x%x\n",
61ec48b6c9SMichal Simek readl(&iou_scntr_secure->counter_control_register));
62ec48b6c9SMichal Simek debug("timer 0x%llx\n", get_ticks());
63ec48b6c9SMichal Simek debug("timer 0x%llx\n", get_ticks());
64ec48b6c9SMichal Simek
65ec48b6c9SMichal Simek return 0;
66ec48b6c9SMichal Simek }
67ec48b6c9SMichal Simek
dram_init_banksize(void)68ec48b6c9SMichal Simek int dram_init_banksize(void)
69ec48b6c9SMichal Simek {
70ec48b6c9SMichal Simek fdtdec_setup_memory_banksize();
71ec48b6c9SMichal Simek
72ec48b6c9SMichal Simek return 0;
73ec48b6c9SMichal Simek }
74ec48b6c9SMichal Simek
dram_init(void)75ec48b6c9SMichal Simek int dram_init(void)
76ec48b6c9SMichal Simek {
77ec48b6c9SMichal Simek if (fdtdec_setup_mem_size_base() != 0)
78ec48b6c9SMichal Simek return -EINVAL;
79ec48b6c9SMichal Simek
80ec48b6c9SMichal Simek return 0;
81ec48b6c9SMichal Simek }
82ec48b6c9SMichal Simek
reset_cpu(ulong addr)83ec48b6c9SMichal Simek void reset_cpu(ulong addr)
84ec48b6c9SMichal Simek {
85ec48b6c9SMichal Simek }
86