blob: 801e96336bc9579a4e3171b641873d08472cb5e7 [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
3#include <arch/exception.h>
4#include <arch/stages.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +02005#include <cbmem.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +02006#include <console/console.h>
Julius Werner7dcf9d52015-10-16 13:10:02 -07007#include <lib.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +02008#include <program_loading.h>
Arthur Heymans3e914d32022-04-06 22:25:50 +02009#include <romstage_common.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020010#include <soc/addressmap.h>
11#include <soc/ccplex.h>
12#include <soc/clock.h>
Arthur Heymans3e914d32022-04-06 22:25:50 +020013#include <soc/nvidia/tegra/apbmisc.h>
14#include <soc/romstage.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020015#include <soc/sdram.h>
16#include <soc/sdram_configs.h>
Julius Werner7dcf9d52015-10-16 13:10:02 -070017#include <symbols.h>
Patrick Georgi40a3e322015-06-22 19:41:29 +020018#include <vendorcode/google/chromeos/chromeos.h>
19
Aaron Durbin64031672018-04-21 14:45:32 -060020void __weak romstage_mainboard_init(void)
Patrick Georgi40a3e322015-06-22 19:41:29 +020021{
22 /* Default empty implementation. */
23}
24
25void romstage(void)
26{
27 console_init();
28 exception_init();
29
Arthur Heymans3e914d32022-04-06 22:25:50 +020030 romstage_main();
31}
32
33void __noreturn romstage_main(void)
34{
Patrick Georgi40a3e322015-06-22 19:41:29 +020035 printk(BIOS_INFO, "T210: romstage here\n");
36
Julius Wernercd49cce2019-03-05 16:53:33 -080037#if CONFIG(BOOTROM_SDRAM_INIT)
Patrick Georgi40a3e322015-06-22 19:41:29 +020038 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äfer5268b762018-02-12 12:24:25 +010052 * initialization because CBMEM lives right below the Trust Zone which
Patrick Georgi40a3e322015-06-22 19:41:29 +020053 * needs to be properly identified.
54 */
55 trustzone_region_init();
56
Tom Warren0bdb88b2015-08-03 14:58:11 -070057 /* Now do various other carveouts */
Patrick Georgi40a3e322015-06-22 19:41:29 +020058 gpu_region_init();
Tom Warren0bdb88b2015-08-03 14:58:11 -070059 nvdec_region_init();
60 tsec_region_init();
Tom Warren50967872015-08-04 13:08:50 -070061 vpr_region_init();
Patrick Georgi40a3e322015-06-22 19:41:29 +020062
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 HAOUAS038e7242016-07-29 18:31:16 +020071 printk(BIOS_INFO, "T210 romstage: CPU prepare done\n");
Patrick Georgi40a3e322015-06-22 19:41:29 +020072
73 romstage_mainboard_init();
74
75 run_ramstage();
76}
77
78void platform_prog_run(struct prog *prog)
79{
Julius Werner7dcf9d52015-10-16 13:10:02 -070080 /* We'll switch to a new stack, so validate our old one here. */
81 checkstack(_estack, 0);
82
Patrick Georgi40a3e322015-06-22 19:41:29 +020083 ccplex_cpu_start(prog_entry(prog));
84
85 clock_halt_avp();
86}