1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
6 #include <linux/spinlock.h>
7 #include <asm/barrier.h>
8 #include <asm/sysreg.h>
9 #include <soc/qcom/kryo-l2-accessors.h>
11 #define L2CPUSRSELR_EL1 sys_reg(3, 3, 15, 0, 6)
12 #define L2CPUSRDR_EL1 sys_reg(3, 3, 15, 0, 7)
14 static DEFINE_RAW_SPINLOCK(l2_access_lock
);
17 * kryo_l2_set_indirect_reg() - write value to an L2 register
18 * @reg: Address of L2 register.
19 * @val: Value to be written to register.
21 * Use architecturally required barriers for ordering between system register
22 * accesses, and system registers with respect to device memory
24 void kryo_l2_set_indirect_reg(u64 reg
, u64 val
)
28 raw_spin_lock_irqsave(&l2_access_lock
, flags
);
29 write_sysreg_s(reg
, L2CPUSRSELR_EL1
);
31 write_sysreg_s(val
, L2CPUSRDR_EL1
);
33 raw_spin_unlock_irqrestore(&l2_access_lock
, flags
);
35 EXPORT_SYMBOL(kryo_l2_set_indirect_reg
);
38 * kryo_l2_get_indirect_reg() - read an L2 register value
39 * @reg: Address of L2 register.
41 * Use architecturally required barriers for ordering between system register
42 * accesses, and system registers with respect to device memory
44 u64
kryo_l2_get_indirect_reg(u64 reg
)
49 raw_spin_lock_irqsave(&l2_access_lock
, flags
);
50 write_sysreg_s(reg
, L2CPUSRSELR_EL1
);
52 val
= read_sysreg_s(L2CPUSRDR_EL1
);
53 raw_spin_unlock_irqrestore(&l2_access_lock
, flags
);
57 EXPORT_SYMBOL(kryo_l2_get_indirect_reg
);