qcacmn: Fix crash caused by sdio ramdump allocation

For TF sdio chip with platform driver, ramdump is
configured in platform driver. Driver can get the
virtual memory, but it can't call ioremap again.

If there is a platform driver, ramdump should be
allocated in platform driver, and if there is no
platform driver, ramdump should be allocated in
driver.

CRs-Fixed: 2060381
Change-Id: Ia2a32a4895f354e365522a30bbfac949ccb7a391
diff --git a/hif/src/sdio/if_sdio.c b/hif/src/sdio/if_sdio.c
index 65ba4d6..f117f04 100644
--- a/hif/src/sdio/if_sdio.c
+++ b/hif/src/sdio/if_sdio.c
@@ -54,6 +54,7 @@
 #include "pktlog_ac.h"
 #endif
 #include "epping_main.h"
+#include "pld_sdio.h"
 
 #ifndef ATH_BUS_PM
 #ifdef CONFIG_PM
@@ -168,14 +169,18 @@
 	scn->ol_sc = *ol_sc;
 	ol_sc->target_info.target_type = target_type;
 
-#ifndef TARGET_DUMP_FOR_NON_QC_PLATFORM
-	scn->ramdump_base = ioremap(RAMDUMP_ADDR, RAMDUMP_SIZE);
-	scn->ramdump_size = RAMDUMP_SIZE;
-	if (scn->ramdump_base == NULL) {
-		scn->ramdump_base = 0;
-		scn->ramdump_size = 0;
+	scn->ramdump_base = pld_hif_sdio_get_virt_ramdump_mem(
+					scn->aps_osdev.device,
+					&scn->ramdump_size);
+	if (scn->ramdump_base == NULL || !scn->ramdump_size) {
+		QDF_TRACE(QDF_MODULE_ID_HIF, QDF_TRACE_LEVEL_ERROR,
+			"%s: Failed to get RAM dump memory address or size!\n",
+			__func__);
+	} else {
+		QDF_TRACE(QDF_MODULE_ID_HIF, QDF_TRACE_LEVEL_INFO,
+			"%s: ramdump base 0x%p size %d\n", __func__,
+			scn->ramdump_base, (int)scn->ramdump_size);
 	}
-#endif
 
 	if (athdiag_procfs_init(scn) != 0) {
 		QDF_TRACE(QDF_MODULE_ID_HIF, QDF_TRACE_LEVEL_ERROR,
@@ -190,6 +195,8 @@
 	return 0;
 
 err_attach1:
+	if (scn->ramdump_base)
+		pld_hif_sdio_release_ramdump_mem(scn->ramdump_base);
 	qdf_mem_free(ol_sc);
 err_attach:
 	qdf_mem_free(scn);
diff --git a/pld_stub/inc/pld_common.h b/pld_stub/inc/pld_common.h
index 7ff5803..750aeb1 100644
--- a/pld_stub/inc/pld_common.h
+++ b/pld_stub/inc/pld_common.h
@@ -260,6 +260,14 @@
 {
 	return 0;
 }
+static inline void *pld_hif_sdio_get_virt_ramdump_mem(struct device *dev,
+						unsigned long *size)
+{
+	return NULL;
+}
+static inline void pld_hif_sdio_release_ramdump_mem(unsigned long *address)
+{
+}
 
 #endif
 #endif