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 | |
| 3 | #include <arch/exception.h> |
| 4 | #include <arch/stages.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 5 | #include <cbmem.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 6 | #include <console/console.h> |
Julius Werner | 7dcf9d5 | 2015-10-16 13:10:02 -0700 | [diff] [blame] | 7 | #include <lib.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 8 | #include <program_loading.h> |
Arthur Heymans | 3e914d3 | 2022-04-06 22:25:50 +0200 | [diff] [blame] | 9 | #include <romstage_common.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 10 | #include <soc/addressmap.h> |
| 11 | #include <soc/ccplex.h> |
| 12 | #include <soc/clock.h> |
Arthur Heymans | 3e914d3 | 2022-04-06 22:25:50 +0200 | [diff] [blame] | 13 | #include <soc/nvidia/tegra/apbmisc.h> |
| 14 | #include <soc/romstage.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 15 | #include <soc/sdram.h> |
| 16 | #include <soc/sdram_configs.h> |
Julius Werner | 7dcf9d5 | 2015-10-16 13:10:02 -0700 | [diff] [blame] | 17 | #include <symbols.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 18 | #include <vendorcode/google/chromeos/chromeos.h> |
| 19 | |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 20 | void __weak romstage_mainboard_init(void) |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 21 | { |
| 22 | /* Default empty implementation. */ |
| 23 | } |
| 24 | |
| 25 | void romstage(void) |
| 26 | { |
| 27 | console_init(); |
| 28 | exception_init(); |
| 29 | |
Arthur Heymans | 3e914d3 | 2022-04-06 22:25:50 +0200 | [diff] [blame] | 30 | romstage_main(); |
| 31 | } |
| 32 | |
| 33 | void __noreturn romstage_main(void) |
| 34 | { |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 35 | printk(BIOS_INFO, "T210: romstage here\n"); |
| 36 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 37 | #if CONFIG(BOOTROM_SDRAM_INIT) |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 38 | printk(BIOS_INFO, "T210 romstage: SDRAM init done by BootROM, RAMCODE = %d\n", |
| 39 | sdram_get_ram_code()); |
| 40 | #else |
| 41 | sdram_init(get_sdram_config()); |
| 42 | printk(BIOS_INFO, "T210 romstage: sdram_init done\n"); |
| 43 | #endif |
| 44 | |
| 45 | /* |
| 46 | * IMPORTANT: |
| 47 | * DO NOT INITIALIZE ANY CARVEOUT BEFORE TZ. |
| 48 | * |
| 49 | * Trust Zone needs to be initialized after the DRAM initialization |
| 50 | * because carveout registers are programmed during DRAM init. |
| 51 | * cbmem_initialize() is dependent on the Trust Zone region |
Jonathan Neuschäfer | 5268b76 | 2018-02-12 12:24:25 +0100 | [diff] [blame] | 52 | * initialization because CBMEM lives right below the Trust Zone which |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 53 | * needs to be properly identified. |
| 54 | */ |
| 55 | trustzone_region_init(); |
| 56 | |
Tom Warren | 0bdb88b | 2015-08-03 14:58:11 -0700 | [diff] [blame] | 57 | /* Now do various other carveouts */ |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 58 | gpu_region_init(); |
Tom Warren | 0bdb88b | 2015-08-03 14:58:11 -0700 | [diff] [blame] | 59 | nvdec_region_init(); |
| 60 | tsec_region_init(); |
Tom Warren | 5096787 | 2015-08-04 13:08:50 -0700 | [diff] [blame] | 61 | vpr_region_init(); |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | * When romstage is running it's always on the reboot path -- never a |
| 65 | * resume path where cbmem recovery is required. Therefore, always |
| 66 | * initialize the cbmem area to be empty. |
| 67 | */ |
| 68 | cbmem_initialize_empty(); |
| 69 | |
| 70 | ccplex_cpu_prepare(); |
Elyes HAOUAS | 038e724 | 2016-07-29 18:31:16 +0200 | [diff] [blame] | 71 | printk(BIOS_INFO, "T210 romstage: CPU prepare done\n"); |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 72 | |
| 73 | romstage_mainboard_init(); |
| 74 | |
| 75 | run_ramstage(); |
| 76 | } |
| 77 | |
| 78 | void platform_prog_run(struct prog *prog) |
| 79 | { |
Julius Werner | 7dcf9d5 | 2015-10-16 13:10:02 -0700 | [diff] [blame] | 80 | /* We'll switch to a new stack, so validate our old one here. */ |
| 81 | checkstack(_estack, 0); |
| 82 | |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 83 | ccplex_cpu_start(prog_entry(prog)); |
| 84 | |
| 85 | clock_halt_avp(); |
| 86 | } |