OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | From patchwork Fri Dec 8 09:42:19 2017 |
2 | Content-Type: text/plain; charset="utf-8" |
||
3 | MIME-Version: 1.0 |
||
4 | Content-Transfer-Encoding: 7bit |
||
5 | Subject: [v4,01/12] ARM: Add Krait L2 register accessor functions |
||
6 | From: Sricharan R <sricharan@codeaurora.org> |
||
7 | X-Patchwork-Id: 10102101 |
||
8 | Message-Id: <1512726150-7204-2-git-send-email-sricharan@codeaurora.org> |
||
9 | To: mturquette@baylibre.com, sboyd@codeaurora.org, |
||
10 | devicetree@vger.kernel.org, linux-pm@vger.kernel.org, |
||
11 | linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, |
||
12 | viresh.kumar@linaro.org, linux-arm-kernel@lists.infradead.org |
||
13 | Cc: sricharan@codeaurora.org, Mark Rutland <mark.rutland@arm.com>, |
||
14 | Russell King <linux@arm.linux.org.uk>, |
||
15 | Courtney Cavin <courtney.cavin@sonymobile.com> |
||
16 | Date: Fri, 8 Dec 2017 15:12:19 +0530 |
||
17 | |||
18 | From: Stephen Boyd <sboyd@codeaurora.org> |
||
19 | |||
20 | Krait CPUs have a handful of L2 cache controller registers that |
||
21 | live behind a cp15 based indirection register. First you program |
||
22 | the indirection register (l2cpselr) to point the L2 'window' |
||
23 | register (l2cpdr) at what you want to read/write. Then you |
||
24 | read/write the 'window' register to do what you want. The |
||
25 | l2cpselr register is not banked per-cpu so we must lock around |
||
26 | accesses to it to prevent other CPUs from re-pointing l2cpdr |
||
27 | underneath us. |
||
28 | |||
29 | Cc: Mark Rutland <mark.rutland@arm.com> |
||
30 | Cc: Russell King <linux@arm.linux.org.uk> |
||
31 | Cc: Courtney Cavin <courtney.cavin@sonymobile.com> |
||
32 | Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> |
||
33 | --- |
||
34 | arch/arm/common/Kconfig | 3 ++ |
||
35 | arch/arm/common/Makefile | 1 + |
||
36 | arch/arm/common/krait-l2-accessors.c | 58 +++++++++++++++++++++++++++++++ |
||
37 | arch/arm/include/asm/krait-l2-accessors.h | 20 +++++++++++ |
||
38 | 4 files changed, 82 insertions(+) |
||
39 | create mode 100644 arch/arm/common/krait-l2-accessors.c |
||
40 | create mode 100644 arch/arm/include/asm/krait-l2-accessors.h |
||
41 | |||
42 | --- a/arch/arm/common/Kconfig |
||
43 | +++ b/arch/arm/common/Kconfig |
||
44 | @@ -7,6 +7,9 @@ config DMABOUNCE |
||
45 | bool |
||
46 | select ZONE_DMA |
||
47 | |||
48 | +config KRAIT_L2_ACCESSORS |
||
49 | + bool |
||
50 | + |
||
51 | config SHARP_LOCOMO |
||
52 | bool |
||
53 | |||
54 | --- a/arch/arm/common/Makefile |
||
55 | +++ b/arch/arm/common/Makefile |
||
56 | @@ -7,6 +7,7 @@ obj-y += firmware.o |
||
57 | |||
58 | obj-$(CONFIG_SA1111) += sa1111.o |
||
59 | obj-$(CONFIG_DMABOUNCE) += dmabounce.o |
||
60 | +obj-$(CONFIG_KRAIT_L2_ACCESSORS) += krait-l2-accessors.o |
||
61 | obj-$(CONFIG_SHARP_LOCOMO) += locomo.o |
||
62 | obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o |
||
63 | obj-$(CONFIG_SHARP_SCOOP) += scoop.o |
||
64 | --- /dev/null |
||
65 | +++ b/arch/arm/common/krait-l2-accessors.c |
||
66 | @@ -0,0 +1,58 @@ |
||
67 | +/* |
||
68 | + * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
||
69 | + * |
||
70 | + * This program is free software; you can redistribute it and/or modify |
||
71 | + * it under the terms of the GNU General Public License version 2 and |
||
72 | + * only version 2 as published by the Free Software Foundation. |
||
73 | + * |
||
74 | + * This program is distributed in the hope that it will be useful, |
||
75 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
76 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
77 | + * GNU General Public License for more details. |
||
78 | + */ |
||
79 | + |
||
80 | +#include <linux/spinlock.h> |
||
81 | +#include <linux/export.h> |
||
82 | + |
||
83 | +#include <asm/barrier.h> |
||
84 | +#include <asm/krait-l2-accessors.h> |
||
85 | + |
||
86 | +static DEFINE_RAW_SPINLOCK(krait_l2_lock); |
||
87 | + |
||
88 | +void krait_set_l2_indirect_reg(u32 addr, u32 val) |
||
89 | +{ |
||
90 | + unsigned long flags; |
||
91 | + |
||
92 | + raw_spin_lock_irqsave(&krait_l2_lock, flags); |
||
93 | + /* |
||
94 | + * Select the L2 window by poking l2cpselr, then write to the window |
||
95 | + * via l2cpdr. |
||
96 | + */ |
||
97 | + asm volatile ("mcr p15, 3, %0, c15, c0, 6 @ l2cpselr" : : "r" (addr)); |
||
98 | + isb(); |
||
99 | + asm volatile ("mcr p15, 3, %0, c15, c0, 7 @ l2cpdr" : : "r" (val)); |
||
100 | + isb(); |
||
101 | + |
||
102 | + raw_spin_unlock_irqrestore(&krait_l2_lock, flags); |
||
103 | +} |
||
104 | +EXPORT_SYMBOL(krait_set_l2_indirect_reg); |
||
105 | + |
||
106 | +u32 krait_get_l2_indirect_reg(u32 addr) |
||
107 | +{ |
||
108 | + u32 val; |
||
109 | + unsigned long flags; |
||
110 | + |
||
111 | + raw_spin_lock_irqsave(&krait_l2_lock, flags); |
||
112 | + /* |
||
113 | + * Select the L2 window by poking l2cpselr, then read from the window |
||
114 | + * via l2cpdr. |
||
115 | + */ |
||
116 | + asm volatile ("mcr p15, 3, %0, c15, c0, 6 @ l2cpselr" : : "r" (addr)); |
||
117 | + isb(); |
||
118 | + asm volatile ("mrc p15, 3, %0, c15, c0, 7 @ l2cpdr" : "=r" (val)); |
||
119 | + |
||
120 | + raw_spin_unlock_irqrestore(&krait_l2_lock, flags); |
||
121 | + |
||
122 | + return val; |
||
123 | +} |
||
124 | +EXPORT_SYMBOL(krait_get_l2_indirect_reg); |
||
125 | --- /dev/null |
||
126 | +++ b/arch/arm/include/asm/krait-l2-accessors.h |
||
127 | @@ -0,0 +1,20 @@ |
||
128 | +/* |
||
129 | + * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
||
130 | + * |
||
131 | + * This program is free software; you can redistribute it and/or modify |
||
132 | + * it under the terms of the GNU General Public License version 2 and |
||
133 | + * only version 2 as published by the Free Software Foundation. |
||
134 | + * |
||
135 | + * This program is distributed in the hope that it will be useful, |
||
136 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
137 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
138 | + * GNU General Public License for more details. |
||
139 | + */ |
||
140 | + |
||
141 | +#ifndef __ASMARM_KRAIT_L2_ACCESSORS_H |
||
142 | +#define __ASMARM_KRAIT_L2_ACCESSORS_H |
||
143 | + |
||
144 | +extern void krait_set_l2_indirect_reg(u32 addr, u32 val); |
||
145 | +extern u32 krait_get_l2_indirect_reg(u32 addr); |
||
146 | + |
||
147 | +#endif |