Angel Pons | a2ee761 | 2020-04-04 18:51:15 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 2 | |
Julius Werner | 73be9dd | 2018-08-07 14:02:55 -0700 | [diff] [blame] | 3 | #include <arch/lib_helpers.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 4 | #include <arch/stages.h> |
Arthur Heymans | 879c9fc | 2019-11-01 21:42:33 +0100 | [diff] [blame] | 5 | #include <cbmem.h> |
Elyes HAOUAS | 20eaef0 | 2019-03-29 17:45:28 +0100 | [diff] [blame] | 6 | #include <console/console.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 7 | #include <device/mmio.h> |
Julius Werner | 7dcf9d5 | 2015-10-16 13:10:02 -0700 | [diff] [blame] | 8 | #include <gic.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 9 | #include <soc/addressmap.h> |
| 10 | #include <soc/clock.h> |
| 11 | #include <soc/mmu_operations.h> |
Furquan Shaikh | fdb3a8d | 2015-10-15 15:50:30 -0700 | [diff] [blame] | 12 | #include <soc/mtc.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 13 | |
Julius Werner | 7dcf9d5 | 2015-10-16 13:10:02 -0700 | [diff] [blame] | 14 | static void arm64_arch_timer_init(void) |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 15 | { |
| 16 | uint32_t freq = clock_get_osc_khz() * 1000; |
| 17 | // Set the cntfrq register. |
Julius Werner | 73be9dd | 2018-08-07 14:02:55 -0700 | [diff] [blame] | 18 | raw_write_cntfrq_el0(freq); |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 19 | } |
| 20 | |
Yen Lin | c2eae1a | 2015-05-07 12:28:43 -0700 | [diff] [blame] | 21 | static 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 Werner | 7dcf9d5 | 2015-10-16 13:10:02 -0700 | [diff] [blame] | 40 | /* Tegra-specific entry point, called from assembly in stage_entry.S */ |
| 41 | void ramstage_entry(void); |
| 42 | void ramstage_entry(void) |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 43 | { |
Julius Werner | 7dcf9d5 | 2015-10-16 13:10:02 -0700 | [diff] [blame] | 44 | /* TODO: Is this still needed? */ |
| 45 | gic_init(); |
| 46 | |
| 47 | /* TODO: Move arch timer setup to BL31? */ |
| 48 | arm64_arch_timer_init(); |
| 49 | |
Yen Lin | c2eae1a | 2015-05-07 12:28:43 -0700 | [diff] [blame] | 50 | /* Enable WRAP to INCR burst type conversion in MSELECT */ |
| 51 | mselect_enable_wrap(); |
| 52 | |
Julius Werner | 7dcf9d5 | 2015-10-16 13:10:02 -0700 | [diff] [blame] | 53 | /* TODO: Move TrustZone setup to BL31? */ |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 54 | trustzone_region_init(); |
| 55 | |
| 56 | tegra210_mmu_init(); |
Furquan Shaikh | fdb3a8d | 2015-10-15 15:50:30 -0700 | [diff] [blame] | 57 | |
| 58 | clock_init_arm_generic_timer(); |
| 59 | |
| 60 | if (tegra210_run_mtc() != 0) |
| 61 | printk(BIOS_ERR, "MTC: No training data.\n"); |
Julius Werner | 7dcf9d5 | 2015-10-16 13:10:02 -0700 | [diff] [blame] | 62 | |
Arthur Heymans | 879c9fc | 2019-11-01 21:42:33 +0100 | [diff] [blame] | 63 | /* 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 Werner | 7dcf9d5 | 2015-10-16 13:10:02 -0700 | [diff] [blame] | 68 | /* Jump to boot state machine in common code. */ |
| 69 | main(); |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 70 | } |