Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mm/cache-l2x0.c - L210/L220 cache controller support |
| 3 | * |
| 4 | * Copyright (C) 2007 ARM Limited |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 19 | #include <linux/err.h> |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 20 | #include <linux/init.h> |
Catalin Marinas | 0762097 | 2007-07-20 11:42:40 +0100 | [diff] [blame] | 21 | #include <linux/spinlock.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 22 | #include <linux/io.h> |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 23 | #include <linux/of.h> |
| 24 | #include <linux/of_address.h> |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 25 | |
| 26 | #include <asm/cacheflush.h> |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 27 | #include <asm/hardware/cache-l2x0.h> |
| 28 | |
| 29 | #define CACHE_LINE_SIZE 32 |
| 30 | |
| 31 | static void __iomem *l2x0_base; |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 32 | static DEFINE_RAW_SPINLOCK(l2x0_lock); |
Russell King | 3e175ca | 2011-09-18 11:27:30 +0100 | [diff] [blame] | 33 | static u32 l2x0_way_mask; /* Bitmask of active ways */ |
| 34 | static u32 l2x0_size; |
Will Deacon | f154fe9 | 2012-04-20 17:21:08 +0100 | [diff] [blame] | 35 | static unsigned long sync_reg_offset = L2X0_CACHE_SYNC; |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 36 | |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 37 | struct l2x0_regs l2x0_saved_regs; |
| 38 | |
| 39 | struct l2x0_of_data { |
Russell King | 3e175ca | 2011-09-18 11:27:30 +0100 | [diff] [blame] | 40 | void (*setup)(const struct device_node *, u32 *, u32 *); |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 41 | void (*save)(void); |
Gregory CLEMENT | 6248d06 | 2012-10-01 10:56:42 +0100 | [diff] [blame^] | 42 | struct outer_cache_fns outer_cache; |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 43 | }; |
| 44 | |
Gregory CLEMENT | 6248d06 | 2012-10-01 10:56:42 +0100 | [diff] [blame^] | 45 | static bool of_init = false; |
| 46 | |
Catalin Marinas | 9a6655e | 2010-08-31 13:05:22 +0100 | [diff] [blame] | 47 | static inline void cache_wait_way(void __iomem *reg, unsigned long mask) |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 48 | { |
Catalin Marinas | 9a6655e | 2010-08-31 13:05:22 +0100 | [diff] [blame] | 49 | /* wait for cache operation by line or way to complete */ |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 50 | while (readl_relaxed(reg) & mask) |
Barry Song | 1caf309 | 2011-09-09 10:30:34 +0100 | [diff] [blame] | 51 | cpu_relax(); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 52 | } |
| 53 | |
Catalin Marinas | 9a6655e | 2010-08-31 13:05:22 +0100 | [diff] [blame] | 54 | #ifdef CONFIG_CACHE_PL310 |
| 55 | static inline void cache_wait(void __iomem *reg, unsigned long mask) |
| 56 | { |
| 57 | /* cache operations by line are atomic on PL310 */ |
| 58 | } |
| 59 | #else |
| 60 | #define cache_wait cache_wait_way |
| 61 | #endif |
| 62 | |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 63 | static inline void cache_sync(void) |
| 64 | { |
Russell King | 3d10743 | 2009-11-19 11:41:09 +0000 | [diff] [blame] | 65 | void __iomem *base = l2x0_base; |
Srinidhi Kasagar | 885028e | 2011-02-17 07:03:51 +0100 | [diff] [blame] | 66 | |
Will Deacon | f154fe9 | 2012-04-20 17:21:08 +0100 | [diff] [blame] | 67 | writel_relaxed(0, base + sync_reg_offset); |
Russell King | 3d10743 | 2009-11-19 11:41:09 +0000 | [diff] [blame] | 68 | cache_wait(base + L2X0_CACHE_SYNC, 1); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 69 | } |
| 70 | |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 71 | static inline void l2x0_clean_line(unsigned long addr) |
| 72 | { |
| 73 | void __iomem *base = l2x0_base; |
| 74 | cache_wait(base + L2X0_CLEAN_LINE_PA, 1); |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 75 | writel_relaxed(addr, base + L2X0_CLEAN_LINE_PA); |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | static inline void l2x0_inv_line(unsigned long addr) |
| 79 | { |
| 80 | void __iomem *base = l2x0_base; |
| 81 | cache_wait(base + L2X0_INV_LINE_PA, 1); |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 82 | writel_relaxed(addr, base + L2X0_INV_LINE_PA); |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 83 | } |
| 84 | |
Santosh Shilimkar | 2839e06 | 2011-03-08 06:59:54 +0100 | [diff] [blame] | 85 | #if defined(CONFIG_PL310_ERRATA_588369) || defined(CONFIG_PL310_ERRATA_727915) |
Will Deacon | ab4d536 | 2012-04-20 17:22:11 +0100 | [diff] [blame] | 86 | static inline void debug_writel(unsigned long val) |
| 87 | { |
| 88 | if (outer_cache.set_debug) |
| 89 | outer_cache.set_debug(val); |
| 90 | } |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 91 | |
Will Deacon | ab4d536 | 2012-04-20 17:22:11 +0100 | [diff] [blame] | 92 | static void pl310_set_debug(unsigned long val) |
Santosh Shilimkar | 2839e06 | 2011-03-08 06:59:54 +0100 | [diff] [blame] | 93 | { |
| 94 | writel_relaxed(val, l2x0_base + L2X0_DEBUG_CTRL); |
| 95 | } |
| 96 | #else |
| 97 | /* Optimised out for non-errata case */ |
| 98 | static inline void debug_writel(unsigned long val) |
| 99 | { |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 100 | } |
| 101 | |
Will Deacon | ab4d536 | 2012-04-20 17:22:11 +0100 | [diff] [blame] | 102 | #define pl310_set_debug NULL |
Santosh Shilimkar | 2839e06 | 2011-03-08 06:59:54 +0100 | [diff] [blame] | 103 | #endif |
| 104 | |
| 105 | #ifdef CONFIG_PL310_ERRATA_588369 |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 106 | static inline void l2x0_flush_line(unsigned long addr) |
| 107 | { |
| 108 | void __iomem *base = l2x0_base; |
| 109 | |
| 110 | /* Clean by PA followed by Invalidate by PA */ |
| 111 | cache_wait(base + L2X0_CLEAN_LINE_PA, 1); |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 112 | writel_relaxed(addr, base + L2X0_CLEAN_LINE_PA); |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 113 | cache_wait(base + L2X0_INV_LINE_PA, 1); |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 114 | writel_relaxed(addr, base + L2X0_INV_LINE_PA); |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 115 | } |
| 116 | #else |
| 117 | |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 118 | static inline void l2x0_flush_line(unsigned long addr) |
| 119 | { |
| 120 | void __iomem *base = l2x0_base; |
| 121 | cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1); |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 122 | writel_relaxed(addr, base + L2X0_CLEAN_INV_LINE_PA); |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 123 | } |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 124 | #endif |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 125 | |
Catalin Marinas | 23107c5 | 2010-03-24 16:48:53 +0100 | [diff] [blame] | 126 | static void l2x0_cache_sync(void) |
| 127 | { |
| 128 | unsigned long flags; |
| 129 | |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 130 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Catalin Marinas | 23107c5 | 2010-03-24 16:48:53 +0100 | [diff] [blame] | 131 | cache_sync(); |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 132 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
Catalin Marinas | 23107c5 | 2010-03-24 16:48:53 +0100 | [diff] [blame] | 133 | } |
| 134 | |
Will Deacon | 38a8914 | 2011-07-01 14:36:19 +0100 | [diff] [blame] | 135 | static void __l2x0_flush_all(void) |
| 136 | { |
| 137 | debug_writel(0x03); |
| 138 | writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_CLEAN_INV_WAY); |
| 139 | cache_wait_way(l2x0_base + L2X0_CLEAN_INV_WAY, l2x0_way_mask); |
| 140 | cache_sync(); |
| 141 | debug_writel(0x00); |
| 142 | } |
| 143 | |
Thomas Gleixner | 2fd8658 | 2010-07-31 21:05:24 +0530 | [diff] [blame] | 144 | static void l2x0_flush_all(void) |
| 145 | { |
| 146 | unsigned long flags; |
| 147 | |
| 148 | /* clean all ways */ |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 149 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Will Deacon | 38a8914 | 2011-07-01 14:36:19 +0100 | [diff] [blame] | 150 | __l2x0_flush_all(); |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 151 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
Thomas Gleixner | 2fd8658 | 2010-07-31 21:05:24 +0530 | [diff] [blame] | 152 | } |
| 153 | |
Santosh Shilimkar | 444457c | 2010-07-11 14:58:41 +0530 | [diff] [blame] | 154 | static void l2x0_clean_all(void) |
| 155 | { |
| 156 | unsigned long flags; |
| 157 | |
| 158 | /* clean all ways */ |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 159 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Santosh Shilimkar | 444457c | 2010-07-11 14:58:41 +0530 | [diff] [blame] | 160 | writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_CLEAN_WAY); |
| 161 | cache_wait_way(l2x0_base + L2X0_CLEAN_WAY, l2x0_way_mask); |
| 162 | cache_sync(); |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 163 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
Santosh Shilimkar | 444457c | 2010-07-11 14:58:41 +0530 | [diff] [blame] | 164 | } |
| 165 | |
Thomas Gleixner | 2fd8658 | 2010-07-31 21:05:24 +0530 | [diff] [blame] | 166 | static void l2x0_inv_all(void) |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 167 | { |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 168 | unsigned long flags; |
| 169 | |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 170 | /* invalidate all ways */ |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 171 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Thomas Gleixner | 2fd8658 | 2010-07-31 21:05:24 +0530 | [diff] [blame] | 172 | /* Invalidating when L2 is enabled is a nono */ |
| 173 | BUG_ON(readl(l2x0_base + L2X0_CTRL) & 1); |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 174 | writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_INV_WAY); |
Catalin Marinas | 9a6655e | 2010-08-31 13:05:22 +0100 | [diff] [blame] | 175 | cache_wait_way(l2x0_base + L2X0_INV_WAY, l2x0_way_mask); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 176 | cache_sync(); |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 177 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | static void l2x0_inv_range(unsigned long start, unsigned long end) |
| 181 | { |
Russell King | 3d10743 | 2009-11-19 11:41:09 +0000 | [diff] [blame] | 182 | void __iomem *base = l2x0_base; |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 183 | unsigned long flags; |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 184 | |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 185 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Rui Sousa | 4f6627a | 2007-09-15 00:56:19 +0100 | [diff] [blame] | 186 | if (start & (CACHE_LINE_SIZE - 1)) { |
| 187 | start &= ~(CACHE_LINE_SIZE - 1); |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 188 | debug_writel(0x03); |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 189 | l2x0_flush_line(start); |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 190 | debug_writel(0x00); |
Rui Sousa | 4f6627a | 2007-09-15 00:56:19 +0100 | [diff] [blame] | 191 | start += CACHE_LINE_SIZE; |
| 192 | } |
| 193 | |
| 194 | if (end & (CACHE_LINE_SIZE - 1)) { |
| 195 | end &= ~(CACHE_LINE_SIZE - 1); |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 196 | debug_writel(0x03); |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 197 | l2x0_flush_line(end); |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 198 | debug_writel(0x00); |
Rui Sousa | 4f6627a | 2007-09-15 00:56:19 +0100 | [diff] [blame] | 199 | } |
| 200 | |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 201 | while (start < end) { |
| 202 | unsigned long blk_end = start + min(end - start, 4096UL); |
| 203 | |
| 204 | while (start < blk_end) { |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 205 | l2x0_inv_line(start); |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 206 | start += CACHE_LINE_SIZE; |
| 207 | } |
| 208 | |
| 209 | if (blk_end < end) { |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 210 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
| 211 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 212 | } |
| 213 | } |
Russell King | 3d10743 | 2009-11-19 11:41:09 +0000 | [diff] [blame] | 214 | cache_wait(base + L2X0_INV_LINE_PA, 1); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 215 | cache_sync(); |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 216 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | static void l2x0_clean_range(unsigned long start, unsigned long end) |
| 220 | { |
Russell King | 3d10743 | 2009-11-19 11:41:09 +0000 | [diff] [blame] | 221 | void __iomem *base = l2x0_base; |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 222 | unsigned long flags; |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 223 | |
Santosh Shilimkar | 444457c | 2010-07-11 14:58:41 +0530 | [diff] [blame] | 224 | if ((end - start) >= l2x0_size) { |
| 225 | l2x0_clean_all(); |
| 226 | return; |
| 227 | } |
| 228 | |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 229 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 230 | start &= ~(CACHE_LINE_SIZE - 1); |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 231 | while (start < end) { |
| 232 | unsigned long blk_end = start + min(end - start, 4096UL); |
| 233 | |
| 234 | while (start < blk_end) { |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 235 | l2x0_clean_line(start); |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 236 | start += CACHE_LINE_SIZE; |
| 237 | } |
| 238 | |
| 239 | if (blk_end < end) { |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 240 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
| 241 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 242 | } |
| 243 | } |
Russell King | 3d10743 | 2009-11-19 11:41:09 +0000 | [diff] [blame] | 244 | cache_wait(base + L2X0_CLEAN_LINE_PA, 1); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 245 | cache_sync(); |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 246 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | static void l2x0_flush_range(unsigned long start, unsigned long end) |
| 250 | { |
Russell King | 3d10743 | 2009-11-19 11:41:09 +0000 | [diff] [blame] | 251 | void __iomem *base = l2x0_base; |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 252 | unsigned long flags; |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 253 | |
Santosh Shilimkar | 444457c | 2010-07-11 14:58:41 +0530 | [diff] [blame] | 254 | if ((end - start) >= l2x0_size) { |
| 255 | l2x0_flush_all(); |
| 256 | return; |
| 257 | } |
| 258 | |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 259 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 260 | start &= ~(CACHE_LINE_SIZE - 1); |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 261 | while (start < end) { |
| 262 | unsigned long blk_end = start + min(end - start, 4096UL); |
| 263 | |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 264 | debug_writel(0x03); |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 265 | while (start < blk_end) { |
Santosh Shilimkar | 424d6b1 | 2010-02-04 19:35:06 +0100 | [diff] [blame] | 266 | l2x0_flush_line(start); |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 267 | start += CACHE_LINE_SIZE; |
| 268 | } |
Santosh Shilimkar | 9e65582 | 2010-02-04 19:42:42 +0100 | [diff] [blame] | 269 | debug_writel(0x00); |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 270 | |
| 271 | if (blk_end < end) { |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 272 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
| 273 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Russell King | 0eb948d | 2009-11-19 11:12:15 +0000 | [diff] [blame] | 274 | } |
| 275 | } |
Russell King | 3d10743 | 2009-11-19 11:41:09 +0000 | [diff] [blame] | 276 | cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 277 | cache_sync(); |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 278 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 279 | } |
| 280 | |
Thomas Gleixner | 2fd8658 | 2010-07-31 21:05:24 +0530 | [diff] [blame] | 281 | static void l2x0_disable(void) |
| 282 | { |
| 283 | unsigned long flags; |
| 284 | |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 285 | raw_spin_lock_irqsave(&l2x0_lock, flags); |
Will Deacon | 38a8914 | 2011-07-01 14:36:19 +0100 | [diff] [blame] | 286 | __l2x0_flush_all(); |
| 287 | writel_relaxed(0, l2x0_base + L2X0_CTRL); |
| 288 | dsb(); |
Thomas Gleixner | bd31b85 | 2009-07-03 08:44:46 -0500 | [diff] [blame] | 289 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
Thomas Gleixner | 2fd8658 | 2010-07-31 21:05:24 +0530 | [diff] [blame] | 290 | } |
| 291 | |
Russell King | 3e175ca | 2011-09-18 11:27:30 +0100 | [diff] [blame] | 292 | static void l2x0_unlock(u32 cache_id) |
Linus Walleij | bac7e6e | 2011-09-06 07:45:46 +0100 | [diff] [blame] | 293 | { |
| 294 | int lockregs; |
| 295 | int i; |
| 296 | |
| 297 | if (cache_id == L2X0_CACHE_ID_PART_L310) |
| 298 | lockregs = 8; |
| 299 | else |
| 300 | /* L210 and unknown types */ |
| 301 | lockregs = 1; |
| 302 | |
| 303 | for (i = 0; i < lockregs; i++) { |
| 304 | writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_D_BASE + |
| 305 | i * L2X0_LOCKDOWN_STRIDE); |
| 306 | writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_I_BASE + |
| 307 | i * L2X0_LOCKDOWN_STRIDE); |
| 308 | } |
| 309 | } |
| 310 | |
Russell King | 3e175ca | 2011-09-18 11:27:30 +0100 | [diff] [blame] | 311 | void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 312 | { |
Russell King | 3e175ca | 2011-09-18 11:27:30 +0100 | [diff] [blame] | 313 | u32 aux; |
| 314 | u32 cache_id; |
| 315 | u32 way_size = 0; |
Jason McMullan | 64039be | 2010-05-05 18:59:37 +0100 | [diff] [blame] | 316 | int ways; |
| 317 | const char *type; |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 318 | |
| 319 | l2x0_base = base; |
| 320 | |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 321 | cache_id = readl_relaxed(l2x0_base + L2X0_CACHE_ID); |
| 322 | aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); |
Jason McMullan | 64039be | 2010-05-05 18:59:37 +0100 | [diff] [blame] | 323 | |
Sascha Hauer | 4082cfa | 2010-07-08 08:36:21 +0100 | [diff] [blame] | 324 | aux &= aux_mask; |
| 325 | aux |= aux_val; |
| 326 | |
Jason McMullan | 64039be | 2010-05-05 18:59:37 +0100 | [diff] [blame] | 327 | /* Determine the number of ways */ |
| 328 | switch (cache_id & L2X0_CACHE_ID_PART_MASK) { |
| 329 | case L2X0_CACHE_ID_PART_L310: |
| 330 | if (aux & (1 << 16)) |
| 331 | ways = 16; |
| 332 | else |
| 333 | ways = 8; |
| 334 | type = "L310"; |
Will Deacon | f154fe9 | 2012-04-20 17:21:08 +0100 | [diff] [blame] | 335 | #ifdef CONFIG_PL310_ERRATA_753970 |
| 336 | /* Unmapped register. */ |
| 337 | sync_reg_offset = L2X0_DUMMY_REG; |
| 338 | #endif |
Will Deacon | ab4d536 | 2012-04-20 17:22:11 +0100 | [diff] [blame] | 339 | outer_cache.set_debug = pl310_set_debug; |
Jason McMullan | 64039be | 2010-05-05 18:59:37 +0100 | [diff] [blame] | 340 | break; |
| 341 | case L2X0_CACHE_ID_PART_L210: |
| 342 | ways = (aux >> 13) & 0xf; |
| 343 | type = "L210"; |
| 344 | break; |
| 345 | default: |
| 346 | /* Assume unknown chips have 8 ways */ |
| 347 | ways = 8; |
| 348 | type = "L2x0 series"; |
| 349 | break; |
| 350 | } |
| 351 | |
| 352 | l2x0_way_mask = (1 << ways) - 1; |
| 353 | |
Srinidhi Kasagar | 48371cd | 2009-12-02 06:18:03 +0100 | [diff] [blame] | 354 | /* |
Santosh Shilimkar | 5ba7037 | 2010-07-11 14:35:37 +0530 | [diff] [blame] | 355 | * L2 cache Size = Way size * Number of ways |
| 356 | */ |
| 357 | way_size = (aux & L2X0_AUX_CTRL_WAY_SIZE_MASK) >> 17; |
| 358 | way_size = 1 << (way_size + 3); |
| 359 | l2x0_size = ways * way_size * SZ_1K; |
| 360 | |
| 361 | /* |
Srinidhi Kasagar | 48371cd | 2009-12-02 06:18:03 +0100 | [diff] [blame] | 362 | * Check if l2x0 controller is already enabled. |
| 363 | * If you are booting from non-secure mode |
| 364 | * accessing the below registers will fault. |
| 365 | */ |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 366 | if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & 1)) { |
Linus Walleij | bac7e6e | 2011-09-06 07:45:46 +0100 | [diff] [blame] | 367 | /* Make sure that I&D is not locked down when starting */ |
| 368 | l2x0_unlock(cache_id); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 369 | |
Srinidhi Kasagar | 48371cd | 2009-12-02 06:18:03 +0100 | [diff] [blame] | 370 | /* l2x0 controller is disabled */ |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 371 | writel_relaxed(aux, l2x0_base + L2X0_AUX_CTRL); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 372 | |
Srinidhi Kasagar | 48371cd | 2009-12-02 06:18:03 +0100 | [diff] [blame] | 373 | l2x0_inv_all(); |
| 374 | |
| 375 | /* enable L2X0 */ |
Catalin Marinas | 6775a55 | 2010-07-28 22:01:25 +0100 | [diff] [blame] | 376 | writel_relaxed(1, l2x0_base + L2X0_CTRL); |
Srinidhi Kasagar | 48371cd | 2009-12-02 06:18:03 +0100 | [diff] [blame] | 377 | } |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 378 | |
Yilu Mao | 9d4876f | 2012-09-03 09:14:56 +0100 | [diff] [blame] | 379 | /* Re-read it in case some bits are reserved. */ |
| 380 | aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); |
| 381 | |
| 382 | /* Save the value for resuming. */ |
| 383 | l2x0_saved_regs.aux_ctrl = aux; |
| 384 | |
Gregory CLEMENT | 6248d06 | 2012-10-01 10:56:42 +0100 | [diff] [blame^] | 385 | if (!of_init) { |
| 386 | outer_cache.inv_range = l2x0_inv_range; |
| 387 | outer_cache.clean_range = l2x0_clean_range; |
| 388 | outer_cache.flush_range = l2x0_flush_range; |
| 389 | outer_cache.sync = l2x0_cache_sync; |
| 390 | outer_cache.flush_all = l2x0_flush_all; |
| 391 | outer_cache.inv_all = l2x0_inv_all; |
| 392 | outer_cache.disable = l2x0_disable; |
| 393 | } |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 394 | |
Jason McMullan | 64039be | 2010-05-05 18:59:37 +0100 | [diff] [blame] | 395 | printk(KERN_INFO "%s cache controller enabled\n", type); |
Santosh Shilimkar | 5ba7037 | 2010-07-11 14:35:37 +0530 | [diff] [blame] | 396 | printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d B\n", |
| 397 | ways, cache_id, aux, l2x0_size); |
Catalin Marinas | 382266a | 2007-02-05 14:48:19 +0100 | [diff] [blame] | 398 | } |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 399 | |
| 400 | #ifdef CONFIG_OF |
| 401 | static void __init l2x0_of_setup(const struct device_node *np, |
Russell King | 3e175ca | 2011-09-18 11:27:30 +0100 | [diff] [blame] | 402 | u32 *aux_val, u32 *aux_mask) |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 403 | { |
| 404 | u32 data[2] = { 0, 0 }; |
| 405 | u32 tag = 0; |
| 406 | u32 dirty = 0; |
| 407 | u32 val = 0, mask = 0; |
| 408 | |
| 409 | of_property_read_u32(np, "arm,tag-latency", &tag); |
| 410 | if (tag) { |
| 411 | mask |= L2X0_AUX_CTRL_TAG_LATENCY_MASK; |
| 412 | val |= (tag - 1) << L2X0_AUX_CTRL_TAG_LATENCY_SHIFT; |
| 413 | } |
| 414 | |
| 415 | of_property_read_u32_array(np, "arm,data-latency", |
| 416 | data, ARRAY_SIZE(data)); |
| 417 | if (data[0] && data[1]) { |
| 418 | mask |= L2X0_AUX_CTRL_DATA_RD_LATENCY_MASK | |
| 419 | L2X0_AUX_CTRL_DATA_WR_LATENCY_MASK; |
| 420 | val |= ((data[0] - 1) << L2X0_AUX_CTRL_DATA_RD_LATENCY_SHIFT) | |
| 421 | ((data[1] - 1) << L2X0_AUX_CTRL_DATA_WR_LATENCY_SHIFT); |
| 422 | } |
| 423 | |
| 424 | of_property_read_u32(np, "arm,dirty-latency", &dirty); |
| 425 | if (dirty) { |
| 426 | mask |= L2X0_AUX_CTRL_DIRTY_LATENCY_MASK; |
| 427 | val |= (dirty - 1) << L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT; |
| 428 | } |
| 429 | |
| 430 | *aux_val &= ~mask; |
| 431 | *aux_val |= val; |
| 432 | *aux_mask &= ~mask; |
| 433 | } |
| 434 | |
| 435 | static void __init pl310_of_setup(const struct device_node *np, |
Russell King | 3e175ca | 2011-09-18 11:27:30 +0100 | [diff] [blame] | 436 | u32 *aux_val, u32 *aux_mask) |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 437 | { |
| 438 | u32 data[3] = { 0, 0, 0 }; |
| 439 | u32 tag[3] = { 0, 0, 0 }; |
| 440 | u32 filter[2] = { 0, 0 }; |
| 441 | |
| 442 | of_property_read_u32_array(np, "arm,tag-latency", tag, ARRAY_SIZE(tag)); |
| 443 | if (tag[0] && tag[1] && tag[2]) |
| 444 | writel_relaxed( |
| 445 | ((tag[0] - 1) << L2X0_LATENCY_CTRL_RD_SHIFT) | |
| 446 | ((tag[1] - 1) << L2X0_LATENCY_CTRL_WR_SHIFT) | |
| 447 | ((tag[2] - 1) << L2X0_LATENCY_CTRL_SETUP_SHIFT), |
| 448 | l2x0_base + L2X0_TAG_LATENCY_CTRL); |
| 449 | |
| 450 | of_property_read_u32_array(np, "arm,data-latency", |
| 451 | data, ARRAY_SIZE(data)); |
| 452 | if (data[0] && data[1] && data[2]) |
| 453 | writel_relaxed( |
| 454 | ((data[0] - 1) << L2X0_LATENCY_CTRL_RD_SHIFT) | |
| 455 | ((data[1] - 1) << L2X0_LATENCY_CTRL_WR_SHIFT) | |
| 456 | ((data[2] - 1) << L2X0_LATENCY_CTRL_SETUP_SHIFT), |
| 457 | l2x0_base + L2X0_DATA_LATENCY_CTRL); |
| 458 | |
| 459 | of_property_read_u32_array(np, "arm,filter-ranges", |
| 460 | filter, ARRAY_SIZE(filter)); |
Barry Song | 74d41f3 | 2011-09-14 03:20:01 +0100 | [diff] [blame] | 461 | if (filter[1]) { |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 462 | writel_relaxed(ALIGN(filter[0] + filter[1], SZ_1M), |
| 463 | l2x0_base + L2X0_ADDR_FILTER_END); |
| 464 | writel_relaxed((filter[0] & ~(SZ_1M - 1)) | L2X0_ADDR_FILTER_EN, |
| 465 | l2x0_base + L2X0_ADDR_FILTER_START); |
| 466 | } |
| 467 | } |
| 468 | |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 469 | static void __init pl310_save(void) |
| 470 | { |
| 471 | u32 l2x0_revision = readl_relaxed(l2x0_base + L2X0_CACHE_ID) & |
| 472 | L2X0_CACHE_ID_RTL_MASK; |
| 473 | |
| 474 | l2x0_saved_regs.tag_latency = readl_relaxed(l2x0_base + |
| 475 | L2X0_TAG_LATENCY_CTRL); |
| 476 | l2x0_saved_regs.data_latency = readl_relaxed(l2x0_base + |
| 477 | L2X0_DATA_LATENCY_CTRL); |
| 478 | l2x0_saved_regs.filter_end = readl_relaxed(l2x0_base + |
| 479 | L2X0_ADDR_FILTER_END); |
| 480 | l2x0_saved_regs.filter_start = readl_relaxed(l2x0_base + |
| 481 | L2X0_ADDR_FILTER_START); |
| 482 | |
| 483 | if (l2x0_revision >= L2X0_CACHE_ID_RTL_R2P0) { |
| 484 | /* |
| 485 | * From r2p0, there is Prefetch offset/control register |
| 486 | */ |
| 487 | l2x0_saved_regs.prefetch_ctrl = readl_relaxed(l2x0_base + |
| 488 | L2X0_PREFETCH_CTRL); |
| 489 | /* |
| 490 | * From r3p0, there is Power control register |
| 491 | */ |
| 492 | if (l2x0_revision >= L2X0_CACHE_ID_RTL_R3P0) |
| 493 | l2x0_saved_regs.pwr_ctrl = readl_relaxed(l2x0_base + |
| 494 | L2X0_POWER_CTRL); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | static void l2x0_resume(void) |
| 499 | { |
| 500 | if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & 1)) { |
| 501 | /* restore aux ctrl and enable l2 */ |
| 502 | l2x0_unlock(readl_relaxed(l2x0_base + L2X0_CACHE_ID)); |
| 503 | |
| 504 | writel_relaxed(l2x0_saved_regs.aux_ctrl, l2x0_base + |
| 505 | L2X0_AUX_CTRL); |
| 506 | |
| 507 | l2x0_inv_all(); |
| 508 | |
| 509 | writel_relaxed(1, l2x0_base + L2X0_CTRL); |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | static void pl310_resume(void) |
| 514 | { |
| 515 | u32 l2x0_revision; |
| 516 | |
| 517 | if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & 1)) { |
| 518 | /* restore pl310 setup */ |
| 519 | writel_relaxed(l2x0_saved_regs.tag_latency, |
| 520 | l2x0_base + L2X0_TAG_LATENCY_CTRL); |
| 521 | writel_relaxed(l2x0_saved_regs.data_latency, |
| 522 | l2x0_base + L2X0_DATA_LATENCY_CTRL); |
| 523 | writel_relaxed(l2x0_saved_regs.filter_end, |
| 524 | l2x0_base + L2X0_ADDR_FILTER_END); |
| 525 | writel_relaxed(l2x0_saved_regs.filter_start, |
| 526 | l2x0_base + L2X0_ADDR_FILTER_START); |
| 527 | |
| 528 | l2x0_revision = readl_relaxed(l2x0_base + L2X0_CACHE_ID) & |
| 529 | L2X0_CACHE_ID_RTL_MASK; |
| 530 | |
| 531 | if (l2x0_revision >= L2X0_CACHE_ID_RTL_R2P0) { |
| 532 | writel_relaxed(l2x0_saved_regs.prefetch_ctrl, |
| 533 | l2x0_base + L2X0_PREFETCH_CTRL); |
| 534 | if (l2x0_revision >= L2X0_CACHE_ID_RTL_R3P0) |
| 535 | writel_relaxed(l2x0_saved_regs.pwr_ctrl, |
| 536 | l2x0_base + L2X0_POWER_CTRL); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | l2x0_resume(); |
| 541 | } |
| 542 | |
| 543 | static const struct l2x0_of_data pl310_data = { |
Gregory CLEMENT | 6248d06 | 2012-10-01 10:56:42 +0100 | [diff] [blame^] | 544 | .setup = pl310_of_setup, |
| 545 | .save = pl310_save, |
| 546 | .outer_cache = { |
| 547 | .resume = pl310_resume, |
| 548 | .inv_range = l2x0_inv_range, |
| 549 | .clean_range = l2x0_clean_range, |
| 550 | .flush_range = l2x0_flush_range, |
| 551 | .sync = l2x0_cache_sync, |
| 552 | .flush_all = l2x0_flush_all, |
| 553 | .inv_all = l2x0_inv_all, |
| 554 | .disable = l2x0_disable, |
| 555 | .set_debug = pl310_set_debug, |
| 556 | }, |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 557 | }; |
| 558 | |
| 559 | static const struct l2x0_of_data l2x0_data = { |
Gregory CLEMENT | 6248d06 | 2012-10-01 10:56:42 +0100 | [diff] [blame^] | 560 | .setup = l2x0_of_setup, |
| 561 | .save = NULL, |
| 562 | .outer_cache = { |
| 563 | .resume = l2x0_resume, |
| 564 | .inv_range = l2x0_inv_range, |
| 565 | .clean_range = l2x0_clean_range, |
| 566 | .flush_range = l2x0_flush_range, |
| 567 | .sync = l2x0_cache_sync, |
| 568 | .flush_all = l2x0_flush_all, |
| 569 | .inv_all = l2x0_inv_all, |
| 570 | .disable = l2x0_disable, |
| 571 | }, |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 572 | }; |
| 573 | |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 574 | static const struct of_device_id l2x0_ids[] __initconst = { |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 575 | { .compatible = "arm,pl310-cache", .data = (void *)&pl310_data }, |
| 576 | { .compatible = "arm,l220-cache", .data = (void *)&l2x0_data }, |
| 577 | { .compatible = "arm,l210-cache", .data = (void *)&l2x0_data }, |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 578 | {} |
| 579 | }; |
| 580 | |
Russell King | 3e175ca | 2011-09-18 11:27:30 +0100 | [diff] [blame] | 581 | int __init l2x0_of_init(u32 aux_val, u32 aux_mask) |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 582 | { |
| 583 | struct device_node *np; |
Uwe Kleine-König | e5b5d02 | 2012-05-21 21:54:06 +0200 | [diff] [blame] | 584 | const struct l2x0_of_data *data; |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 585 | struct resource res; |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 586 | |
| 587 | np = of_find_matching_node(NULL, l2x0_ids); |
| 588 | if (!np) |
| 589 | return -ENODEV; |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 590 | |
| 591 | if (of_address_to_resource(np, 0, &res)) |
| 592 | return -ENODEV; |
| 593 | |
| 594 | l2x0_base = ioremap(res.start, resource_size(&res)); |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 595 | if (!l2x0_base) |
| 596 | return -ENOMEM; |
| 597 | |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 598 | l2x0_saved_regs.phy_base = res.start; |
| 599 | |
| 600 | data = of_match_node(l2x0_ids, np)->data; |
| 601 | |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 602 | /* L2 configuration can only be changed if the cache is disabled */ |
| 603 | if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & 1)) { |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 604 | if (data->setup) |
| 605 | data->setup(np, &aux_val, &aux_mask); |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 606 | } |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 607 | |
| 608 | if (data->save) |
| 609 | data->save(); |
| 610 | |
Gregory CLEMENT | 6248d06 | 2012-10-01 10:56:42 +0100 | [diff] [blame^] | 611 | of_init = true; |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 612 | l2x0_init(l2x0_base, aux_val, aux_mask); |
Barry Song | 91c2ebb | 2011-09-30 14:43:12 +0100 | [diff] [blame] | 613 | |
Gregory CLEMENT | 6248d06 | 2012-10-01 10:56:42 +0100 | [diff] [blame^] | 614 | memcpy(&outer_cache, &data->outer_cache, sizeof(outer_cache)); |
| 615 | |
Rob Herring | 8c36926 | 2011-08-03 18:12:05 +0100 | [diff] [blame] | 616 | return 0; |
| 617 | } |
| 618 | #endif |