3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
8 /* for now: just dummy functions to satisfy the linker */
14 * Flush range from all levels of d-cache/unified-cache.
15 * Affects the range [start, start + size - 1].
17 __weak void flush_cache(unsigned long start, unsigned long size)
19 flush_dcache_range(start, start + size);
23 * Default implementation:
24 * do a range flush for the entire range
26 __weak void flush_dcache_all(void)
32 * Default implementation of enable_caches()
33 * Real implementation should be in platform code
35 __weak void enable_caches(void)
37 puts("WARNING: Caches not enabled\n");
40 __weak void invalidate_dcache_range(unsigned long start, unsigned long stop)
42 /* An empty stub, real implementation should be in platform code */
44 __weak void flush_dcache_range(unsigned long start, unsigned long stop)
46 /* An empty stub, real implementation should be in platform code */
49 int check_cache_range(unsigned long start, unsigned long stop)
53 if (start & (CONFIG_SYS_CACHELINE_SIZE - 1))
56 if (stop & (CONFIG_SYS_CACHELINE_SIZE - 1))
60 warn_non_spl("CACHE: Misaligned operation at range [%08lx, %08lx]\n",
67 #ifdef CONFIG_SYS_NONCACHED_MEMORY
69 * Reserve one MMU section worth of address space below the malloc() area that
70 * will be mapped uncached.
72 static unsigned long noncached_start;
73 static unsigned long noncached_end;
74 static unsigned long noncached_next;
76 void noncached_init(void)
78 phys_addr_t start, end;
81 end = ALIGN(mem_malloc_start, MMU_SECTION_SIZE) - MMU_SECTION_SIZE;
82 size = ALIGN(CONFIG_SYS_NONCACHED_MEMORY, MMU_SECTION_SIZE);
85 debug("mapping memory %pa-%pa non-cached\n", &start, &end);
87 noncached_start = start;
89 noncached_next = start;
91 #ifndef CONFIG_SYS_DCACHE_OFF
92 mmu_set_region_dcache_behaviour(noncached_start, size, DCACHE_OFF);
96 phys_addr_t noncached_alloc(size_t size, size_t align)
98 phys_addr_t next = ALIGN(noncached_next, align);
100 if (next >= noncached_end || (noncached_end - next) < size)
103 debug("allocated %zu bytes of uncached memory @%pa\n", size, &next);
104 noncached_next = next + size;
108 #endif /* CONFIG_SYS_NONCACHED_MEMORY */
110 #if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
111 void invalidate_l2_cache(void)
113 unsigned int val = 0;
115 asm volatile("mcr p15, 1, %0, c15, c11, 0 @ invl l2 cache"
116 : : "r" (val) : "cc");