qcacld-3.0: Update prefix for multi-interface with chip name

1. The paths for driver to get ini and fw files
   are incorrect for QCA SDIO chip on Dual-WiFi
   platforms, with wrong prefix or no prefix.
   Correct prefix for ini file, from '<mod_name>'
   to '<chip_name>/'; add prefix '<chip_name>/'
   for fw files.

2. For QCA9377, there is a special cnss API for getting
   fw names, it's cnss_get_qca9377_fw_files().
   Use the right cnss API to get fw files for QCA9377

Change-Id: Ia7616153b6823e9550703e649c7fc21ab306ca07
CRs-Fixed: 2008217
diff --git a/Kbuild b/Kbuild
index 72f192d..838f849 100644
--- a/Kbuild
+++ b/Kbuild
@@ -1737,6 +1737,10 @@
 endif
 endif
 
+ifeq ($(CONFIG_ARCH_MDM9607), y)
+CDEFINES += -DCONFIG_TUFELLO_DUAL_FW_SUPPORT
+endif
+
 #Enable Signed firmware support for split binary format
 ifeq ($(CONFIG_QCA_SIGNED_SPLIT_BINARY_SUPPORT), 1)
 CDEFINES += -DQCA_SIGNED_SPLIT_BINARY_SUPPORT
@@ -1884,13 +1888,14 @@
 EXTRA_CFLAGS += -Wheader-guard
 endif
 # If the module name is not "wlan", then the define MULTI_IF_NAME to be the
-# same a the module name. The host driver will then append MULTI_IF_NAME to
+# same a the QCA CHIP name. The host driver will then append MULTI_IF_NAME to
 # any string that must be unique for all instances of the driver on the system.
 # This allows multiple instances of the driver with different module names.
 # If the module name is wlan, leave MULTI_IF_NAME undefined and the code will
 # treat the driver as the primary driver.
 ifneq ($(MODNAME), wlan)
-CDEFINES += -DMULTI_IF_NAME=\"$(MODNAME)\"
+CHIP_NAME ?= $(MODNAME)
+CDEFINES += -DMULTI_IF_NAME=\"$(CHIP_NAME)\"
 endif
 
 # WLAN_HDD_ADAPTER_MAGIC must be unique for all instances of the driver on the
diff --git a/core/hdd/inc/wlan_hdd_misc.h b/core/hdd/inc/wlan_hdd_misc.h
index 82e1b2b..0ca4a05 100644
--- a/core/hdd/inc/wlan_hdd_misc.h
+++ b/core/hdd/inc/wlan_hdd_misc.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2014,2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2014,2016-2017 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -32,7 +32,7 @@
  * to prevent name conflicts when loading multiple instances of the driver.
  */
 #ifdef MULTI_IF_NAME
-#define PREFIX MULTI_IF_NAME
+#define PREFIX MULTI_IF_NAME "/"
 #else
 #define PREFIX ""
 #endif
diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h
index 763a9d3..35b6c35 100644
--- a/core/pld/inc/pld_common.h
+++ b/core/pld/inc/pld_common.h
@@ -31,6 +31,7 @@
 #include <linux/device.h>
 #include <linux/interrupt.h>
 #include <linux/pm.h>
+#include <osapi_linux.h>
 
 #define PLD_IMAGE_FILE               "athwlan.bin"
 #define PLD_UTF_FIRMWARE_FILE        "utf.bin"
@@ -70,7 +71,7 @@
 	PLD_BUS_WIDTH_HIGH
 };
 
-#define PLD_MAX_FILE_NAME 20
+#define PLD_MAX_FILE_NAME NAME_MAX
 
 /**
  * struct pld_fw_file - WLAN FW file names
diff --git a/core/pld/src/pld_sdio.c b/core/pld/src/pld_sdio.c
index 14b17f9..87df90a 100644
--- a/core/pld/src/pld_sdio.c
+++ b/core/pld/src/pld_sdio.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -28,6 +28,8 @@
 
 #include "pld_common.h"
 #include "pld_internal.h"
+#include "pld_sdio.h"
+
 
 #ifdef CONFIG_SDIO
 /* SDIO manufacturer ID and Codes */
@@ -288,6 +290,18 @@
 #endif
 
 #ifdef CONFIG_PLD_SDIO_CNSS
