blob: 9dc308bbc3d931e3a6ef218a64e714fbdec40fb1 [file] [log] [blame]
Michal Simek4b066a12018-08-22 14:55:27 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2016 - 2018 Xilinx, Inc.
4 * Michal Simek <michal.simek@xilinx.com>
5 */
6
7#include <common.h>
Simon Glass97589732020-05-10 11:40:02 -06008#include <init.h>
Michal Simek4b066a12018-08-22 14:55:27 +02009#include <asm/armv8/mmu.h>
Simon Glass274e0b02020-05-10 11:39:56 -060010#include <asm/cache.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060011#include <asm/global_data.h>
Michal Simek4b066a12018-08-22 14:55:27 +020012#include <asm/io.h>
Siva Durga Prasad Paladugu775aa952019-01-08 21:47:26 +053013#include <asm/arch/hardware.h>
14#include <asm/arch/sys_proto.h>
Ovidiu Panait2b618472020-03-29 20:57:40 +030015#include <asm/cache.h>
T Karthik Reddycb8485b2021-08-10 06:50:19 -060016#include <dm/platdata.h>
Siva Durga Prasad Paladugu775aa952019-01-08 21:47:26 +053017
18DECLARE_GLOBAL_DATA_PTR;
Michal Simek4b066a12018-08-22 14:55:27 +020019
Michal Simekfe2eb112019-09-11 09:39:59 +020020#define VERSAL_MEM_MAP_USED 5
Michal Simek21eb5cc2019-04-29 09:39:09 -070021
22#define DRAM_BANKS CONFIG_NR_DRAM_BANKS
23
Michal Simekfe2eb112019-09-11 09:39:59 +020024#if defined(CONFIG_DEFINE_TCM_OCM_MMAP)
25#define TCM_MAP 1
26#else
27#define TCM_MAP 0
28#endif
29
Michal Simek21eb5cc2019-04-29 09:39:09 -070030/* +1 is end of list which needs to be empty */
Michal Simekfe2eb112019-09-11 09:39:59 +020031#define VERSAL_MEM_MAP_MAX (VERSAL_MEM_MAP_USED + DRAM_BANKS + TCM_MAP + 1)
Michal Simek21eb5cc2019-04-29 09:39:09 -070032
33static struct mm_region versal_mem_map[VERSAL_MEM_MAP_MAX] = {
Michal Simek4b066a12018-08-22 14:55:27 +020034 {
Michal Simek4b066a12018-08-22 14:55:27 +020035 .virt = 0x80000000UL,
36 .phys = 0x80000000UL,
37 .size = 0x70000000UL,
38 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
39 PTE_BLOCK_NON_SHARE |
40 PTE_BLOCK_PXN | PTE_BLOCK_UXN
41 }, {
42 .virt = 0xf0000000UL,
43 .phys = 0xf0000000UL,
44 .size = 0x0fe00000UL,
45 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
46 PTE_BLOCK_NON_SHARE |
47 PTE_BLOCK_PXN | PTE_BLOCK_UXN
48 }, {
Michal Simek4b066a12018-08-22 14:55:27 +020049 .virt = 0x400000000UL,
50 .phys = 0x400000000UL,
51 .size = 0x200000000UL,
52 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
53 PTE_BLOCK_NON_SHARE |
54 PTE_BLOCK_PXN | PTE_BLOCK_UXN
55 }, {
56 .virt = 0x600000000UL,
57 .phys = 0x600000000UL,
58 .size = 0x800000000UL,
59 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
60 PTE_BLOCK_INNER_SHARE
61 }, {
62 .virt = 0xe00000000UL,
63 .phys = 0xe00000000UL,
64 .size = 0xf200000000UL,
65 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
66 PTE_BLOCK_NON_SHARE |
67 PTE_BLOCK_PXN | PTE_BLOCK_UXN
Michal Simek4b066a12018-08-22 14:55:27 +020068 }
69};
70
Michal Simek21eb5cc2019-04-29 09:39:09 -070071void mem_map_fill(void)
72{
73 int banks = VERSAL_MEM_MAP_USED;
74
Michal Simekfe2eb112019-09-11 09:39:59 +020075#if defined(CONFIG_DEFINE_TCM_OCM_MMAP)
76 versal_mem_map[banks].virt = 0xffe00000UL;
77 versal_mem_map[banks].phys = 0xffe00000UL;
78 versal_mem_map[banks].size = 0x00200000UL;
79 versal_mem_map[banks].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
80 PTE_BLOCK_INNER_SHARE;
81 banks = banks + 1;
82#endif
83
Michal Simek21eb5cc2019-04-29 09:39:09 -070084 for (int i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
85 /* Zero size means no more DDR that's this is end */
86 if (!gd->bd->bi_dram[i].size)
87 break;
88
Michal Simekdfcd21d2020-03-18 13:45:21 +010089#if defined(CONFIG_VERSAL_NO_DDR)
90 if (gd->bd->bi_dram[i].start < 0x80000000UL ||
91 gd->bd->bi_dram[i].start > 0x100000000UL) {
92 printf("Ignore caches over %llx/%llx\n",
93 gd->bd->bi_dram[i].start,
94 gd->bd->bi_dram[i].size);
95 continue;
96 }
97#endif
Michal Simek21eb5cc2019-04-29 09:39:09 -070098 versal_mem_map[banks].virt = gd->bd->bi_dram[i].start;
99 versal_mem_map[banks].phys = gd->bd->bi_dram[i].start;
100 versal_mem_map[banks].size = gd->bd->bi_dram[i].size;
101 versal_mem_map[banks].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
102 PTE_BLOCK_INNER_SHARE;
103 banks = banks + 1;
104 }
105}
106
Michal Simek4b066a12018-08-22 14:55:27 +0200107struct mm_region *mem_map = versal_mem_map;
108
109u64 get_page_table_size(void)
110{
111 return 0x14000;
112}
Siva Durga Prasad Paladugu775aa952019-01-08 21:47:26 +0530113
114#if defined(CONFIG_SYS_MEM_RSVD_FOR_MMU)
Ovidiu Panait2b618472020-03-29 20:57:40 +0300115int arm_reserve_mmu(void)
Siva Durga Prasad Paladugu775aa952019-01-08 21:47:26 +0530116{
117 tcm_init(TCM_LOCK);
118 gd->arch.tlb_size = PGTABLE_SIZE;
119 gd->arch.tlb_addr = VERSAL_TCM_BASE_ADDR;
120
121 return 0;
122}
123#endif
T Karthik Reddycb8485b2021-08-10 06:50:19 -0600124
125U_BOOT_DRVINFO(soc_xilinx_versal) = {
126 .name = "soc_xilinx_versal",
127};