aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-keystone/keystone.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-keystone/keystone.c')
-rw-r--r--arch/arm/mach-keystone/keystone.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c
index e0b9e1b9cf30..155eb062e8d1 100644
--- a/arch/arm/mach-keystone/keystone.c
+++ b/arch/arm/mach-keystone/keystone.c
@@ -20,6 +20,9 @@
20#include <asm/mach/arch.h> 20#include <asm/mach/arch.h>
21#include <asm/mach/time.h> 21#include <asm/mach/time.h>
22#include <asm/smp_plat.h> 22#include <asm/smp_plat.h>
23#include <asm/memory.h>
24
25#include "memory.h"
23 26
24#include "keystone.h" 27#include "keystone.h"
25 28
@@ -45,6 +48,50 @@ static void __init keystone_init(void)
45 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 48 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
46} 49}
47 50
51static phys_addr_t keystone_virt_to_idmap(unsigned long x)
52{
53 return (phys_addr_t)(x) - CONFIG_PAGE_OFFSET + KEYSTONE_LOW_PHYS_START;
54}
55
56static void __init keystone_init_meminfo(void)
57{
58 bool lpae = IS_ENABLED(CONFIG_ARM_LPAE);
59 bool pvpatch = IS_ENABLED(CONFIG_ARM_PATCH_PHYS_VIRT);
60 phys_addr_t offset = PHYS_OFFSET - KEYSTONE_LOW_PHYS_START;
61 phys_addr_t mem_start, mem_end;
62
63 BUG_ON(meminfo.nr_banks < 1);
64 mem_start = meminfo.bank[0].start;
65 mem_end = mem_start + meminfo.bank[0].size - 1;
66
67 /* nothing to do if we are running out of the <32-bit space */
68 if (mem_start >= KEYSTONE_LOW_PHYS_START &&
69 mem_end <= KEYSTONE_LOW_PHYS_END)
70 return;
71
72 if (!lpae || !pvpatch) {
73 pr_crit("Enable %s%s%s to run outside 32-bit space\n",
74 !lpae ? __stringify(CONFIG_ARM_LPAE) : "",
75 (!lpae && !pvpatch) ? " and " : "",
76 !pvpatch ? __stringify(CONFIG_ARM_PATCH_PHYS_VIRT) : "");
77 }
78
79 if (mem_start < KEYSTONE_HIGH_PHYS_START ||
80 mem_end > KEYSTONE_HIGH_PHYS_END) {
81 pr_crit("Invalid address space for memory (%08llx-%08llx)\n",
82 (u64)mem_start, (u64)mem_end);
83 }
84
85 offset += KEYSTONE_HIGH_PHYS_START;
86 __pv_phys_pfn_offset = PFN_DOWN(offset);
87 __pv_offset = (offset - PAGE_OFFSET);
88
89 /* Populate the arch idmap hook */
90 arch_virt_to_idmap = keystone_virt_to_idmap;
91
92 pr_info("Switching to high address space at 0x%llx\n", (u64)offset);
93}
94
48static const char *keystone_match[] __initconst = { 95static const char *keystone_match[] __initconst = {
49 "ti,keystone", 96 "ti,keystone",
50 NULL, 97 NULL,
@@ -76,4 +123,5 @@ DT_MACHINE_START(KEYSTONE, "Keystone")
76 .init_machine = keystone_init, 123 .init_machine = keystone_init,
77 .dt_compat = keystone_match, 124 .dt_compat = keystone_match,
78 .restart = keystone_restart, 125 .restart = keystone_restart,
126 .init_meminfo = keystone_init_meminfo,
79MACHINE_END 127MACHINE_END