ARM: cache-l2x0: Save L2CC registers using pl310 save/resume
Renamed the l2x0_suspend and resume functions to l2cc suspend
and resume. Functions pl310 save/resume takes care of the L2CC
registers. Moving the functions outside CONFIG_OF so that
those could be directly used.
Change-Id: I07a156de37ee0504debbbd392bc017ebfa9cae1e
Signed-off-by: Taniya Das <tdas@codeaurora.org>
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 01d6ac5..dee5479 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -30,8 +30,6 @@
#define CACHE_LINE_SIZE 32
static void __iomem *l2x0_base;
-static uint32_t aux_ctrl_save;
-static uint32_t data_latency_ctrl;
static DEFINE_RAW_SPINLOCK(l2x0_lock);
static uint32_t l2x0_way_mask; /* Bitmask of active ways */
@@ -449,51 +447,6 @@
ways, cache_id, aux, l2x0_size);
}
-void l2x0_suspend(void)
-{
- /* Save aux control register value */
- aux_ctrl_save = readl_relaxed(l2x0_base + L2X0_AUX_CTRL);
- data_latency_ctrl = readl_relaxed(l2x0_base + L2X0_DATA_LATENCY_CTRL);
- /* Flush all cache */
- l2x0_flush_all();
- /* Disable the cache */
- writel_relaxed(0, l2x0_base + L2X0_CTRL);
-
- /* Memory barrier */
- dmb();
-}
-
-void l2x0_resume(int collapsed)
-{
- if (collapsed) {
- /* Disable the cache */
- writel_relaxed(0, l2x0_base + L2X0_CTRL);
-
- /* Restore aux control register value */
- writel_relaxed(aux_ctrl_save, l2x0_base + L2X0_AUX_CTRL);
- writel_relaxed(data_latency_ctrl, l2x0_base +
- L2X0_DATA_LATENCY_CTRL);
-
- /* Invalidate the cache */
- l2x0_inv_all();
- /*
- * TBD: make sure that l2xo_inv_all finished
- * before actually enabling the cache. Logically this
- * is not required as cache sync is atomic operation.
- * but on 8x25, observed the random crashes and they go
- * away if we add dmb or disable the L2.
- * keeping this as temporary workaround until root
- * cause is find out.
- */
- dmb();
- }
-
- /* Enable the cache */
- writel_relaxed(1, l2x0_base + L2X0_CTRL);
-
- mb();
-}
-
#ifdef CONFIG_OF
static void __init l2x0_of_setup(const struct device_node *np,
u32 *aux_val, u32 *aux_mask)
@@ -562,6 +515,7 @@
l2x0_base + L2X0_ADDR_FILTER_START);
}
}
+#endif
static void __init pl310_save(void)
{
@@ -637,6 +591,7 @@
l2x0_resume();
}
+#ifdef CONFIG_OF
static const struct l2x0_of_data pl310_data = {
pl310_of_setup,
pl310_save,
@@ -692,3 +647,17 @@
return 0;
}
#endif
+
+void l2cc_suspend(void)
+{
+ pl310_save();
+ l2x0_disable();
+ dmb();
+}
+
+void l2cc_resume(int collapsed)
+{
+ if (collapsed)
+ pl310_resume();
+ dmb();
+}