@@ -9,6 +9,7 @@
#include <auxinfo.h>
#include <asm/thread_info.h>
#include <asm/asm-offsets.h>
+#include <asm/pgtable-hwdef.h>
#include <asm/ptrace.h>
#include <asm/sysreg.h>
@@ -166,9 +167,11 @@ halt:
.globl asm_mmu_enable
asm_mmu_enable:
/* TTBCR */
- mrc p15, 0, r2, c2, c0, 2
- orr r2, #(1 << 31) @ TTB_EAE
+ ldr r2, =(TTBCR_EAE | \
+ TTBCR_SH0_SHARED | \
+ TTBCR_IRGN0_WBWA | TTBCR_ORGN0_WBWA)
mcr p15, 0, r2, c2, c0, 2
+ isb
/* MAIR */
ldr r2, =PRRR
@@ -31,8 +31,8 @@ static inline void flush_tlb_all(void)
static inline void flush_tlb_page(unsigned long vaddr)
{
- /* TLBIMVAA */
- asm volatile("mcr p15, 0, %0, c8, c7, 3" :: "r" (vaddr));
+ /* TLBIMVAAIS */
+ asm volatile("mcr p15, 0, %0, c8, c3, 3" :: "r" (vaddr));
dsb();
isb();
}
@@ -108,4 +108,12 @@
#define PHYS_MASK_SHIFT (40)
#define PHYS_MASK ((_AC(1, ULL) << PHYS_MASK_SHIFT) - 1)
+#define TTBCR_IRGN0_WBWA (_AC(1, UL) << 8)
+#define TTBCR_ORGN0_WBWA (_AC(1, UL) << 10)
+#define TTBCR_SH0_SHARED (_AC(3, UL) << 12)
+#define TTBCR_IRGN1_WBWA (_AC(1, UL) << 24)
+#define TTBCR_ORGN1_WBWA (_AC(1, UL) << 26)
+#define TTBCR_SH1_SHARED (_AC(3, UL) << 28)
+#define TTBCR_EAE (_AC(1, UL) << 31)
+
#endif /* _ASMARM_PGTABLE_HWDEF_H_ */
@@ -73,17 +73,6 @@ void mmu_disable(void)
asm_mmu_disable();
}
-static void flush_entry(pgd_t *pgtable, uintptr_t vaddr)
-{
- pgd_t *pgd = pgd_offset(pgtable, vaddr);
- pmd_t *pmd = pmd_offset(pgd, vaddr);
-
- flush_dcache_addr((ulong)pgd);
- flush_dcache_addr((ulong)pmd);
- flush_dcache_addr((ulong)pte_offset(pmd, vaddr));
- flush_tlb_page(vaddr);
-}
-
static pteval_t *get_pte(pgd_t *pgtable, uintptr_t vaddr)
{
pgd_t *pgd = pgd_offset(pgtable, vaddr);
@@ -98,7 +87,7 @@ static pteval_t *install_pte(pgd_t *pgtable, uintptr_t vaddr, pteval_t pte)
pteval_t *p_pte = get_pte(pgtable, vaddr);
*p_pte = pte;
- flush_entry(pgtable, vaddr);
+ flush_tlb_page(vaddr);
return p_pte;
}
@@ -148,7 +137,6 @@ void mmu_set_range_sect(pgd_t *pgtable, uintptr_t virt_offset,
pgd_val(*pgd) = paddr;
pgd_val(*pgd) |= PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S;
pgd_val(*pgd) |= pgprot_val(prot);
- flush_dcache_addr((ulong)pgd);
flush_tlb_page(vaddr);
}
}