rockchip: rk3399: use grf structure to access reg
[oweals/u-boot.git] / arch / arm / mach-rockchip / rk3399 / rk3399.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2016 Rockchip Electronics Co., Ltd
4  */
5
6 #include <common.h>
7 #include <spl_gpio.h>
8 #include <asm/armv8/mmu.h>
9 #include <asm/io.h>
10 #include <asm/arch-rockchip/grf_rk3399.h>
11 #include <asm/arch-rockchip/hardware.h>
12
13 DECLARE_GLOBAL_DATA_PTR;
14
15 #define GRF_EMMCCORE_CON11 0xff77f02c
16 #define GRF_BASE        0xff770000
17
18 static struct mm_region rk3399_mem_map[] = {
19         {
20                 .virt = 0x0UL,
21                 .phys = 0x0UL,
22                 .size = 0xf8000000UL,
23                 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
24                          PTE_BLOCK_INNER_SHARE
25         }, {
26                 .virt = 0xf8000000UL,
27                 .phys = 0xf8000000UL,
28                 .size = 0x08000000UL,
29                 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
30                          PTE_BLOCK_NON_SHARE |
31                          PTE_BLOCK_PXN | PTE_BLOCK_UXN
32         }, {
33                 /* List terminator */
34                 0,
35         }
36 };
37
38 struct mm_region *mem_map = rk3399_mem_map;
39
40 int dram_init_banksize(void)
41 {
42         size_t max_size = min((unsigned long)gd->ram_size, gd->ram_top);
43
44         /* Reserve 0x200000 for ATF bl31 */
45         gd->bd->bi_dram[0].start = 0x200000;
46         gd->bd->bi_dram[0].size = max_size - gd->bd->bi_dram[0].start;
47
48         return 0;
49 }
50
51 int arch_cpu_init(void)
52 {
53         /* We do some SoC one time setting here. */
54         struct rk3399_grf_regs * const grf = (void *)GRF_BASE;
55
56         /* Emmc clock generator: disable the clock multipilier */
57         rk_clrreg(&grf->emmccore_con[11], 0x0ff);
58
59         return 0;
60 }