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
)
16 raw_spin_lock_irqsave(&krait_l2_lock
, flags
);
18 * Select the L2 window by poking l2cpselr, then write to the window
21 asm volatile ("mcr p15, 3, %0, c15, c0, 6 @ l2cpselr" : : "r" (addr
));
23 asm volatile ("mcr p15, 3, %0, c15, c0, 7 @ l2cpdr" : : "r" (val
));
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
)
35 raw_spin_lock_irqsave(&krait_l2_lock
, flags
);
37 * Select the L2 window by poking l2cpselr, then read from the window
40 asm volatile ("mcr p15, 3, %0, c15, c0, 6 @ l2cpselr" : : "r" (addr
));
42 asm volatile ("mrc p15, 3, %0, c15, c0, 7 @ l2cpdr" : "=r" (val
));
44 raw_spin_unlock_irqrestore(&krait_l2_lock
, flags
);
48 EXPORT_SYMBOL(krait_get_l2_indirect_reg
);