Linux 5.7.7
[linux/fpc-iii.git] / arch / arm / common / krait-l2-accessors.c
blob9a97ddadecd67963474533c8851a289f3da998ca
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2018, The Linux Foundation. All rights reserved.
4 #include <linux/spinlock.h>
5 #include <linux/export.h>
7 #include <asm/barrier.h>
8 #include <asm/krait-l2-accessors.h>
10 static DEFINE_RAW_SPINLOCK(krait_l2_lock);
12 void krait_set_l2_indirect_reg(u32 addr, u32 val)
14 unsigned long flags;
16 raw_spin_lock_irqsave(&krait_l2_lock, flags);
18 * Select the L2 window by poking l2cpselr, then write to the window
19 * via l2cpdr.
21 asm volatile ("mcr p15, 3, %0, c15, c0, 6 @ l2cpselr" : : "r" (addr));
22 isb();
23 asm volatile ("mcr p15, 3, %0, c15, c0, 7 @ l2cpdr" : : "r" (val));
24 isb();
26 raw_spin_unlock_irqrestore(&krait_l2_lock, flags);
28 EXPORT_SYMBOL(krait_set_l2_indirect_reg);
30 u32 krait_get_l2_indirect_reg(u32 addr)
32 u32 val;
33 unsigned long flags;
35 raw_spin_lock_irqsave(&krait_l2_lock, flags);
37 * Select the L2 window by poking l2cpselr, then read from the window
38 * via l2cpdr.
40 asm volatile ("mcr p15, 3, %0, c15, c0, 6 @ l2cpselr" : : "r" (addr));
41 isb();
42 asm volatile ("mrc p15, 3, %0, c15, c0, 7 @ l2cpdr" : "=r" (val));
44 raw_spin_unlock_irqrestore(&krait_l2_lock, flags);
46 return val;
48 EXPORT_SYMBOL(krait_get_l2_indirect_reg);