msm: pil-gss: Request the AXI port to halt before shutting down peripheral

This makes sure the bus port is idle prior to shutting down GSS, which
avoid the possibility of locking up the system fabric if GSS is shutdown
before it is idle.

Change-Id: Idf09482ebb3f7a8977ea244d6501f62b4adebbd1
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
diff --git a/arch/arm/mach-msm/pil-gss.c b/arch/arm/mach-msm/pil-gss.c
index c4477ff..78a6054 100644
--- a/arch/arm/mach-msm/pil-gss.c
+++ b/arch/arm/mach-msm/pil-gss.c
@@ -26,6 +26,8 @@
 #include <mach/msm_iomap.h>
 #include <mach/msm_xo.h>
 #include <mach/socinfo.h>
+#include <mach/msm_bus_board.h>
+#include <mach/msm_bus.h>
 
 #include "peripheral-loader.h"
 #include "scm-pas.h"
@@ -166,6 +168,9 @@
 		return ret;
 	}
 
+	/* Make sure bus port is halted. */
+	msm_bus_axi_porthalt(MSM_BUS_MASTER_GSS_NAV);
+
 	/*
 	 * Vote PLL on in GSS's voting register and wait for it to enable.
 	 * The PLL must be enable to switch the GFMUX to a low-power source.
@@ -216,6 +221,14 @@
 	if (ret)
 		return ret;
 
+	/* Unhalt bus port. */
+	ret = msm_bus_axi_portunhalt(MSM_BUS_MASTER_GSS_NAV);
+	if (ret) {
+		dev_err(pil->dev, "Failed to unhalt bus port\n");
+		remove_gss_proxy_votes_now(drv);
+		return ret;
+	}
+
 	/* Vote PLL on in GSS's voting register and wait for it to enable. */
 	writel_relaxed(PLL5_VOTE, PLL_ENA_GSS);
 	while ((readl_relaxed(PLL5_STATUS) & PLL_STATUS) == 0)
@@ -278,6 +291,7 @@
 		return ret;
 	}
 
+	msm_bus_axi_porthalt(MSM_BUS_MASTER_GSS_NAV);
 	ret = pas_shutdown(PAS_GSS);
 	clk_disable_unprepare(drv->xo);
 	remove_gss_proxy_votes_now(drv);
@@ -292,11 +306,17 @@
 
 	err = make_gss_proxy_votes(pil->dev);
 	if (err)
-		return err;
+		goto out;
+
+	err = msm_bus_axi_portunhalt(MSM_BUS_MASTER_GSS_NAV);
+	if (err) {
+		dev_err(pil->dev, "Failed to unhalt bus port\n");
+		goto remove_votes;
+	}
 
 	err =  pas_auth_and_reset(PAS_GSS);
 	if (err)
-		remove_gss_proxy_votes_now(drv);
+		goto halt_port;
 
 	if (cpu_is_apq8064() &&
 	    ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1) &&
@@ -314,7 +334,13 @@
 		 */
 		writel_relaxed(0x0, drv->base + GSS_CSR_RESET);
 	}
+	return 0;
 
+halt_port:
+	msm_bus_axi_porthalt(MSM_BUS_MASTER_GSS_NAV);
+remove_votes:
+	remove_gss_proxy_votes_now(drv);
+out:
 	return err;
 }