msm: footswitch-8x60: Collapse core memory during core power-collapse

Even when a core's power is collapsed, memory within the core remains
powered. Call the clk_set_flags(CLKFLAG_NORETAIN) API from the clock
driver to allow the core memory to collapse when the core clock is
disabled as part of the footswitch collapse sequence. Also re-nable
the retention mode as part of the restore sequence.

CRs-Fixed: 322181
Change-Id: I8e73654d2de0ff108c6579b94700c80ddba186e4
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
diff --git a/arch/arm/mach-msm/footswitch-8x60.c b/arch/arm/mach-msm/footswitch-8x60.c
index cd6e582..296c111 100644
--- a/arch/arm/mach-msm/footswitch-8x60.c
+++ b/arch/arm/mach-msm/footswitch-8x60.c
@@ -213,6 +213,9 @@
 		udelay(RESET_DELAY_US);
 	}
 
+	/* Prevent core memory from collapsing when its clock is gated. */
+	clk_set_flags(fs->core_clk, CLKFLAG_RETAIN);
+
 	/* Return clocks to their state before this function. */
 	restore_clocks(fs);
 
@@ -242,6 +245,9 @@
 	if (rc)
 		return rc;
 
+	/* Allow core memory to collapse when its clock is gated. */
+	clk_set_flags(fs->core_clk, CLKFLAG_NORETAIN);
+
 	/* Halt all bus ports in the power domain. */
 	if (fs->bus_port0) {
 		rc = msm_bus_axi_porthalt(fs->bus_port0);
@@ -294,6 +300,7 @@
 err_port2_halt:
 	msm_bus_axi_portunhalt(fs->bus_port0);
 err:
+	clk_set_flags(fs->core_clk, CLKFLAG_RETAIN);
 	restore_clocks(fs);
 	return rc;
 }
@@ -360,6 +367,9 @@
 	/* Re-enable core clock. */
 	clk_prepare_enable(fs->core_clk);
 
+	/* Prevent core memory from collapsing when its clock is gated. */
+	clk_set_flags(fs->core_clk, CLKFLAG_RETAIN);
+
 	/* Return clocks to their state before this function. */
 	restore_clocks(fs);
 
@@ -387,6 +397,9 @@
 	if (rc)
 		return rc;
 
+	/* Allow core memory to collapse when its clock is gated. */
+	clk_set_flags(fs->core_clk, CLKFLAG_NORETAIN);
+
 	/* Halt all bus ports in the power domain. */
 	if (fs->bus_port0) {
 		rc = msm_bus_axi_porthalt(fs->bus_port0);
@@ -431,6 +444,7 @@
 	return 0;
 
 err:
+	clk_set_flags(fs->core_clk, CLKFLAG_RETAIN);
 	restore_clocks(fs);
 	return rc;
 }