+#ifdef CONFIG_TUFELLO_DUAL_FW_SUPPORT
+static inline int pld_sdio_is_tufello_dual_fw_supported(void)
+{
+	return 1;
+}
+#else
+static inline int pld_sdio_is_tufello_dual_fw_supported(void)
+{
+	return 0;
+#endif
+}
+
 /**
  * pld_sdio_get_fw_files_for_target() - Get FW file names
  * @pfw_files: buffer for FW file names
@@ -310,25 +324,30 @@
 
 	memset(pfw_files, 0, sizeof(*pfw_files));
 
-	ret = cnss_get_fw_files_for_target(&cnss_fw_files,
+	if (target_version == PLD_QCA9377_REV1_1_VERSION) {
+		cnss_get_qca9377_fw_files(&cnss_fw_files, PLD_MAX_FILE_NAME,
+			pld_sdio_is_tufello_dual_fw_supported());
+	} else {
+		ret = cnss_get_fw_files_for_target(&cnss_fw_files,
 					   target_type, target_version);
+	}
 	if (0 != ret)
 		return ret;
 
-	strlcpy(pfw_files->image_file, cnss_fw_files.image_file,
-		PLD_MAX_FILE_NAME);
-	strlcpy(pfw_files->board_data, cnss_fw_files.board_data,
-		PLD_MAX_FILE_NAME);
-	strlcpy(pfw_files->otp_data, cnss_fw_files.otp_data,
-		PLD_MAX_FILE_NAME);
-	strlcpy(pfw_files->utf_file, cnss_fw_files.utf_file,
-		PLD_MAX_FILE_NAME);
-	strlcpy(pfw_files->utf_board_data, cnss_fw_files.utf_board_data,
-		PLD_MAX_FILE_NAME);
-	strlcpy(pfw_files->epping_file, cnss_fw_files.epping_file,
-		PLD_MAX_FILE_NAME);
-	strlcpy(pfw_files->evicted_data, cnss_fw_files.evicted_data,
-		PLD_MAX_FILE_NAME);
+	snprintf(pfw_files->image_file, PLD_MAX_FILE_NAME, PREFIX "%s",
+		cnss_fw_files.image_file);
+	snprintf(pfw_files->board_data, PLD_MAX_FILE_NAME, PREFIX "%s",
+		cnss_fw_files.board_data);
+	snprintf(pfw_files->otp_data, PLD_MAX_FILE_NAME, PREFIX "%s",
+		cnss_fw_files.otp_data);
+	snprintf(pfw_files->utf_file, PLD_MAX_FILE_NAME, PREFIX "%s",
+		cnss_fw_files.utf_file);
+	snprintf(pfw_files->utf_board_data, PLD_MAX_FILE_NAME, PREFIX "%s",
+		cnss_fw_files.utf_board_data);
+	snprintf(pfw_files->epping_file, PLD_MAX_FILE_NAME, PREFIX "%s",
+		cnss_fw_files.epping_file);
+	snprintf(pfw_files->evicted_data, PLD_MAX_FILE_NAME, PREFIX "%s",
+		cnss_fw_files.evicted_data);
 
 	return ret;
 }
diff --git a/core/pld/src/pld_sdio.h b/core/pld/src/pld_sdio.h
index 2ac4cea..77cf0dd 100644
--- a/core/pld/src/pld_sdio.h
+++ b/core/pld/src/pld_sdio.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -21,6 +21,14 @@
 
 #include "pld_common.h"
 
+#ifdef MULTI_IF_NAME
+#define PREFIX MULTI_IF_NAME "/"
+#else
+#define PREFIX ""
+#endif
+
+#define PLD_QCA9377_REV1_1_VERSION          0x5020001
+
 #ifndef CONFIG_CNSS
 #define PLD_AR6004_VERSION_REV1_3           0x31c8088a
 #define PLD_AR9888_REV2_VERSION             0x4100016c
@@ -31,13 +39,7 @@
 #define PLD_AR6320_REV3_VERSION             0x5020000
 #define PLD_AR6320_REV3_2_VERSION           0x5030000
 #define PLD_AR6320_DEV_VERSION              0x1000000
-#define PLD_QCA9377_REV1_1_VERSION          0x5020001
 
-#ifdef MULTI_IF_NAME
-#define PREFIX MULTI_IF_NAME
-#else
-#define PREFIX ""
-#endif
 
 struct pld_fw_files fw_files_qca6174_fw_1_1 = {
 	PREFIX "qwlan11.bin", PREFIX  "bdwlan11.bin", PREFIX "otp11.bin",