blob: c470e6b5cd036f32b8f11d091d4cce2ee2c660c5 [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>
Julius Werner7dcf9d52015-10-16 13:10:02 -07008#include <gic.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +02009#include <soc/addressmap.h>
10#include <soc/clock.h>
11#include <soc/mmu_operations.h>
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070012#include <soc/mtc.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020013
Julius Werner7dcf9d52015-10-16 13:10:02 -070014static void arm64_arch_timer_init(void)
Patrick Georgi40a3e322015-06-22 19:41:29 +020015{
16 uint32_t freq = clock_get_osc_khz() * 1000;
17 // Set the cntfrq register.
Julius Werner73be9dd2018-08-07 14:02:55 -070018 raw_write_cntfrq_el0(freq);
Patrick Georgi40a3e322015-06-22 19:41:29 +020019}
20
Yen Linc2eae1a2015-05-07 12:28:43 -070021static void mselect_enable_wrap(void)
22{
23 uint32_t reg;
24
25#define ERR_RESP_EN_SLAVE1 (0x1 << 24)
26#define ERR_RESP_EN_SLAVE2 (0x1 << 25)
27#define WRAP_TO_INCR_SLAVE0 (0x1 << 27)
28#define WRAP_TO_INCR_SLAVE1 (0x1 << 28)
29#define WRAP_TO_INCR_SLAVE2 (0x1 << 29)
30
31 reg = read32((void *)TEGRA_MSELECT_CONFIG);
32 /* Disable error mechanism */
33 reg &= ~(ERR_RESP_EN_SLAVE1 | ERR_RESP_EN_SLAVE2);
34 /* Enable WRAP type conversion */
35 reg |= (WRAP_TO_INCR_SLAVE0 | WRAP_TO_INCR_SLAVE1 |
36 WRAP_TO_INCR_SLAVE2);
37 write32((void *)TEGRA_MSELECT_CONFIG, reg);
38}
39
Julius Werner7dcf9d52015-10-16 13:10:02 -070040/* Tegra-specific entry point, called from assembly in stage_entry.S */
41void ramstage_entry(void);
42void ramstage_entry(void)
Patrick Georgi40a3e322015-06-22 19:41:29 +020043{
Julius Werner7dcf9d52015-10-16 13:10:02 -070044 /* TODO: Is this still needed? */
45 gic_init();
46
47 /* TODO: Move arch timer setup to BL31? */
48 arm64_arch_timer_init();
49
Yen Linc2eae1a2015-05-07 12:28:43 -070050 /* Enable WRAP to INCR burst type conversion in MSELECT */
51 mselect_enable_wrap();
52
Julius Werner7dcf9d52015-10-16 13:10:02 -070053 /* TODO: Move TrustZone setup to BL31? */
Patrick Georgi40a3e322015-06-22 19:41:29 +020054 trustzone_region_init();
55
56 tegra210_mmu_init();
Furquan Shaikhfdb3a8d2015-10-15 15:50:30 -070057
58 clock_init_arm_generic_timer();
59
60 if (tegra210_run_mtc() != 0)
61 printk(BIOS_ERR, "MTC: No training data.\n");
Julius Werner7dcf9d52015-10-16 13:10:02 -070062
Arthur Heymans879c9fc2019-11-01 21:42:33 +010063 /* Ramstage is run on a different core, so passing cbmem_top
64 via calling arguments is not an option, but it is not a problem
65 to call cbmem_top_chipset() again here to populate _cbmem_top_ptr. */
66 _cbmem_top_ptr = (uintptr_t)cbmem_top_chipset();
67
Julius Werner7dcf9d52015-10-16 13:10:02 -070068 /* Jump to boot state machine in common code. */
69 main();
Patrick Georgi40a3e322015-06-22 19:41:29 +020070}