import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-mt8127 / innercache.c
1 #include <linux/module.h>
2 #include <linux/interrupt.h>
3 #include <linux/cpu.h>
4 #include <linux/smp.h>
5 #include "mach/mt_reg_base.h"
6 #include "mach/sync_write.h"
7
8 /* config L2 to its size */
9 extern void __inner_flush_dcache_all(void);
10 extern void __inner_flush_dcache_L1(void);
11 extern void __inner_flush_dcache_L2(void);
12
13 /*
14 * inner_dcache_flush_all: Flush (clean + invalidate) the entire L1 data cache.
15 *
16 * This can be used ONLY by the M4U driver!!
17 * Other drivers should NOT use this function at all!!
18 * Others should use DMA-mapping APIs!!
19 *
20 * After calling the function, the buffer should not be touched anymore.
21 * And the M4U driver should then call outer_flush_all() immediately.
22 * Here is the example:
23 * // Cannot touch the buffer from here.
24 * inner_dcache_flush_all();
25 * outer_flush_all();
26 * // Can touch the buffer from here.
27 * If preemption occurs and the driver cannot guarantee that no other process will touch the buffer,
28 * the driver should use LOCK to protect this code segment.
29 */
30
31 void inner_dcache_flush_all(void)
32 {
33 __inner_flush_dcache_all();
34 }
35
36 void inner_dcache_flush_L1(void)
37 {
38 __inner_flush_dcache_L1();
39 }
40
41 void inner_dcache_flush_L2(void)
42 {
43 __inner_flush_dcache_L2();
44 }
45
46 /*
47 * smp_inner_dcache_flush_all: Flush (clean + invalidate) the entire L1 data cache.
48 *
49 * This can be used ONLY by the M4U driver!!
50 * Other drivers should NOT use this function at all!!
51 * Others should use DMA-mapping APIs!!
52 *
53 * This is the smp version of inner_dcache_flush_all().
54 * It will use IPI to do flush on all CPUs.
55 * Must not call this function with disabled interrupts or from a
56 * hardware interrupt handler or from a bottom half handler.
57 */
58 void smp_inner_dcache_flush_all(void)
59 {
60 if (in_interrupt()) {
61 printk(KERN_ERR
62 "Cannot invoke smp_inner_dcache_flush_all() in interrupt/softirq context\n");
63 return;
64 }
65 get_online_cpus();
66
67 on_each_cpu((smp_call_func_t)inner_dcache_flush_L1, NULL, true);
68 inner_dcache_flush_L2();
69
70 put_online_cpus();
71
72 }
73
74 EXPORT_SYMBOL(inner_dcache_flush_all);
75 EXPORT_SYMBOL(smp_inner_dcache_flush_all);