platform: msm_shared: integrate dload & normal reboot reason in a function

Integrate dload & normal reboot reason in a function, so that it could
avoid the normal reboot reason macro collision with dload mode.

Change-Id: Icc7c9d465e6c993d71e84bd793c5650bf51a4d28
diff --git a/platform/msm_shared/reboot.c b/platform/msm_shared/reboot.c
index 4c21d11..9071096 100644
--- a/platform/msm_shared/reboot.c
+++ b/platform/msm_shared/reboot.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -76,7 +76,7 @@
 	hard_restart_reason = REG_READ(PON_SOFT_RB_SPARE);
 	REG_WRITE(PON_SOFT_RB_SPARE, hard_restart_reason & 0x03);
 
-	/* Extract the bits 5 to 7 and return */
+	/* Extract the bits 2 to 7 and return */
 	return (hard_restart_reason & 0xFC) >> 2;
 }
 
@@ -103,11 +103,11 @@
 	uint8_t value;
 #endif
 
-	/* Need to clear the SW_RESET_ENTRY register and
-	 * write to the BOOT_MISC_REG for known reset cases
-	 */
-	if(reboot_reason != DLOAD)
-		scm_dload_mode(NORMAL_MODE);
+	/* Set cookie for dload mode */
+	if(set_download_mode(reboot_reason)) {
+		dprintf(CRITICAL, "HALT: set_download_mode not supported\n");
+		return;
+	}
 
 #if USE_PON_REBOOT_REG
 	value = REG_READ(PON_SOFT_RB_SPARE);
@@ -120,9 +120,10 @@
 	 * For other cases do a hard reset
 	 */
 #if USE_PON_REBOOT_REG
-	if(reboot_reason == DLOAD)
+	if(reboot_reason == NORMAL_DLOAD || reboot_reason == EMERGENCY_DLOAD)
 #else
-	if(reboot_reason == FASTBOOT_MODE || (reboot_reason == DLOAD) || (reboot_reason == RECOVERY_MODE))
+	if(reboot_reason == FASTBOOT_MODE || reboot_reason == NORMAL_DLOAD ||
+		reboot_reason == EMERGENCY_DLOAD || reboot_reason == RECOVERY_MODE)
 #endif
 		reset_type = PON_PSHOLD_WARM_RESET;
 	else