summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-05-17 13:58:19 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2018-05-18 08:13:18 +0200
commit96c5da3a41bff361bcc95c38a169c18c19d9cd61 (patch)
treeaed1ab9ad4f5a8449be4fec06f60f3d956fa6fbf /arch
parenta8c5aed648362329a080c7414aaa6ed8846910fb (diff)
downloadbarebox-96c5da3a41bff361bcc95c38a169c18c19d9cd61.tar.gz
barebox-96c5da3a41bff361bcc95c38a169c18c19d9cd61.tar.xz
ARM: mmu: Share code for initial flat mapping creation
Code creating inital 4GiB flat mapping is identical between mmu.c and mmu-early.c, so move it to mmu.h and share. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/cpu/mmu-early.c4
-rw-r--r--arch/arm/cpu/mmu.c6
-rw-r--r--arch/arm/cpu/mmu.h8
3 files changed, 10 insertions, 8 deletions
diff --git a/arch/arm/cpu/mmu-early.c b/arch/arm/cpu/mmu-early.c
index 5304f63562..d9aafdd8a3 100644
--- a/arch/arm/cpu/mmu-early.c
+++ b/arch/arm/cpu/mmu-early.c
@@ -5,7 +5,6 @@
#include <asm/memory.h>
#include <asm/system.h>
#include <asm/cache.h>
-#include <asm/pgtable.h>
#include "mmu.h"
@@ -30,8 +29,7 @@ void mmu_early_enable(unsigned long membase, unsigned long memsize,
set_ttbr(ttb);
set_domain(DOMAIN_MANAGER);
- create_sections(ttb, 0, 0xffffffff, PMD_SECT_AP_WRITE |
- PMD_SECT_AP_READ | PMD_TYPE_SECT);
+ create_flat_mapping(ttb);
map_cachable(membase, memsize);
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 567b22f15b..f0f279ffac 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -27,14 +27,12 @@
#include <asm/barebox-arm.h>
#include <asm/system.h>
#include <asm/cache.h>
-#include <asm/pgtable.h>
#include <memory.h>
#include <asm/system_info.h>
#include <asm/sections.h>
#include "mmu.h"
-#define PMD_SECT_DEF_UNCACHED (PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT)
#define PMD_SECT_DEF_CACHED (PMD_SECT_WB | PMD_SECT_DEF_UNCACHED)
static uint32_t *ttb;
@@ -459,9 +457,7 @@ static int mmu_init(void)
set_ttbr(ttb);
set_domain(DOMAIN_MANAGER);
- /* create a flat mapping using 1MiB sections */
- create_sections(ttb, 0, 0xffffffff, PMD_SECT_AP_WRITE | PMD_SECT_AP_READ |
- PMD_TYPE_SECT);
+ create_flat_mapping(ttb);
__mmu_cache_flush();
vectors_init();
diff --git a/arch/arm/cpu/mmu.h b/arch/arm/cpu/mmu.h
index fa01cbe4e9..68c13e44eb 100644
--- a/arch/arm/cpu/mmu.h
+++ b/arch/arm/cpu/mmu.h
@@ -1,6 +1,7 @@
#ifndef __ARM_MMU_H
#define __ARM_MMU_H
+#include <asm/pgtable.h>
#include <linux/sizes.h>
#ifdef CONFIG_MMU
@@ -40,5 +41,12 @@ create_sections(uint32_t *ttb, unsigned long first,
}
}
+#define PMD_SECT_DEF_UNCACHED (PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT)
+
+static inline void create_flat_mapping(uint32_t *ttb)
+{
+ /* create a flat mapping using 1MiB sections */
+ create_sections(ttb, 0, 0xffffffff, PMD_SECT_DEF_UNCACHED);
+}
#endif /* __ARM_MMU_H */