Michal Simek | 4b066a1 | 2018-08-22 14:55:27 +0200 | [diff] [blame] | 1 | // 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 Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 8 | #include <init.h> |
Michal Simek | 4b066a1 | 2018-08-22 14:55:27 +0200 | [diff] [blame] | 9 | #include <asm/armv8/mmu.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 10 | #include <asm/cache.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 11 | #include <asm/global_data.h> |
Michal Simek | 4b066a1 | 2018-08-22 14:55:27 +0200 | [diff] [blame] | 12 | #include <asm/io.h> |
Siva Durga Prasad Paladugu | 775aa95 | 2019-01-08 21:47:26 +0530 | [diff] [blame] | 13 | #include <asm/arch/hardware.h> |
| 14 | #include <asm/arch/sys_proto.h> |
Ovidiu Panait | 2b61847 | 2020-03-29 20:57:40 +0300 | [diff] [blame] | 15 | #include <asm/cache.h> |
T Karthik Reddy | cb8485b | 2021-08-10 06:50:19 -0600 | [diff] [blame] | 16 | #include <dm/platdata.h> |
Siva Durga Prasad Paladugu | 775aa95 | 2019-01-08 21:47:26 +0530 | [diff] [blame] | 17 | |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
Michal Simek | 4b066a1 | 2018-08-22 14:55:27 +0200 | [diff] [blame] | 19 | |
Michal Simek | fe2eb11 | 2019-09-11 09:39:59 +0200 | [diff] [blame] | 20 | #define VERSAL_MEM_MAP_USED 5 |
Michal Simek | 21eb5cc | 2019-04-29 09:39:09 -0700 | [diff] [blame] | 21 | |
| 22 | #define DRAM_BANKS CONFIG_NR_DRAM_BANKS |
| 23 | |
Michal Simek | fe2eb11 | 2019-09-11 09:39:59 +0200 | [diff] [blame] | 24 | #if defined(CONFIG_DEFINE_TCM_OCM_MMAP) |
| 25 | #define TCM_MAP 1 |
| 26 | #else |
| 27 | #define TCM_MAP 0 |
| 28 | #endif |
| 29 | |
Michal Simek | 21eb5cc | 2019-04-29 09:39:09 -0700 | [diff] [blame] | 30 | /* +1 is end of list which needs to be empty */ |
Michal Simek | fe2eb11 | 2019-09-11 09:39:59 +0200 | [diff] [blame] | 31 | #define VERSAL_MEM_MAP_MAX (VERSAL_MEM_MAP_USED + DRAM_BANKS + TCM_MAP + 1) |
Michal Simek | 21eb5cc | 2019-04-29 09:39:09 -0700 | [diff] [blame] | 32 | |
| 33 | static struct mm_region versal_mem_map[VERSAL_MEM_MAP_MAX] = { |
Michal Simek | 4b066a1 | 2018-08-22 14:55:27 +0200 | [diff] [blame] | 34 | { |
Michal Simek | 4b066a1 | 2018-08-22 14:55:27 +0200 | [diff] [blame] | 35 | .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 Simek | 4b066a1 | 2018-08-22 14:55:27 +0200 | [diff] [blame] | 49 | .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 Simek | 4b066a1 | 2018-08-22 14:55:27 +0200 | [diff] [blame] | 68 | } |
| 69 | }; |
| 70 | |
Michal Simek | 21eb5cc | 2019-04-29 09:39:09 -0700 | [diff] [blame] | 71 | void mem_map_fill(void) |
| 72 | { |
| 73 | int banks = VERSAL_MEM_MAP_USED; |
| 74 | |
Michal Simek | fe2eb11 | 2019-09-11 09:39:59 +0200 | [diff] [blame] | 75 | #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 Simek | 21eb5cc | 2019-04-29 09:39:09 -0700 | [diff] [blame] | 84 | 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 Simek | dfcd21d | 2020-03-18 13:45:21 +0100 | [diff] [blame] | 89 | #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 Simek | 21eb5cc | 2019-04-29 09:39:09 -0700 | [diff] [blame] | 98 | 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 Simek | 4b066a1 | 2018-08-22 14:55:27 +0200 | [diff] [blame] | 107 | struct mm_region *mem_map = versal_mem_map; |
| 108 | |
| 109 | u64 get_page_table_size(void) |
| 110 | { |
| 111 | return 0x14000; |
| 112 | } |
Siva Durga Prasad Paladugu | 775aa95 | 2019-01-08 21:47:26 +0530 | [diff] [blame] | 113 | |
| 114 | #if defined(CONFIG_SYS_MEM_RSVD_FOR_MMU) |
Ovidiu Panait | 2b61847 | 2020-03-29 20:57:40 +0300 | [diff] [blame] | 115 | int arm_reserve_mmu(void) |
Siva Durga Prasad Paladugu | 775aa95 | 2019-01-08 21:47:26 +0530 | [diff] [blame] | 116 | { |
| 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 Reddy | cb8485b | 2021-08-10 06:50:19 -0600 | [diff] [blame] | 124 | |
| 125 | U_BOOT_DRVINFO(soc_xilinx_versal) = { |
| 126 | .name = "soc_xilinx_versal", |
| 127 | }; |