greybus: svc: skip setting flags for boot over unipro

We need to skip setting E2EFC and other flags to the SVC connection
create request, for all cports, on an interface that need to boot over
unipro, i.e. interfaces required to download firmware.

This also adds a FIXME as we need to do it differently for ES3.

Tested-by: Eli Sennesh <esennesh@leaflabs.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off by: Eli Sennesh <esennesh@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
diff --git a/drivers/staging/greybus/svc.c b/drivers/staging/greybus/svc.c
index da2ffd6..4b9eb38 100644
--- a/drivers/staging/greybus/svc.c
+++ b/drivers/staging/greybus/svc.c
@@ -207,6 +207,18 @@
 		return -ENODEV;
 	}
 
+	/*
+	 * Check if the module needs to boot from unipro.
+	 * For ES2: We need to check lowest 8 bits of 'value'.
+	 * For ES3: We need to check highest 8 bits out of 32 of 'value'.
+	 *
+	 * FIXME: Add code to find if we are on ES2 or ES3 to have separate
+	 * checks.
+	 */
+	if (value == DME_TSI_UNIPRO_BOOT_STARTED ||
+	    value == DME_TSI_FALLBACK_UNIPRO_BOOT_STARTED)
+		intf->boot_over_unipro = true;
+
 	return gb_svc_dme_peer_set(hd->svc, intf->interface_id,
 				   DME_ATTR_T_TST_SRC_INCREMENT,
 				   DME_ATTR_SELECTOR_INDEX, 0);
@@ -214,7 +226,8 @@
 
 int gb_svc_connection_create(struct gb_svc *svc,
 				u8 intf1_id, u16 cport1_id,
-				u8 intf2_id, u16 cport2_id)
+				u8 intf2_id, u16 cport2_id,
+				bool boot_over_unipro)
 {
 	struct gb_svc_conn_create_request request;
 
@@ -227,7 +240,16 @@
 	 * for now.
 	 */
 	request.tc = 0;
-	request.flags = CPORT_FLAGS_CSV_N | CPORT_FLAGS_E2EFC;
+
+	/*
+	 * We need to skip setting E2EFC and other flags to the connection
+	 * create request, for all cports, on an interface that need to boot
+	 * over unipro, i.e. interfaces required to download firmware.
+	 */
+	if (boot_over_unipro)
+		request.flags = CPORT_FLAGS_CSV_N | CPORT_FLAGS_CSD_N;
+	else
+		request.flags = CPORT_FLAGS_CSV_N | CPORT_FLAGS_E2EFC;
 
 	return gb_operation_sync(svc->connection, GB_SVC_TYPE_CONN_CREATE,
 				 &request, sizeof(request), NULL, 0);