ARM: qca: ipq8064: Secondary flash type setting is board specific

flash_secondary_type is specific to ipq8064. Initialization of this
parameter is moved into boards specific file.

Change-Id: If1a0e44e3d0a674ce497de045d9c5095b67bc913
Signed-off-by: Gokul Sriram Palanisamy <gpalan@codeaurora.org>
diff --git a/arch/arm/include/asm/arch-qca-common/qca_common.h b/arch/arm/include/asm/arch-qca-common/qca_common.h
index 2a57334..6e7d67a 100644
--- a/arch/arm/include/asm/arch-qca-common/qca_common.h
+++ b/arch/arm/include/asm/arch-qca-common/qca_common.h
@@ -14,6 +14,7 @@
 #ifndef ___QCA_COMMON_H_
 #define ___QCA_COMMON_H_
 #include <asm/u-boot.h>
+#include <asm/arch-qca-common/smem.h>
 
 #ifdef CONFIG_IPQ807x
 #include <asm/arch-ipq807x/clk.h>
@@ -48,6 +49,8 @@
 int qca_mmc_init(bd_t *, qca_mmc *);
 void board_mmc_deinit(void);
 
+void set_flash_secondary_type(qca_smem_flash_info_t *);
+
 struct dumpinfo_t{
 	char name[16]; /* use only file name in 8.3 format */
 	uint32_t start;
diff --git a/board/qca/arm/common/board_init.c b/board/qca/arm/common/board_init.c
index a166cd9..0c6e706 100644
--- a/board/qca/arm/common/board_init.c
+++ b/board/qca/arm/common/board_init.c
@@ -146,7 +146,12 @@
 		if (ret < 0) {
 			qca_part_entry_t *part = entries[i].part;
 
-			smem->flash_secondary_type = SMEM_BOOT_NAND_FLASH;
+			/*
+			 * To set SoC specific secondary flash type to
+			 * eMMC/NAND device based on the one that is enabled.
+			 */
+			set_flash_secondary_type(smem);
+
 			debug("cdp: get part failed for %s\n", entries[i].name);
 			part->offset = 0xBAD0FF5E;
 			part->size = 0xBAD0FF5E;
diff --git a/board/qca/arm/ipq40xx/ipq40xx.c b/board/qca/arm/ipq40xx/ipq40xx.c
index 5f54197..f0a4512 100644
--- a/board/qca/arm/ipq40xx/ipq40xx.c
+++ b/board/qca/arm/ipq40xx/ipq40xx.c
@@ -314,3 +314,8 @@
 {
 	return 0;
 }
+
+void set_flash_secondary_type(qca_smem_flash_info_t * smem)
+{
+	return;
+}
diff --git a/board/qca/arm/ipq806x/ipq806x.c b/board/qca/arm/ipq806x/ipq806x.c
index 19a9fd5..e140d28 100644
--- a/board/qca/arm/ipq806x/ipq806x.c
+++ b/board/qca/arm/ipq806x/ipq806x.c
@@ -332,3 +332,25 @@
 	emmc_clock_disable();
 }
 
+void set_flash_secondary_type(qca_smem_flash_info_t *smem)
+{
+	/*
+	 * Both eMMC and NAND share common GPIOs, only one of them shall be
+	 * enabled from device tree, based on board configuration.
+	 *
+	 * flash_secondary_type is set to eMMC/NAND device whichever is
+	 * initialized, as there is no smem entry to differentiate between the
+	 * two.
+	 */
+#ifdef CONFIG_QCA_MMC
+	struct mmc *mmc;
+
+	mmc = find_mmc_device(mmc_host.dev_num);
+	if (mmc) {
+		smem->flash_secondary_type = SMEM_BOOT_MMC_FLASH;
+		return;
+	}
+#endif
+	smem->flash_secondary_type = SMEM_BOOT_NAND_FLASH;
+	return;
+}
diff --git a/board/qca/arm/ipq807x/ipq807x.c b/board/qca/arm/ipq807x/ipq807x.c
index 28ad2b5..d53ce5b 100644
--- a/board/qca/arm/ipq807x/ipq807x.c
+++ b/board/qca/arm/ipq807x/ipq807x.c
@@ -208,3 +208,8 @@
 {
 	return 0;
 }
+
+void set_flash_secondary_type(qca_smem_flash_info_t *smem)
+{
+	return;
+};