bcm53xx: add early support for Linksys EA6300 V1
[openwrt/openwrt.git] / target / linux / bcm53xx / patches-4.1 / 073-ARM-l2c-only-unlock-caches-if-NS_LOCKDOWN-bit-is-set.patch
1 From e946a8cbe4a47a7c2615ffb0d45712e72c7d0f3a Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@arm.linux.org.uk>
3 Date: Fri, 15 May 2015 11:51:51 +0100
4 Subject: [PATCH 73/74] ARM: l2c: only unlock caches if NS_LOCKDOWN bit is set
5
6 Some L2C caches have a bit which allows non-secure software to control
7 the cache lockdown. Some platforms are unable to set this bit. To
8 avoid receiving an abort while trying to unlock the cache lines, check
9 the state of this bit before unlocking. We do this by providing a new
10 method in the l2c_init_data to perform the unlocking.
11
12 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
13 ---
14 arch/arm/mm/cache-l2x0.c | 26 +++++++++++++++++++++++++-
15 1 file changed, 25 insertions(+), 1 deletion(-)
16
17 --- a/arch/arm/mm/cache-l2x0.c
18 +++ b/arch/arm/mm/cache-l2x0.c
19 @@ -42,6 +42,7 @@ struct l2c_init_data {
20 void (*fixup)(void __iomem *, u32, struct outer_cache_fns *);
21 void (*save)(void __iomem *);
22 void (*configure)(void __iomem *);
23 + void (*unlock)(void __iomem *, unsigned);
24 struct outer_cache_fns outer_cache;
25 };
26
27 @@ -128,7 +129,7 @@ static void l2c_enable(void __iomem *bas
28 else
29 l2x0_data->configure(base);
30
31 - l2c_unlock(base, num_lock);
32 + l2x0_data->unlock(base, num_lock);
33
34 local_irq_save(flags);
35 __l2c_op_way(base + L2X0_INV_WAY);
36 @@ -249,6 +250,7 @@ static const struct l2c_init_data l2c210
37 .enable = l2c_enable,
38 .save = l2c_save,
39 .configure = l2c_configure,
40 + .unlock = l2c_unlock,
41 .outer_cache = {
42 .inv_range = l2c210_inv_range,
43 .clean_range = l2c210_clean_range,
44 @@ -400,6 +402,12 @@ static void l2c220_enable(void __iomem *
45 l2c_enable(base, aux, num_lock);
46 }
47
48 +static void l2c220_unlock(void __iomem *base, unsigned num_lock)
49 +{
50 + if (readl_relaxed(base + L2X0_AUX_CTRL) & L220_AUX_CTRL_NS_LOCKDOWN)
51 + l2c_unlock(base, num_lock);
52 +}
53 +
54 static const struct l2c_init_data l2c220_data = {
55 .type = "L2C-220",
56 .way_size_0 = SZ_8K,
57 @@ -407,6 +415,7 @@ static const struct l2c_init_data l2c220
58 .enable = l2c220_enable,
59 .save = l2c_save,
60 .configure = l2c_configure,
61 + .unlock = l2c220_unlock,
62 .outer_cache = {
63 .inv_range = l2c220_inv_range,
64 .clean_range = l2c220_clean_range,
65 @@ -755,6 +764,12 @@ static void l2c310_resume(void)
66 set_auxcr(get_auxcr() | BIT(3) | BIT(2) | BIT(1));
67 }
68
69 +static void l2c310_unlock(void __iomem *base, unsigned num_lock)
70 +{
71 + if (readl_relaxed(base + L2X0_AUX_CTRL) & L310_AUX_CTRL_NS_LOCKDOWN)
72 + l2c_unlock(base, num_lock);
73 +}
74 +
75 static const struct l2c_init_data l2c310_init_fns __initconst = {
76 .type = "L2C-310",
77 .way_size_0 = SZ_8K,
78 @@ -763,6 +778,7 @@ static const struct l2c_init_data l2c310
79 .fixup = l2c310_fixup,
80 .save = l2c310_save,
81 .configure = l2c310_configure,
82 + .unlock = l2c310_unlock,
83 .outer_cache = {
84 .inv_range = l2c210_inv_range,
85 .clean_range = l2c210_clean_range,
86 @@ -1067,6 +1083,7 @@ static const struct l2c_init_data of_l2c
87 .enable = l2c_enable,
88 .save = l2c_save,
89 .configure = l2c_configure,
90 + .unlock = l2c_unlock,
91 .outer_cache = {
92 .inv_range = l2c210_inv_range,
93 .clean_range = l2c210_clean_range,
94 @@ -1086,6 +1103,7 @@ static const struct l2c_init_data of_l2c
95 .enable = l2c220_enable,
96 .save = l2c_save,
97 .configure = l2c_configure,
98 + .unlock = l2c220_unlock,
99 .outer_cache = {
100 .inv_range = l2c220_inv_range,
101 .clean_range = l2c220_clean_range,
102 @@ -1213,6 +1231,7 @@ static const struct l2c_init_data of_l2c
103 .fixup = l2c310_fixup,
104 .save = l2c310_save,
105 .configure = l2c310_configure,
106 + .unlock = l2c310_unlock,
107 .outer_cache = {
108 .inv_range = l2c210_inv_range,
109 .clean_range = l2c210_clean_range,
110 @@ -1242,6 +1261,7 @@ static const struct l2c_init_data of_l2c
111 .fixup = l2c310_fixup,
112 .save = l2c310_save,
113 .configure = l2c310_configure,
114 + .unlock = l2c310_unlock,
115 .outer_cache = {
116 .inv_range = l2c210_inv_range,
117 .clean_range = l2c210_clean_range,
118 @@ -1419,6 +1439,7 @@ static const struct l2c_init_data of_aur
119 .fixup = aurora_fixup,
120 .save = aurora_save,
121 .configure = l2c_configure,
122 + .unlock = l2c_unlock,
123 .outer_cache = {
124 .inv_range = aurora_inv_range,
125 .clean_range = aurora_clean_range,
126 @@ -1439,6 +1460,7 @@ static const struct l2c_init_data of_aur
127 .fixup = aurora_fixup,
128 .save = aurora_save,
129 .configure = l2c_configure,
130 + .unlock = l2c_unlock,
131 .outer_cache = {
132 .resume = l2c_resume,
133 },
134 @@ -1589,6 +1611,7 @@ static const struct l2c_init_data of_bcm
135 .enable = l2c310_enable,
136 .save = l2c310_save,
137 .configure = l2c310_configure,
138 + .unlock = l2c310_unlock,
139 .outer_cache = {
140 .inv_range = bcm_inv_range,
141 .clean_range = bcm_clean_range,
142 @@ -1626,6 +1649,7 @@ static const struct l2c_init_data of_tau
143 .enable = l2c_enable,
144 .save = tauros3_save,
145 .configure = tauros3_configure,
146 + .unlock = l2c_unlock,
147 /* Tauros3 broadcasts L1 cache operations to L2 */
148 .outer_cache = {
149 .resume = l2c_resume,