scsi: ufs-qcom: increase max UFS host count to 2

Newer chipsets may have 2 instances of UFS host controllers, one for
embedded UFS device and another for removable UFS card. This change
increases the MAX_UFS_QCOM_HOSTS to 2 so it can hold the pointers
to data structures of both the UFS host controllers. To save the
pointers at relevant index, we will get alias id for the given
device_node using the "ufshcX" alias ids (where X is either 1 or 2).

Change-Id: I1bf47a499a64407b2d10fb36c5cd3e77c90b0bb8
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index bea0183..9706273 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1832,6 +1832,24 @@
 		pr_info("%s: will disable all LPM modes\n", __func__);
 }
 
+static void ufs_qcom_save_host_ptr(struct ufs_hba *hba)
+{
+	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
+	int id;
+
+	if (!hba->dev->of_node)
+		return;
+
+	/* Extract platform data */
+	id = of_alias_get_id(hba->dev->of_node, "ufshc");
+	if (id <= 0)
+		dev_err(hba->dev, "Failed to get host index %d\n", id);
+	else if (id <= MAX_UFS_QCOM_HOSTS)
+		ufs_qcom_hosts[id - 1] = host;
+	else
+		dev_err(hba->dev, "invalid host index %d\n", id);
+}
+
 /**
  * ufs_qcom_init - bind phy with controller
  * @hba: host controller instance
@@ -1968,9 +1986,6 @@
 
 	ufs_qcom_setup_clocks(hba, true, false);
 
-	if (hba->dev->id < MAX_UFS_QCOM_HOSTS)
-		ufs_qcom_hosts[hba->dev->id] = host;
-
 	host->dbg_print_en |= UFS_QCOM_DEFAULT_DBG_PRINT_EN;
 	ufs_qcom_get_default_testbus_cfg(host);
 	err = ufs_qcom_testbus_config(host);
@@ -1980,6 +1995,8 @@
 		err = 0;
 	}
 
+	ufs_qcom_save_host_ptr(hba);
+
 	goto out;
 
 out_disable_phy: