blob: 45b221b3fca12e3ae4441641ff46705d0e147506 [file] [log] [blame]
Angel Ponsa2ee7612020-04-04 18:51:15 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgi40a3e322015-06-22 19:41:29 +02002
Julius Werner73be9dd2018-08-07 14:02:55 -07003#include <arch/lib_helpers.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +02004#include <arch/stages.h>
Arthur Heymans879c9fc2019-11-01 21:42:33 +01005#include <cbmem.h>
Elyes HAOUAS20eaef02019-03-29 17:45:28 +01006#include <console/console.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +02007#include <device/mmio.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +02008#include <soc/addressmap.h>
9#include <soc/clock.h>
10#include <soc/mmu_operations.h>
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070011#include <soc/mtc.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020012
Julius Werner7dcf9d52015-10-16 13:10:02 -070013static void arm64_arch_timer_init(void)
Patrick Georgi40a3e322015-06-22 19:41:29 +020014{
15 uint32_t freq = clock_get_osc_khz() * 1000;
16 // Set the cntfrq register.
Julius Werner73be9dd2018-08-07 14:02:55 -070017 raw_write_cntfrq_el0(freq);
Patrick Georgi40a3e322015-06-22 19:41:29 +020018}
19
Yen Linc2eae1a2015-05-07 12:28:43 -070020static void mselect_enable_wrap(void)
21{
22 uint32_t reg;
23
24#define ERR_RESP_EN_SLAVE1 (0x1 << 24)
25#define ERR_RESP_EN_SLAVE2 (0x1 << 25)
26#define WRAP_TO_INCR_SLAVE0 (0x1 << 27)
27#define WRAP_TO_INCR_SLAVE1 (0x1 << 28)
28#define WRAP_TO_INCR_SLAVE2 (0x1 << 29)
29
30 reg = read32((void *)TEGRA_MSELECT_CONFIG);
31 /* Disable error mechanism */
32 reg &= ~(ERR_RESP_EN_SLAVE1 | ERR_RESP_EN_SLAVE2);
33 /* Enable WRAP type conversion */
34 reg |= (WRAP_TO_INCR_SLAVE0 | WRAP_TO_INCR_SLAVE1 |
35 WRAP_TO_INCR_SLAVE2);
36 write32((void *)TEGRA_MSELECT_CONFIG, reg);
37}
38
Julius Werner7dcf9d52015-10-16 13:10:02 -070039/* Tegra-specific entry point, called from assembly in stage_entry.S */
40void ramstage_entry(void);
41void ramstage_entry(void)
Patrick Georgi40a3e322015-06-22 19:41:29 +020042{
Julius Werner7dcf9d52015-10-16 13:10:02 -070043 /* TODO: Move arch timer setup to BL31? */
44 arm64_arch_timer_init();
45
Yen Linc2eae1a2015-05-07 12:28:43 -070046 /* Enable WRAP to INCR burst type conversion in MSELECT */
47 mselect_enable_wrap();
48
Julius Werner7dcf9d52015-10-16 13:10:02 -070049 /* TODO: Move TrustZone setup to BL31? */
Patrick Georgi40a3e322015-06-22 19:41:29 +020050 trustzone_region_init();
51
52 tegra210_mmu_init();
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070053
54 clock_init_arm_generic_timer();
55
56 if (tegra210_run_mtc() != 0)
57 printk(BIOS_ERR, "MTC: No training data.\n");
Julius Werner7dcf9d52015-10-16 13:10:02 -070058
Arthur Heymans879c9fc2019-11-01 21:42:33 +010059 /* Ramstage is run on a different core, so passing cbmem_top
60 via calling arguments is not an option, but it is not a problem
61 to call cbmem_top_chipset() again here to populate _cbmem_top_ptr. */
Elyes Haouas799c3212022-11-09 14:00:44 +010062 _cbmem_top_ptr = cbmem_top_chipset();
Arthur Heymans879c9fc2019-11-01 21:42:33 +010063
Julius Werner7dcf9d52015-10-16 13:10:02 -070064 /* Jump to boot state machine in common code. */
65 main();
Patrick Georgi40a3e322015-06-22 19:41:29 +020066}