xref: /openbmc/u-boot/arch/arm/mach-rockchip/rk3399/rk3399.c (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2a381bcf5SKever Yang /*
3a381bcf5SKever Yang  * Copyright (c) 2016 Rockchip Electronics Co., Ltd
4a381bcf5SKever Yang  */
5a381bcf5SKever Yang 
6a381bcf5SKever Yang #include <common.h>
7a381bcf5SKever Yang #include <asm/armv8/mmu.h>
827b95d25SKever Yang #include <asm/io.h>
927b95d25SKever Yang #include <asm/arch/hardware.h>
1027b95d25SKever Yang 
11975e4abaSKever Yang DECLARE_GLOBAL_DATA_PTR;
12975e4abaSKever Yang 
1327b95d25SKever Yang #define GRF_EMMCCORE_CON11 0xff77f02c
14a381bcf5SKever Yang 
15a381bcf5SKever Yang static struct mm_region rk3399_mem_map[] = {
16a381bcf5SKever Yang 	{
17a381bcf5SKever Yang 		.virt = 0x0UL,
18a381bcf5SKever Yang 		.phys = 0x0UL,
1990c9127eSKever Yang 		.size = 0xf8000000UL,
20a381bcf5SKever Yang 		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
21a381bcf5SKever Yang 			 PTE_BLOCK_INNER_SHARE
22a381bcf5SKever Yang 	}, {
2390c9127eSKever Yang 		.virt = 0xf8000000UL,
2490c9127eSKever Yang 		.phys = 0xf8000000UL,
2590c9127eSKever Yang 		.size = 0x08000000UL,
26a381bcf5SKever Yang 		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
27a381bcf5SKever Yang 			 PTE_BLOCK_NON_SHARE |
28a381bcf5SKever Yang 			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
29a381bcf5SKever Yang 	}, {
30a381bcf5SKever Yang 		/* List terminator */
31a381bcf5SKever Yang 		0,
32a381bcf5SKever Yang 	}
33a381bcf5SKever Yang };
34a381bcf5SKever Yang 
35a381bcf5SKever Yang struct mm_region *mem_map = rk3399_mem_map;
3627b95d25SKever Yang 
dram_init_banksize(void)37975e4abaSKever Yang int dram_init_banksize(void)
38975e4abaSKever Yang {
39975e4abaSKever Yang 	size_t max_size = min((unsigned long)gd->ram_size, gd->ram_top);
40975e4abaSKever Yang 
41975e4abaSKever Yang 	/* Reserve 0x200000 for ATF bl31 */
42975e4abaSKever Yang 	gd->bd->bi_dram[0].start = 0x200000;
43975e4abaSKever Yang 	gd->bd->bi_dram[0].size = max_size - gd->bd->bi_dram[0].start;
44975e4abaSKever Yang 
45975e4abaSKever Yang 	return 0;
46975e4abaSKever Yang }
47975e4abaSKever Yang 
arch_cpu_init(void)4827b95d25SKever Yang int arch_cpu_init(void)
4927b95d25SKever Yang {
5027b95d25SKever Yang 	/* We do some SoC one time setting here. */
5127b95d25SKever Yang 
5227b95d25SKever Yang 	/* Emmc clock generator: disable the clock multipilier */
5327b95d25SKever Yang 	rk_clrreg(GRF_EMMCCORE_CON11, 0x0ff);
5427b95d25SKever Yang 
5527b95d25SKever Yang 	return 0;
5627b95d25SKever Yang }
57