Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2014 - 2015 Xilinx, Inc. |
| 3 | * Michal Simek <michal.simek@xilinx.com> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <asm/arch/hardware.h> |
| 10 | #include <asm/arch/sys_proto.h> |
Alexander Graf | 0e2088c | 2016-03-04 01:09:49 +0100 | [diff] [blame] | 11 | #include <asm/armv8/mmu.h> |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 12 | #include <asm/io.h> |
| 13 | |
| 14 | #define ZYNQ_SILICON_VER_MASK 0xF000 |
| 15 | #define ZYNQ_SILICON_VER_SHIFT 12 |
| 16 | |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
Alexander Graf | 0e2088c | 2016-03-04 01:09:49 +0100 | [diff] [blame] | 19 | static struct mm_region zynqmp_mem_map[] = { |
| 20 | { |
York Sun | c7104e5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 21 | .virt = 0x0UL, |
| 22 | .phys = 0x0UL, |
Alexander Graf | 0e2088c | 2016-03-04 01:09:49 +0100 | [diff] [blame] | 23 | .size = 0x80000000UL, |
| 24 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 25 | PTE_BLOCK_INNER_SHARE |
| 26 | }, { |
York Sun | c7104e5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 27 | .virt = 0x80000000UL, |
| 28 | .phys = 0x80000000UL, |
Alexander Graf | 0e2088c | 2016-03-04 01:09:49 +0100 | [diff] [blame] | 29 | .size = 0x70000000UL, |
| 30 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 31 | PTE_BLOCK_NON_SHARE | |
| 32 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 33 | }, { |
York Sun | c7104e5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 34 | .virt = 0xf8000000UL, |
| 35 | .phys = 0xf8000000UL, |
Alexander Graf | 0e2088c | 2016-03-04 01:09:49 +0100 | [diff] [blame] | 36 | .size = 0x07e00000UL, |
| 37 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 38 | PTE_BLOCK_NON_SHARE | |
| 39 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 40 | }, { |
York Sun | c7104e5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 41 | .virt = 0xffe00000UL, |
| 42 | .phys = 0xffe00000UL, |
Alexander Graf | 0e2088c | 2016-03-04 01:09:49 +0100 | [diff] [blame] | 43 | .size = 0x00200000UL, |
| 44 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 45 | PTE_BLOCK_INNER_SHARE |
| 46 | }, { |
York Sun | c7104e5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 47 | .virt = 0x400000000UL, |
| 48 | .phys = 0x400000000UL, |
Alexander Graf | 0e2088c | 2016-03-04 01:09:49 +0100 | [diff] [blame] | 49 | .size = 0x200000000UL, |
| 50 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 51 | PTE_BLOCK_NON_SHARE | |
| 52 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 53 | }, { |
York Sun | c7104e5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 54 | .virt = 0x600000000UL, |
| 55 | .phys = 0x600000000UL, |
Alexander Graf | 0e2088c | 2016-03-04 01:09:49 +0100 | [diff] [blame] | 56 | .size = 0x800000000UL, |
| 57 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 58 | PTE_BLOCK_INNER_SHARE |
| 59 | }, { |
York Sun | c7104e5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 60 | .virt = 0xe00000000UL, |
| 61 | .phys = 0xe00000000UL, |
Alexander Graf | 0e2088c | 2016-03-04 01:09:49 +0100 | [diff] [blame] | 62 | .size = 0xf200000000UL, |
| 63 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 64 | PTE_BLOCK_NON_SHARE | |
| 65 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 66 | }, { |
| 67 | /* List terminator */ |
| 68 | 0, |
| 69 | } |
| 70 | }; |
| 71 | struct mm_region *mem_map = zynqmp_mem_map; |
| 72 | |
Michal Simek | 1a2d5e2 | 2016-05-30 10:41:26 +0200 | [diff] [blame] | 73 | u64 get_page_table_size(void) |
| 74 | { |
| 75 | return 0x14000; |
| 76 | } |
| 77 | |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 78 | static unsigned int zynqmp_get_silicon_version_secure(void) |
| 79 | { |
| 80 | u32 ver; |
| 81 | |
| 82 | ver = readl(&csu_base->version); |
| 83 | ver &= ZYNQMP_SILICON_VER_MASK; |
| 84 | ver >>= ZYNQMP_SILICON_VER_SHIFT; |
| 85 | |
| 86 | return ver; |
| 87 | } |
| 88 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 89 | unsigned int zynqmp_get_silicon_version(void) |
| 90 | { |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 91 | if (current_el() == 3) |
| 92 | return zynqmp_get_silicon_version_secure(); |
| 93 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 94 | gd->cpu_clk = get_tbclk(); |
| 95 | |
| 96 | switch (gd->cpu_clk) { |
Michal Simek | 0ca5557 | 2015-04-15 14:59:19 +0200 | [diff] [blame] | 97 | case 0 ... 1000000: |
| 98 | return ZYNQMP_CSU_VERSION_VELOCE; |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 99 | case 50000000: |
| 100 | return ZYNQMP_CSU_VERSION_QEMU; |
Michal Simek | 8d2c02d | 2015-08-20 14:01:39 +0200 | [diff] [blame] | 101 | case 4000000: |
| 102 | return ZYNQMP_CSU_VERSION_EP108; |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 103 | } |
| 104 | |
Michal Simek | 8d2c02d | 2015-08-20 14:01:39 +0200 | [diff] [blame] | 105 | return ZYNQMP_CSU_VERSION_SILICON; |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 106 | } |