qcacmn: Support for wifidown and wifiup without modules removal

Release the iomem requested during the cleanup path.
Successive request to iomem resource fails,
if the ioremapped region is not released
during the last cleanup

Change-Id: Icc88647df8d21f9f230b784faa8e7fdaf5968814
Acked-by: Balamurugan Mahalingam <bmahalin@codeaurora.org>
CRs-Fixed: 1056971
diff --git a/hif/src/dispatcher/ahb_api.h b/hif/src/dispatcher/ahb_api.h
index 8ba0c75..2bba2ff 100644
--- a/hif/src/dispatcher/ahb_api.h
+++ b/hif/src/dispatcher/ahb_api.h
@@ -26,6 +26,7 @@
 
 void hif_ahb_disable_isr(struct hif_softc *hif_ctx);
 void hif_ahb_nointrs(struct hif_softc *scn);
+void hif_ahb_reset_soc(struct hif_softc *hif_ctx);
 QDF_STATUS hif_ahb_enable_bus(struct hif_softc *ol_sc,
 			  struct device *dev, void *bdev,
 			  const hif_bus_id *bid,
diff --git a/hif/src/dispatcher/multibus_ahb.c b/hif/src/dispatcher/multibus_ahb.c
index b543e8f..d1bee78 100644
--- a/hif/src/dispatcher/multibus_ahb.c
+++ b/hif/src/dispatcher/multibus_ahb.c
@@ -38,7 +38,7 @@
 	bus_ops->hif_bus_open = &hif_ahb_open;
 	bus_ops->hif_bus_close = &hif_ahb_close;
 	bus_ops->hif_bus_prevent_linkdown = &hif_dummy_bus_prevent_linkdown;
-	bus_ops->hif_reset_soc = &hif_dummy_reset_soc;
+	bus_ops->hif_reset_soc = &hif_ahb_reset_soc;
 	bus_ops->hif_bus_suspend = &hif_dummy_bus_suspend;
 	bus_ops->hif_bus_resume = &hif_dummy_bus_resume;
 	bus_ops->hif_target_sleep_state_adjust =
diff --git a/hif/src/snoc/if_ahb.c b/hif/src/snoc/if_ahb.c
index dc60778..6f986fd 100644
--- a/hif/src/snoc/if_ahb.c
+++ b/hif/src/snoc/if_ahb.c
@@ -233,15 +233,29 @@
 	struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
 	void __iomem *mem;
 	struct platform_device *pdev = (struct platform_device *)sc->pdev;
+	struct resource *memres = NULL;
+	int mem_pa_size = 0;
 
 	/*Disable WIFI clock input*/
-	hif_ahb_clk_enable_disable(&pdev->dev, 0);
+	if (sc->mem) {
+		memres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		if (!memres) {
+			HIF_INFO("%s: Failed to get IORESOURCE_MEM\n",
+								__func__);
+			return;
+		}
+		mem_pa_size = memres->end - memres->start + 1;
 
-	hif_ahb_device_reset(scn);
-	mem = (void __iomem *)sc->mem;
-	if (mem) {
-		devm_iounmap(&pdev->dev, mem);
-		sc->mem = NULL;
+		hif_ahb_clk_enable_disable(&pdev->dev, 0);
+
+		hif_ahb_device_reset(scn);
+		mem = (void __iomem *)sc->mem;
+		if (mem) {
+			devm_iounmap(&pdev->dev, mem);
+			devm_release_mem_region(&pdev->dev, scn->mem_pa,
+								mem_pa_size);
+			sc->mem = NULL;
+		}
 	}
 	scn->mem = NULL;
 }
@@ -324,6 +338,7 @@
 	sc->mem = mem;
 	ol_sc->mem = mem;
 	ol_sc->mem_pa = memres->start;
+
 	tgt_info = hif_get_target_info_handle((struct hif_opaque_softc *)ol_sc);
 
 	tgt_info->target_type = target_type;
@@ -362,10 +377,9 @@
  * Return: void
  */
 /* Function to reset SoC */
-void hif_ahb_reset_soc(struct hif_opaque_softc *hif_ctx)
+void hif_ahb_reset_soc(struct hif_softc *hif_ctx)
 {
-	struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_ctx);
-	hif_ahb_device_reset((struct hif_softc *)sc);
+	hif_ahb_device_reset(hif_ctx);
 }