cache-l2x0.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705
  1. /*
  2. * arch/arm/mm/cache-l2x0.c - L210/L220/L310 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. */
  19. #include <linux/cpu.h>
  20. #include <linux/err.h>
  21. #include <linux/init.h>
  22. #include <linux/smp.h>
  23. #include <linux/spinlock.h>
  24. #include <linux/log2.h>
  25. #include <linux/io.h>
  26. #include <linux/of.h>
  27. #include <linux/of_address.h>
  28. #include <asm/cacheflush.h>
  29. #include <asm/cp15.h>
  30. #include <asm/cputype.h>
  31. #include <asm/hardware/cache-l2x0.h>
  32. #include "cache-tauros3.h"
  33. #include "cache-aurora-l2.h"
  34. struct l2c_init_data {
  35. const char *type;
  36. unsigned way_size_0;
  37. unsigned num_lock;
  38. void (*of_parse)(const struct device_node *, u32 *, u32 *);
  39. void (*enable)(void __iomem *, u32, unsigned);
  40. void (*fixup)(void __iomem *, u32, struct outer_cache_fns *);
  41. void (*save)(void __iomem *);
  42. void (*configure)(void __iomem *);
  43. struct outer_cache_fns outer_cache;
  44. };
  45. #define CACHE_LINE_SIZE 32
  46. static void __iomem *l2x0_base;
  47. static const struct l2c_init_data *l2x0_data;
  48. static DEFINE_RAW_SPINLOCK(l2x0_lock);
  49. static u32 l2x0_way_mask; /* Bitmask of active ways */
  50. static u32 l2x0_size;
  51. static unsigned long sync_reg_offset = L2X0_CACHE_SYNC;
  52. struct l2x0_regs l2x0_saved_regs;
  53. /*
  54. * Common code for all cache controllers.
  55. */
  56. static inline void l2c_wait_mask(void __iomem *reg, unsigned long mask)
  57. {
  58. /* wait for cache operation by line or way to complete */
  59. while (readl_relaxed(reg) & mask)
  60. cpu_relax();
  61. }
  62. /*
  63. * By default, we write directly to secure registers. Platforms must
  64. * override this if they are running non-secure.
  65. */
  66. static void l2c_write_sec(unsigned long val, void __iomem *base, unsigned reg)
  67. {
  68. if (val == readl_relaxed(base + reg))
  69. return;
  70. if (outer_cache.write_sec)
  71. outer_cache.write_sec(val, reg);
  72. else
  73. writel_relaxed(val, base + reg);
  74. }
  75. /*
  76. * This should only be called when we have a requirement that the
  77. * register be written due to a work-around, as platforms running
  78. * in non-secure mode may not be able to access this register.
  79. */
  80. static inline void l2c_set_debug(void __iomem *base, unsigned long val)
  81. {
  82. l2c_write_sec(val, base, L2X0_DEBUG_CTRL);
  83. }
  84. static void __l2c_op_way(void __iomem *reg)
  85. {
  86. writel_relaxed(l2x0_way_mask, reg);
  87. l2c_wait_mask(reg, l2x0_way_mask);
  88. }
  89. static inline void l2c_unlock(void __iomem *base, unsigned num)
  90. {
  91. unsigned i;
  92. for (i = 0; i < num; i++) {
  93. writel_relaxed(0, base + L2X0_LOCKDOWN_WAY_D_BASE +
  94. i * L2X0_LOCKDOWN_STRIDE);
  95. writel_relaxed(0, base + L2X0_LOCKDOWN_WAY_I_BASE +
  96. i * L2X0_LOCKDOWN_STRIDE);
  97. }
  98. }
  99. static void l2c_configure(void __iomem *base)
  100. {
  101. if (outer_cache.configure) {
  102. outer_cache.configure(&l2x0_saved_regs);
  103. return;
  104. }
  105. if (l2x0_data->configure)
  106. l2x0_data->configure(base);
  107. l2c_write_sec(l2x0_saved_regs.aux_ctrl, base, L2X0_AUX_CTRL);
  108. }
  109. /*
  110. * Enable the L2 cache controller. This function must only be
  111. * called when the cache controller is known to be disabled.
  112. */
  113. static void l2c_enable(void __iomem *base, u32 aux, unsigned num_lock)
  114. {
  115. unsigned long flags;
  116. /* Do not touch the controller if already enabled. */
  117. if (readl_relaxed(base + L2X0_CTRL) & L2X0_CTRL_EN)
  118. return;
  119. l2x0_saved_regs.aux_ctrl = aux;
  120. l2c_configure(base);
  121. l2c_unlock(base, num_lock);
  122. local_irq_save(flags);
  123. __l2c_op_way(base + L2X0_INV_WAY);
  124. writel_relaxed(0, base + sync_reg_offset);
  125. l2c_wait_mask(base + sync_reg_offset, 1);
  126. local_irq_restore(flags);
  127. l2c_write_sec(L2X0_CTRL_EN, base, L2X0_CTRL);
  128. }
  129. static void l2c_disable(void)
  130. {
  131. void __iomem *base = l2x0_base;
  132. outer_cache.flush_all();
  133. l2c_write_sec(0, base, L2X0_CTRL);
  134. dsb(st);
  135. }
  136. static void l2c_save(void __iomem *base)
  137. {
  138. l2x0_saved_regs.aux_ctrl = readl_relaxed(l2x0_base + L2X0_AUX_CTRL);
  139. }
  140. static void l2c_resume(void)
  141. {
  142. l2c_enable(l2x0_base, l2x0_saved_regs.aux_ctrl, l2x0_data->num_lock);
  143. }
  144. /*
  145. * L2C-210 specific code.
  146. *
  147. * The L2C-2x0 PA, set/way and sync operations are atomic, but we must
  148. * ensure that no background operation is running. The way operations
  149. * are all background tasks.
  150. *
  151. * While a background operation is in progress, any new operation is
  152. * ignored (unspecified whether this causes an error.) Thankfully, not
  153. * used on SMP.
  154. *
  155. * Never has a different sync register other than L2X0_CACHE_SYNC, but
  156. * we use sync_reg_offset here so we can share some of this with L2C-310.
  157. */
  158. static void __l2c210_cache_sync(void __iomem *base)
  159. {
  160. writel_relaxed(0, base + sync_reg_offset);
  161. }
  162. static void __l2c210_op_pa_range(void __iomem *reg, unsigned long start,
  163. unsigned long end)
  164. {
  165. while (start < end) {
  166. writel_relaxed(start, reg);
  167. start += CACHE_LINE_SIZE;
  168. }
  169. }
  170. static void l2c210_inv_range(unsigned long start, unsigned long end)
  171. {
  172. void __iomem *base = l2x0_base;
  173. if (start & (CACHE_LINE_SIZE - 1)) {
  174. start &= ~(CACHE_LINE_SIZE - 1);
  175. writel_relaxed(start, base + L2X0_CLEAN_INV_LINE_PA);
  176. start += CACHE_LINE_SIZE;
  177. }
  178. if (end & (CACHE_LINE_SIZE - 1)) {
  179. end &= ~(CACHE_LINE_SIZE - 1);
  180. writel_relaxed(end, base + L2X0_CLEAN_INV_LINE_PA);
  181. }
  182. __l2c210_op_pa_range(base + L2X0_INV_LINE_PA, start, end);
  183. __l2c210_cache_sync(base);
  184. }
  185. static void l2c210_clean_range(unsigned long start, unsigned long end)
  186. {
  187. void __iomem *base = l2x0_base;
  188. start &= ~(CACHE_LINE_SIZE - 1);
  189. __l2c210_op_pa_range(base + L2X0_CLEAN_LINE_PA, start, end);
  190. __l2c210_cache_sync(base);
  191. }
  192. static void l2c210_flush_range(unsigned long start, unsigned long end)
  193. {
  194. void __iomem *base = l2x0_base;
  195. start &= ~(CACHE_LINE_SIZE - 1);
  196. __l2c210_op_pa_range(base + L2X0_CLEAN_INV_LINE_PA, start, end);
  197. __l2c210_cache_sync(base);
  198. }
  199. static void l2c210_flush_all(void)
  200. {
  201. void __iomem *base = l2x0_base;
  202. BUG_ON(!irqs_disabled());
  203. __l2c_op_way(base + L2X0_CLEAN_INV_WAY);
  204. __l2c210_cache_sync(base);
  205. }
  206. static void l2c210_sync(void)
  207. {
  208. __l2c210_cache_sync(l2x0_base);
  209. }
  210. static const struct l2c_init_data l2c210_data __initconst = {
  211. .type = "L2C-210",
  212. .way_size_0 = SZ_8K,
  213. .num_lock = 1,
  214. .enable = l2c_enable,
  215. .save = l2c_save,
  216. .outer_cache = {
  217. .inv_range = l2c210_inv_range,
  218. .clean_range = l2c210_clean_range,
  219. .flush_range = l2c210_flush_range,
  220. .flush_all = l2c210_flush_all,
  221. .disable = l2c_disable,
  222. .sync = l2c210_sync,
  223. .resume = l2c_resume,
  224. },
  225. };
  226. /*
  227. * L2C-220 specific code.
  228. *
  229. * All operations are background operations: they have to be waited for.
  230. * Conflicting requests generate a slave error (which will cause an
  231. * imprecise abort.) Never uses sync_reg_offset, so we hard-code the
  232. * sync register here.
  233. *
  234. * However, we can re-use the l2c210_resume call.
  235. */
  236. static inline void __l2c220_cache_sync(void __iomem *base)
  237. {
  238. writel_relaxed(0, base + L2X0_CACHE_SYNC);
  239. l2c_wait_mask(base + L2X0_CACHE_SYNC, 1);
  240. }
  241. static void l2c220_op_way(void __iomem *base, unsigned reg)
  242. {
  243. unsigned long flags;
  244. raw_spin_lock_irqsave(&l2x0_lock, flags);
  245. __l2c_op_way(base + reg);
  246. __l2c220_cache_sync(base);
  247. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  248. }
  249. static unsigned long l2c220_op_pa_range(void __iomem *reg, unsigned long start,
  250. unsigned long end, unsigned long flags)
  251. {
  252. raw_spinlock_t *lock = &l2x0_lock;
  253. while (start < end) {
  254. unsigned long blk_end = start + min(end - start, 4096UL);
  255. while (start < blk_end) {
  256. l2c_wait_mask(reg, 1);
  257. writel_relaxed(start, reg);
  258. start += CACHE_LINE_SIZE;
  259. }
  260. if (blk_end < end) {
  261. raw_spin_unlock_irqrestore(lock, flags);
  262. raw_spin_lock_irqsave(lock, flags);
  263. }
  264. }
  265. return flags;
  266. }
  267. static void l2c220_inv_range(unsigned long start, unsigned long end)
  268. {
  269. void __iomem *base = l2x0_base;
  270. unsigned long flags;
  271. raw_spin_lock_irqsave(&l2x0_lock, flags);
  272. if ((start | end) & (CACHE_LINE_SIZE - 1)) {
  273. if (start & (CACHE_LINE_SIZE - 1)) {
  274. start &= ~(CACHE_LINE_SIZE - 1);
  275. writel_relaxed(start, base + L2X0_CLEAN_INV_LINE_PA);
  276. start += CACHE_LINE_SIZE;
  277. }
  278. if (end & (CACHE_LINE_SIZE - 1)) {
  279. end &= ~(CACHE_LINE_SIZE - 1);
  280. l2c_wait_mask(base + L2X0_CLEAN_INV_LINE_PA, 1);
  281. writel_relaxed(end, base + L2X0_CLEAN_INV_LINE_PA);
  282. }
  283. }
  284. flags = l2c220_op_pa_range(base + L2X0_INV_LINE_PA,
  285. start, end, flags);
  286. l2c_wait_mask(base + L2X0_INV_LINE_PA, 1);
  287. __l2c220_cache_sync(base);
  288. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  289. }
  290. static void l2c220_clean_range(unsigned long start, unsigned long end)
  291. {
  292. void __iomem *base = l2x0_base;
  293. unsigned long flags;
  294. start &= ~(CACHE_LINE_SIZE - 1);
  295. if ((end - start) >= l2x0_size) {
  296. l2c220_op_way(base, L2X0_CLEAN_WAY);
  297. return;
  298. }
  299. raw_spin_lock_irqsave(&l2x0_lock, flags);
  300. flags = l2c220_op_pa_range(base + L2X0_CLEAN_LINE_PA,
  301. start, end, flags);
  302. l2c_wait_mask(base + L2X0_CLEAN_INV_LINE_PA, 1);
  303. __l2c220_cache_sync(base);
  304. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  305. }
  306. static void l2c220_flush_range(unsigned long start, unsigned long end)
  307. {
  308. void __iomem *base = l2x0_base;
  309. unsigned long flags;
  310. start &= ~(CACHE_LINE_SIZE - 1);
  311. if ((end - start) >= l2x0_size) {
  312. l2c220_op_way(base, L2X0_CLEAN_INV_WAY);
  313. return;
  314. }
  315. raw_spin_lock_irqsave(&l2x0_lock, flags);
  316. flags = l2c220_op_pa_range(base + L2X0_CLEAN_INV_LINE_PA,
  317. start, end, flags);
  318. l2c_wait_mask(base + L2X0_CLEAN_INV_LINE_PA, 1);
  319. __l2c220_cache_sync(base);
  320. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  321. }
  322. static void l2c220_flush_all(void)
  323. {
  324. l2c220_op_way(l2x0_base, L2X0_CLEAN_INV_WAY);
  325. }
  326. static void l2c220_sync(void)
  327. {
  328. unsigned long flags;
  329. raw_spin_lock_irqsave(&l2x0_lock, flags);
  330. __l2c220_cache_sync(l2x0_base);
  331. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  332. }
  333. static void l2c220_enable(void __iomem *base, u32 aux, unsigned num_lock)
  334. {
  335. /*
  336. * Always enable non-secure access to the lockdown registers -
  337. * we write to them as part of the L2C enable sequence so they
  338. * need to be accessible.
  339. */
  340. aux |= L220_AUX_CTRL_NS_LOCKDOWN;
  341. l2c_enable(base, aux, num_lock);
  342. }
  343. static const struct l2c_init_data l2c220_data = {
  344. .type = "L2C-220",
  345. .way_size_0 = SZ_8K,
  346. .num_lock = 1,
  347. .enable = l2c220_enable,
  348. .save = l2c_save,
  349. .outer_cache = {
  350. .inv_range = l2c220_inv_range,
  351. .clean_range = l2c220_clean_range,
  352. .flush_range = l2c220_flush_range,
  353. .flush_all = l2c220_flush_all,
  354. .disable = l2c_disable,
  355. .sync = l2c220_sync,
  356. .resume = l2c_resume,
  357. },
  358. };
  359. /*
  360. * L2C-310 specific code.
  361. *
  362. * Very similar to L2C-210, the PA, set/way and sync operations are atomic,
  363. * and the way operations are all background tasks. However, issuing an
  364. * operation while a background operation is in progress results in a
  365. * SLVERR response. We can reuse:
  366. *
  367. * __l2c210_cache_sync (using sync_reg_offset)
  368. * l2c210_sync
  369. * l2c210_inv_range (if 588369 is not applicable)
  370. * l2c210_clean_range
  371. * l2c210_flush_range (if 588369 is not applicable)
  372. * l2c210_flush_all (if 727915 is not applicable)
  373. *
  374. * Errata:
  375. * 588369: PL310 R0P0->R1P0, fixed R2P0.
  376. * Affects: all clean+invalidate operations
  377. * clean and invalidate skips the invalidate step, so we need to issue
  378. * separate operations. We also require the above debug workaround
  379. * enclosing this code fragment on affected parts. On unaffected parts,
  380. * we must not use this workaround without the debug register writes
  381. * to avoid exposing a problem similar to 727915.
  382. *
  383. * 727915: PL310 R2P0->R3P0, fixed R3P1.
  384. * Affects: clean+invalidate by way
  385. * clean and invalidate by way runs in the background, and a store can
  386. * hit the line between the clean operation and invalidate operation,
  387. * resulting in the store being lost.
  388. *
  389. * 752271: PL310 R3P0->R3P1-50REL0, fixed R3P2.
  390. * Affects: 8x64-bit (double fill) line fetches
  391. * double fill line fetches can fail to cause dirty data to be evicted
  392. * from the cache before the new data overwrites the second line.
  393. *
  394. * 753970: PL310 R3P0, fixed R3P1.
  395. * Affects: sync
  396. * prevents merging writes after the sync operation, until another L2C
  397. * operation is performed (or a number of other conditions.)
  398. *
  399. * 769419: PL310 R0P0->R3P1, fixed R3P2.
  400. * Affects: store buffer
  401. * store buffer is not automatically drained.
  402. */
  403. static void l2c310_inv_range_erratum(unsigned long start, unsigned long end)
  404. {
  405. void __iomem *base = l2x0_base;
  406. if ((start | end) & (CACHE_LINE_SIZE - 1)) {
  407. unsigned long flags;
  408. /* Erratum 588369 for both clean+invalidate operations */
  409. raw_spin_lock_irqsave(&l2x0_lock, flags);
  410. l2c_set_debug(base, 0x03);
  411. if (start & (CACHE_LINE_SIZE - 1)) {
  412. start &= ~(CACHE_LINE_SIZE - 1);
  413. writel_relaxed(start, base + L2X0_CLEAN_LINE_PA);
  414. writel_relaxed(start, base + L2X0_INV_LINE_PA);
  415. start += CACHE_LINE_SIZE;
  416. }
  417. if (end & (CACHE_LINE_SIZE - 1)) {
  418. end &= ~(CACHE_LINE_SIZE - 1);
  419. writel_relaxed(end, base + L2X0_CLEAN_LINE_PA);
  420. writel_relaxed(end, base + L2X0_INV_LINE_PA);
  421. }
  422. l2c_set_debug(base, 0x00);
  423. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  424. }
  425. __l2c210_op_pa_range(base + L2X0_INV_LINE_PA, start, end);
  426. __l2c210_cache_sync(base);
  427. }
  428. static void l2c310_flush_range_erratum(unsigned long start, unsigned long end)
  429. {
  430. raw_spinlock_t *lock = &l2x0_lock;
  431. unsigned long flags;
  432. void __iomem *base = l2x0_base;
  433. raw_spin_lock_irqsave(lock, flags);
  434. while (start < end) {
  435. unsigned long blk_end = start + min(end - start, 4096UL);
  436. l2c_set_debug(base, 0x03);
  437. while (start < blk_end) {
  438. writel_relaxed(start, base + L2X0_CLEAN_LINE_PA);
  439. writel_relaxed(start, base + L2X0_INV_LINE_PA);
  440. start += CACHE_LINE_SIZE;
  441. }
  442. l2c_set_debug(base, 0x00);
  443. if (blk_end < end) {
  444. raw_spin_unlock_irqrestore(lock, flags);
  445. raw_spin_lock_irqsave(lock, flags);
  446. }
  447. }
  448. raw_spin_unlock_irqrestore(lock, flags);
  449. __l2c210_cache_sync(base);
  450. }
  451. static void l2c310_flush_all_erratum(void)
  452. {
  453. void __iomem *base = l2x0_base;
  454. unsigned long flags;
  455. raw_spin_lock_irqsave(&l2x0_lock, flags);
  456. l2c_set_debug(base, 0x03);
  457. __l2c_op_way(base + L2X0_CLEAN_INV_WAY);
  458. l2c_set_debug(base, 0x00);
  459. __l2c210_cache_sync(base);
  460. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  461. }
  462. static void __init l2c310_save(void __iomem *base)
  463. {
  464. unsigned revision;
  465. l2c_save(base);
  466. l2x0_saved_regs.tag_latency = readl_relaxed(base +
  467. L310_TAG_LATENCY_CTRL);
  468. l2x0_saved_regs.data_latency = readl_relaxed(base +
  469. L310_DATA_LATENCY_CTRL);
  470. l2x0_saved_regs.filter_end = readl_relaxed(base +
  471. L310_ADDR_FILTER_END);
  472. l2x0_saved_regs.filter_start = readl_relaxed(base +
  473. L310_ADDR_FILTER_START);
  474. revision = readl_relaxed(base + L2X0_CACHE_ID) &
  475. L2X0_CACHE_ID_RTL_MASK;
  476. /* From r2p0, there is Prefetch offset/control register */
  477. if (revision >= L310_CACHE_ID_RTL_R2P0)
  478. l2x0_saved_regs.prefetch_ctrl = readl_relaxed(base +
  479. L310_PREFETCH_CTRL);
  480. /* From r3p0, there is Power control register */
  481. if (revision >= L310_CACHE_ID_RTL_R3P0)
  482. l2x0_saved_regs.pwr_ctrl = readl_relaxed(base +
  483. L310_POWER_CTRL);
  484. }
  485. static void l2c310_configure(void __iomem *base)
  486. {
  487. unsigned revision;
  488. /* restore pl310 setup */
  489. l2c_write_sec(l2x0_saved_regs.tag_latency, base,
  490. L310_TAG_LATENCY_CTRL);
  491. l2c_write_sec(l2x0_saved_regs.data_latency, base,
  492. L310_DATA_LATENCY_CTRL);
  493. l2c_write_sec(l2x0_saved_regs.filter_end, base,
  494. L310_ADDR_FILTER_END);
  495. l2c_write_sec(l2x0_saved_regs.filter_start, base,
  496. L310_ADDR_FILTER_START);
  497. revision = readl_relaxed(base + L2X0_CACHE_ID) &
  498. L2X0_CACHE_ID_RTL_MASK;
  499. if (revision >= L310_CACHE_ID_RTL_R2P0)
  500. l2c_write_sec(l2x0_saved_regs.prefetch_ctrl, base,
  501. L310_PREFETCH_CTRL);
  502. if (revision >= L310_CACHE_ID_RTL_R3P0)
  503. l2c_write_sec(l2x0_saved_regs.pwr_ctrl, base,
  504. L310_POWER_CTRL);
  505. }
  506. static int l2c310_cpu_enable_flz(struct notifier_block *nb, unsigned long act, void *data)
  507. {
  508. switch (act & ~CPU_TASKS_FROZEN) {
  509. case CPU_STARTING:
  510. set_auxcr(get_auxcr() | BIT(3) | BIT(2) | BIT(1));
  511. break;
  512. case CPU_DYING:
  513. set_auxcr(get_auxcr() & ~(BIT(3) | BIT(2) | BIT(1)));
  514. break;
  515. }
  516. return NOTIFY_OK;
  517. }
  518. static void __init l2c310_enable(void __iomem *base, u32 aux, unsigned num_lock)
  519. {
  520. unsigned rev = readl_relaxed(base + L2X0_CACHE_ID) & L2X0_CACHE_ID_RTL_MASK;
  521. bool cortex_a9 = read_cpuid_part() == ARM_CPU_PART_CORTEX_A9;
  522. if (rev >= L310_CACHE_ID_RTL_R2P0) {
  523. if (cortex_a9) {
  524. aux |= L310_AUX_CTRL_EARLY_BRESP;
  525. pr_info("L2C-310 enabling early BRESP for Cortex-A9\n");
  526. } else if (aux & L310_AUX_CTRL_EARLY_BRESP) {
  527. pr_warn("L2C-310 early BRESP only supported with Cortex-A9\n");
  528. aux &= ~L310_AUX_CTRL_EARLY_BRESP;
  529. }
  530. }
  531. if (cortex_a9) {
  532. u32 aux_cur = readl_relaxed(base + L2X0_AUX_CTRL);
  533. u32 acr = get_auxcr();
  534. pr_debug("Cortex-A9 ACR=0x%08x\n", acr);
  535. if (acr & BIT(3) && !(aux_cur & L310_AUX_CTRL_FULL_LINE_ZERO))
  536. pr_err("L2C-310: full line of zeros enabled in Cortex-A9 but not L2C-310 - invalid\n");
  537. if (aux & L310_AUX_CTRL_FULL_LINE_ZERO && !(acr & BIT(3)))
  538. pr_err("L2C-310: enabling full line of zeros but not enabled in Cortex-A9\n");
  539. if (!(aux & L310_AUX_CTRL_FULL_LINE_ZERO) && !outer_cache.write_sec) {
  540. aux |= L310_AUX_CTRL_FULL_LINE_ZERO;
  541. pr_info("L2C-310 full line of zeros enabled for Cortex-A9\n");
  542. }
  543. } else if (aux & (L310_AUX_CTRL_FULL_LINE_ZERO | L310_AUX_CTRL_EARLY_BRESP)) {
  544. pr_err("L2C-310: disabling Cortex-A9 specific feature bits\n");
  545. aux &= ~(L310_AUX_CTRL_FULL_LINE_ZERO | L310_AUX_CTRL_EARLY_BRESP);
  546. }
  547. /* r3p0 or later has power control register */
  548. if (rev >= L310_CACHE_ID_RTL_R3P0)
  549. l2x0_saved_regs.pwr_ctrl = L310_DYNAMIC_CLK_GATING_EN |
  550. L310_STNDBY_MODE_EN;
  551. /*
  552. * Always enable non-secure access to the lockdown registers -
  553. * we write to them as part of the L2C enable sequence so they
  554. * need to be accessible.
  555. */
  556. aux |= L310_AUX_CTRL_NS_LOCKDOWN;
  557. l2c_enable(base, aux, num_lock);
  558. /* Read back resulting AUX_CTRL value as it could have been altered. */
  559. aux = readl_relaxed(base + L2X0_AUX_CTRL);
  560. if (aux & (L310_AUX_CTRL_DATA_PREFETCH | L310_AUX_CTRL_INSTR_PREFETCH)) {
  561. u32 prefetch = readl_relaxed(base + L310_PREFETCH_CTRL);
  562. pr_info("L2C-310 %s%s prefetch enabled, offset %u lines\n",
  563. aux & L310_AUX_CTRL_INSTR_PREFETCH ? "I" : "",
  564. aux & L310_AUX_CTRL_DATA_PREFETCH ? "D" : "",
  565. 1 + (prefetch & L310_PREFETCH_CTRL_OFFSET_MASK));
  566. }
  567. /* r3p0 or later has power control register */
  568. if (rev >= L310_CACHE_ID_RTL_R3P0) {
  569. u32 power_ctrl;
  570. power_ctrl = readl_relaxed(base + L310_POWER_CTRL);
  571. pr_info("L2C-310 dynamic clock gating %sabled, standby mode %sabled\n",
  572. power_ctrl & L310_DYNAMIC_CLK_GATING_EN ? "en" : "dis",
  573. power_ctrl & L310_STNDBY_MODE_EN ? "en" : "dis");
  574. }
  575. if (aux & L310_AUX_CTRL_FULL_LINE_ZERO) {
  576. set_auxcr(get_auxcr() | BIT(3) | BIT(2) | BIT(1));
  577. cpu_notifier(l2c310_cpu_enable_flz, 0);
  578. }
  579. }
  580. static void __init l2c310_fixup(void __iomem *base, u32 cache_id,
  581. struct outer_cache_fns *fns)
  582. {
  583. unsigned revision = cache_id & L2X0_CACHE_ID_RTL_MASK;
  584. const char *errata[8];
  585. unsigned n = 0;
  586. if (IS_ENABLED(CONFIG_PL310_ERRATA_588369) &&
  587. revision < L310_CACHE_ID_RTL_R2P0 &&
  588. /* For bcm compatibility */
  589. fns->inv_range == l2c210_inv_range) {
  590. fns->inv_range = l2c310_inv_range_erratum;
  591. fns->flush_range = l2c310_flush_range_erratum;
  592. errata[n++] = "588369";
  593. }
  594. if (IS_ENABLED(CONFIG_PL310_ERRATA_727915) &&
  595. revision >= L310_CACHE_ID_RTL_R2P0 &&
  596. revision < L310_CACHE_ID_RTL_R3P1) {
  597. fns->flush_all = l2c310_flush_all_erratum;
  598. errata[n++] = "727915";
  599. }
  600. if (revision >= L310_CACHE_ID_RTL_R3P0 &&
  601. revision < L310_CACHE_ID_RTL_R3P2) {
  602. u32 val = l2x0_saved_regs.prefetch_ctrl;
  603. /* I don't think bit23 is required here... but iMX6 does so */
  604. if (val & (BIT(30) | BIT(23))) {
  605. val &= ~(BIT(30) | BIT(23));
  606. l2x0_saved_regs.prefetch_ctrl = val;
  607. errata[n++] = "752271";
  608. }
  609. }
  610. if (IS_ENABLED(CONFIG_PL310_ERRATA_753970) &&
  611. revision == L310_CACHE_ID_RTL_R3P0) {
  612. sync_reg_offset = L2X0_DUMMY_REG;
  613. errata[n++] = "753970";
  614. }
  615. if (IS_ENABLED(CONFIG_PL310_ERRATA_769419))
  616. errata[n++] = "769419";
  617. if (n) {
  618. unsigned i;
  619. pr_info("L2C-310 errat%s", n > 1 ? "a" : "um");
  620. for (i = 0; i < n; i++)
  621. pr_cont(" %s", errata[i]);
  622. pr_cont(" enabled\n");
  623. }
  624. }
  625. static void l2c310_disable(void)
  626. {
  627. /*
  628. * If full-line-of-zeros is enabled, we must first disable it in the
  629. * Cortex-A9 auxiliary control register before disabling the L2 cache.
  630. */
  631. if (l2x0_saved_regs.aux_ctrl & L310_AUX_CTRL_FULL_LINE_ZERO)
  632. set_auxcr(get_auxcr() & ~(BIT(3) | BIT(2) | BIT(1)));
  633. l2c_disable();
  634. }
  635. static void l2c310_resume(void)
  636. {
  637. l2c_resume();
  638. /* Re-enable full-line-of-zeros for Cortex-A9 */
  639. if (l2x0_saved_regs.aux_ctrl & L310_AUX_CTRL_FULL_LINE_ZERO)
  640. set_auxcr(get_auxcr() | BIT(3) | BIT(2) | BIT(1));
  641. }
  642. static const struct l2c_init_data l2c310_init_fns __initconst = {
  643. .type = "L2C-310",
  644. .way_size_0 = SZ_8K,
  645. .num_lock = 8,
  646. .enable = l2c310_enable,
  647. .fixup = l2c310_fixup,
  648. .save = l2c310_save,
  649. .configure = l2c310_configure,
  650. .outer_cache = {
  651. .inv_range = l2c210_inv_range,
  652. .clean_range = l2c210_clean_range,
  653. .flush_range = l2c210_flush_range,
  654. .flush_all = l2c210_flush_all,
  655. .disable = l2c310_disable,
  656. .sync = l2c210_sync,
  657. .resume = l2c310_resume,
  658. },
  659. };
  660. static int __init __l2c_init(const struct l2c_init_data *data,
  661. u32 aux_val, u32 aux_mask, u32 cache_id)
  662. {
  663. struct outer_cache_fns fns;
  664. unsigned way_size_bits, ways;
  665. u32 aux, old_aux;
  666. /*
  667. * Save the pointer globally so that callbacks which do not receive
  668. * context from callers can access the structure.
  669. */
  670. l2x0_data = kmemdup(data, sizeof(*data), GFP_KERNEL);
  671. if (!l2x0_data)
  672. return -ENOMEM;
  673. /*
  674. * Sanity check the aux values. aux_mask is the bits we preserve
  675. * from reading the hardware register, and aux_val is the bits we
  676. * set.
  677. */
  678. if (aux_val & aux_mask)
  679. pr_alert("L2C: platform provided aux values permit register corruption.\n");
  680. old_aux = aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL);
  681. aux &= aux_mask;
  682. aux |= aux_val;
  683. if (old_aux != aux)
  684. pr_warn("L2C: DT/platform modifies aux control register: 0x%08x -> 0x%08x\n",
  685. old_aux, aux);
  686. /* Determine the number of ways */
  687. switch (cache_id & L2X0_CACHE_ID_PART_MASK) {
  688. case L2X0_CACHE_ID_PART_L310:
  689. if ((aux_val | ~aux_mask) & (L2C_AUX_CTRL_WAY_SIZE_MASK | L310_AUX_CTRL_ASSOCIATIVITY_16))
  690. pr_warn("L2C: DT/platform tries to modify or specify cache size\n");
  691. if (aux & (1 << 16))
  692. ways = 16;
  693. else
  694. ways = 8;
  695. break;
  696. case L2X0_CACHE_ID_PART_L210:
  697. case L2X0_CACHE_ID_PART_L220:
  698. ways = (aux >> 13) & 0xf;
  699. break;
  700. case AURORA_CACHE_ID:
  701. ways = (aux >> 13) & 0xf;
  702. ways = 2 << ((ways + 1) >> 2);
  703. break;
  704. default:
  705. /* Assume unknown chips have 8 ways */
  706. ways = 8;
  707. break;
  708. }
  709. l2x0_way_mask = (1 << ways) - 1;
  710. /*
  711. * way_size_0 is the size that a way_size value of zero would be
  712. * given the calculation: way_size = way_size_0 << way_size_bits.
  713. * So, if way_size_bits=0 is reserved, but way_size_bits=1 is 16k,
  714. * then way_size_0 would be 8k.
  715. *
  716. * L2 cache size = number of ways * way size.
  717. */
  718. way_size_bits = (aux & L2C_AUX_CTRL_WAY_SIZE_MASK) >>
  719. L2C_AUX_CTRL_WAY_SIZE_SHIFT;
  720. l2x0_size = ways * (data->way_size_0 << way_size_bits);
  721. fns = data->outer_cache;
  722. fns.write_sec = outer_cache.write_sec;
  723. fns.configure = outer_cache.configure;
  724. if (data->fixup)
  725. data->fixup(l2x0_base, cache_id, &fns);
  726. /*
  727. * Check if l2x0 controller is already enabled. If we are booting
  728. * in non-secure mode accessing the below registers will fault.
  729. */
  730. if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN))
  731. data->enable(l2x0_base, aux, data->num_lock);
  732. outer_cache = fns;
  733. /*
  734. * It is strange to save the register state before initialisation,
  735. * but hey, this is what the DT implementations decided to do.
  736. */
  737. if (data->save)
  738. data->save(l2x0_base);
  739. /* Re-read it in case some bits are reserved. */
  740. aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL);
  741. pr_info("%s cache controller enabled, %d ways, %d kB\n",
  742. data->type, ways, l2x0_size >> 10);
  743. pr_info("%s: CACHE_ID 0x%08x, AUX_CTRL 0x%08x\n",
  744. data->type, cache_id, aux);
  745. return 0;
  746. }
  747. void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask)
  748. {
  749. const struct l2c_init_data *data;
  750. u32 cache_id;
  751. l2x0_base = base;
  752. cache_id = readl_relaxed(base + L2X0_CACHE_ID);
  753. switch (cache_id & L2X0_CACHE_ID_PART_MASK) {
  754. default:
  755. case L2X0_CACHE_ID_PART_L210:
  756. data = &l2c210_data;
  757. break;
  758. case L2X0_CACHE_ID_PART_L220:
  759. data = &l2c220_data;
  760. break;
  761. case L2X0_CACHE_ID_PART_L310:
  762. data = &l2c310_init_fns;
  763. break;
  764. }
  765. /* Read back current (default) hardware configuration */
  766. if (data->save)
  767. data->save(l2x0_base);
  768. __l2c_init(data, aux_val, aux_mask, cache_id);
  769. }
  770. #ifdef CONFIG_OF
  771. static int l2_wt_override;
  772. /* Aurora don't have the cache ID register available, so we have to
  773. * pass it though the device tree */
  774. static u32 cache_id_part_number_from_dt;
  775. /**
  776. * l2x0_cache_size_of_parse() - read cache size parameters from DT
  777. * @np: the device tree node for the l2 cache
  778. * @aux_val: pointer to machine-supplied auxilary register value, to
  779. * be augmented by the call (bits to be set to 1)
  780. * @aux_mask: pointer to machine-supplied auxilary register mask, to
  781. * be augmented by the call (bits to be set to 0)
  782. * @associativity: variable to return the calculated associativity in
  783. * @max_way_size: the maximum size in bytes for the cache ways
  784. */
  785. static int __init l2x0_cache_size_of_parse(const struct device_node *np,
  786. u32 *aux_val, u32 *aux_mask,
  787. u32 *associativity,
  788. u32 max_way_size)
  789. {
  790. u32 mask = 0, val = 0;
  791. u32 cache_size = 0, sets = 0;
  792. u32 way_size_bits = 1;
  793. u32 way_size = 0;
  794. u32 block_size = 0;
  795. u32 line_size = 0;
  796. of_property_read_u32(np, "cache-size", &cache_size);
  797. of_property_read_u32(np, "cache-sets", &sets);
  798. of_property_read_u32(np, "cache-block-size", &block_size);
  799. of_property_read_u32(np, "cache-line-size", &line_size);
  800. if (!cache_size || !sets)
  801. return -ENODEV;
  802. /* All these l2 caches have the same line = block size actually */
  803. if (!line_size) {
  804. if (block_size) {
  805. /* If linesize is not given, it is equal to blocksize */
  806. line_size = block_size;
  807. } else {
  808. /* Fall back to known size */
  809. pr_warn("L2C OF: no cache block/line size given: "
  810. "falling back to default size %d bytes\n",
  811. CACHE_LINE_SIZE);
  812. line_size = CACHE_LINE_SIZE;
  813. }
  814. }
  815. if (line_size != CACHE_LINE_SIZE)
  816. pr_warn("L2C OF: DT supplied line size %d bytes does "
  817. "not match hardware line size of %d bytes\n",
  818. line_size,
  819. CACHE_LINE_SIZE);
  820. /*
  821. * Since:
  822. * set size = cache size / sets
  823. * ways = cache size / (sets * line size)
  824. * way size = cache size / (cache size / (sets * line size))
  825. * way size = sets * line size
  826. * associativity = ways = cache size / way size
  827. */
  828. way_size = sets * line_size;
  829. *associativity = cache_size / way_size;
  830. if (way_size > max_way_size) {
  831. pr_err("L2C OF: set size %dKB is too large\n", way_size);
  832. return -EINVAL;
  833. }
  834. pr_info("L2C OF: override cache size: %d bytes (%dKB)\n",
  835. cache_size, cache_size >> 10);
  836. pr_info("L2C OF: override line size: %d bytes\n", line_size);
  837. pr_info("L2C OF: override way size: %d bytes (%dKB)\n",
  838. way_size, way_size >> 10);
  839. pr_info("L2C OF: override associativity: %d\n", *associativity);
  840. /*
  841. * Calculates the bits 17:19 to set for way size:
  842. * 512KB -> 6, 256KB -> 5, ... 16KB -> 1
  843. */
  844. way_size_bits = ilog2(way_size >> 10) - 3;
  845. if (way_size_bits < 1 || way_size_bits > 6) {
  846. pr_err("L2C OF: cache way size illegal: %dKB is not mapped\n",
  847. way_size);
  848. return -EINVAL;
  849. }
  850. mask |= L2C_AUX_CTRL_WAY_SIZE_MASK;
  851. val |= (way_size_bits << L2C_AUX_CTRL_WAY_SIZE_SHIFT);
  852. *aux_val &= ~mask;
  853. *aux_val |= val;
  854. *aux_mask &= ~mask;
  855. return 0;
  856. }
  857. static void __init l2x0_of_parse(const struct device_node *np,
  858. u32 *aux_val, u32 *aux_mask)
  859. {
  860. u32 data[2] = { 0, 0 };
  861. u32 tag = 0;
  862. u32 dirty = 0;
  863. u32 val = 0, mask = 0;
  864. u32 assoc;
  865. int ret;
  866. of_property_read_u32(np, "arm,tag-latency", &tag);
  867. if (tag) {
  868. mask |= L2X0_AUX_CTRL_TAG_LATENCY_MASK;
  869. val |= (tag - 1) << L2X0_AUX_CTRL_TAG_LATENCY_SHIFT;
  870. }
  871. of_property_read_u32_array(np, "arm,data-latency",
  872. data, ARRAY_SIZE(data));
  873. if (data[0] && data[1]) {
  874. mask |= L2X0_AUX_CTRL_DATA_RD_LATENCY_MASK |
  875. L2X0_AUX_CTRL_DATA_WR_LATENCY_MASK;
  876. val |= ((data[0] - 1) << L2X0_AUX_CTRL_DATA_RD_LATENCY_SHIFT) |
  877. ((data[1] - 1) << L2X0_AUX_CTRL_DATA_WR_LATENCY_SHIFT);
  878. }
  879. of_property_read_u32(np, "arm,dirty-latency", &dirty);
  880. if (dirty) {
  881. mask |= L2X0_AUX_CTRL_DIRTY_LATENCY_MASK;
  882. val |= (dirty - 1) << L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT;
  883. }
  884. ret = l2x0_cache_size_of_parse(np, aux_val, aux_mask, &assoc, SZ_256K);
  885. if (ret)
  886. return;
  887. if (assoc > 8) {
  888. pr_err("l2x0 of: cache setting yield too high associativity\n");
  889. pr_err("l2x0 of: %d calculated, max 8\n", assoc);
  890. } else {
  891. mask |= L2X0_AUX_CTRL_ASSOC_MASK;
  892. val |= (assoc << L2X0_AUX_CTRL_ASSOC_SHIFT);
  893. }
  894. *aux_val &= ~mask;
  895. *aux_val |= val;
  896. *aux_mask &= ~mask;
  897. }
  898. static const struct l2c_init_data of_l2c210_data __initconst = {
  899. .type = "L2C-210",
  900. .way_size_0 = SZ_8K,
  901. .num_lock = 1,
  902. .of_parse = l2x0_of_parse,
  903. .enable = l2c_enable,
  904. .save = l2c_save,
  905. .outer_cache = {
  906. .inv_range = l2c210_inv_range,
  907. .clean_range = l2c210_clean_range,
  908. .flush_range = l2c210_flush_range,
  909. .flush_all = l2c210_flush_all,
  910. .disable = l2c_disable,
  911. .sync = l2c210_sync,
  912. .resume = l2c_resume,
  913. },
  914. };
  915. static const struct l2c_init_data of_l2c220_data __initconst = {
  916. .type = "L2C-220",
  917. .way_size_0 = SZ_8K,
  918. .num_lock = 1,
  919. .of_parse = l2x0_of_parse,
  920. .enable = l2c220_enable,
  921. .save = l2c_save,
  922. .outer_cache = {
  923. .inv_range = l2c220_inv_range,
  924. .clean_range = l2c220_clean_range,
  925. .flush_range = l2c220_flush_range,
  926. .flush_all = l2c220_flush_all,
  927. .disable = l2c_disable,
  928. .sync = l2c220_sync,
  929. .resume = l2c_resume,
  930. },
  931. };
  932. static void __init l2c310_of_parse(const struct device_node *np,
  933. u32 *aux_val, u32 *aux_mask)
  934. {
  935. u32 data[3] = { 0, 0, 0 };
  936. u32 tag[3] = { 0, 0, 0 };
  937. u32 filter[2] = { 0, 0 };
  938. u32 assoc;
  939. u32 prefetch;
  940. u32 val;
  941. int ret;
  942. of_property_read_u32_array(np, "arm,tag-latency", tag, ARRAY_SIZE(tag));
  943. if (tag[0] && tag[1] && tag[2])
  944. l2x0_saved_regs.tag_latency =
  945. L310_LATENCY_CTRL_RD(tag[0] - 1) |
  946. L310_LATENCY_CTRL_WR(tag[1] - 1) |
  947. L310_LATENCY_CTRL_SETUP(tag[2] - 1);
  948. of_property_read_u32_array(np, "arm,data-latency",
  949. data, ARRAY_SIZE(data));
  950. if (data[0] && data[1] && data[2])
  951. l2x0_saved_regs.data_latency =
  952. L310_LATENCY_CTRL_RD(data[0] - 1) |
  953. L310_LATENCY_CTRL_WR(data[1] - 1) |
  954. L310_LATENCY_CTRL_SETUP(data[2] - 1);
  955. of_property_read_u32_array(np, "arm,filter-ranges",
  956. filter, ARRAY_SIZE(filter));
  957. if (filter[1]) {
  958. l2x0_saved_regs.filter_end =
  959. ALIGN(filter[0] + filter[1], SZ_1M);
  960. l2x0_saved_regs.filter_start = (filter[0] & ~(SZ_1M - 1))
  961. | L310_ADDR_FILTER_EN;
  962. }
  963. ret = l2x0_cache_size_of_parse(np, aux_val, aux_mask, &assoc, SZ_512K);
  964. if (!ret) {
  965. switch (assoc) {
  966. case 16:
  967. *aux_val &= ~L2X0_AUX_CTRL_ASSOC_MASK;
  968. *aux_val |= L310_AUX_CTRL_ASSOCIATIVITY_16;
  969. *aux_mask &= ~L2X0_AUX_CTRL_ASSOC_MASK;
  970. break;
  971. case 8:
  972. *aux_val &= ~L2X0_AUX_CTRL_ASSOC_MASK;
  973. *aux_mask &= ~L2X0_AUX_CTRL_ASSOC_MASK;
  974. break;
  975. default:
  976. pr_err("L2C-310 OF cache associativity %d invalid, only 8 or 16 permitted\n",
  977. assoc);
  978. break;
  979. }
  980. }
  981. prefetch = l2x0_saved_regs.prefetch_ctrl;
  982. ret = of_property_read_u32(np, "arm,double-linefill", &val);
  983. if (ret == 0) {
  984. if (val)
  985. prefetch |= L310_PREFETCH_CTRL_DBL_LINEFILL;
  986. else
  987. prefetch &= ~L310_PREFETCH_CTRL_DBL_LINEFILL;
  988. } else if (ret != -EINVAL) {
  989. pr_err("L2C-310 OF arm,double-linefill property value is missing\n");
  990. }
  991. ret = of_property_read_u32(np, "arm,double-linefill-incr", &val);
  992. if (ret == 0) {
  993. if (val)
  994. prefetch |= L310_PREFETCH_CTRL_DBL_LINEFILL_INCR;
  995. else
  996. prefetch &= ~L310_PREFETCH_CTRL_DBL_LINEFILL_INCR;
  997. } else if (ret != -EINVAL) {
  998. pr_err("L2C-310 OF arm,double-linefill-incr property value is missing\n");
  999. }
  1000. ret = of_property_read_u32(np, "arm,double-linefill-wrap", &val);
  1001. if (ret == 0) {
  1002. if (!val)
  1003. prefetch |= L310_PREFETCH_CTRL_DBL_LINEFILL_WRAP;
  1004. else
  1005. prefetch &= ~L310_PREFETCH_CTRL_DBL_LINEFILL_WRAP;
  1006. } else if (ret != -EINVAL) {
  1007. pr_err("L2C-310 OF arm,double-linefill-wrap property value is missing\n");
  1008. }
  1009. ret = of_property_read_u32(np, "arm,prefetch-drop", &val);
  1010. if (ret == 0) {
  1011. if (val)
  1012. prefetch |= L310_PREFETCH_CTRL_PREFETCH_DROP;
  1013. else
  1014. prefetch &= ~L310_PREFETCH_CTRL_PREFETCH_DROP;
  1015. } else if (ret != -EINVAL) {
  1016. pr_err("L2C-310 OF arm,prefetch-drop property value is missing\n");
  1017. }
  1018. ret = of_property_read_u32(np, "arm,prefetch-offset", &val);
  1019. if (ret == 0) {
  1020. prefetch &= ~L310_PREFETCH_CTRL_OFFSET_MASK;
  1021. prefetch |= val & L310_PREFETCH_CTRL_OFFSET_MASK;
  1022. } else if (ret != -EINVAL) {
  1023. pr_err("L2C-310 OF arm,prefetch-offset property value is missing\n");
  1024. }
  1025. l2x0_saved_regs.prefetch_ctrl = prefetch;
  1026. }
  1027. static const struct l2c_init_data of_l2c310_data __initconst = {
  1028. .type = "L2C-310",
  1029. .way_size_0 = SZ_8K,
  1030. .num_lock = 8,
  1031. .of_parse = l2c310_of_parse,
  1032. .enable = l2c310_enable,
  1033. .fixup = l2c310_fixup,
  1034. .save = l2c310_save,
  1035. .configure = l2c310_configure,
  1036. .outer_cache = {
  1037. .inv_range = l2c210_inv_range,
  1038. .clean_range = l2c210_clean_range,
  1039. .flush_range = l2c210_flush_range,
  1040. .flush_all = l2c210_flush_all,
  1041. .disable = l2c310_disable,
  1042. .sync = l2c210_sync,
  1043. .resume = l2c310_resume,
  1044. },
  1045. };
  1046. /*
  1047. * This is a variant of the of_l2c310_data with .sync set to
  1048. * NULL. Outer sync operations are not needed when the system is I/O
  1049. * coherent, and potentially harmful in certain situations (PCIe/PL310
  1050. * deadlock on Armada 375/38x due to hardware I/O coherency). The
  1051. * other operations are kept because they are infrequent (therefore do
  1052. * not cause the deadlock in practice) and needed for secondary CPU
  1053. * boot and other power management activities.
  1054. */
  1055. static const struct l2c_init_data of_l2c310_coherent_data __initconst = {
  1056. .type = "L2C-310 Coherent",
  1057. .way_size_0 = SZ_8K,
  1058. .num_lock = 8,
  1059. .of_parse = l2c310_of_parse,
  1060. .enable = l2c310_enable,
  1061. .fixup = l2c310_fixup,
  1062. .save = l2c310_save,
  1063. .configure = l2c310_configure,
  1064. .outer_cache = {
  1065. .inv_range = l2c210_inv_range,
  1066. .clean_range = l2c210_clean_range,
  1067. .flush_range = l2c210_flush_range,
  1068. .flush_all = l2c210_flush_all,
  1069. .disable = l2c310_disable,
  1070. .resume = l2c310_resume,
  1071. },
  1072. };
  1073. /*
  1074. * Note that the end addresses passed to Linux primitives are
  1075. * noninclusive, while the hardware cache range operations use
  1076. * inclusive start and end addresses.
  1077. */
  1078. static unsigned long aurora_range_end(unsigned long start, unsigned long end)
  1079. {
  1080. /*
  1081. * Limit the number of cache lines processed at once,
  1082. * since cache range operations stall the CPU pipeline
  1083. * until completion.
  1084. */
  1085. if (end > start + MAX_RANGE_SIZE)
  1086. end = start + MAX_RANGE_SIZE;
  1087. /*
  1088. * Cache range operations can't straddle a page boundary.
  1089. */
  1090. if (end > PAGE_ALIGN(start+1))
  1091. end = PAGE_ALIGN(start+1);
  1092. return end;
  1093. }
  1094. static void aurora_pa_range(unsigned long start, unsigned long end,
  1095. unsigned long offset)
  1096. {
  1097. void __iomem *base = l2x0_base;
  1098. unsigned long range_end;
  1099. unsigned long flags;
  1100. /*
  1101. * round start and end adresses up to cache line size
  1102. */
  1103. start &= ~(CACHE_LINE_SIZE - 1);
  1104. end = ALIGN(end, CACHE_LINE_SIZE);
  1105. /*
  1106. * perform operation on all full cache lines between 'start' and 'end'
  1107. */
  1108. while (start < end) {
  1109. range_end = aurora_range_end(start, end);
  1110. raw_spin_lock_irqsave(&l2x0_lock, flags);
  1111. writel_relaxed(start, base + AURORA_RANGE_BASE_ADDR_REG);
  1112. writel_relaxed(range_end - CACHE_LINE_SIZE, base + offset);
  1113. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  1114. writel_relaxed(0, base + AURORA_SYNC_REG);
  1115. start = range_end;
  1116. }
  1117. }
  1118. static void aurora_inv_range(unsigned long start, unsigned long end)
  1119. {
  1120. aurora_pa_range(start, end, AURORA_INVAL_RANGE_REG);
  1121. }
  1122. static void aurora_clean_range(unsigned long start, unsigned long end)
  1123. {
  1124. /*
  1125. * If L2 is forced to WT, the L2 will always be clean and we
  1126. * don't need to do anything here.
  1127. */
  1128. if (!l2_wt_override)
  1129. aurora_pa_range(start, end, AURORA_CLEAN_RANGE_REG);
  1130. }
  1131. static void aurora_flush_range(unsigned long start, unsigned long end)
  1132. {
  1133. if (l2_wt_override)
  1134. aurora_pa_range(start, end, AURORA_INVAL_RANGE_REG);
  1135. else
  1136. aurora_pa_range(start, end, AURORA_FLUSH_RANGE_REG);
  1137. }
  1138. static void aurora_flush_all(void)
  1139. {
  1140. void __iomem *base = l2x0_base;
  1141. unsigned long flags;
  1142. /* clean all ways */
  1143. raw_spin_lock_irqsave(&l2x0_lock, flags);
  1144. __l2c_op_way(base + L2X0_CLEAN_INV_WAY);
  1145. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  1146. writel_relaxed(0, base + AURORA_SYNC_REG);
  1147. }
  1148. static void aurora_cache_sync(void)
  1149. {
  1150. writel_relaxed(0, l2x0_base + AURORA_SYNC_REG);
  1151. }
  1152. static void aurora_disable(void)
  1153. {
  1154. void __iomem *base = l2x0_base;
  1155. unsigned long flags;
  1156. raw_spin_lock_irqsave(&l2x0_lock, flags);
  1157. __l2c_op_way(base + L2X0_CLEAN_INV_WAY);
  1158. writel_relaxed(0, base + AURORA_SYNC_REG);
  1159. l2c_write_sec(0, base, L2X0_CTRL);
  1160. dsb(st);
  1161. raw_spin_unlock_irqrestore(&l2x0_lock, flags);
  1162. }
  1163. static void aurora_save(void __iomem *base)
  1164. {
  1165. l2x0_saved_regs.ctrl = readl_relaxed(base + L2X0_CTRL);
  1166. l2x0_saved_regs.aux_ctrl = readl_relaxed(base + L2X0_AUX_CTRL);
  1167. }
  1168. /*
  1169. * For Aurora cache in no outer mode, enable via the CP15 coprocessor
  1170. * broadcasting of cache commands to L2.
  1171. */
  1172. static void __init aurora_enable_no_outer(void __iomem *base, u32 aux,
  1173. unsigned num_lock)
  1174. {
  1175. u32 u;
  1176. asm volatile("mrc p15, 1, %0, c15, c2, 0" : "=r" (u));
  1177. u |= AURORA_CTRL_FW; /* Set the FW bit */
  1178. asm volatile("mcr p15, 1, %0, c15, c2, 0" : : "r" (u));
  1179. isb();
  1180. l2c_enable(base, aux, num_lock);
  1181. }
  1182. static void __init aurora_fixup(void __iomem *base, u32 cache_id,
  1183. struct outer_cache_fns *fns)
  1184. {
  1185. sync_reg_offset = AURORA_SYNC_REG;
  1186. }
  1187. static void __init aurora_of_parse(const struct device_node *np,
  1188. u32 *aux_val, u32 *aux_mask)
  1189. {
  1190. u32 val = AURORA_ACR_REPLACEMENT_TYPE_SEMIPLRU;
  1191. u32 mask = AURORA_ACR_REPLACEMENT_MASK;
  1192. of_property_read_u32(np, "cache-id-part",
  1193. &cache_id_part_number_from_dt);
  1194. /* Determine and save the write policy */
  1195. l2_wt_override = of_property_read_bool(np, "wt-override");
  1196. if (l2_wt_override) {
  1197. val |= AURORA_ACR_FORCE_WRITE_THRO_POLICY;
  1198. mask |= AURORA_ACR_FORCE_WRITE_POLICY_MASK;
  1199. }
  1200. *aux_val &= ~mask;
  1201. *aux_val |= val;
  1202. *aux_mask &= ~mask;
  1203. }
  1204. static const struct l2c_init_data of_aurora_with_outer_data __initconst = {
  1205. .type = "Aurora",
  1206. .way_size_0 = SZ_4K,
  1207. .num_lock = 4,
  1208. .of_parse = aurora_of_parse,
  1209. .enable = l2c_enable,
  1210. .fixup = aurora_fixup,
  1211. .save = aurora_save,
  1212. .outer_cache = {
  1213. .inv_range = aurora_inv_range,
  1214. .clean_range = aurora_clean_range,
  1215. .flush_range = aurora_flush_range,
  1216. .flush_all = aurora_flush_all,
  1217. .disable = aurora_disable,
  1218. .sync = aurora_cache_sync,
  1219. .resume = l2c_resume,
  1220. },
  1221. };
  1222. static const struct l2c_init_data of_aurora_no_outer_data __initconst = {
  1223. .type = "Aurora",
  1224. .way_size_0 = SZ_4K,
  1225. .num_lock = 4,
  1226. .of_parse = aurora_of_parse,
  1227. .enable = aurora_enable_no_outer,
  1228. .fixup = aurora_fixup,
  1229. .save = aurora_save,
  1230. .outer_cache = {
  1231. .resume = l2c_resume,
  1232. },
  1233. };
  1234. /*
  1235. * For certain Broadcom SoCs, depending on the address range, different offsets
  1236. * need to be added to the address before passing it to L2 for
  1237. * invalidation/clean/flush
  1238. *
  1239. * Section Address Range Offset EMI
  1240. * 1 0x00000000 - 0x3FFFFFFF 0x80000000 VC
  1241. * 2 0x40000000 - 0xBFFFFFFF 0x40000000 SYS
  1242. * 3 0xC0000000 - 0xFFFFFFFF 0x80000000 VC
  1243. *
  1244. * When the start and end addresses have crossed two different sections, we
  1245. * need to break the L2 operation into two, each within its own section.
  1246. * For example, if we need to invalidate addresses starts at 0xBFFF0000 and
  1247. * ends at 0xC0001000, we need do invalidate 1) 0xBFFF0000 - 0xBFFFFFFF and 2)
  1248. * 0xC0000000 - 0xC0001000
  1249. *
  1250. * Note 1:
  1251. * By breaking a single L2 operation into two, we may potentially suffer some
  1252. * performance hit, but keep in mind the cross section case is very rare
  1253. *
  1254. * Note 2:
  1255. * We do not need to handle the case when the start address is in
  1256. * Section 1 and the end address is in Section 3, since it is not a valid use
  1257. * case
  1258. *
  1259. * Note 3:
  1260. * Section 1 in practical terms can no longer be used on rev A2. Because of
  1261. * that the code does not need to handle section 1 at all.
  1262. *
  1263. */
  1264. #define BCM_SYS_EMI_START_ADDR 0x40000000UL
  1265. #define BCM_VC_EMI_SEC3_START_ADDR 0xC0000000UL
  1266. #define BCM_SYS_EMI_OFFSET 0x40000000UL
  1267. #define BCM_VC_EMI_OFFSET 0x80000000UL
  1268. static inline int bcm_addr_is_sys_emi(unsigned long addr)
  1269. {
  1270. return (addr >= BCM_SYS_EMI_START_ADDR) &&
  1271. (addr < BCM_VC_EMI_SEC3_START_ADDR);
  1272. }
  1273. static inline unsigned long bcm_l2_phys_addr(unsigned long addr)
  1274. {
  1275. if (bcm_addr_is_sys_emi(addr))
  1276. return addr + BCM_SYS_EMI_OFFSET;
  1277. else
  1278. return addr + BCM_VC_EMI_OFFSET;
  1279. }
  1280. static void bcm_inv_range(unsigned long start, unsigned long end)
  1281. {
  1282. unsigned long new_start, new_end;
  1283. BUG_ON(start < BCM_SYS_EMI_START_ADDR);
  1284. if (unlikely(end <= start))
  1285. return;
  1286. new_start = bcm_l2_phys_addr(start);
  1287. new_end = bcm_l2_phys_addr(end);
  1288. /* normal case, no cross section between start and end */
  1289. if (likely(bcm_addr_is_sys_emi(end) || !bcm_addr_is_sys_emi(start))) {
  1290. l2c210_inv_range(new_start, new_end);
  1291. return;
  1292. }
  1293. /* They cross sections, so it can only be a cross from section
  1294. * 2 to section 3
  1295. */
  1296. l2c210_inv_range(new_start,
  1297. bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR-1));
  1298. l2c210_inv_range(bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR),
  1299. new_end);
  1300. }
  1301. static void bcm_clean_range(unsigned long start, unsigned long end)
  1302. {
  1303. unsigned long new_start, new_end;
  1304. BUG_ON(start < BCM_SYS_EMI_START_ADDR);
  1305. if (unlikely(end <= start))
  1306. return;
  1307. new_start = bcm_l2_phys_addr(start);
  1308. new_end = bcm_l2_phys_addr(end);
  1309. /* normal case, no cross section between start and end */
  1310. if (likely(bcm_addr_is_sys_emi(end) || !bcm_addr_is_sys_emi(start))) {
  1311. l2c210_clean_range(new_start, new_end);
  1312. return;
  1313. }
  1314. /* They cross sections, so it can only be a cross from section
  1315. * 2 to section 3
  1316. */
  1317. l2c210_clean_range(new_start,
  1318. bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR-1));
  1319. l2c210_clean_range(bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR),
  1320. new_end);
  1321. }
  1322. static void bcm_flush_range(unsigned long start, unsigned long end)
  1323. {
  1324. unsigned long new_start, new_end;
  1325. BUG_ON(start < BCM_SYS_EMI_START_ADDR);
  1326. if (unlikely(end <= start))
  1327. return;
  1328. if ((end - start) >= l2x0_size) {
  1329. outer_cache.flush_all();
  1330. return;
  1331. }
  1332. new_start = bcm_l2_phys_addr(start);
  1333. new_end = bcm_l2_phys_addr(end);
  1334. /* normal case, no cross section between start and end */
  1335. if (likely(bcm_addr_is_sys_emi(end) || !bcm_addr_is_sys_emi(start))) {
  1336. l2c210_flush_range(new_start, new_end);
  1337. return;
  1338. }
  1339. /* They cross sections, so it can only be a cross from section
  1340. * 2 to section 3
  1341. */
  1342. l2c210_flush_range(new_start,
  1343. bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR-1));
  1344. l2c210_flush_range(bcm_l2_phys_addr(BCM_VC_EMI_SEC3_START_ADDR),
  1345. new_end);
  1346. }
  1347. /* Broadcom L2C-310 start from ARMs R3P2 or later, and require no fixups */
  1348. static const struct l2c_init_data of_bcm_l2x0_data __initconst = {
  1349. .type = "BCM-L2C-310",
  1350. .way_size_0 = SZ_8K,
  1351. .num_lock = 8,
  1352. .of_parse = l2c310_of_parse,
  1353. .enable = l2c310_enable,
  1354. .save = l2c310_save,
  1355. .configure = l2c310_configure,
  1356. .outer_cache = {
  1357. .inv_range = bcm_inv_range,
  1358. .clean_range = bcm_clean_range,
  1359. .flush_range = bcm_flush_range,
  1360. .flush_all = l2c210_flush_all,
  1361. .disable = l2c310_disable,
  1362. .sync = l2c210_sync,
  1363. .resume = l2c310_resume,
  1364. },
  1365. };
  1366. static void __init tauros3_save(void __iomem *base)
  1367. {
  1368. l2c_save(base);
  1369. l2x0_saved_regs.aux2_ctrl =
  1370. readl_relaxed(base + TAUROS3_AUX2_CTRL);
  1371. l2x0_saved_regs.prefetch_ctrl =
  1372. readl_relaxed(base + L310_PREFETCH_CTRL);
  1373. }
  1374. static void tauros3_configure(void __iomem *base)
  1375. {
  1376. writel_relaxed(l2x0_saved_regs.aux2_ctrl,
  1377. base + TAUROS3_AUX2_CTRL);
  1378. writel_relaxed(l2x0_saved_regs.prefetch_ctrl,
  1379. base + L310_PREFETCH_CTRL);
  1380. }
  1381. static const struct l2c_init_data of_tauros3_data __initconst = {
  1382. .type = "Tauros3",
  1383. .way_size_0 = SZ_8K,
  1384. .num_lock = 8,
  1385. .enable = l2c_enable,
  1386. .save = tauros3_save,
  1387. .configure = tauros3_configure,
  1388. /* Tauros3 broadcasts L1 cache operations to L2 */
  1389. .outer_cache = {
  1390. .resume = l2c_resume,
  1391. },
  1392. };
  1393. #define L2C_ID(name, fns) { .compatible = name, .data = (void *)&fns }
  1394. static const struct of_device_id l2x0_ids[] __initconst = {
  1395. L2C_ID("arm,l210-cache", of_l2c210_data),
  1396. L2C_ID("arm,l220-cache", of_l2c220_data),
  1397. L2C_ID("arm,pl310-cache", of_l2c310_data),
  1398. L2C_ID("brcm,bcm11351-a2-pl310-cache", of_bcm_l2x0_data),
  1399. L2C_ID("marvell,aurora-outer-cache", of_aurora_with_outer_data),
  1400. L2C_ID("marvell,aurora-system-cache", of_aurora_no_outer_data),
  1401. L2C_ID("marvell,tauros3-cache", of_tauros3_data),
  1402. /* Deprecated IDs */
  1403. L2C_ID("bcm,bcm11351-a2-pl310-cache", of_bcm_l2x0_data),
  1404. {}
  1405. };
  1406. int __init l2x0_of_init(u32 aux_val, u32 aux_mask)
  1407. {
  1408. const struct l2c_init_data *data;
  1409. struct device_node *np;
  1410. struct resource res;
  1411. u32 cache_id, old_aux;
  1412. u32 cache_level = 2;
  1413. np = of_find_matching_node(NULL, l2x0_ids);
  1414. if (!np)
  1415. return -ENODEV;
  1416. if (of_address_to_resource(np, 0, &res))
  1417. return -ENODEV;
  1418. l2x0_base = ioremap(res.start, resource_size(&res));
  1419. if (!l2x0_base)
  1420. return -ENOMEM;
  1421. l2x0_saved_regs.phy_base = res.start;
  1422. data = of_match_node(l2x0_ids, np)->data;
  1423. if (of_device_is_compatible(np, "arm,pl310-cache") &&
  1424. of_property_read_bool(np, "arm,io-coherent"))
  1425. data = &of_l2c310_coherent_data;
  1426. old_aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL);
  1427. if (old_aux != ((old_aux & aux_mask) | aux_val)) {
  1428. pr_warn("L2C: platform modifies aux control register: 0x%08x -> 0x%08x\n",
  1429. old_aux, (old_aux & aux_mask) | aux_val);
  1430. } else if (aux_mask != ~0U && aux_val != 0) {
  1431. pr_alert("L2C: platform provided aux values match the hardware, so have no effect. Please remove them.\n");
  1432. }
  1433. /* All L2 caches are unified, so this property should be specified */
  1434. if (!of_property_read_bool(np, "cache-unified"))
  1435. pr_err("L2C: device tree omits to specify unified cache\n");
  1436. if (of_property_read_u32(np, "cache-level", &cache_level))
  1437. pr_err("L2C: device tree omits to specify cache-level\n");
  1438. if (cache_level != 2)
  1439. pr_err("L2C: device tree specifies invalid cache level\n");
  1440. /* Read back current (default) hardware configuration */
  1441. if (data->save)
  1442. data->save(l2x0_base);
  1443. /* L2 configuration can only be changed if the cache is disabled */
  1444. if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN))
  1445. if (data->of_parse)
  1446. data->of_parse(np, &aux_val, &aux_mask);
  1447. if (cache_id_part_number_from_dt)
  1448. cache_id = cache_id_part_number_from_dt;
  1449. else
  1450. cache_id = readl_relaxed(l2x0_base + L2X0_CACHE_ID);
  1451. return __l2c_init(data, aux_val, aux_mask, cache_id);
  1452. }
  1453. #endif