Angel Pons | a2ee761 | 2020-04-04 18:51:15 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 2 | |
| 3 | #include <arch/cache.h> |
| 4 | #include <arch/exception.h> |
Daisuke Nojiri | 23727ca | 2014-12-01 17:19:10 -0800 | [diff] [blame] | 5 | #include <arch/hlt.h> |
| 6 | #include <arch/stages.h> |
Aaron Durbin | 0946a1b | 2015-05-01 16:48:54 -0500 | [diff] [blame] | 7 | #include <program_loading.h> |
Julius Werner | f0d21ff3 | 2014-10-20 13:24:14 -0700 | [diff] [blame] | 8 | #include <soc/cache.h> |
| 9 | #include <soc/early_configs.h> |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 10 | #include <symbols.h> |
Aaron Durbin | 5a4f289 | 2015-10-01 16:24:28 -0500 | [diff] [blame] | 11 | #include <vendorcode/google/chromeos/chromeos.h> |
Stefan Reinauer | 77b1655 | 2015-01-14 19:51:47 +0100 | [diff] [blame] | 12 | |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 13 | static void enable_cache(void) |
Stefan Reinauer | 77b1655 | 2015-01-14 19:51:47 +0100 | [diff] [blame] | 14 | { |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 15 | mmu_init(); |
| 16 | /* Whole space is uncached. */ |
| 17 | mmu_config_range(0, 4096, DCACHE_OFF); |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 18 | /* SRAM is cached. MMU code will round size up to page size. */ |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 19 | mmu_config_range((uintptr_t)_sram/MiB, |
| 20 | DIV_ROUND_UP(REGION_SIZE(sram), MiB), |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 21 | DCACHE_WRITEBACK); |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 22 | mmu_disable_range(0, 1); |
| 23 | dcache_mmu_enable(); |
| 24 | } |
Daisuke Nojiri | bcc1d42 | 2014-06-19 19:16:24 -0700 | [diff] [blame] | 25 | |
Aaron Durbin | 5a4f289 | 2015-10-01 16:24:28 -0500 | [diff] [blame] | 26 | void verstage_mainboard_init(void) |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 27 | { |
Aaron Durbin | 5a4f289 | 2015-10-01 16:24:28 -0500 | [diff] [blame] | 28 | /* Do the minimum to run vboot at full speed */ |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 29 | configure_l2_cache(); |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 30 | enable_cache(); |
Daisuke Nojiri | 23727ca | 2014-12-01 17:19:10 -0800 | [diff] [blame] | 31 | early_mainboard_init(); |
Daisuke Nojiri | 23727ca | 2014-12-01 17:19:10 -0800 | [diff] [blame] | 32 | } |
| 33 | |
Arthur Heymans | 2f389f1 | 2019-10-20 01:00:57 +0200 | [diff] [blame] | 34 | void stage_entry(uintptr_t unused) |
Daisuke Nojiri | efddcfb | 2014-09-04 09:55:34 -0700 | [diff] [blame] | 35 | { |
| 36 | asm volatile ("bl arm_init_caches" |
| 37 | : : : "r0", "r1", "r2", "r3", "r4", "r5", "ip"); |
Julius Werner | 94d9411 | 2017-03-16 19:21:51 -0700 | [diff] [blame] | 38 | main(); |
Stefan Reinauer | 77b1655 | 2015-01-14 19:51:47 +0100 | [diff] [blame] | 39 | } |