aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm/cache-l2x0.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2014-03-15 12:47:52 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2014-05-29 19:47:43 -0400
commit96054b0a99f4b7104c02e5521ee5c0d7b1fb09bc (patch)
tree5f89df251a271ab88261cb930de6ae447bb748b6 /arch/arm/mm/cache-l2x0.c
parent14b882cfa3f9db3430037dca6038e161eda953a1 (diff)
ARM: l2c: clean up OF initialisation a bit
Rather than having a boolean and other tricks to disable some bits of l2x0_init(), split this function into two parts: a common part shared between OF and non-OF, and the non-OF part. The common part can take a block of function pointers, and the cache ID (to cope with Aurora's DT specified ID.) Eliminate the redundant setting of l2x0_base in the OF case, moving it to the non-OF init function. This allows us to localise the OF-specific initialisation handling from the non-OF handling. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm/cache-l2x0.c')
-rw-r--r--arch/arm/mm/cache-l2x0.c66
1 files changed, 40 insertions, 26 deletions
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index c39602ef2cdd..0d83b24b7971 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -42,14 +42,8 @@ static u32 l2x0_way_mask; /* Bitmask of active ways */
42static u32 l2x0_size; 42static u32 l2x0_size;
43static unsigned long sync_reg_offset = L2X0_CACHE_SYNC; 43static unsigned long sync_reg_offset = L2X0_CACHE_SYNC;
44 44
45/* Aurora don't have the cache ID register available, so we have to
46 * pass it though the device tree */
47static u32 cache_id_part_number_from_dt;
48
49struct l2x0_regs l2x0_saved_regs; 45struct l2x0_regs l2x0_saved_regs;
50 46
51static bool of_init = false;
52
53/* 47/*
54 * Common code for all cache controllers. 48 * Common code for all cache controllers.
55 */ 49 */
@@ -343,20 +337,26 @@ static void l2x0_unlock(u32 cache_id)
343 l2c_unlock(l2x0_base, lockregs); 337 l2c_unlock(l2x0_base, lockregs);
344} 338}
345 339
346void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) 340static const struct l2c_init_data l2x0_init_fns __initconst = {
341 .outer_cache = {
342 .inv_range = l2x0_inv_range,
343 .clean_range = l2x0_clean_range,
344 .flush_range = l2x0_flush_range,
345 .flush_all = l2x0_flush_all,
346 .disable = l2x0_disable,
347 .sync = l2x0_cache_sync,
348 },
349};
350
351static void __init __l2c_init(const struct l2c_init_data *data,
352 u32 aux_val, u32 aux_mask, u32 cache_id)
347{ 353{
348 u32 aux; 354 u32 aux;
349 u32 cache_id;
350 u32 way_size = 0; 355 u32 way_size = 0;
351 int ways; 356 int ways;
352 int way_size_shift = L2X0_WAY_SIZE_SHIFT; 357 int way_size_shift = L2X0_WAY_SIZE_SHIFT;
353 const char *type; 358 const char *type;
354 359
355 l2x0_base = base;
356 if (cache_id_part_number_from_dt)
357 cache_id = cache_id_part_number_from_dt;
358 else
359 cache_id = readl_relaxed(l2x0_base + L2X0_CACHE_ID);
360 aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); 360 aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL);
361 361
362 aux &= aux_mask; 362 aux &= aux_mask;
@@ -374,8 +374,6 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask)
374 /* Unmapped register. */ 374 /* Unmapped register. */
375 sync_reg_offset = L2X0_DUMMY_REG; 375 sync_reg_offset = L2X0_DUMMY_REG;
376#endif 376#endif
377 if ((cache_id & L2X0_CACHE_ID_RTL_MASK) <= L310_CACHE_ID_RTL_R3P0)
378 outer_cache.set_debug = pl310_set_debug;
379 break; 377 break;
380 case L2X0_CACHE_ID_PART_L210: 378 case L2X0_CACHE_ID_PART_L210:
381 ways = (aux >> 13) & 0xf; 379 ways = (aux >> 13) & 0xf;
@@ -430,23 +428,35 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask)
430 /* Save the value for resuming. */ 428 /* Save the value for resuming. */
431 l2x0_saved_regs.aux_ctrl = aux; 429 l2x0_saved_regs.aux_ctrl = aux;
432 430
433 if (!of_init) { 431 outer_cache = data->outer_cache;
434 outer_cache.inv_range = l2x0_inv_range; 432
435 outer_cache.clean_range = l2x0_clean_range; 433 if ((cache_id & L2X0_CACHE_ID_PART_MASK) == L2X0_CACHE_ID_PART_L310 &&
436 outer_cache.flush_range = l2x0_flush_range; 434 (cache_id & L2X0_CACHE_ID_RTL_MASK) <= L310_CACHE_ID_RTL_R3P0)
437 outer_cache.sync = l2x0_cache_sync; 435 outer_cache.set_debug = pl310_set_debug;
438 outer_cache.flush_all = l2x0_flush_all;
439 outer_cache.disable = l2x0_disable;
440 }
441 436
442 pr_info("%s cache controller enabled\n", type); 437 pr_info("%s cache controller enabled\n", type);
443 pr_info("l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d kB\n", 438 pr_info("l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d kB\n",
444 ways, cache_id, aux, l2x0_size >> 10); 439 ways, cache_id, aux, l2x0_size >> 10);
445} 440}
446 441
442void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask)
443{
444 u32 cache_id;
445
446 l2x0_base = base;
447
448 cache_id = readl_relaxed(base + L2X0_CACHE_ID);
449
450 __l2c_init(&l2x0_init_fns, aux_val, aux_mask, cache_id);
451}
452
447#ifdef CONFIG_OF 453#ifdef CONFIG_OF
448static int l2_wt_override; 454static int l2_wt_override;
449 455
456/* Aurora don't have the cache ID register available, so we have to
457 * pass it though the device tree */
458static u32 cache_id_part_number_from_dt;
459
450/* 460/*
451 * Note that the end addresses passed to Linux primitives are 461 * Note that the end addresses passed to Linux primitives are
452 * noninclusive, while the hardware cache range operations use 462 * noninclusive, while the hardware cache range operations use
@@ -985,6 +995,7 @@ int __init l2x0_of_init(u32 aux_val, u32 aux_mask)
985 const struct l2c_init_data *data; 995 const struct l2c_init_data *data;
986 struct device_node *np; 996 struct device_node *np;
987 struct resource res; 997 struct resource res;
998 u32 cache_id;
988 999
989 np = of_find_matching_node(NULL, l2x0_ids); 1000 np = of_find_matching_node(NULL, l2x0_ids);
990 if (!np) 1001 if (!np)
@@ -1015,9 +1026,12 @@ int __init l2x0_of_init(u32 aux_val, u32 aux_mask)
1015 if (data->save) 1026 if (data->save)
1016 data->save(); 1027 data->save();
1017 1028
1018 of_init = true; 1029 if (cache_id_part_number_from_dt)
1019 memcpy(&outer_cache, &data->outer_cache, sizeof(outer_cache)); 1030 cache_id = cache_id_part_number_from_dt;
1020 l2x0_init(l2x0_base, aux_val, aux_mask); 1031 else
1032 cache_id = readl_relaxed(l2x0_base + L2X0_CACHE_ID);
1033
1034 __l2c_init(data, aux_val, aux_mask, cache_id);
1021 1035
1022 return 0; 1036 return 0;
1023} 1037}