]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
armv8: caches: Added routine to set non cacheable region
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Sat, 6 Dec 2014 07:27:52 +0000 (12:57 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 8 Dec 2014 09:43:42 +0000 (10:43 +0100)
Added routine mmu_set_region_dcache_behaviour() to set a
particular region as non cacheable.

Define dummy routine for mmu_set_region_dcache_behaviour()
to handle incase of dcahe off

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/arm/cpu/armv8/cache_v8.c
arch/arm/include/asm/system.h

index 9dbcdf22afe266e35eb40804b267f51c5f2c8e65..3b63571d970022cdd5a72a417de5cab13c4e24aa 100644 (file)
@@ -135,6 +135,24 @@ int dcache_status(void)
        return (get_sctlr() & CR_C) != 0;
 }
 
+void mmu_set_region_dcache_behaviour(u32 start, int size,
+                                    enum dcache_option option)
+{
+       /* get the level2_table0 start address */
+       u64 *page_table = (u64 *)(gd->arch.tlb_addr + 0x3000);
+       u64 upto, end;
+
+       end = ALIGN(start + size, (1 << MMU_SECTION_SHIFT)) >>
+             MMU_SECTION_SHIFT;
+       start = start >> MMU_SECTION_SHIFT;
+       for (upto = start; upto < end; upto++) {
+               page_table[upto] &= ~PMD_ATTRINDX_MASK;
+               page_table[upto] |= PMD_ATTRINDX(option);
+       }
+
+       flush_dcache_range(page_table[start], page_table[end]);
+       __asm_invalidate_tlb_all();
+}
 #else  /* CONFIG_SYS_DCACHE_OFF */
 
 void invalidate_dcache_all(void)
@@ -166,6 +184,11 @@ int dcache_status(void)
        return 0;
 }
 
+void mmu_set_region_dcache_behaviour(u32 start, int size,
+                                    enum dcache_option option)
+{
+}
+
 #endif /* CONFIG_SYS_DCACHE_OFF */
 
 #ifndef CONFIG_SYS_ICACHE_OFF
index ca2d44faf4e935e7f80f7acff6adb5e96192d5cf..fa2fd124f26a7adf824060a5302eb93ff10a7aab 100644 (file)
 #define CR_EE          (1 << 25)       /* Exception (Big) Endian       */
 
 #define PGTABLE_SIZE   (0x10000)
+/* 2M granularity */
+#define MMU_SECTION_SHIFT      21
 
 #ifndef __ASSEMBLY__
 
+enum dcache_option {
+       DCACHE_OFF = 0x3,
+};
+
 #define isb()                          \
        ({asm volatile(                 \
        "isb" : : : "memory");          \
@@ -194,16 +200,6 @@ enum {
        MMU_SECTION_SIZE        = 1 << MMU_SECTION_SHIFT,
 };
 
-/**
- * Change the cache settings for a region.
- *
- * \param start                start address of memory region to change
- * \param size         size of memory region to change
- * \param option       dcache option to select
- */
-void mmu_set_region_dcache_behaviour(u32 start, int size,
-                                    enum dcache_option option);
-
 /**
  * Register an update to the page tables, and flush the TLB
  *
@@ -220,4 +216,16 @@ void mmu_page_table_flush(unsigned long start, unsigned long stop);
 
 #endif /* CONFIG_ARM64 */
 
+#ifndef __ASSEMBLY__
+/**
+ * Change the cache settings for a region.
+ *
+ * \param start                start address of memory region to change
+ * \param size         size of memory region to change
+ * \param option       dcache option to select
+ */
+void mmu_set_region_dcache_behaviour(u32 start, int size,
+                                    enum dcache_option option);
+#endif /* __ASSEMBLY__ */
+
 #endif