forked from microsoft/WSL2-Linux-Kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
soc: qcom: Separate kryo l2 accessors from PMU driver
The driver provides kernel level API for other drivers to access the MSM8996 L2 cache registers. Separating the L2 access code from the PMU driver and making it public to allow other drivers use it. The accesses must be separated with a single spinlock, maintained in this driver. Signed-off-by: Ilia Lin <ilialin@codeaurora.org> Signed-off-by: Loic Poulain <loic.poulain@linaro.org> Link: https://lore.kernel.org/r/1593766185-16346-2-git-send-email-loic.poulain@linaro.org Acked-by: Will Deacon <will@kernel.org> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
- Loading branch information
Showing
6 changed files
with
99 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Copyright (c) 2018, The Linux Foundation. All rights reserved. | ||
*/ | ||
|
||
#include <linux/spinlock.h> | ||
#include <asm/barrier.h> | ||
#include <asm/sysreg.h> | ||
#include <soc/qcom/kryo-l2-accessors.h> | ||
|
||
#define L2CPUSRSELR_EL1 sys_reg(3, 3, 15, 0, 6) | ||
#define L2CPUSRDR_EL1 sys_reg(3, 3, 15, 0, 7) | ||
|
||
static DEFINE_RAW_SPINLOCK(l2_access_lock); | ||
|
||
/** | ||
* kryo_l2_set_indirect_reg() - write value to an L2 register | ||
* @reg: Address of L2 register. | ||
* @value: Value to be written to register. | ||
* | ||
* Use architecturally required barriers for ordering between system register | ||
* accesses, and system registers with respect to device memory | ||
*/ | ||
void kryo_l2_set_indirect_reg(u64 reg, u64 val) | ||
{ | ||
unsigned long flags; | ||
|
||
raw_spin_lock_irqsave(&l2_access_lock, flags); | ||
write_sysreg_s(reg, L2CPUSRSELR_EL1); | ||
isb(); | ||
write_sysreg_s(val, L2CPUSRDR_EL1); | ||
isb(); | ||
raw_spin_unlock_irqrestore(&l2_access_lock, flags); | ||
} | ||
EXPORT_SYMBOL(kryo_l2_set_indirect_reg); | ||
|
||
/** | ||
* kryo_l2_get_indirect_reg() - read an L2 register value | ||
* @reg: Address of L2 register. | ||
* | ||
* Use architecturally required barriers for ordering between system register | ||
* accesses, and system registers with respect to device memory | ||
*/ | ||
u64 kryo_l2_get_indirect_reg(u64 reg) | ||
{ | ||
u64 val; | ||
unsigned long flags; | ||
|
||
raw_spin_lock_irqsave(&l2_access_lock, flags); | ||
write_sysreg_s(reg, L2CPUSRSELR_EL1); | ||
isb(); | ||
val = read_sysreg_s(L2CPUSRDR_EL1); | ||
raw_spin_unlock_irqrestore(&l2_access_lock, flags); | ||
|
||
return val; | ||
} | ||
EXPORT_SYMBOL(kryo_l2_get_indirect_reg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* Copyright (c) 2018, The Linux Foundation. All rights reserved. | ||
*/ | ||
|
||
#ifndef __SOC_ARCH_QCOM_KRYO_L2_ACCESSORS_H | ||
#define __SOC_ARCH_QCOM_KRYO_L2_ACCESSORS_H | ||
|
||
void kryo_l2_set_indirect_reg(u64 reg, u64 val); | ||
u64 kryo_l2_get_indirect_reg(u64 reg); | ||
|
||
#endif |